microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
lib/app-center-node-client/src/codepush/operations/codePushDeploymentReleases.js
803lines · modecode
| 1 | /* |
| 2 | * Code generated by Microsoft (R) AutoRest Code Generator. |
| 3 | * Changes may cause incorrect behavior and will be lost if the code is |
| 4 | * regenerated. |
| 5 | */ |
| 6 | |
| 7 | 'use strict'; |
| 8 | |
| 9 | const msRest = require('ms-rest'); |
| 10 | const WebResource = msRest.WebResource; |
| 11 | |
| 12 | /** |
| 13 | * Clears a Deployment of releases |
| 14 | * |
| 15 | * @param {string} appName The name of the application |
| 16 | * |
| 17 | * @param {string} deploymentName deployment name |
| 18 | * |
| 19 | * @param {string} ownerName The name of the owner |
| 20 | * |
| 21 | * @param {object} [options] Optional Parameters. |
| 22 | * |
| 23 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 24 | * request |
| 25 | * |
| 26 | * @param {function} callback - The callback. |
| 27 | * |
| 28 | * @returns {function} callback(err, result, request, response) |
| 29 | * |
| 30 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 31 | * |
| 32 | * {null} [result] - The deserialized result object if an error did not occur. |
| 33 | * |
| 34 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 35 | * |
| 36 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 37 | */ |
| 38 | function _deleteMethod(appName, deploymentName, ownerName, options, callback) { |
| 39 | /* jshint validthis: true */ |
| 40 | let client = this.client; |
| 41 | if(!callback && typeof options === 'function') { |
| 42 | callback = options; |
| 43 | options = null; |
| 44 | } |
| 45 | if (!callback) { |
| 46 | throw new Error('callback cannot be null.'); |
| 47 | } |
| 48 | // Validate |
| 49 | try { |
| 50 | if (appName === null || appName === undefined || typeof appName.valueOf() !== 'string') { |
| 51 | throw new Error('appName cannot be null or undefined and it must be of type string.'); |
| 52 | } |
| 53 | if (deploymentName === null || deploymentName === undefined || typeof deploymentName.valueOf() !== 'string') { |
| 54 | throw new Error('deploymentName cannot be null or undefined and it must be of type string.'); |
| 55 | } |
| 56 | if (ownerName === null || ownerName === undefined || typeof ownerName.valueOf() !== 'string') { |
| 57 | throw new Error('ownerName cannot be null or undefined and it must be of type string.'); |
| 58 | } |
| 59 | } catch (error) { |
| 60 | return callback(error); |
| 61 | } |
| 62 | |
| 63 | // Construct URL |
| 64 | let baseUrl = this.client.baseUri; |
| 65 | let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/apps/{owner_name}/{app_name}/deployments/{deployment_name}/releases'; |
| 66 | requestUrl = requestUrl.replace('{app_name}', encodeURIComponent(appName)); |
| 67 | requestUrl = requestUrl.replace('{deployment_name}', encodeURIComponent(deploymentName)); |
| 68 | requestUrl = requestUrl.replace('{owner_name}', encodeURIComponent(ownerName)); |
| 69 | |
| 70 | // Create HTTP transport objects |
| 71 | let httpRequest = new WebResource(); |
| 72 | httpRequest.method = 'DELETE'; |
| 73 | httpRequest.url = requestUrl; |
| 74 | httpRequest.headers = {}; |
| 75 | // Set Headers |
| 76 | httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; |
| 77 | if(options) { |
| 78 | for(let headerName in options['customHeaders']) { |
| 79 | if (options['customHeaders'].hasOwnProperty(headerName)) { |
| 80 | httpRequest.headers[headerName] = options['customHeaders'][headerName]; |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | httpRequest.body = null; |
| 85 | // Send Request |
| 86 | return client.pipeline(httpRequest, (err, response, responseBody) => { |
| 87 | if (err) { |
| 88 | return callback(err); |
| 89 | } |
| 90 | let statusCode = response.statusCode; |
| 91 | if (statusCode < 200 || statusCode >= 300) { |
| 92 | let error = new Error(responseBody); |
| 93 | error.statusCode = response.statusCode; |
| 94 | error.request = msRest.stripRequest(httpRequest); |
| 95 | error.response = msRest.stripResponse(response); |
| 96 | if (responseBody === '') responseBody = null; |
| 97 | let parsedErrorResponse; |
| 98 | try { |
| 99 | parsedErrorResponse = JSON.parse(responseBody); |
| 100 | if (parsedErrorResponse) { |
| 101 | let internalError = null; |
| 102 | if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; |
| 103 | error.code = internalError ? internalError.code : parsedErrorResponse.code; |
| 104 | error.message = internalError ? internalError.message : parsedErrorResponse.message; |
| 105 | } |
| 106 | } catch (defaultError) { |
| 107 | error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + |
| 108 | `- "${responseBody}" for the default response.`; |
| 109 | return callback(error); |
| 110 | } |
| 111 | return callback(error); |
| 112 | } |
| 113 | // Create Result |
| 114 | let result = null; |
| 115 | if (responseBody === '') responseBody = null; |
| 116 | |
| 117 | return callback(null, result, httpRequest, response); |
| 118 | }); |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * Gets the history of releases on a Deployment |
| 123 | * |
| 124 | * @param {string} appName The name of the application |
| 125 | * |
| 126 | * @param {string} deploymentName deployment name |
| 127 | * |
| 128 | * @param {string} ownerName The name of the owner |
| 129 | * |
| 130 | * @param {object} [options] Optional Parameters. |
| 131 | * |
| 132 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 133 | * request |
| 134 | * |
| 135 | * @param {function} callback - The callback. |
| 136 | * |
| 137 | * @returns {function} callback(err, result, request, response) |
| 138 | * |
| 139 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 140 | * |
| 141 | * {array} [result] - The deserialized result object if an error did not occur. |
| 142 | * |
| 143 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 144 | * |
| 145 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 146 | */ |
| 147 | function _get(appName, deploymentName, ownerName, options, callback) { |
| 148 | /* jshint validthis: true */ |
| 149 | let client = this.client; |
| 150 | if(!callback && typeof options === 'function') { |
| 151 | callback = options; |
| 152 | options = null; |
| 153 | } |
| 154 | if (!callback) { |
| 155 | throw new Error('callback cannot be null.'); |
| 156 | } |
| 157 | // Validate |
| 158 | try { |
| 159 | if (appName === null || appName === undefined || typeof appName.valueOf() !== 'string') { |
| 160 | throw new Error('appName cannot be null or undefined and it must be of type string.'); |
| 161 | } |
| 162 | if (deploymentName === null || deploymentName === undefined || typeof deploymentName.valueOf() !== 'string') { |
| 163 | throw new Error('deploymentName cannot be null or undefined and it must be of type string.'); |
| 164 | } |
| 165 | if (ownerName === null || ownerName === undefined || typeof ownerName.valueOf() !== 'string') { |
| 166 | throw new Error('ownerName cannot be null or undefined and it must be of type string.'); |
| 167 | } |
| 168 | } catch (error) { |
| 169 | return callback(error); |
| 170 | } |
| 171 | |
| 172 | // Construct URL |
| 173 | let baseUrl = this.client.baseUri; |
| 174 | let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/apps/{owner_name}/{app_name}/deployments/{deployment_name}/releases'; |
| 175 | requestUrl = requestUrl.replace('{app_name}', encodeURIComponent(appName)); |
| 176 | requestUrl = requestUrl.replace('{deployment_name}', encodeURIComponent(deploymentName)); |
| 177 | requestUrl = requestUrl.replace('{owner_name}', encodeURIComponent(ownerName)); |
| 178 | |
| 179 | // Create HTTP transport objects |
| 180 | let httpRequest = new WebResource(); |
| 181 | httpRequest.method = 'GET'; |
| 182 | httpRequest.url = requestUrl; |
| 183 | httpRequest.headers = {}; |
| 184 | // Set Headers |
| 185 | httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; |
| 186 | if(options) { |
| 187 | for(let headerName in options['customHeaders']) { |
| 188 | if (options['customHeaders'].hasOwnProperty(headerName)) { |
| 189 | httpRequest.headers[headerName] = options['customHeaders'][headerName]; |
| 190 | } |
| 191 | } |
| 192 | } |
| 193 | httpRequest.body = null; |
| 194 | // Send Request |
| 195 | return client.pipeline(httpRequest, (err, response, responseBody) => { |
| 196 | if (err) { |
| 197 | return callback(err); |
| 198 | } |
| 199 | let statusCode = response.statusCode; |
| 200 | if (statusCode !== 200) { |
| 201 | let error = new Error(responseBody); |
| 202 | error.statusCode = response.statusCode; |
| 203 | error.request = msRest.stripRequest(httpRequest); |
| 204 | error.response = msRest.stripResponse(response); |
| 205 | if (responseBody === '') responseBody = null; |
| 206 | let parsedErrorResponse; |
| 207 | try { |
| 208 | parsedErrorResponse = JSON.parse(responseBody); |
| 209 | if (parsedErrorResponse) { |
| 210 | let internalError = null; |
| 211 | if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; |
| 212 | error.code = internalError ? internalError.code : parsedErrorResponse.code; |
| 213 | error.message = internalError ? internalError.message : parsedErrorResponse.message; |
| 214 | } |
| 215 | } catch (defaultError) { |
| 216 | error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + |
| 217 | `- "${responseBody}" for the default response.`; |
| 218 | return callback(error); |
| 219 | } |
| 220 | return callback(error); |
| 221 | } |
| 222 | // Create Result |
| 223 | let result = null; |
| 224 | if (responseBody === '') responseBody = null; |
| 225 | // Deserialize Response |
| 226 | if (statusCode === 200) { |
| 227 | let parsedResponse = null; |
| 228 | try { |
| 229 | parsedResponse = JSON.parse(responseBody); |
| 230 | result = JSON.parse(responseBody); |
| 231 | if (parsedResponse !== null && parsedResponse !== undefined) { |
| 232 | let resultMapper = { |
| 233 | required: false, |
| 234 | serializedName: 'parsedResponse', |
| 235 | type: { |
| 236 | name: 'Sequence', |
| 237 | element: { |
| 238 | required: false, |
| 239 | serializedName: 'CodePushReleaseElementType', |
| 240 | type: { |
| 241 | name: 'Composite', |
| 242 | className: 'CodePushRelease' |
| 243 | } |
| 244 | } |
| 245 | } |
| 246 | }; |
| 247 | result = client.deserialize(resultMapper, parsedResponse, 'result'); |
| 248 | } |
| 249 | } catch (error) { |
| 250 | let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); |
| 251 | deserializationError.request = msRest.stripRequest(httpRequest); |
| 252 | deserializationError.response = msRest.stripResponse(response); |
| 253 | return callback(deserializationError); |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | return callback(null, result, httpRequest, response); |
| 258 | }); |
| 259 | } |
| 260 | |
| 261 | /** |
| 262 | * Create a new CodePush release for the specified deployment |
| 263 | * |
| 264 | * @param {string} appName The name of the application |
| 265 | * |
| 266 | * @param {string} deploymentName1 deployment name |
| 267 | * |
| 268 | * @param {string} ownerName The name of the owner |
| 269 | * |
| 270 | * @param {string} targetBinaryVersion the binary version of the application |
| 271 | * |
| 272 | * @param {object} [options] Optional Parameters. |
| 273 | * |
| 274 | * @param {string} [options.deploymentName] This specifies which deployment you |
| 275 | * want to release the update to. Default is Staging. |
| 276 | * |
| 277 | * @param {string} [options.description] This provides an optional "change log" |
| 278 | * for the deployment. |
| 279 | * |
| 280 | * @param {boolean} [options.disabled] This specifies whether an update should |
| 281 | * be downloadable by end users or not. |
| 282 | * |
| 283 | * @param {boolean} [options.mandatory] This specifies whether the update |
| 284 | * should be considered mandatory or not (e.g. it includes a critical security |
| 285 | * fix). |
| 286 | * |
| 287 | * @param {boolean} [options.noDuplicateReleaseError] This specifies that if |
| 288 | * the update is identical to the latest release on the deployment, the CLI |
| 289 | * should generate a warning instead of an error. |
| 290 | * |
| 291 | * @param {object} [options.packageProperty] The upload zip file |
| 292 | * |
| 293 | * @param {number} [options.rollout] This specifies the percentage of users (as |
| 294 | * an integer between 1 and 100) that should be eligible to receive this |
| 295 | * update. |
| 296 | * |
| 297 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 298 | * request |
| 299 | * |
| 300 | * @param {function} callback - The callback. |
| 301 | * |
| 302 | * @returns {function} callback(err, result, request, response) |
| 303 | * |
| 304 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 305 | * |
| 306 | * {object} [result] - The deserialized result object if an error did not occur. |
| 307 | * See {@link CodePushRelease} for more information. |
| 308 | * |
| 309 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 310 | * |
| 311 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 312 | */ |
| 313 | function _create(appName, deploymentName1, ownerName, targetBinaryVersion, options, callback) { |
| 314 | /* jshint validthis: true */ |
| 315 | let client = this.client; |
| 316 | if(!callback && typeof options === 'function') { |
| 317 | callback = options; |
| 318 | options = null; |
| 319 | } |
| 320 | if (!callback) { |
| 321 | throw new Error('callback cannot be null.'); |
| 322 | } |
| 323 | let deploymentName = (options && options.deploymentName !== undefined) ? options.deploymentName : undefined; |
| 324 | let description = (options && options.description !== undefined) ? options.description : undefined; |
| 325 | let disabled = (options && options.disabled !== undefined) ? options.disabled : undefined; |
| 326 | let mandatory = (options && options.mandatory !== undefined) ? options.mandatory : undefined; |
| 327 | let noDuplicateReleaseError = (options && options.noDuplicateReleaseError !== undefined) ? options.noDuplicateReleaseError : undefined; |
| 328 | let packageProperty = (options && options.packageProperty !== undefined) ? options.packageProperty : undefined; |
| 329 | let rollout = (options && options.rollout !== undefined) ? options.rollout : undefined; |
| 330 | // Validate |
| 331 | try { |
| 332 | if (appName === null || appName === undefined || typeof appName.valueOf() !== 'string') { |
| 333 | throw new Error('appName cannot be null or undefined and it must be of type string.'); |
| 334 | } |
| 335 | if (deploymentName !== null && deploymentName !== undefined && typeof deploymentName.valueOf() !== 'string') { |
| 336 | throw new Error('deploymentName must be of type string.'); |
| 337 | } |
| 338 | if (deploymentName1 === null || deploymentName1 === undefined || typeof deploymentName1.valueOf() !== 'string') { |
| 339 | throw new Error('deploymentName1 cannot be null or undefined and it must be of type string.'); |
| 340 | } |
| 341 | if (description !== null && description !== undefined && typeof description.valueOf() !== 'string') { |
| 342 | throw new Error('description must be of type string.'); |
| 343 | } |
| 344 | if (disabled !== null && disabled !== undefined && typeof disabled !== 'boolean') { |
| 345 | throw new Error('disabled must be of type boolean.'); |
| 346 | } |
| 347 | if (mandatory !== null && mandatory !== undefined && typeof mandatory !== 'boolean') { |
| 348 | throw new Error('mandatory must be of type boolean.'); |
| 349 | } |
| 350 | if (noDuplicateReleaseError !== null && noDuplicateReleaseError !== undefined && typeof noDuplicateReleaseError !== 'boolean') { |
| 351 | throw new Error('noDuplicateReleaseError must be of type boolean.'); |
| 352 | } |
| 353 | if (ownerName === null || ownerName === undefined || typeof ownerName.valueOf() !== 'string') { |
| 354 | throw new Error('ownerName cannot be null or undefined and it must be of type string.'); |
| 355 | } |
| 356 | if (packageProperty !== null && packageProperty !== undefined && typeof packageProperty.valueOf() !== 'object') { |
| 357 | throw new Error('packageProperty must be of type object.'); |
| 358 | } |
| 359 | if (rollout !== null && rollout !== undefined && typeof rollout !== 'number') { |
| 360 | throw new Error('rollout must be of type number.'); |
| 361 | } |
| 362 | if (targetBinaryVersion === null || targetBinaryVersion === undefined || typeof targetBinaryVersion.valueOf() !== 'string') { |
| 363 | throw new Error('targetBinaryVersion cannot be null or undefined and it must be of type string.'); |
| 364 | } |
| 365 | } catch (error) { |
| 366 | return callback(error); |
| 367 | } |
| 368 | |
| 369 | // Construct URL |
| 370 | let baseUrl = this.client.baseUri; |
| 371 | let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/apps/{owner_name}/{app_name}/deployments/{deployment_name}/releases'; |
| 372 | requestUrl = requestUrl.replace('{app_name}', encodeURIComponent(appName)); |
| 373 | requestUrl = requestUrl.replace('{deployment_name}', encodeURIComponent(deploymentName1)); |
| 374 | requestUrl = requestUrl.replace('{owner_name}', encodeURIComponent(ownerName)); |
| 375 | |
| 376 | // Create HTTP transport objects |
| 377 | let httpRequest = new WebResource(); |
| 378 | httpRequest.method = 'POST'; |
| 379 | httpRequest.url = requestUrl; |
| 380 | httpRequest.headers = {}; |
| 381 | // Set Headers |
| 382 | httpRequest.headers['Content-Type'] = 'multipart/form-data'; |
| 383 | if(options) { |
| 384 | for(let headerName in options['customHeaders']) { |
| 385 | if (options['customHeaders'].hasOwnProperty(headerName)) { |
| 386 | httpRequest.headers[headerName] = options['customHeaders'][headerName]; |
| 387 | } |
| 388 | } |
| 389 | } |
| 390 | // Serialize Request |
| 391 | let formData = {}; |
| 392 | if (deploymentName !== undefined && deploymentName !== null) { |
| 393 | formData['deploymentName'] = deploymentName; |
| 394 | } |
| 395 | if (description !== undefined && description !== null) { |
| 396 | formData['description'] = description; |
| 397 | } |
| 398 | if (disabled !== undefined && disabled !== null) { |
| 399 | formData['disabled'] = disabled.toString(); |
| 400 | } |
| 401 | if (mandatory !== undefined && mandatory !== null) { |
| 402 | formData['mandatory'] = mandatory.toString(); |
| 403 | } |
| 404 | if (noDuplicateReleaseError !== undefined && noDuplicateReleaseError !== null) { |
| 405 | formData['noDuplicateReleaseError'] = noDuplicateReleaseError.toString(); |
| 406 | } |
| 407 | if (packageProperty !== undefined && packageProperty !== null) { |
| 408 | formData['package'] = packageProperty; |
| 409 | } |
| 410 | if (rollout !== undefined && rollout !== null) { |
| 411 | formData['rollout'] = rollout.toString(); |
| 412 | } |
| 413 | if (targetBinaryVersion !== undefined && targetBinaryVersion !== null) { |
| 414 | formData['targetBinaryVersion'] = targetBinaryVersion; |
| 415 | } |
| 416 | httpRequest.formData = formData; |
| 417 | // Send Request |
| 418 | return client.pipeline(httpRequest, (err, response, responseBody) => { |
| 419 | if (err) { |
| 420 | return callback(err); |
| 421 | } |
| 422 | let statusCode = response.statusCode; |
| 423 | if (statusCode !== 201) { |
| 424 | let error = new Error(responseBody); |
| 425 | error.statusCode = response.statusCode; |
| 426 | error.request = msRest.stripRequest(httpRequest); |
| 427 | error.response = msRest.stripResponse(response); |
| 428 | if (responseBody === '') responseBody = null; |
| 429 | let parsedErrorResponse; |
| 430 | try { |
| 431 | parsedErrorResponse = JSON.parse(responseBody); |
| 432 | if (parsedErrorResponse) { |
| 433 | let internalError = null; |
| 434 | if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; |
| 435 | error.code = internalError ? internalError.code : parsedErrorResponse.code; |
| 436 | error.message = internalError ? internalError.message : parsedErrorResponse.message; |
| 437 | } |
| 438 | } catch (defaultError) { |
| 439 | error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + |
| 440 | `- "${responseBody}" for the default response.`; |
| 441 | return callback(error); |
| 442 | } |
| 443 | return callback(error); |
| 444 | } |
| 445 | // Create Result |
| 446 | let result = null; |
| 447 | if (responseBody === '') responseBody = null; |
| 448 | // Deserialize Response |
| 449 | if (statusCode === 201) { |
| 450 | let parsedResponse = null; |
| 451 | try { |
| 452 | parsedResponse = JSON.parse(responseBody); |
| 453 | result = JSON.parse(responseBody); |
| 454 | if (parsedResponse !== null && parsedResponse !== undefined) { |
| 455 | let resultMapper = new client.models['CodePushRelease']().mapper(); |
| 456 | result = client.deserialize(resultMapper, parsedResponse, 'result'); |
| 457 | } |
| 458 | } catch (error) { |
| 459 | let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); |
| 460 | deserializationError.request = msRest.stripRequest(httpRequest); |
| 461 | deserializationError.response = msRest.stripResponse(response); |
| 462 | return callback(deserializationError); |
| 463 | } |
| 464 | } |
| 465 | |
| 466 | return callback(null, result, httpRequest, response); |
| 467 | }); |
| 468 | } |
| 469 | |
| 470 | /** Class representing a CodePushDeploymentReleases. */ |
| 471 | class CodePushDeploymentReleases { |
| 472 | /** |
| 473 | * Create a CodePushDeploymentReleases. |
| 474 | * @param {CodepushClient} client Reference to the service client. |
| 475 | */ |
| 476 | constructor(client) { |
| 477 | this.client = client; |
| 478 | this._deleteMethod = _deleteMethod; |
| 479 | this._get = _get; |
| 480 | this._create = _create; |
| 481 | } |
| 482 | |
| 483 | /** |
| 484 | * Clears a Deployment of releases |
| 485 | * |
| 486 | * @param {string} appName The name of the application |
| 487 | * |
| 488 | * @param {string} deploymentName deployment name |
| 489 | * |
| 490 | * @param {string} ownerName The name of the owner |
| 491 | * |
| 492 | * @param {object} [options] Optional Parameters. |
| 493 | * |
| 494 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 495 | * request |
| 496 | * |
| 497 | * @returns {Promise} A promise is returned |
| 498 | * |
| 499 | * @resolve {HttpOperationResponse<null>} - The deserialized result object. |
| 500 | * |
| 501 | * @reject {Error} - The error object. |
| 502 | */ |
| 503 | deleteMethodWithHttpOperationResponse(appName, deploymentName, ownerName, options) { |
| 504 | let client = this.client; |
| 505 | let self = this; |
| 506 | return new Promise((resolve, reject) => { |
| 507 | self._deleteMethod(appName, deploymentName, ownerName, options, (err, result, request, response) => { |
| 508 | let httpOperationResponse = new msRest.HttpOperationResponse(request, response); |
| 509 | httpOperationResponse.body = result; |
| 510 | if (err) { reject(err); } |
| 511 | else { resolve(httpOperationResponse); } |
| 512 | return; |
| 513 | }); |
| 514 | }); |
| 515 | } |
| 516 | |
| 517 | /** |
| 518 | * Clears a Deployment of releases |
| 519 | * |
| 520 | * @param {string} appName The name of the application |
| 521 | * |
| 522 | * @param {string} deploymentName deployment name |
| 523 | * |
| 524 | * @param {string} ownerName The name of the owner |
| 525 | * |
| 526 | * @param {object} [options] Optional Parameters. |
| 527 | * |
| 528 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 529 | * request |
| 530 | * |
| 531 | * @param {function} [optionalCallback] - The optional callback. |
| 532 | * |
| 533 | * @returns {function|Promise} If a callback was passed as the last parameter |
| 534 | * then it returns the callback else returns a Promise. |
| 535 | * |
| 536 | * {Promise} A promise is returned |
| 537 | * |
| 538 | * @resolve {null} - The deserialized result object. |
| 539 | * |
| 540 | * @reject {Error} - The error object. |
| 541 | * |
| 542 | * {function} optionalCallback(err, result, request, response) |
| 543 | * |
| 544 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 545 | * |
| 546 | * {null} [result] - The deserialized result object if an error did not occur. |
| 547 | * |
| 548 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 549 | * |
| 550 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 551 | */ |
| 552 | deleteMethod(appName, deploymentName, ownerName, options, optionalCallback) { |
| 553 | let client = this.client; |
| 554 | let self = this; |
| 555 | if (!optionalCallback && typeof options === 'function') { |
| 556 | optionalCallback = options; |
| 557 | options = null; |
| 558 | } |
| 559 | if (!optionalCallback) { |
| 560 | return new Promise((resolve, reject) => { |
| 561 | self._deleteMethod(appName, deploymentName, ownerName, options, (err, result, request, response) => { |
| 562 | if (err) { reject(err); } |
| 563 | else { resolve(result); } |
| 564 | return; |
| 565 | }); |
| 566 | }); |
| 567 | } else { |
| 568 | return self._deleteMethod(appName, deploymentName, ownerName, options, optionalCallback); |
| 569 | } |
| 570 | } |
| 571 | |
| 572 | /** |
| 573 | * Gets the history of releases on a Deployment |
| 574 | * |
| 575 | * @param {string} appName The name of the application |
| 576 | * |
| 577 | * @param {string} deploymentName deployment name |
| 578 | * |
| 579 | * @param {string} ownerName The name of the owner |
| 580 | * |
| 581 | * @param {object} [options] Optional Parameters. |
| 582 | * |
| 583 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 584 | * request |
| 585 | * |
| 586 | * @returns {Promise} A promise is returned |
| 587 | * |
| 588 | * @resolve {HttpOperationResponse<Array>} - The deserialized result object. |
| 589 | * |
| 590 | * @reject {Error} - The error object. |
| 591 | */ |
| 592 | getWithHttpOperationResponse(appName, deploymentName, ownerName, options) { |
| 593 | let client = this.client; |
| 594 | let self = this; |
| 595 | return new Promise((resolve, reject) => { |
| 596 | self._get(appName, deploymentName, ownerName, options, (err, result, request, response) => { |
| 597 | let httpOperationResponse = new msRest.HttpOperationResponse(request, response); |
| 598 | httpOperationResponse.body = result; |
| 599 | if (err) { reject(err); } |
| 600 | else { resolve(httpOperationResponse); } |
| 601 | return; |
| 602 | }); |
| 603 | }); |
| 604 | } |
| 605 | |
| 606 | /** |
| 607 | * Gets the history of releases on a Deployment |
| 608 | * |
| 609 | * @param {string} appName The name of the application |
| 610 | * |
| 611 | * @param {string} deploymentName deployment name |
| 612 | * |
| 613 | * @param {string} ownerName The name of the owner |
| 614 | * |
| 615 | * @param {object} [options] Optional Parameters. |
| 616 | * |
| 617 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 618 | * request |
| 619 | * |
| 620 | * @param {function} [optionalCallback] - The optional callback. |
| 621 | * |
| 622 | * @returns {function|Promise} If a callback was passed as the last parameter |
| 623 | * then it returns the callback else returns a Promise. |
| 624 | * |
| 625 | * {Promise} A promise is returned |
| 626 | * |
| 627 | * @resolve {Array} - The deserialized result object. |
| 628 | * |
| 629 | * @reject {Error} - The error object. |
| 630 | * |
| 631 | * {function} optionalCallback(err, result, request, response) |
| 632 | * |
| 633 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 634 | * |
| 635 | * {array} [result] - The deserialized result object if an error did not occur. |
| 636 | * |
| 637 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 638 | * |
| 639 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 640 | */ |
| 641 | get(appName, deploymentName, ownerName, options, optionalCallback) { |
| 642 | let client = this.client; |
| 643 | let self = this; |
| 644 | if (!optionalCallback && typeof options === 'function') { |
| 645 | optionalCallback = options; |
| 646 | options = null; |
| 647 | } |
| 648 | if (!optionalCallback) { |
| 649 | return new Promise((resolve, reject) => { |
| 650 | self._get(appName, deploymentName, ownerName, options, (err, result, request, response) => { |
| 651 | if (err) { reject(err); } |
| 652 | else { resolve(result); } |
| 653 | return; |
| 654 | }); |
| 655 | }); |
| 656 | } else { |
| 657 | return self._get(appName, deploymentName, ownerName, options, optionalCallback); |
| 658 | } |
| 659 | } |
| 660 | |
| 661 | /** |
| 662 | * Create a new CodePush release for the specified deployment |
| 663 | * |
| 664 | * @param {string} appName The name of the application |
| 665 | * |
| 666 | * @param {string} deploymentName1 deployment name |
| 667 | * |
| 668 | * @param {string} ownerName The name of the owner |
| 669 | * |
| 670 | * @param {string} targetBinaryVersion the binary version of the application |
| 671 | * |
| 672 | * @param {object} [options] Optional Parameters. |
| 673 | * |
| 674 | * @param {string} [options.deploymentName] This specifies which deployment you |
| 675 | * want to release the update to. Default is Staging. |
| 676 | * |
| 677 | * @param {string} [options.description] This provides an optional "change log" |
| 678 | * for the deployment. |
| 679 | * |
| 680 | * @param {boolean} [options.disabled] This specifies whether an update should |
| 681 | * be downloadable by end users or not. |
| 682 | * |
| 683 | * @param {boolean} [options.mandatory] This specifies whether the update |
| 684 | * should be considered mandatory or not (e.g. it includes a critical security |
| 685 | * fix). |
| 686 | * |
| 687 | * @param {boolean} [options.noDuplicateReleaseError] This specifies that if |
| 688 | * the update is identical to the latest release on the deployment, the CLI |
| 689 | * should generate a warning instead of an error. |
| 690 | * |
| 691 | * @param {object} [options.packageProperty] The upload zip file |
| 692 | * |
| 693 | * @param {number} [options.rollout] This specifies the percentage of users (as |
| 694 | * an integer between 1 and 100) that should be eligible to receive this |
| 695 | * update. |
| 696 | * |
| 697 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 698 | * request |
| 699 | * |
| 700 | * @returns {Promise} A promise is returned |
| 701 | * |
| 702 | * @resolve {HttpOperationResponse<CodePushRelease>} - The deserialized result object. |
| 703 | * |
| 704 | * @reject {Error} - The error object. |
| 705 | */ |
| 706 | createWithHttpOperationResponse(appName, deploymentName1, ownerName, targetBinaryVersion, options) { |
| 707 | let client = this.client; |
| 708 | let self = this; |
| 709 | return new Promise((resolve, reject) => { |
| 710 | self._create(appName, deploymentName1, ownerName, targetBinaryVersion, options, (err, result, request, response) => { |
| 711 | let httpOperationResponse = new msRest.HttpOperationResponse(request, response); |
| 712 | httpOperationResponse.body = result; |
| 713 | if (err) { reject(err); } |
| 714 | else { resolve(httpOperationResponse); } |
| 715 | return; |
| 716 | }); |
| 717 | }); |
| 718 | } |
| 719 | |
| 720 | /** |
| 721 | * Create a new CodePush release for the specified deployment |
| 722 | * |
| 723 | * @param {string} appName The name of the application |
| 724 | * |
| 725 | * @param {string} deploymentName1 deployment name |
| 726 | * |
| 727 | * @param {string} ownerName The name of the owner |
| 728 | * |
| 729 | * @param {string} targetBinaryVersion the binary version of the application |
| 730 | * |
| 731 | * @param {object} [options] Optional Parameters. |
| 732 | * |
| 733 | * @param {string} [options.deploymentName] This specifies which deployment you |
| 734 | * want to release the update to. Default is Staging. |
| 735 | * |
| 736 | * @param {string} [options.description] This provides an optional "change log" |
| 737 | * for the deployment. |
| 738 | * |
| 739 | * @param {boolean} [options.disabled] This specifies whether an update should |
| 740 | * be downloadable by end users or not. |
| 741 | * |
| 742 | * @param {boolean} [options.mandatory] This specifies whether the update |
| 743 | * should be considered mandatory or not (e.g. it includes a critical security |
| 744 | * fix). |
| 745 | * |
| 746 | * @param {boolean} [options.noDuplicateReleaseError] This specifies that if |
| 747 | * the update is identical to the latest release on the deployment, the CLI |
| 748 | * should generate a warning instead of an error. |
| 749 | * |
| 750 | * @param {object} [options.packageProperty] The upload zip file |
| 751 | * |
| 752 | * @param {number} [options.rollout] This specifies the percentage of users (as |
| 753 | * an integer between 1 and 100) that should be eligible to receive this |
| 754 | * update. |
| 755 | * |
| 756 | * @param {object} [options.customHeaders] Headers that will be added to the |
| 757 | * request |
| 758 | * |
| 759 | * @param {function} [optionalCallback] - The optional callback. |
| 760 | * |
| 761 | * @returns {function|Promise} If a callback was passed as the last parameter |
| 762 | * then it returns the callback else returns a Promise. |
| 763 | * |
| 764 | * {Promise} A promise is returned |
| 765 | * |
| 766 | * @resolve {CodePushRelease} - The deserialized result object. |
| 767 | * |
| 768 | * @reject {Error} - The error object. |
| 769 | * |
| 770 | * {function} optionalCallback(err, result, request, response) |
| 771 | * |
| 772 | * {Error} err - The Error object if an error occurred, null otherwise. |
| 773 | * |
| 774 | * {object} [result] - The deserialized result object if an error did not occur. |
| 775 | * See {@link CodePushRelease} for more information. |
| 776 | * |
| 777 | * {object} [request] - The HTTP Request object if an error did not occur. |
| 778 | * |
| 779 | * {stream} [response] - The HTTP Response stream if an error did not occur. |
| 780 | */ |
| 781 | create(appName, deploymentName1, ownerName, targetBinaryVersion, options, optionalCallback) { |
| 782 | let client = this.client; |
| 783 | let self = this; |
| 784 | if (!optionalCallback && typeof options === 'function') { |
| 785 | optionalCallback = options; |
| 786 | options = null; |
| 787 | } |
| 788 | if (!optionalCallback) { |
| 789 | return new Promise((resolve, reject) => { |
| 790 | self._create(appName, deploymentName1, ownerName, targetBinaryVersion, options, (err, result, request, response) => { |
| 791 | if (err) { reject(err); } |
| 792 | else { resolve(result); } |
| 793 | return; |
| 794 | }); |
| 795 | }); |
| 796 | } else { |
| 797 | return self._create(appName, deploymentName1, ownerName, targetBinaryVersion, options, optionalCallback); |
| 798 | } |
| 799 | } |
| 800 | |
| 801 | } |
| 802 | |
| 803 | module.exports = CodePushDeploymentReleases; |