Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * code-push-api
  3.  * The CodePush service backend
  4.  *
  5.  * OpenAPI spec version: 0.1.0
  6.  *
  7.  *
  8.  * NOTE: This class is auto generated by the swagger code generator program.
  9.  * https://github.com/swagger-api/swagger-codegen.git
  10.  * Do not edit the class manually.
  11.  */
  12.  
  13. import request = require('request');
  14. import http = require('http');
  15. import Promise = require('bluebird');
  16.  
  17. let defaultBasePath = 'https://code-push-api.mobilecenter-int.avalanch.es/v0.1';
  18.  
  19. // ===============================================
  20. // This file is autogenerated - Please do not edit
  21. // ===============================================
  22.  
  23. /* tslint:disable:no-unused-variable */
  24.  
  25. export class AcquisitionStatusSuccessResponse {
  26.     /**
  27.     * The code indicating the status
  28.     */
  29.     'code': string;
  30.     /**
  31.     * The message indicating the status
  32.     */
  33.     'message': string;
  34. }
  35.  
  36. export class BlobInfo {
  37.     'size': number;
  38.     'url': string;
  39. }
  40.  
  41. export class CodePushRelease extends CodePushReleaseInfo {
  42.     'label': string;
  43.     'packageHash': string;
  44.     'blobUrl': string;
  45.     'diffPackageMap': PackageHashToBlobInfoMap;
  46.     /**
  47.     * Set on 'Promote'
  48.     */
  49.     'originalDeployment': string;
  50.     /**
  51.     * Set on 'Promote' and 'Rollback'
  52.     */
  53.     'originalLabel': string;
  54.     'releasedBy': string;
  55.     /**
  56.     * The release method is unknown if unspecified
  57.     */
  58.     'releaseMethod': CodePushRelease.ReleaseMethodEnum;
  59.     'size': number;
  60.     'uploadTime': number;
  61. }
  62.  
  63. export namespace CodePushRelease {
  64.     export enum ReleaseMethodEnum {
  65.         Upload = <any> 'Upload',
  66.         Promote = <any> 'Promote',
  67.         Rollback = <any> 'Rollback'
  68.     }
  69. }
  70. export class CodePushReleaseInfo {
  71.     'targetBinaryRange': string;
  72.     'description': string;
  73.     'isDisabled': boolean;
  74.     'isMandatory': boolean;
  75.     'rollout': number;
  76. }
  77.  
  78. export class CodePushReleaseLabel {
  79.     'label': string;
  80. }
  81.  
  82. export class CodePushReleaseMetric {
  83.     'label': string;
  84.     'active': number;
  85.     'downloaded': number;
  86.     'failed': number;
  87.     'installed': number;
  88. }
  89.  
  90. export class CodePushReleaseModification extends CodePushReleaseInfo {
  91. }
  92.  
  93. export class CodePushReleasePromote extends CodePushReleaseInfo {
  94.     'label': string;
  95. }
  96.  
  97. export class CodePushStatusMetricMetadata {
  98.     'deploymentKey': string;
  99.     'label': string;
  100.     'appVersion': string;
  101.     'previousDeploymentKey': string;
  102.     'previousLabelOrAppVersion': string;
  103.     'status': string;
  104.     'clientUniqueId': string;
  105. }
  106.  
  107. export class Deployment {
  108.     'key': string;
  109.     'name': string;
  110.     'latestRelease': CodePushRelease;
  111. }
  112.  
  113. export class DeploymentModification {
  114.     'name': string;
  115. }
  116.  
  117. /**
  118. * An error response
  119. */
  120. export class Failure {
  121.     /**
  122.     * The code indicating the error
  123.     */
  124.     'code': string;
  125.     /**
  126.     * The message indicating the error
  127.     */
  128.     'message': string;
  129. }
  130.  
  131. export class PackageHashToBlobInfoMap extends null<String, BlobInfo> {
  132. }
  133.  
  134. export class StatusResponse {
  135.     'status': string;
  136. }
  137.  
  138. export class UpdateCheckResponse extends CodePushReleaseInfo {
  139.     'downloadUrl': string;
  140.     'isAvailable': boolean;
  141.     'packageSize': number;
  142.     'shouldRunBinaryVersion': boolean;
  143.     'updateAppVersion': boolean;
  144.     'packageHash': string;
  145.     'label': string;
  146. }
  147.  
  148.  
  149. export interface Authentication {
  150.     /**
  151.     * Apply authentication settings to header and query params.
  152.     */
  153.     applyToRequest(requestOptions: request.Options): void;
  154. }
  155.  
  156. export class HttpBasicAuth implements Authentication {
  157.     public username: string;
  158.     public password: string;
  159.     applyToRequest(requestOptions: request.Options): void {
  160.         requestOptions.auth = {
  161.             username: this.username, password: this.password
  162.         }
  163.     }
  164. }
  165.  
  166. export class ApiKeyAuth implements Authentication {
  167.     public apiKey: string;
  168.  
  169.     constructor(private location: string, private paramName: string) {
  170.     }
  171.  
  172.     applyToRequest(requestOptions: request.Options): void {
  173.         if (this.location == "query") {
  174.             (<any>requestOptions.qs)[this.paramName] = this.apiKey;
  175.         } else if (this.location == "header" && requestOptions && requestOptions.headers) {
  176.             requestOptions.headers[this.paramName] = this.apiKey;
  177.         }
  178.     }
  179. }
  180.  
  181. export class OAuth implements Authentication {
  182.     public accessToken: string;
  183.  
  184.     applyToRequest(requestOptions: request.Options): void {
  185.         if (requestOptions && requestOptions.headers) {
  186.             requestOptions.headers["Authorization"] = "Bearer " + this.accessToken;
  187.         }
  188.     }
  189. }
  190.  
  191. export class VoidAuth implements Authentication {
  192.     public username: string;
  193.     public password: string;
  194.     applyToRequest(_: request.Options): void {
  195.         // Do nothing
  196.     }
  197. }
  198.  
  199. export enum AcquisitionApiApiKeys {
  200.     Bearer,
  201. }
  202.  
  203. export class AcquisitionApi {
  204.     protected _basePath = defaultBasePath;
  205.     protected defaultHeaders : any = {};
  206.     protected _useQuerystring : boolean = false;
  207.  
  208.     protected authentications = {
  209.         'default': <Authentication>new VoidAuth(),
  210.         'Bearer': new ApiKeyAuth('header', 'Authorization'),
  211.     }
  212.  
  213.     constructor(basePath?: string);
  214.     constructor(basePathOrUsername: string, password?: string, basePath?: string) {
  215.         if (password) {
  216.             if (basePath) {
  217.                 this.basePath = basePath;
  218.             }
  219.         } else {
  220.             if (basePathOrUsername) {
  221.                 this.basePath = basePathOrUsername
  222.             }
  223.         }
  224.     }
  225.  
  226.     set useQuerystring(value: boolean) {
  227.         this._useQuerystring = value;
  228.     }
  229.  
  230.     set basePath(basePath: string) {
  231.         this._basePath = basePath;
  232.     }
  233.  
  234.     get basePath() {
  235.         return this._basePath;
  236.     }
  237.  
  238.     public setDefaultAuthentication(auth: Authentication) {
  239.     this.authentications.default = auth;
  240.     }
  241.  
  242.     public setApiKey(key: AcquisitionApiApiKeys, value: string) {
  243.         this.authentications[AcquisitionApiApiKeys[key]].apiKey = value;
  244.     }
  245.     /**
  246.      * Returns the acquisition service status to the caller
  247.      */
  248.     public getAcquisitionStatus () : Promise<{ response: http.ClientResponse; body: AcquisitionStatusSuccessResponse;  }> {
  249.         const localVarPath = this.basePath + '/public/hotfix/status';
  250.         let queryParameters: any = {};
  251.         let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
  252.         let formParams: any = {};
  253.  
  254.  
  255.         let useFormData = false;
  256.  
  257.         let requestOptions: request.Options = {
  258.             method: 'GET',
  259.             qs: queryParameters,
  260.             headers: headerParams,
  261.             uri: localVarPath,
  262.             useQuerystring: this._useQuerystring,
  263.             json: true,
  264.         };
  265.  
  266.         this.authentications.default.applyToRequest(requestOptions);
  267.  
  268.         if (Object.keys(formParams).length) {
  269.             if (useFormData) {
  270.                 (<any>requestOptions).formData = formParams;
  271.             } else {
  272.                 requestOptions.form = formParams;
  273.             }
  274.         }
  275.         return new Promise<{ response: http.ClientResponse; body: AcquisitionStatusSuccessResponse;  }>((resolve, reject) => {
  276.             request(requestOptions, (error, response, body) => {
  277.                 if (error) {
  278.                     reject(error);
  279.                 } else {
  280.                     if (response.statusCode >= 200 && response.statusCode <= 299) {
  281.                         resolve({ response: response, body: body });
  282.                     } else {
  283.                         reject({ response: response, body: body });
  284.                     }
  285.                 }
  286.             });
  287.         });
  288.     }
  289.     /**
  290.      * Check for updates
  291.      * @param deploymentKey
  292.      * @param appVersion
  293.      * @param packageHash
  294.      * @param label
  295.      * @param clientUniqueId
  296.      * @param isCompanion
  297.      * @param previousLabelOrAppVersion
  298.      * @param previousDeploymentKey
  299.      */
  300.     public getUpdate (deploymentKey: string, appVersion: string, packageHash?: string, label?: string, clientUniqueId?: string, isCompanion?: boolean, previousLabelOrAppVersion?: string, previousDeploymentKey?: string) : Promise<{ response: http.ClientResponse; body: UpdateCheckResponse;  }> {
  301.         const localVarPath = this.basePath + '/public/hotfix/update_check';
  302.         let queryParameters: any = {};
  303.         let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
  304.         let formParams: any = {};
  305.  
  306.  
  307.         // verify required parameter 'deploymentKey' is not null or undefined
  308.         if (deploymentKey === null || deploymentKey === undefined) {
  309.             throw new Error('Required parameter deploymentKey was null or undefined when calling getUpdate.');
  310.         }
  311.  
  312.         // verify required parameter 'appVersion' is not null or undefined
  313.         if (appVersion === null || appVersion === undefined) {
  314.             throw new Error('Required parameter appVersion was null or undefined when calling getUpdate.');
  315.         }
  316.  
  317.         if (deploymentKey !== undefined) {
  318.             queryParameters['deployment_key'] = deploymentKey;
  319.         }
  320.  
  321.         if (appVersion !== undefined) {
  322.             queryParameters['app_version'] = appVersion;
  323.         }
  324.  
  325.         if (packageHash !== undefined) {
  326.             queryParameters['package_hash'] = packageHash;
  327.         }
  328.  
  329.         if (label !== undefined) {
  330.             queryParameters['label'] = label;
  331.         }
  332.  
  333.         if (clientUniqueId !== undefined) {
  334.             queryParameters['client_unique_id'] = clientUniqueId;
  335.         }
  336.  
  337.         if (isCompanion !== undefined) {
  338.             queryParameters['is_companion'] = isCompanion;
  339.         }
  340.  
  341.         if (previousLabelOrAppVersion !== undefined) {
  342.             queryParameters['previous_label_or_app_version'] = previousLabelOrAppVersion;
  343.         }
  344.  
  345.         if (previousDeploymentKey !== undefined) {
  346.             queryParameters['previous_deployment_key'] = previousDeploymentKey;
  347.         }
  348.  
  349.         let useFormData = false;
  350.  
  351.         let requestOptions: request.Options = {
  352.             method: 'GET',
  353.             qs: queryParameters,
  354.             headers: headerParams,
  355.             uri: localVarPath,
  356.             useQuerystring: this._useQuerystring,
  357.             json: true,
  358.         };
  359.  
  360.         this.authentications.default.applyToRequest(requestOptions);
  361.  
  362.         if (Object.keys(formParams).length) {
  363.             if (useFormData) {
  364.                 (<any>requestOptions).formData = formParams;
  365.             } else {
  366.                 requestOptions.form = formParams;
  367.             }
  368.         }
  369.         return new Promise<{ response: http.ClientResponse; body: UpdateCheckResponse;  }>((resolve, reject) => {
  370.             request(requestOptions, (error, response, body) => {
  371.                 if (error) {
  372.                     reject(error);
  373.                 } else {
  374.                     if (response.statusCode >= 200 && response.statusCode <= 299) {
  375.                         resolve({ response: response, body: body });
  376.                     } else {
  377.                         reject({ response: response, body: body });
  378.                     }
  379.                 }
  380.             });
  381.         });
  382.     }
  383.     /**
  384.      * Report Deployment status metric
  385.      * @param releaseMetadata Deployment status metric properties
  386.      */
  387.     public postDeployStatusMetric (releaseMetadata: CodePushStatusMetricMetadata) : Promise<{ response: http.ClientResponse; body?: any;  }> {
  388.         const localVarPath = this.basePath + '/public/hotfix/report_status/deploy';
  389.         let queryParameters: any = {};
  390.         let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
  391.         let formParams: any = {};
  392.  
  393.  
  394.         // verify required parameter 'releaseMetadata' is not null or undefined
  395.         if (releaseMetadata === null || releaseMetadata === undefined) {
  396.             throw new Error('Required parameter releaseMetadata was null or undefined when calling postDeployStatusMetric.');
  397.         }
  398.  
  399.         let useFormData = false;
  400.  
  401.         let requestOptions: request.Options = {
  402.             method: 'POST',
  403.             qs: queryParameters,
  404.             headers: headerParams,
  405.             uri: localVarPath,
  406.             useQuerystring: this._useQuerystring,
  407.             json: true,
  408.             body: releaseMetadata,
  409.         };
  410.  
  411.         this.authentications.default.applyToRequest(requestOptions);
  412.  
  413.         if (Object.keys(formParams).length) {
  414.             if (useFormData) {
  415.                 (<any>requestOptions).formData = formParams;
  416.             } else {
  417.                 requestOptions.form = formParams;
  418.             }
  419.         }
  420.         return new Promise<{ response: http.ClientResponse; body?: any;  }>((resolve, reject) => {
  421.             request(requestOptions, (error, response, body) => {
  422.                 if (error) {
  423.                     reject(error);
  424.                 } else {
  425.                     if (response.statusCode >= 200 && response.statusCode <= 299) {
  426.                         resolve({ response: response, body: body });
  427.                     } else {
  428.                         reject({ response: response, body: body });
  429.                     }
  430.                 }
  431.             });
  432.         });
  433.     }
  434.     /**
  435.      * Report download of specified release
  436.      * @param releaseMetadata Deployment status metric properties
  437.      */
  438.     public postDownloadStatusMetric (releaseMetadata: CodePushStatusMetricMetadata) : Promise<{ response: http.ClientResponse; body?: any;  }> {
  439.         const localVarPath = this.basePath + '/public/hotfix/report_status/download';
  440.         let queryParameters: any = {};
  441.         let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
  442.         let formParams: any = {};
  443.  
  444.  
  445.         // verify required parameter 'releaseMetadata' is not null or undefined
  446.         if (releaseMetadata === null || releaseMetadata === undefined) {
  447.             throw new Error('Required parameter releaseMetadata was null or undefined when calling postDownloadStatusMetric.');
  448.         }
  449.  
  450.         let useFormData = false;
  451.  
  452.         let requestOptions: request.Options = {
  453.             method: 'POST',
  454.             qs: queryParameters,
  455.             headers: headerParams,
  456.             uri: localVarPath,
  457.             useQuerystring: this._useQuerystring,
  458.             json: true,
  459.             body: releaseMetadata,
  460.         };
  461.  
  462.         this.authentications.default.applyToRequest(requestOptions);
  463.  
  464.         if (Object.keys(formParams).length) {
  465.             if (useFormData) {
  466.                 (<any>requestOptions).formData = formParams;
  467.             } else {
  468.                 requestOptions.form = formParams;
  469.             }
  470.         }
  471.         return new Promise<{ response: http.ClientResponse; body?: any;  }>((resolve, reject) => {
  472.             request(requestOptions, (error, response, body) => {
  473.                 if (error) {
  474.                     reject(error);
  475.                 } else {
  476.                     if (response.statusCode >= 200 && response.statusCode <= 299) {
  477.                         resolve({ response: response, body: body });
  478.                     } else {
  479.                         reject({ response: response, body: body });
  480.                     }
  481.                 }
  482.             });
  483.         });
  484.     }
  485. }
  486. export enum DeploymentsApiApiKeys {
  487.     Bearer,
  488. }
  489.  
  490. export class DeploymentsApi {
  491.     protected _basePath = defaultBasePath;
  492.     protected defaultHeaders : any = {};
  493.     protected _useQuerystring : boolean = false;
  494.  
  495.     protected authentications = {
  496.         'default': <Authentication>new VoidAuth(),
  497.         'Bearer': new ApiKeyAuth('header', 'Authorization'),
  498.     }
  499.  
  500.     constructor(basePath?: string);
  501.     constructor(basePathOrUsername: string, password?: string, basePath?: string) {
  502.         if (password) {
  503.             if (basePath) {
  504.                 this.basePath = basePath;
  505.             }
  506.         } else {
  507.             if (basePathOrUsername) {
  508.                 this.basePath = basePathOrUsername
  509.             }
  510.         }
  511.     }
  512.  
  513.     set useQuerystring(value: boolean) {
  514.         this._useQuerystring = value;
  515.     }
  516.  
  517.     set basePath(basePath: string) {
  518.         this._basePath = basePath;
  519.     }
  520.  
  521.     get basePath() {
  522.         return this._basePath;
  523.     }
  524.  
  525.     public setDefaultAuthentication(auth: Authentication) {
  526.     this.authentications.default = auth;
  527.     }
  528.  
  529.     public setApiKey(key: DeploymentsApiApiKeys, value: string) {
  530.         this.authentications[DeploymentsApiApiKeys[key]].apiKey = value;
  531.     }
  532.     /**
  533.      * Deletes a CodePush Deployment for the given app
  534.      * @param appId application id
  535.      * @param deploymentName deployment name
  536.      */
  537.     public deleteDeployment (appId: string, deploymentName: string) : Promise<{ response: http.ClientResponse; body?: any;  }> {
  538.         const localVarPath = this.basePath + '/apps/{app_id}/deployments/{deployment_name}'
  539.             .replace('{' + 'app_id' + '}', String(appId))
  540.             .replace('{' + 'deployment_name' + '}', String(deploymentName));
  541.         let queryParameters: any = {};
  542.         let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
  543.         let formParams: any = {};
  544.  
  545.  
  546.         // verify required parameter 'appId' is not null or undefined
  547.         if (appId === null || appId === undefined) {
  548.             throw new Error('Required parameter appId was null or undefined when calling deleteDeployment.');
  549.         }
  550.  
  551.         // verify required parameter 'deploymentName' is not null or undefined
  552.         if (deploymentName === null || deploymentName === undefined) {
  553.             throw new Error('Required parameter deploymentName was null or undefined when calling deleteDeployment.');
  554.         }
  555.  
  556.         let useFormData = false;
  557.  
  558.         let requestOptions: request.Options = {
  559.             method: 'DELETE',
  560.             qs: queryParameters,
  561.             headers: headerParams,
  562.             uri: localVarPath,
  563.             useQuerystring: this._useQuerystring,
  564.             json: true,
  565.         };
  566.  
  567.         this.authentications.Bearer.applyToRequest(requestOptions);
  568.  
  569.         this.authentications.default.applyToRequest(requestOptions);
  570.  
  571.         if (Object.keys(formParams).length) {
  572.             if (useFormData) {
  573.                 (<any>requestOptions).formData = formParams;
  574.             } else {
  575.                 requestOptions.form = formParams;
  576.             }
  577.         }
  578.         return new Promise<{ response: http.ClientResponse; body?: any;  }>((resolve, reject) => {
  579.             request(requestOptions, (error, response, body) => {
  580.                 if (error) {
  581.                     reject(error);
  582.                 } else {
  583.                     if (response.statusCode >= 200 && response.statusCode <= 299) {
  584.                         resolve({ response: response, body: body });
  585.                     } else {
  586.                         reject({ response: response, body: body });
  587.                     }
  588.                 }
  589.             });
  590.         });
  591.     }
  592.     /**
  593.      * Gets a CodePush Deployment for the given app
  594.      * @param appId application id
  595.      * @param deploymentName deployment name
  596.      */
  597.     public getDeployment (appId: string, deploymentName: string) : Promise<{ response: http.ClientResponse; body: Deployment;  }> {
  598.         const localVarPath = this.basePath + '/apps/{app_id}/deployments/{deployment_name}'
  599.             .replace('{' + 'app_id' + '}', String(appId))
  600.             .replace('{' + 'deployment_name' + '}', String(deploymentName));
  601.         let queryParameters: any = {};
  602.         let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
  603.         let formParams: any = {};
  604.  
  605.  
  606.         // verify required parameter 'appId' is not null or undefined
  607.         if (appId === null || appId === undefined) {
  608.             throw new Error('Required parameter appId was null or undefined when calling getDeployment.');
  609.         }
  610.  
  611.         // verify required parameter 'deploymentName' is not null or undefined
  612.         if (deploymentName === null || deploymentName === undefined) {
  613.             throw new Error('Required parameter deploymentName was null or undefined when calling getDeployment.');
  614.         }
  615.  
  616.         let useFormData = false;
  617.  
  618.         let requestOptions: request.Options = {
  619.             method: 'GET',
  620.             qs: queryParameters,
  621.             headers: headerParams,
  622.             uri: localVarPath,
  623.             useQuerystring: this._useQuerystring,
  624.             json: true,
  625.         };
  626.  
  627.         this.authentications.Bearer.applyToRequest(requestOptions);
  628.  
  629.         this.authentications.default.applyToRequest(requestOptions);
  630.  
  631.         if (Object.keys(formParams).length) {
  632.             if (useFormData) {
  633.                 (<any>requestOptions).formData = formParams;
  634.             } else {
  635.                 requestOptions.form = formParams;
  636.             }
  637.         }
  638.         return new Promise<{ response: http.ClientResponse; body: Deployment;  }>((resolve, reject) => {
  639.             request(requestOptions, (error, response, body) => {
  640.                 if (error) {
  641.                     reject(error);
  642.                 } else {
  643.                     if (response.statusCode >= 200 && response.statusCode <= 299) {
  644.                         resolve({ response: response, body: body });
  645.                     } else {
  646.                         reject({ response: response, body: body });
  647.                     }
  648.                 }
  649.             });
  650.         });
  651.     }
  652.     /**
  653.      * Gets a list of CodePush deployments for the given app
  654.      * @param appId application id
  655.      */
  656.     public getDeployments (appId: string) : Promise<{ response: http.ClientResponse; body: Array<Deployment>;  }> {
  657.         const localVarPath = this.basePath + '/apps/{app_id}/deployments'
  658.             .replace('{' + 'app_id' + '}', String(appId));
  659.         let queryParameters: any = {};
  660.         let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
  661.         let formParams: any = {};
  662.  
  663.  
  664.         // verify required parameter 'appId' is not null or undefined
  665.         if (appId === null || appId === undefined) {
  666.             throw new Error('Required parameter appId was null or undefined when calling getDeployments.');
  667.         }
  668.  
  669.         let useFormData = false;
  670.  
  671.         let requestOptions: request.Options = {
  672.             method: 'GET',
  673.             qs: queryParameters,
  674.             headers: headerParams,
  675.             uri: localVarPath,
  676.             useQuerystring: this._useQuerystring,
  677.             json: true,
  678.         };
  679.  
  680.         this.authentications.Bearer.applyToRequest(requestOptions);
  681.  
  682.         this.authentications.default.applyToRequest(requestOptions);
  683.  
  684.         if (Object.keys(formParams).length) {
  685.             if (useFormData) {
  686.                 (<any>requestOptions).formData = formParams;
  687.             } else {
  688.                 requestOptions.form = formParams;
  689.             }
  690.         }
  691.         return new Promise<{ response: http.ClientResponse; body: Array<Deployment>;  }>((resolve, reject) => {
  692.             request(requestOptions, (error, response, body) => {
  693.                 if (error) {
  694.                     reject(error);
  695.                 } else {
  696.                     if (response.statusCode >= 200 && response.statusCode <= 299) {
  697.                         resolve({ response: response, body: body });
  698.                     } else {
  699.                         reject({ response: response, body: body });
  700.                     }
  701.                 }
  702.             });
  703.         });
  704.     }
  705.     /**
  706.      * Modifies a CodePush Deployment for the given app
  707.      * @param appId application id
  708.      * @param deploymentName deployment name
  709.      * @param deployment Deployment modification. All fields are optional and only provided fields will get updated.
  710.      */
  711.     public patchDeployment (appId: string, deploymentName: string, deployment: DeploymentModification) : Promise<{ response: http.ClientResponse; body?: any;  }> {
  712.         const localVarPath = this.basePath + '/apps/{app_id}/deployments/{deployment_name}'
  713.             .replace('{' + 'app_id' + '}', String(appId))
  714.             .replace('{' + 'deployment_name' + '}', String(deploymentName));
  715.         let queryParameters: any = {};
  716.         let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
  717.         let formParams: any = {};
  718.  
  719.  
  720.         // verify required parameter 'appId' is not null or undefined
  721.         if (appId === null || appId === undefined) {
  722.             throw new Error('Required parameter appId was null or undefined when calling patchDeployment.');
  723.         }
  724.  
  725.         // verify required parameter 'deploymentName' is not null or undefined
  726.         if (deploymentName === null || deploymentName === undefined) {
  727.             throw new Error('Required parameter deploymentName was null or undefined when calling patchDeployment.');
  728.         }
  729.  
  730.         // verify required parameter 'deployment' is not null or undefined
  731.         if (deployment === null || deployment === undefined) {
  732.             throw new Error('Required parameter deployment was null or undefined when calling patchDeployment.');
  733.         }
  734.  
  735.         let useFormData = false;
  736.  
  737.         let requestOptions: request.Options = {
  738.             method: 'PATCH',
  739.             qs: queryParameters,
  740.             headers: headerParams,
  741.             uri: localVarPath,
  742.             useQuerystring: this._useQuerystring,
  743.             json: true,
  744.             body: deployment,
  745.         };
  746.  
  747.         this.authentications.Bearer.applyToRequest(requestOptions);
  748.  
  749.         this.authentications.default.applyToRequest(requestOptions);
  750.  
  751.         if (Object.keys(formParams).length) {
  752.             if (useFormData) {
  753.                 (<any>requestOptions).formData = formParams;
  754.             } else {
  755.                 requestOptions.form = formParams;
  756.             }
  757.         }
  758.         return new Promise<{ response: http.ClientResponse; body?: any;  }>((resolve, reject) => {
  759.             request(requestOptions, (error, response, body) => {
  760.                 if (error) {
  761.                     reject(error);
  762.                 } else {
  763.                     if (response.statusCode >= 200 && response.statusCode <= 299) {
  764.                         resolve({ response: response, body: body });
  765.                     } else {
  766.                         reject({ response: response, body: body });
  767.                     }
  768.                 }
  769.             });
  770.         });
  771.     }
  772.     /**
  773.      * Creates a CodePush Deployment for the given app
  774.      * @param appId application id
  775.      * @param deployment Deployment to be created
  776.      */
  777.     public postDeployments (appId: string, deployment: Deployment) : Promise<{ response: http.ClientResponse; body: Deployment;  }> {
  778.         const localVarPath = this.basePath + '/apps/{app_id}/deployments'
  779.             .replace('{' + 'app_id' + '}', String(appId));
  780.         let queryParameters: any = {};
  781.         let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
  782.         let formParams: any = {};
  783.  
  784.  
  785.         // verify required parameter 'appId' is not null or undefined
  786.         if (appId === null || appId === undefined) {
  787.             throw new Error('Required parameter appId was null or undefined when calling postDeployments.');
  788.         }
  789.  
  790.         // verify required parameter 'deployment' is not null or undefined
  791.         if (deployment === null || deployment === undefined) {
  792.             throw new Error('Required parameter deployment was null or undefined when calling postDeployments.');
  793.         }
  794.  
  795.         let useFormData = false;
  796.  
  797.         let requestOptions: request.Options = {
  798.             method: 'POST',
  799.             qs: queryParameters,
  800.             headers: headerParams,
  801.             uri: localVarPath,
  802.             useQuerystring: this._useQuerystring,
  803.             json: true,
  804.             body: deployment,
  805.         };
  806.  
  807.         this.authentications.Bearer.applyToRequest(requestOptions);
  808.  
  809.         this.authentications.default.applyToRequest(requestOptions);
  810.  
  811.         if (Object.keys(formParams).length) {
  812.             if (useFormData) {
  813.                 (<any>requestOptions).formData = formParams;
  814.             } else {
  815.                 requestOptions.form = formParams;
  816.             }
  817.         }
  818.         return new Promise<{ response: http.ClientResponse; body: Deployment;  }>((resolve, reject) => {
  819.             request(requestOptions, (error, response, body) => {
  820.                 if (error) {
  821.                     reject(error);
  822.                 } else {
  823.                     if (response.statusCode >= 200 && response.statusCode <= 299) {
  824.                         resolve({ response: response, body: body });
  825.                     } else {
  826.                         reject({ response: response, body: body });
  827.                     }
  828.                 }
  829.             });
  830.         });
  831.     }
  832.     /**
  833.      * Promote one release (default latest one) from one deployment to another
  834.      * @param appId application id
  835.      * @param deploymentName deployment name
  836.      * @param promoteDeploymentName deployment name
  837.      * @param internalUserEmail The ID of the user
  838.      * @param release Release to be promoted, only needs to provide optional fields, description, label, disabled, mandatory, rollout, targetBinaryVersion
  839.      */
  840.     public promoteDeployment (appId: string, deploymentName: string, promoteDeploymentName: string, internalUserEmail: string, release?: CodePushReleasePromote) : Promise<{ response: http.ClientResponse; body: CodePushRelease;  }> {
  841.         const localVarPath = this.basePath + '/apps/{app_id}/deployments/{deployment_name}/promote_release/{promote_deployment_name}'
  842.             .replace('{' + 'app_id' + '}', String(appId))
  843.             .replace('{' + 'deployment_name' + '}', String(deploymentName))
  844.             .replace('{' + 'promote_deployment_name' + '}', String(promoteDeploymentName));
  845.         let queryParameters: any = {};
  846.         let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
  847.         let formParams: any = {};
  848.  
  849.  
  850.         // verify required parameter 'appId' is not null or undefined
  851.         if (appId === null || appId === undefined) {
  852.             throw new Error('Required parameter appId was null or undefined when calling promoteDeployment.');
  853.         }
  854.  
  855.         // verify required parameter 'deploymentName' is not null or undefined
  856.         if (deploymentName === null || deploymentName === undefined) {
  857.             throw new Error('Required parameter deploymentName was null or undefined when calling promoteDeployment.');
  858.         }
  859.  
  860.         // verify required parameter 'promoteDeploymentName' is not null or undefined
  861.         if (promoteDeploymentName === null || promoteDeploymentName === undefined) {
  862.             throw new Error('Required parameter promoteDeploymentName was null or undefined when calling promoteDeployment.');
  863.         }
  864.  
  865.         // verify required parameter 'internalUserEmail' is not null or undefined
  866.         if (internalUserEmail === null || internalUserEmail === undefined) {
  867.             throw new Error('Required parameter internalUserEmail was null or undefined when calling promoteDeployment.');
  868.         }
  869.  
  870.         headerParams['internal-user-email'] = internalUserEmail;
  871.  
  872.         let useFormData = false;
  873.  
  874.         let requestOptions: request.Options = {
  875.             method: 'POST',
  876.             qs: queryParameters,
  877.             headers: headerParams,
  878.             uri: localVarPath,
  879.             useQuerystring: this._useQuerystring,
  880.             json: true,
  881.             body: release,
  882.         };
  883.  
  884.         this.authentications.Bearer.applyToRequest(requestOptions);
  885.  
  886.         this.authentications.default.applyToRequest(requestOptions);
  887.  
  888.         if (Object.keys(formParams).length) {
  889.             if (useFormData) {
  890.                 (<any>requestOptions).formData = formParams;
  891.             } else {
  892.                 requestOptions.form = formParams;
  893.             }
  894.         }
  895.         return new Promise<{ response: http.ClientResponse; body: CodePushRelease;  }>((resolve, reject) => {
  896.             request(requestOptions, (error, response, body) => {
  897.                 if (error) {
  898.                     reject(error);
  899.                 } else {
  900.                     if (response.statusCode >= 200 && response.statusCode <= 299) {
  901.                         resolve({ response: response, body: body });
  902.                     } else {
  903.                         reject({ response: response, body: body });
  904.                     }
  905.                 }
  906.             });
  907.         });
  908.     }
  909. }
  910. export enum DistributeApiApiKeys {
  911.     Bearer,
  912. }
  913.  
  914. export class DistributeApi {
  915.     protected _basePath = defaultBasePath;
  916.     protected defaultHeaders : any = {};
  917.     protected _useQuerystring : boolean = false;
  918.  
  919.     protected authentications = {
  920.         'default': <Authentication>new VoidAuth(),
  921.         'Bearer': new ApiKeyAuth('header', 'Authorization'),
  922.     }
  923.  
  924.     constructor(basePath?: string);
  925.     constructor(basePathOrUsername: string, password?: string, basePath?: string) {
  926.         if (password) {
  927.             if (basePath) {
  928.                 this.basePath = basePath;
  929.             }
  930.         } else {
  931.             if (basePathOrUsername) {
  932.                 this.basePath = basePathOrUsername
  933.             }
  934.         }
  935.     }
  936.  
  937.     set useQuerystring(value: boolean) {
  938.         this._useQuerystring = value;
  939.     }
  940.  
  941.     set basePath(basePath: string) {
  942.         this._basePath = basePath;
  943.     }
  944.  
  945.     get basePath() {
  946.         return this._basePath;
  947.     }
  948.  
  949.     public setDefaultAuthentication(auth: Authentication) {
  950.     this.authentications.default = auth;
  951.     }
  952.  
  953.     public setApiKey(key: DistributeApiApiKeys, value: string) {
  954.         this.authentications[DistributeApiApiKeys[key]].apiKey = value;
  955.     }
  956.     /**
  957.      * Deletes every Code Push deployment and associated releases that was soft deleted before `maxDays` ago.
  958.      * @param maxDays Delete every release that was soft deleted before &#x60;maxDays&#x60; ago. 60 is the minimum to avoid bugs that will cause unexpected deletion. max 365.
  959.      */
  960.     public purge (maxDays: number) : Promise<{ response: http.ClientResponse; body?: any;  }> {
  961.         const localVarPath = this.basePath + '/manage/codePush/purge';
  962.         let queryParameters: any = {};
  963.         let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
  964.         let formParams: any = {};
  965.  
  966.  
  967.         // verify required parameter 'maxDays' is not null or undefined
  968.         if (maxDays === null || maxDays === undefined) {
  969.             throw new Error('Required parameter maxDays was null or undefined when calling purge.');
  970.         }
  971.  
  972.         if (maxDays !== undefined) {
  973.             queryParameters['maxDays'] = maxDays;
  974.         }
  975.  
  976.         let useFormData = false;
  977.  
  978.         let requestOptions: request.Options = {
  979.             method: 'POST',
  980.             qs: queryParameters,
  981.             headers: headerParams,
  982.             uri: localVarPath,
  983.             useQuerystring: this._useQuerystring,
  984.             json: true,
  985.         };
  986.  
  987.         this.authentications.default.applyToRequest(requestOptions);
  988.  
  989.         if (Object.keys(formParams).length) {
  990.             if (useFormData) {
  991.                 (<any>requestOptions).formData = formParams;
  992.             } else {
  993.                 requestOptions.form = formParams;
  994.             }
  995.         }
  996.         return new Promise<{ response: http.ClientResponse; body?: any;  }>((resolve, reject) => {
  997.             request(requestOptions, (error, response, body) => {
  998.                 if (error) {
  999.                     reject(error);
  1000.                 } else {
  1001.                     if (response.statusCode >= 200 && response.statusCode <= 299) {
  1002.                         resolve({ response: response, body: body });
  1003.                     } else {
  1004.                         reject({ response: response, body: body });
  1005.                     }
  1006.                 }
  1007.             });
  1008.         });
  1009.     }
  1010. }
  1011. export enum ReleasesApiApiKeys {
  1012.     Bearer,
  1013. }
  1014.  
  1015. export class ReleasesApi {
  1016.     protected _basePath = defaultBasePath;
  1017.     protected defaultHeaders : any = {};
  1018.     protected _useQuerystring : boolean = false;
  1019.  
  1020.     protected authentications = {
  1021.         'default': <Authentication>new VoidAuth(),
  1022.         'Bearer': new ApiKeyAuth('header', 'Authorization'),
  1023.     }
  1024.  
  1025.     constructor(basePath?: string);
  1026.     constructor(basePathOrUsername: string, password?: string, basePath?: string) {
  1027.         if (password) {
  1028.             if (basePath) {
  1029.                 this.basePath = basePath;
  1030.             }
  1031.         } else {
  1032.             if (basePathOrUsername) {
  1033.                 this.basePath = basePathOrUsername
  1034.             }
  1035.         }
  1036.     }
  1037.  
  1038.     set useQuerystring(value: boolean) {
  1039.         this._useQuerystring = value;
  1040.     }
  1041.  
  1042.     set basePath(basePath: string) {
  1043.         this._basePath = basePath;
  1044.     }
  1045.  
  1046.     get basePath() {
  1047.         return this._basePath;
  1048.     }
  1049.  
  1050.     public setDefaultAuthentication(auth: Authentication) {
  1051.     this.authentications.default = auth;
  1052.     }
  1053.  
  1054.     public setApiKey(key: ReleasesApiApiKeys, value: string) {
  1055.         this.authentications[ReleasesApiApiKeys[key]].apiKey = value;
  1056.     }
  1057.     /**
  1058.      * Clears a Deployment of releases
  1059.      * @param appId application id
  1060.      * @param deploymentName deployment name
  1061.      */
  1062.     public deleteReleases (appId: string, deploymentName: string) : Promise<{ response: http.ClientResponse; body?: any;  }> {
  1063.         const localVarPath = this.basePath + '/apps/{app_id}/deployments/{deployment_name}/releases'
  1064.             .replace('{' + 'app_id' + '}', String(appId))
  1065.             .replace('{' + 'deployment_name' + '}', String(deploymentName));
  1066.         let queryParameters: any = {};
  1067.         let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
  1068.         let formParams: any = {};
  1069.  
  1070.  
  1071.         // verify required parameter 'appId' is not null or undefined
  1072.         if (appId === null || appId === undefined) {
  1073.             throw new Error('Required parameter appId was null or undefined when calling deleteReleases.');
  1074.         }
  1075.  
  1076.         // verify required parameter 'deploymentName' is not null or undefined
  1077.         if (deploymentName === null || deploymentName === undefined) {
  1078.             throw new Error('Required parameter deploymentName was null or undefined when calling deleteReleases.');
  1079.         }
  1080.  
  1081.         let useFormData = false;
  1082.  
  1083.         let requestOptions: request.Options = {
  1084.             method: 'DELETE',
  1085.             qs: queryParameters,
  1086.             headers: headerParams,
  1087.             uri: localVarPath,
  1088.             useQuerystring: this._useQuerystring,
  1089.             json: true,
  1090.         };
  1091.  
  1092.         this.authentications.Bearer.applyToRequest(requestOptions);
  1093.  
  1094.         this.authentications.default.applyToRequest(requestOptions);
  1095.  
  1096.         if (Object.keys(formParams).length) {
  1097.             if (useFormData) {
  1098.                 (<any>requestOptions).formData = formParams;
  1099.             } else {
  1100.                 requestOptions.form = formParams;
  1101.             }
  1102.         }
  1103.         return new Promise<{ response: http.ClientResponse; body?: any;  }>((resolve, reject) => {
  1104.             request(requestOptions, (error, response, body) => {
  1105.                 if (error) {
  1106.                     reject(error);
  1107.                 } else {
  1108.                     if (response.statusCode >= 200 && response.statusCode <= 299) {
  1109.                         resolve({ response: response, body: body });
  1110.                     } else {
  1111.                         reject({ response: response, body: body });
  1112.                     }
  1113.                 }
  1114.             });
  1115.         });
  1116.     }
  1117.     /**
  1118.      * Gets all releases metrics for specified Deployment
  1119.      * @param appId application id
  1120.      * @param deploymentName deployment name
  1121.      */
  1122.     public getDeploymentMetrics (appId: string, deploymentName: string) : Promise<{ response: http.ClientResponse; body: Array<CodePushReleaseMetric>;  }> {
  1123.         const localVarPath = this.basePath + '/apps/{app_id}/deployments/{deployment_name}/metrics'
  1124.             .replace('{' + 'app_id' + '}', String(appId))
  1125.             .replace('{' + 'deployment_name' + '}', String(deploymentName));
  1126.         let queryParameters: any = {};
  1127.         let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
  1128.         let formParams: any = {};
  1129.  
  1130.  
  1131.         // verify required parameter 'appId' is not null or undefined
  1132.         if (appId === null || appId === undefined) {
  1133.             throw new Error('Required parameter appId was null or undefined when calling getDeploymentMetrics.');
  1134.         }
  1135.  
  1136.         // verify required parameter 'deploymentName' is not null or undefined
  1137.         if (deploymentName === null || deploymentName === undefined) {
  1138.             throw new Error('Required parameter deploymentName was null or undefined when calling getDeploymentMetrics.');
  1139.         }
  1140.  
  1141.         let useFormData = false;
  1142.  
  1143.         let requestOptions: request.Options = {
  1144.             method: 'GET',
  1145.             qs: queryParameters,
  1146.             headers: headerParams,
  1147.             uri: localVarPath,
  1148.             useQuerystring: this._useQuerystring,
  1149.             json: true,
  1150.         };
  1151.  
  1152.         this.authentications.Bearer.applyToRequest(requestOptions);
  1153.  
  1154.         this.authentications.default.applyToRequest(requestOptions);
  1155.  
  1156.         if (Object.keys(formParams).length) {
  1157.             if (useFormData) {
  1158.                 (<any>requestOptions).formData = formParams;
  1159.             } else {
  1160.                 requestOptions.form = formParams;
  1161.             }
  1162.         }
  1163.         return new Promise<{ response: http.ClientResponse; body: Array<CodePushReleaseMetric>;  }>((resolve, reject) => {
  1164.             request(requestOptions, (error, response, body) => {
  1165.                 if (error) {
  1166.                     reject(error);
  1167.                 } else {
  1168.                     if (response.statusCode >= 200 && response.statusCode <= 299) {
  1169.                         resolve({ response: response, body: body });
  1170.                     } else {
  1171.                         reject({ response: response, body: body });
  1172.                     }
  1173.                 }
  1174.             });
  1175.         });
  1176.     }
  1177.     /**
  1178.      * Gets the history of releases on a Deployment
  1179.      * @param appId application id
  1180.      * @param deploymentName deployment name
  1181.      */
  1182.     public getReleases (appId: string, deploymentName: string) : Promise<{ response: http.ClientResponse; body: Array<CodePushRelease>;  }> {
  1183.         const localVarPath = this.basePath + '/apps/{app_id}/deployments/{deployment_name}/releases'
  1184.             .replace('{' + 'app_id' + '}', String(appId))
  1185.             .replace('{' + 'deployment_name' + '}', String(deploymentName));
  1186.         let queryParameters: any = {};
  1187.         let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
  1188.         let formParams: any = {};
  1189.  
  1190.  
  1191.         // verify required parameter 'appId' is not null or undefined
  1192.         if (appId === null || appId === undefined) {
  1193.             throw new Error('Required parameter appId was null or undefined when calling getReleases.');
  1194.         }
  1195.  
  1196.         // verify required parameter 'deploymentName' is not null or undefined
  1197.         if (deploymentName === null || deploymentName === undefined) {
  1198.             throw new Error('Required parameter deploymentName was null or undefined when calling getReleases.');
  1199.         }
  1200.  
  1201.         let useFormData = false;
  1202.  
  1203.         let requestOptions: request.Options = {
  1204.             method: 'GET',
  1205.             qs: queryParameters,
  1206.             headers: headerParams,
  1207.             uri: localVarPath,
  1208.             useQuerystring: this._useQuerystring,
  1209.             json: true,
  1210.         };
  1211.  
  1212.         this.authentications.Bearer.applyToRequest(requestOptions);
  1213.  
  1214.         this.authentications.default.applyToRequest(requestOptions);
  1215.  
  1216.         if (Object.keys(formParams).length) {
  1217.             if (useFormData) {
  1218.                 (<any>requestOptions).formData = formParams;
  1219.             } else {
  1220.                 requestOptions.form = formParams;
  1221.             }
  1222.         }
  1223.         return new Promise<{ response: http.ClientResponse; body: Array<CodePushRelease>;  }>((resolve, reject) => {
  1224.             request(requestOptions, (error, response, body) => {
  1225.                 if (error) {
  1226.                     reject(error);
  1227.                 } else {
  1228.                     if (response.statusCode >= 200 && response.statusCode <= 299) {
  1229.                         resolve({ response: response, body: body });
  1230.                     } else {
  1231.                         reject({ response: response, body: body });
  1232.                     }
  1233.                 }
  1234.             });
  1235.         });
  1236.     }
  1237.     /**
  1238.      * Modifies a CodePush release metadata under the given Deployment
  1239.      * @param appId application id
  1240.      * @param deploymentName deployment name
  1241.      * @param releaseLabel release label
  1242.      * @param release Release modification. All fields are optional and only provided fields will get updated.
  1243.      */
  1244.     public patchRelease (appId: string, deploymentName: string, releaseLabel: string, release: CodePushReleaseModification) : Promise<{ response: http.ClientResponse; body: CodePushRelease;  }> {
  1245.         const localVarPath = this.basePath + '/apps/{app_id}/deployments/{deployment_name}/releases/{release_label}'
  1246.             .replace('{' + 'app_id' + '}', String(appId))
  1247.             .replace('{' + 'deployment_name' + '}', String(deploymentName))
  1248.             .replace('{' + 'release_label' + '}', String(releaseLabel));
  1249.         let queryParameters: any = {};
  1250.         let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
  1251.         let formParams: any = {};
  1252.  
  1253.  
  1254.         // verify required parameter 'appId' is not null or undefined
  1255.         if (appId === null || appId === undefined) {
  1256.             throw new Error('Required parameter appId was null or undefined when calling patchRelease.');
  1257.         }
  1258.  
  1259.         // verify required parameter 'deploymentName' is not null or undefined
  1260.         if (deploymentName === null || deploymentName === undefined) {
  1261.             throw new Error('Required parameter deploymentName was null or undefined when calling patchRelease.');
  1262.         }
  1263.  
  1264.         // verify required parameter 'releaseLabel' is not null or undefined
  1265.         if (releaseLabel === null || releaseLabel === undefined) {
  1266.             throw new Error('Required parameter releaseLabel was null or undefined when calling patchRelease.');
  1267.         }
  1268.  
  1269.         // verify required parameter 'release' is not null or undefined
  1270.         if (release === null || release === undefined) {
  1271.             throw new Error('Required parameter release was null or undefined when calling patchRelease.');
  1272.         }
  1273.  
  1274.         let useFormData = false;
  1275.  
  1276.         let requestOptions: request.Options = {
  1277.             method: 'PATCH',
  1278.             qs: queryParameters,
  1279.             headers: headerParams,
  1280.             uri: localVarPath,
  1281.             useQuerystring: this._useQuerystring,
  1282.             json: true,
  1283.             body: release,
  1284.         };
  1285.  
  1286.         this.authentications.Bearer.applyToRequest(requestOptions);
  1287.  
  1288.         this.authentications.default.applyToRequest(requestOptions);
  1289.  
  1290.         if (Object.keys(formParams).length) {
  1291.             if (useFormData) {
  1292.                 (<any>requestOptions).formData = formParams;
  1293.             } else {
  1294.                 requestOptions.form = formParams;
  1295.             }
  1296.         }
  1297.         return new Promise<{ response: http.ClientResponse; body: CodePushRelease;  }>((resolve, reject) => {
  1298.             request(requestOptions, (error, response, body) => {
  1299.                 if (error) {
  1300.                     reject(error);
  1301.                 } else {
  1302.                     if (response.statusCode >= 200 && response.statusCode <= 299) {
  1303.                         resolve({ response: response, body: body });
  1304.                     } else {
  1305.                         reject({ response: response, body: body });
  1306.                     }
  1307.                 }
  1308.             });
  1309.         });
  1310.     }
  1311.     /**
  1312.      * Create a new CodePush release for the specified deployment
  1313.      * @param appId application id
  1314.      * @param deploymentName deployment name
  1315.      * @param internalUserId The ID of the user
  1316.      * @param internalUserEmail The email of the user
  1317.      * @param targetBinaryVersion the binary version of the application
  1318.      * @param _package The upload zip file
  1319.      * @param deploymentName2 This specifies which deployment you want to release the update to. Default is Staging.
  1320.      * @param description This provides an optional \&quot;change log\&quot; for the deployment.
  1321.      * @param disabled This specifies whether an update should be downloadable by end users or not.
  1322.      * @param mandatory This specifies whether the update should be considered mandatory or not (e.g. it includes a critical security fix).
  1323.      * @param noDuplicateReleaseError This specifies that if the update is identical to the latest release on the deployment, the CLI should generate a warning instead of an error.
  1324.      * @param rollout This specifies the percentage of users (as an integer between 1 and 100) that should be eligible to receive this update.
  1325.      */
  1326.     public postRelease (appId: string, deploymentName: string, internalUserId: string, internalUserEmail: string, targetBinaryVersion: string, _package?: Buffer, deploymentName2?: string, description?: string, disabled?: boolean, mandatory?: boolean, noDuplicateReleaseError?: boolean, rollout?: number) : Promise<{ response: http.ClientResponse; body: CodePushRelease;  }> {
  1327.         const localVarPath = this.basePath + '/apps/{app_id}/deployments/{deployment_name}/releases'
  1328.             .replace('{' + 'app_id' + '}', String(appId))
  1329.             .replace('{' + 'deployment_name' + '}', String(deploymentName));
  1330.         let queryParameters: any = {};
  1331.         let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
  1332.         let formParams: any = {};
  1333.  
  1334.  
  1335.         // verify required parameter 'appId' is not null or undefined
  1336.         if (appId === null || appId === undefined) {
  1337.             throw new Error('Required parameter appId was null or undefined when calling postRelease.');
  1338.         }
  1339.  
  1340.         // verify required parameter 'deploymentName' is not null or undefined
  1341.         if (deploymentName === null || deploymentName === undefined) {
  1342.             throw new Error('Required parameter deploymentName was null or undefined when calling postRelease.');
  1343.         }
  1344.  
  1345.         // verify required parameter 'internalUserId' is not null or undefined
  1346.         if (internalUserId === null || internalUserId === undefined) {
  1347.             throw new Error('Required parameter internalUserId was null or undefined when calling postRelease.');
  1348.         }
  1349.  
  1350.         // verify required parameter 'internalUserEmail' is not null or undefined
  1351.         if (internalUserEmail === null || internalUserEmail === undefined) {
  1352.             throw new Error('Required parameter internalUserEmail was null or undefined when calling postRelease.');
  1353.         }
  1354.  
  1355.         // verify required parameter 'targetBinaryVersion' is not null or undefined
  1356.         if (targetBinaryVersion === null || targetBinaryVersion === undefined) {
  1357.             throw new Error('Required parameter targetBinaryVersion was null or undefined when calling postRelease.');
  1358.         }
  1359.  
  1360.         headerParams['internal-user-id'] = internalUserId;
  1361.  
  1362.         headerParams['internal-user-email'] = internalUserEmail;
  1363.  
  1364.         let useFormData = false;
  1365.  
  1366.         if (_package !== undefined) {
  1367.             formParams['package'] = _package;
  1368.         }
  1369.         useFormData = true;
  1370.  
  1371.         if (targetBinaryVersion !== undefined) {
  1372.             formParams['targetBinaryVersion'] = targetBinaryVersion;
  1373.         }
  1374.  
  1375.         if (deploymentName2 !== undefined) {
  1376.             formParams['deploymentName'] = deploymentName2;
  1377.         }
  1378.  
  1379.         if (description !== undefined) {
  1380.             formParams['description'] = description;
  1381.         }
  1382.  
  1383.         if (disabled !== undefined) {
  1384.             formParams['disabled'] = disabled;
  1385.         }
  1386.  
  1387.         if (mandatory !== undefined) {
  1388.             formParams['mandatory'] = mandatory;
  1389.         }
  1390.  
  1391.         if (noDuplicateReleaseError !== undefined) {
  1392.             formParams['noDuplicateReleaseError'] = noDuplicateReleaseError;
  1393.         }
  1394.  
  1395.         if (rollout !== undefined) {
  1396.             formParams['rollout'] = rollout;
  1397.         }
  1398.  
  1399.         let requestOptions: request.Options = {
  1400.             method: 'POST',
  1401.             qs: queryParameters,
  1402.             headers: headerParams,
  1403.             uri: localVarPath,
  1404.             useQuerystring: this._useQuerystring,
  1405.             json: true,
  1406.         };
  1407.  
  1408.         this.authentications.Bearer.applyToRequest(requestOptions);
  1409.  
  1410.         this.authentications.default.applyToRequest(requestOptions);
  1411.  
  1412.         if (Object.keys(formParams).length) {
  1413.             if (useFormData) {
  1414.                 (<any>requestOptions).formData = formParams;
  1415.             } else {
  1416.                 requestOptions.form = formParams;
  1417.             }
  1418.         }
  1419.         return new Promise<{ response: http.ClientResponse; body: CodePushRelease;  }>((resolve, reject) => {
  1420.             request(requestOptions, (error, response, body) => {
  1421.                 if (error) {
  1422.                     reject(error);
  1423.                 } else {
  1424.                     if (response.statusCode >= 200 && response.statusCode <= 299) {
  1425.                         resolve({ response: response, body: body });
  1426.                     } else {
  1427.                         reject({ response: response, body: body });
  1428.                     }
  1429.                 }
  1430.             });
  1431.         });
  1432.     }
  1433.     /**
  1434.      * Rollback the latest or a specific release for an app deployment
  1435.      * @param appId application id
  1436.      * @param deploymentName deployment name
  1437.      * @param internalUserEmail The ID of the user
  1438.      * @param releaseLabel The specific release label that you want to rollback to
  1439.      */
  1440.     public postRollbackRelease (appId: string, deploymentName: string, internalUserEmail: string, releaseLabel?: CodePushReleaseLabel) : Promise<{ response: http.ClientResponse; body: CodePushRelease;  }> {
  1441.         const localVarPath = this.basePath + '/apps/{app_id}/deployments/{deployment_name}/rollback_release'
  1442.             .replace('{' + 'app_id' + '}', String(appId))
  1443.             .replace('{' + 'deployment_name' + '}', String(deploymentName));
  1444.         let queryParameters: any = {};
  1445.         let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
  1446.         let formParams: any = {};
  1447.  
  1448.  
  1449.         // verify required parameter 'appId' is not null or undefined
  1450.         if (appId === null || appId === undefined) {
  1451.             throw new Error('Required parameter appId was null or undefined when calling postRollbackRelease.');
  1452.         }
  1453.  
  1454.         // verify required parameter 'deploymentName' is not null or undefined
  1455.         if (deploymentName === null || deploymentName === undefined) {
  1456.             throw new Error('Required parameter deploymentName was null or undefined when calling postRollbackRelease.');
  1457.         }
  1458.  
  1459.         // verify required parameter 'internalUserEmail' is not null or undefined
  1460.         if (internalUserEmail === null || internalUserEmail === undefined) {
  1461.             throw new Error('Required parameter internalUserEmail was null or undefined when calling postRollbackRelease.');
  1462.         }
  1463.  
  1464.         headerParams['internal-user-email'] = internalUserEmail;
  1465.  
  1466.         let useFormData = false;
  1467.  
  1468.         let requestOptions: request.Options = {
  1469.             method: 'POST',
  1470.             qs: queryParameters,
  1471.             headers: headerParams,
  1472.             uri: localVarPath,
  1473.             useQuerystring: this._useQuerystring,
  1474.             json: true,
  1475.             body: releaseLabel,
  1476.         };
  1477.  
  1478.         this.authentications.Bearer.applyToRequest(requestOptions);
  1479.  
  1480.         this.authentications.default.applyToRequest(requestOptions);
  1481.  
  1482.         if (Object.keys(formParams).length) {
  1483.             if (useFormData) {
  1484.                 (<any>requestOptions).formData = formParams;
  1485.             } else {
  1486.                 requestOptions.form = formParams;
  1487.             }
  1488.         }
  1489.         return new Promise<{ response: http.ClientResponse; body: CodePushRelease;  }>((resolve, reject) => {
  1490.             request(requestOptions, (error, response, body) => {
  1491.                 if (error) {
  1492.                     reject(error);
  1493.                 } else {
  1494.                     if (response.statusCode >= 200 && response.statusCode <= 299) {
  1495.                         resolve({ response: response, body: body });
  1496.                     } else {
  1497.                         reject({ response: response, body: body });
  1498.                     }
  1499.                 }
  1500.             });
  1501.         });
  1502.     }
  1503. }
  1504. export enum ServiceApiApiKeys {
  1505.     Bearer,
  1506. }
  1507.  
  1508. export class ServiceApi {
  1509.     protected _basePath = defaultBasePath;
  1510.     protected defaultHeaders : any = {};
  1511.     protected _useQuerystring : boolean = false;
  1512.  
  1513.     protected authentications = {
  1514.         'default': <Authentication>new VoidAuth(),
  1515.         'Bearer': new ApiKeyAuth('header', 'Authorization'),
  1516.     }
  1517.  
  1518.     constructor(basePath?: string);
  1519.     constructor(basePathOrUsername: string, password?: string, basePath?: string) {
  1520.         if (password) {
  1521.             if (basePath) {
  1522.                 this.basePath = basePath;
  1523.             }
  1524.         } else {
  1525.             if (basePathOrUsername) {
  1526.                 this.basePath = basePathOrUsername
  1527.             }
  1528.         }
  1529.     }
  1530.  
  1531.     set useQuerystring(value: boolean) {
  1532.         this._useQuerystring = value;
  1533.     }
  1534.  
  1535.     set basePath(basePath: string) {
  1536.         this._basePath = basePath;
  1537.     }
  1538.  
  1539.     get basePath() {
  1540.         return this._basePath;
  1541.     }
  1542.  
  1543.     public setDefaultAuthentication(auth: Authentication) {
  1544.     this.authentications.default = auth;
  1545.     }
  1546.  
  1547.     public setApiKey(key: ServiceApiApiKeys, value: string) {
  1548.         this.authentications[ServiceApiApiKeys[key]].apiKey = value;
  1549.     }
  1550.     /**
  1551.      * Returns the service status to the caller
  1552.      */
  1553.     public getStatus () : Promise<{ response: http.ClientResponse; body: StatusResponse;  }> {
  1554.         const localVarPath = this.basePath + '/status';
  1555.         let queryParameters: any = {};
  1556.         let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
  1557.         let formParams: any = {};
  1558.  
  1559.  
  1560.         let useFormData = false;
  1561.  
  1562.         let requestOptions: request.Options = {
  1563.             method: 'GET',
  1564.             qs: queryParameters,
  1565.             headers: headerParams,
  1566.             uri: localVarPath,
  1567.             useQuerystring: this._useQuerystring,
  1568.             json: true,
  1569.         };
  1570.  
  1571.         this.authentications.default.applyToRequest(requestOptions);
  1572.  
  1573.         if (Object.keys(formParams).length) {
  1574.             if (useFormData) {
  1575.                 (<any>requestOptions).formData = formParams;
  1576.             } else {
  1577.                 requestOptions.form = formParams;
  1578.             }
  1579.         }
  1580.         return new Promise<{ response: http.ClientResponse; body: StatusResponse;  }>((resolve, reject) => {
  1581.             request(requestOptions, (error, response, body) => {
  1582.                 if (error) {
  1583.                     reject(error);
  1584.                 } else {
  1585.                     if (response.statusCode >= 200 && response.statusCode <= 299) {
  1586.                         resolve({ response: response, body: body });
  1587.                     } else {
  1588.                         reject({ response: response, body: body });
  1589.                     }
  1590.                 }
  1591.             });
  1592.         });
  1593.     }
  1594. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement