OLD | NEW |
(Empty) | |
| 1 library googleapis.appstate.v1; |
| 2 |
| 3 import "dart:core" as core; |
| 4 import "dart:collection" as collection; |
| 5 import "dart:async" as async; |
| 6 import "dart:convert" as convert; |
| 7 |
| 8 import "package:crypto/crypto.dart" as crypto; |
| 9 import 'package:http/http.dart' as http; |
| 10 import '../src/common_internal.dart' as common_internal; |
| 11 import '../common/common.dart' as common; |
| 12 |
| 13 export '../common/common.dart' show ApiRequestError; |
| 14 export '../common/common.dart' show DetailedApiRequestError; |
| 15 |
| 16 /** The Google App State API. */ |
| 17 class AppstateApi { |
| 18 /** View and manage your data for this application */ |
| 19 static const AppstateScope = "https://www.googleapis.com/auth/appstate"; |
| 20 |
| 21 |
| 22 final common_internal.ApiRequester _requester; |
| 23 |
| 24 StatesResourceApi get states => new StatesResourceApi(_requester); |
| 25 |
| 26 AppstateApi(http.Client client) : |
| 27 _requester = new common_internal.ApiRequester(client, "https://www.googlea
pis.com/", "/appstate/v1/"); |
| 28 } |
| 29 |
| 30 |
| 31 /** Not documented yet. */ |
| 32 class StatesResourceApi { |
| 33 final common_internal.ApiRequester _requester; |
| 34 |
| 35 StatesResourceApi(common_internal.ApiRequester client) : |
| 36 _requester = client; |
| 37 |
| 38 /** |
| 39 * Clears (sets to empty) the data for the passed key if and only if the |
| 40 * passed version matches the currently stored version. This method results in |
| 41 * a conflict error on version mismatch. |
| 42 * |
| 43 * Request parameters: |
| 44 * |
| 45 * [stateKey] - The key for the data to be retrieved. |
| 46 * Value must be between "0" and "3". |
| 47 * |
| 48 * [currentDataVersion] - The version of the data to be cleared. Version |
| 49 * strings are returned by the server. |
| 50 * |
| 51 * Completes with a [WriteResult]. |
| 52 * |
| 53 * Completes with a [common.ApiRequestError] if the API endpoint returned an |
| 54 * error. |
| 55 * |
| 56 * If the used [http.Client] completes with an error when making a REST call, |
| 57 * this method will complete with the same error. |
| 58 */ |
| 59 async.Future<WriteResult> clear(core.int stateKey, {core.String currentDataVer
sion}) { |
| 60 var _url = null; |
| 61 var _queryParams = new core.Map(); |
| 62 var _uploadMedia = null; |
| 63 var _uploadOptions = null; |
| 64 var _downloadOptions = common.DownloadOptions.Metadata; |
| 65 var _body = null; |
| 66 |
| 67 if (stateKey == null) { |
| 68 throw new core.ArgumentError("Parameter stateKey is required."); |
| 69 } |
| 70 if (currentDataVersion != null) { |
| 71 _queryParams["currentDataVersion"] = [currentDataVersion]; |
| 72 } |
| 73 |
| 74 |
| 75 _url = 'states/' + common_internal.Escaper.ecapeVariable('$stateKey') + '/cl
ear'; |
| 76 |
| 77 var _response = _requester.request(_url, |
| 78 "POST", |
| 79 body: _body, |
| 80 queryParams: _queryParams, |
| 81 uploadOptions: _uploadOptions, |
| 82 uploadMedia: _uploadMedia, |
| 83 downloadOptions: _downloadOptions); |
| 84 return _response.then((data) => new WriteResult.fromJson(data)); |
| 85 } |
| 86 |
| 87 /** |
| 88 * Deletes a key and the data associated with it. The key is removed and no |
| 89 * longer counts against the key quota. Note that since this method is not |
| 90 * safe in the face of concurrent modifications, it should only be used for |
| 91 * development and testing purposes. Invoking this method in shipping code can |
| 92 * result in data loss and data corruption. |
| 93 * |
| 94 * Request parameters: |
| 95 * |
| 96 * [stateKey] - The key for the data to be retrieved. |
| 97 * Value must be between "0" and "3". |
| 98 * |
| 99 * Completes with a [common.ApiRequestError] if the API endpoint returned an |
| 100 * error. |
| 101 * |
| 102 * If the used [http.Client] completes with an error when making a REST call, |
| 103 * this method will complete with the same error. |
| 104 */ |
| 105 async.Future delete(core.int stateKey) { |
| 106 var _url = null; |
| 107 var _queryParams = new core.Map(); |
| 108 var _uploadMedia = null; |
| 109 var _uploadOptions = null; |
| 110 var _downloadOptions = common.DownloadOptions.Metadata; |
| 111 var _body = null; |
| 112 |
| 113 if (stateKey == null) { |
| 114 throw new core.ArgumentError("Parameter stateKey is required."); |
| 115 } |
| 116 |
| 117 _downloadOptions = null; |
| 118 |
| 119 _url = 'states/' + common_internal.Escaper.ecapeVariable('$stateKey'); |
| 120 |
| 121 var _response = _requester.request(_url, |
| 122 "DELETE", |
| 123 body: _body, |
| 124 queryParams: _queryParams, |
| 125 uploadOptions: _uploadOptions, |
| 126 uploadMedia: _uploadMedia, |
| 127 downloadOptions: _downloadOptions); |
| 128 return _response.then((data) => null); |
| 129 } |
| 130 |
| 131 /** |
| 132 * Retrieves the data corresponding to the passed key. If the key does not |
| 133 * exist on the server, an HTTP 404 will be returned. |
| 134 * |
| 135 * Request parameters: |
| 136 * |
| 137 * [stateKey] - The key for the data to be retrieved. |
| 138 * Value must be between "0" and "3". |
| 139 * |
| 140 * Completes with a [GetResponse]. |
| 141 * |
| 142 * Completes with a [common.ApiRequestError] if the API endpoint returned an |
| 143 * error. |
| 144 * |
| 145 * If the used [http.Client] completes with an error when making a REST call, |
| 146 * this method will complete with the same error. |
| 147 */ |
| 148 async.Future<GetResponse> get(core.int stateKey) { |
| 149 var _url = null; |
| 150 var _queryParams = new core.Map(); |
| 151 var _uploadMedia = null; |
| 152 var _uploadOptions = null; |
| 153 var _downloadOptions = common.DownloadOptions.Metadata; |
| 154 var _body = null; |
| 155 |
| 156 if (stateKey == null) { |
| 157 throw new core.ArgumentError("Parameter stateKey is required."); |
| 158 } |
| 159 |
| 160 |
| 161 _url = 'states/' + common_internal.Escaper.ecapeVariable('$stateKey'); |
| 162 |
| 163 var _response = _requester.request(_url, |
| 164 "GET", |
| 165 body: _body, |
| 166 queryParams: _queryParams, |
| 167 uploadOptions: _uploadOptions, |
| 168 uploadMedia: _uploadMedia, |
| 169 downloadOptions: _downloadOptions); |
| 170 return _response.then((data) => new GetResponse.fromJson(data)); |
| 171 } |
| 172 |
| 173 /** |
| 174 * Lists all the states keys, and optionally the state data. |
| 175 * |
| 176 * Request parameters: |
| 177 * |
| 178 * [includeData] - Whether to include the full data in addition to the version |
| 179 * number |
| 180 * |
| 181 * Completes with a [ListResponse]. |
| 182 * |
| 183 * Completes with a [common.ApiRequestError] if the API endpoint returned an |
| 184 * error. |
| 185 * |
| 186 * If the used [http.Client] completes with an error when making a REST call, |
| 187 * this method will complete with the same error. |
| 188 */ |
| 189 async.Future<ListResponse> list({core.bool includeData}) { |
| 190 var _url = null; |
| 191 var _queryParams = new core.Map(); |
| 192 var _uploadMedia = null; |
| 193 var _uploadOptions = null; |
| 194 var _downloadOptions = common.DownloadOptions.Metadata; |
| 195 var _body = null; |
| 196 |
| 197 if (includeData != null) { |
| 198 _queryParams["includeData"] = ["${includeData}"]; |
| 199 } |
| 200 |
| 201 |
| 202 _url = 'states'; |
| 203 |
| 204 var _response = _requester.request(_url, |
| 205 "GET", |
| 206 body: _body, |
| 207 queryParams: _queryParams, |
| 208 uploadOptions: _uploadOptions, |
| 209 uploadMedia: _uploadMedia, |
| 210 downloadOptions: _downloadOptions); |
| 211 return _response.then((data) => new ListResponse.fromJson(data)); |
| 212 } |
| 213 |
| 214 /** |
| 215 * Update the data associated with the input key if and only if the passed |
| 216 * version matches the currently stored version. This method is safe in the |
| 217 * face of concurrent writes. Maximum per-key size is 128KB. |
| 218 * |
| 219 * [request] - The metadata request object. |
| 220 * |
| 221 * Request parameters: |
| 222 * |
| 223 * [stateKey] - The key for the data to be retrieved. |
| 224 * Value must be between "0" and "3". |
| 225 * |
| 226 * [currentStateVersion] - The version of the app state your application is |
| 227 * attempting to update. If this does not match the current version, this |
| 228 * method will return a conflict error. If there is no data stored on the |
| 229 * server for this key, the update will succeed irrespective of the value of |
| 230 * this parameter. |
| 231 * |
| 232 * Completes with a [WriteResult]. |
| 233 * |
| 234 * Completes with a [common.ApiRequestError] if the API endpoint returned an |
| 235 * error. |
| 236 * |
| 237 * If the used [http.Client] completes with an error when making a REST call, |
| 238 * this method will complete with the same error. |
| 239 */ |
| 240 async.Future<WriteResult> update(UpdateRequest request, core.int stateKey, {co
re.String currentStateVersion}) { |
| 241 var _url = null; |
| 242 var _queryParams = new core.Map(); |
| 243 var _uploadMedia = null; |
| 244 var _uploadOptions = null; |
| 245 var _downloadOptions = common.DownloadOptions.Metadata; |
| 246 var _body = null; |
| 247 |
| 248 if (request != null) { |
| 249 _body = convert.JSON.encode((request).toJson()); |
| 250 } |
| 251 if (stateKey == null) { |
| 252 throw new core.ArgumentError("Parameter stateKey is required."); |
| 253 } |
| 254 if (currentStateVersion != null) { |
| 255 _queryParams["currentStateVersion"] = [currentStateVersion]; |
| 256 } |
| 257 |
| 258 |
| 259 _url = 'states/' + common_internal.Escaper.ecapeVariable('$stateKey'); |
| 260 |
| 261 var _response = _requester.request(_url, |
| 262 "PUT", |
| 263 body: _body, |
| 264 queryParams: _queryParams, |
| 265 uploadOptions: _uploadOptions, |
| 266 uploadMedia: _uploadMedia, |
| 267 downloadOptions: _downloadOptions); |
| 268 return _response.then((data) => new WriteResult.fromJson(data)); |
| 269 } |
| 270 |
| 271 } |
| 272 |
| 273 |
| 274 |
| 275 /** This is a JSON template for an app state resource. */ |
| 276 class GetResponse { |
| 277 /** The current app state version. */ |
| 278 core.String currentStateVersion; |
| 279 |
| 280 /** The requested data. */ |
| 281 core.String data; |
| 282 |
| 283 /** |
| 284 * Uniquely identifies the type of this resource. Value is always the fixed |
| 285 * string appstate#getResponse. |
| 286 */ |
| 287 core.String kind; |
| 288 |
| 289 /** The key for the data. */ |
| 290 core.int stateKey; |
| 291 |
| 292 |
| 293 GetResponse(); |
| 294 |
| 295 GetResponse.fromJson(core.Map _json) { |
| 296 if (_json.containsKey("currentStateVersion")) { |
| 297 currentStateVersion = _json["currentStateVersion"]; |
| 298 } |
| 299 if (_json.containsKey("data")) { |
| 300 data = _json["data"]; |
| 301 } |
| 302 if (_json.containsKey("kind")) { |
| 303 kind = _json["kind"]; |
| 304 } |
| 305 if (_json.containsKey("stateKey")) { |
| 306 stateKey = _json["stateKey"]; |
| 307 } |
| 308 } |
| 309 |
| 310 core.Map toJson() { |
| 311 var _json = new core.Map(); |
| 312 if (currentStateVersion != null) { |
| 313 _json["currentStateVersion"] = currentStateVersion; |
| 314 } |
| 315 if (data != null) { |
| 316 _json["data"] = data; |
| 317 } |
| 318 if (kind != null) { |
| 319 _json["kind"] = kind; |
| 320 } |
| 321 if (stateKey != null) { |
| 322 _json["stateKey"] = stateKey; |
| 323 } |
| 324 return _json; |
| 325 } |
| 326 } |
| 327 |
| 328 |
| 329 /** This is a JSON template to convert a list-response for app state. */ |
| 330 class ListResponse { |
| 331 /** The app state data. */ |
| 332 core.List<GetResponse> items; |
| 333 |
| 334 /** |
| 335 * Uniquely identifies the type of this resource. Value is always the fixed |
| 336 * string appstate#listResponse. |
| 337 */ |
| 338 core.String kind; |
| 339 |
| 340 /** The maximum number of keys allowed for this user. */ |
| 341 core.int maximumKeyCount; |
| 342 |
| 343 |
| 344 ListResponse(); |
| 345 |
| 346 ListResponse.fromJson(core.Map _json) { |
| 347 if (_json.containsKey("items")) { |
| 348 items = _json["items"].map((value) => new GetResponse.fromJson(value)).toL
ist(); |
| 349 } |
| 350 if (_json.containsKey("kind")) { |
| 351 kind = _json["kind"]; |
| 352 } |
| 353 if (_json.containsKey("maximumKeyCount")) { |
| 354 maximumKeyCount = _json["maximumKeyCount"]; |
| 355 } |
| 356 } |
| 357 |
| 358 core.Map toJson() { |
| 359 var _json = new core.Map(); |
| 360 if (items != null) { |
| 361 _json["items"] = items.map((value) => (value).toJson()).toList(); |
| 362 } |
| 363 if (kind != null) { |
| 364 _json["kind"] = kind; |
| 365 } |
| 366 if (maximumKeyCount != null) { |
| 367 _json["maximumKeyCount"] = maximumKeyCount; |
| 368 } |
| 369 return _json; |
| 370 } |
| 371 } |
| 372 |
| 373 |
| 374 /** This is a JSON template for a requests which update app state */ |
| 375 class UpdateRequest { |
| 376 /** The new app state data that your application is trying to update with. */ |
| 377 core.String data; |
| 378 |
| 379 /** |
| 380 * Uniquely identifies the type of this resource. Value is always the fixed |
| 381 * string appstate#updateRequest. |
| 382 */ |
| 383 core.String kind; |
| 384 |
| 385 |
| 386 UpdateRequest(); |
| 387 |
| 388 UpdateRequest.fromJson(core.Map _json) { |
| 389 if (_json.containsKey("data")) { |
| 390 data = _json["data"]; |
| 391 } |
| 392 if (_json.containsKey("kind")) { |
| 393 kind = _json["kind"]; |
| 394 } |
| 395 } |
| 396 |
| 397 core.Map toJson() { |
| 398 var _json = new core.Map(); |
| 399 if (data != null) { |
| 400 _json["data"] = data; |
| 401 } |
| 402 if (kind != null) { |
| 403 _json["kind"] = kind; |
| 404 } |
| 405 return _json; |
| 406 } |
| 407 } |
| 408 |
| 409 |
| 410 /** This is a JSON template for an app state write result. */ |
| 411 class WriteResult { |
| 412 /** The version of the data for this key on the server. */ |
| 413 core.String currentStateVersion; |
| 414 |
| 415 /** |
| 416 * Uniquely identifies the type of this resource. Value is always the fixed |
| 417 * string appstate#writeResult. |
| 418 */ |
| 419 core.String kind; |
| 420 |
| 421 /** The written key. */ |
| 422 core.int stateKey; |
| 423 |
| 424 |
| 425 WriteResult(); |
| 426 |
| 427 WriteResult.fromJson(core.Map _json) { |
| 428 if (_json.containsKey("currentStateVersion")) { |
| 429 currentStateVersion = _json["currentStateVersion"]; |
| 430 } |
| 431 if (_json.containsKey("kind")) { |
| 432 kind = _json["kind"]; |
| 433 } |
| 434 if (_json.containsKey("stateKey")) { |
| 435 stateKey = _json["stateKey"]; |
| 436 } |
| 437 } |
| 438 |
| 439 core.Map toJson() { |
| 440 var _json = new core.Map(); |
| 441 if (currentStateVersion != null) { |
| 442 _json["currentStateVersion"] = currentStateVersion; |
| 443 } |
| 444 if (kind != null) { |
| 445 _json["kind"] = kind; |
| 446 } |
| 447 if (stateKey != null) { |
| 448 _json["stateKey"] = stateKey; |
| 449 } |
| 450 return _json; |
| 451 } |
| 452 } |
| 453 |
| 454 |
OLD | NEW |