Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * code-push-api
- * The CodePush service backend
- *
- * OpenAPI spec version: 0.1.0
- *
- *
- * NOTE: This class is auto generated by the swagger code generator program.
- * https://github.com/swagger-api/swagger-codegen.git
- * Do not edit the class manually.
- */
- import request = require('request');
- import http = require('http');
- import Promise = require('bluebird');
- let defaultBasePath = 'https://code-push-api.mobilecenter-int.avalanch.es/v0.1';
- // ===============================================
- // This file is autogenerated - Please do not edit
- // ===============================================
- /* tslint:disable:no-unused-variable */
- export class AcquisitionStatusSuccessResponse {
- /**
- * The code indicating the status
- */
- 'code': string;
- /**
- * The message indicating the status
- */
- 'message': string;
- }
- export class BlobInfo {
- 'size': number;
- 'url': string;
- }
- export class CodePushRelease extends CodePushReleaseInfo {
- 'label': string;
- 'packageHash': string;
- 'blobUrl': string;
- 'diffPackageMap': PackageHashToBlobInfoMap;
- /**
- * Set on 'Promote'
- */
- 'originalDeployment': string;
- /**
- * Set on 'Promote' and 'Rollback'
- */
- 'originalLabel': string;
- 'releasedBy': string;
- /**
- * The release method is unknown if unspecified
- */
- 'releaseMethod': CodePushRelease.ReleaseMethodEnum;
- 'size': number;
- 'uploadTime': number;
- }
- export namespace CodePushRelease {
- export enum ReleaseMethodEnum {
- Upload = <any> 'Upload',
- Promote = <any> 'Promote',
- Rollback = <any> 'Rollback'
- }
- }
- export class CodePushReleaseInfo {
- 'targetBinaryRange': string;
- 'description': string;
- 'isDisabled': boolean;
- 'isMandatory': boolean;
- 'rollout': number;
- }
- export class CodePushReleaseLabel {
- 'label': string;
- }
- export class CodePushReleaseMetric {
- 'label': string;
- 'active': number;
- 'downloaded': number;
- 'failed': number;
- 'installed': number;
- }
- export class CodePushReleaseModification extends CodePushReleaseInfo {
- }
- export class CodePushReleasePromote extends CodePushReleaseInfo {
- 'label': string;
- }
- export class CodePushStatusMetricMetadata {
- 'deploymentKey': string;
- 'label': string;
- 'appVersion': string;
- 'previousDeploymentKey': string;
- 'previousLabelOrAppVersion': string;
- 'status': string;
- 'clientUniqueId': string;
- }
- export class Deployment {
- 'key': string;
- 'name': string;
- 'latestRelease': CodePushRelease;
- }
- export class DeploymentModification {
- 'name': string;
- }
- /**
- * An error response
- */
- export class Failure {
- /**
- * The code indicating the error
- */
- 'code': string;
- /**
- * The message indicating the error
- */
- 'message': string;
- }
- export class PackageHashToBlobInfoMap extends null<String, BlobInfo> {
- }
- export class StatusResponse {
- 'status': string;
- }
- export class UpdateCheckResponse extends CodePushReleaseInfo {
- 'downloadUrl': string;
- 'isAvailable': boolean;
- 'packageSize': number;
- 'shouldRunBinaryVersion': boolean;
- 'updateAppVersion': boolean;
- 'packageHash': string;
- 'label': string;
- }
- export interface Authentication {
- /**
- * Apply authentication settings to header and query params.
- */
- applyToRequest(requestOptions: request.Options): void;
- }
- export class HttpBasicAuth implements Authentication {
- public username: string;
- public password: string;
- applyToRequest(requestOptions: request.Options): void {
- requestOptions.auth = {
- username: this.username, password: this.password
- }
- }
- }
- export class ApiKeyAuth implements Authentication {
- public apiKey: string;
- constructor(private location: string, private paramName: string) {
- }
- applyToRequest(requestOptions: request.Options): void {
- if (this.location == "query") {
- (<any>requestOptions.qs)[this.paramName] = this.apiKey;
- } else if (this.location == "header" && requestOptions && requestOptions.headers) {
- requestOptions.headers[this.paramName] = this.apiKey;
- }
- }
- }
- export class OAuth implements Authentication {
- public accessToken: string;
- applyToRequest(requestOptions: request.Options): void {
- if (requestOptions && requestOptions.headers) {
- requestOptions.headers["Authorization"] = "Bearer " + this.accessToken;
- }
- }
- }
- export class VoidAuth implements Authentication {
- public username: string;
- public password: string;
- applyToRequest(_: request.Options): void {
- // Do nothing
- }
- }
- export enum AcquisitionApiApiKeys {
- Bearer,
- }
- export class AcquisitionApi {
- protected _basePath = defaultBasePath;
- protected defaultHeaders : any = {};
- protected _useQuerystring : boolean = false;
- protected authentications = {
- 'default': <Authentication>new VoidAuth(),
- 'Bearer': new ApiKeyAuth('header', 'Authorization'),
- }
- constructor(basePath?: string);
- constructor(basePathOrUsername: string, password?: string, basePath?: string) {
- if (password) {
- if (basePath) {
- this.basePath = basePath;
- }
- } else {
- if (basePathOrUsername) {
- this.basePath = basePathOrUsername
- }
- }
- }
- set useQuerystring(value: boolean) {
- this._useQuerystring = value;
- }
- set basePath(basePath: string) {
- this._basePath = basePath;
- }
- get basePath() {
- return this._basePath;
- }
- public setDefaultAuthentication(auth: Authentication) {
- this.authentications.default = auth;
- }
- public setApiKey(key: AcquisitionApiApiKeys, value: string) {
- this.authentications[AcquisitionApiApiKeys[key]].apiKey = value;
- }
- /**
- * Returns the acquisition service status to the caller
- */
- public getAcquisitionStatus () : Promise<{ response: http.ClientResponse; body: AcquisitionStatusSuccessResponse; }> {
- const localVarPath = this.basePath + '/public/hotfix/status';
- let queryParameters: any = {};
- let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
- let formParams: any = {};
- let useFormData = false;
- let requestOptions: request.Options = {
- method: 'GET',
- qs: queryParameters,
- headers: headerParams,
- uri: localVarPath,
- useQuerystring: this._useQuerystring,
- json: true,
- };
- this.authentications.default.applyToRequest(requestOptions);
- if (Object.keys(formParams).length) {
- if (useFormData) {
- (<any>requestOptions).formData = formParams;
- } else {
- requestOptions.form = formParams;
- }
- }
- return new Promise<{ response: http.ClientResponse; body: AcquisitionStatusSuccessResponse; }>((resolve, reject) => {
- request(requestOptions, (error, response, body) => {
- if (error) {
- reject(error);
- } else {
- if (response.statusCode >= 200 && response.statusCode <= 299) {
- resolve({ response: response, body: body });
- } else {
- reject({ response: response, body: body });
- }
- }
- });
- });
- }
- /**
- * Check for updates
- * @param deploymentKey
- * @param appVersion
- * @param packageHash
- * @param label
- * @param clientUniqueId
- * @param isCompanion
- * @param previousLabelOrAppVersion
- * @param previousDeploymentKey
- */
- public getUpdate (deploymentKey: string, appVersion: string, packageHash?: string, label?: string, clientUniqueId?: string, isCompanion?: boolean, previousLabelOrAppVersion?: string, previousDeploymentKey?: string) : Promise<{ response: http.ClientResponse; body: UpdateCheckResponse; }> {
- const localVarPath = this.basePath + '/public/hotfix/update_check';
- let queryParameters: any = {};
- let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
- let formParams: any = {};
- // verify required parameter 'deploymentKey' is not null or undefined
- if (deploymentKey === null || deploymentKey === undefined) {
- throw new Error('Required parameter deploymentKey was null or undefined when calling getUpdate.');
- }
- // verify required parameter 'appVersion' is not null or undefined
- if (appVersion === null || appVersion === undefined) {
- throw new Error('Required parameter appVersion was null or undefined when calling getUpdate.');
- }
- if (deploymentKey !== undefined) {
- queryParameters['deployment_key'] = deploymentKey;
- }
- if (appVersion !== undefined) {
- queryParameters['app_version'] = appVersion;
- }
- if (packageHash !== undefined) {
- queryParameters['package_hash'] = packageHash;
- }
- if (label !== undefined) {
- queryParameters['label'] = label;
- }
- if (clientUniqueId !== undefined) {
- queryParameters['client_unique_id'] = clientUniqueId;
- }
- if (isCompanion !== undefined) {
- queryParameters['is_companion'] = isCompanion;
- }
- if (previousLabelOrAppVersion !== undefined) {
- queryParameters['previous_label_or_app_version'] = previousLabelOrAppVersion;
- }
- if (previousDeploymentKey !== undefined) {
- queryParameters['previous_deployment_key'] = previousDeploymentKey;
- }
- let useFormData = false;
- let requestOptions: request.Options = {
- method: 'GET',
- qs: queryParameters,
- headers: headerParams,
- uri: localVarPath,
- useQuerystring: this._useQuerystring,
- json: true,
- };
- this.authentications.default.applyToRequest(requestOptions);
- if (Object.keys(formParams).length) {
- if (useFormData) {
- (<any>requestOptions).formData = formParams;
- } else {
- requestOptions.form = formParams;
- }
- }
- return new Promise<{ response: http.ClientResponse; body: UpdateCheckResponse; }>((resolve, reject) => {
- request(requestOptions, (error, response, body) => {
- if (error) {
- reject(error);
- } else {
- if (response.statusCode >= 200 && response.statusCode <= 299) {
- resolve({ response: response, body: body });
- } else {
- reject({ response: response, body: body });
- }
- }
- });
- });
- }
- /**
- * Report Deployment status metric
- * @param releaseMetadata Deployment status metric properties
- */
- public postDeployStatusMetric (releaseMetadata: CodePushStatusMetricMetadata) : Promise<{ response: http.ClientResponse; body?: any; }> {
- const localVarPath = this.basePath + '/public/hotfix/report_status/deploy';
- let queryParameters: any = {};
- let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
- let formParams: any = {};
- // verify required parameter 'releaseMetadata' is not null or undefined
- if (releaseMetadata === null || releaseMetadata === undefined) {
- throw new Error('Required parameter releaseMetadata was null or undefined when calling postDeployStatusMetric.');
- }
- let useFormData = false;
- let requestOptions: request.Options = {
- method: 'POST',
- qs: queryParameters,
- headers: headerParams,
- uri: localVarPath,
- useQuerystring: this._useQuerystring,
- json: true,
- body: releaseMetadata,
- };
- this.authentications.default.applyToRequest(requestOptions);
- if (Object.keys(formParams).length) {
- if (useFormData) {
- (<any>requestOptions).formData = formParams;
- } else {
- requestOptions.form = formParams;
- }
- }
- return new Promise<{ response: http.ClientResponse; body?: any; }>((resolve, reject) => {
- request(requestOptions, (error, response, body) => {
- if (error) {
- reject(error);
- } else {
- if (response.statusCode >= 200 && response.statusCode <= 299) {
- resolve({ response: response, body: body });
- } else {
- reject({ response: response, body: body });
- }
- }
- });
- });
- }
- /**
- * Report download of specified release
- * @param releaseMetadata Deployment status metric properties
- */
- public postDownloadStatusMetric (releaseMetadata: CodePushStatusMetricMetadata) : Promise<{ response: http.ClientResponse; body?: any; }> {
- const localVarPath = this.basePath + '/public/hotfix/report_status/download';
- let queryParameters: any = {};
- let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
- let formParams: any = {};
- // verify required parameter 'releaseMetadata' is not null or undefined
- if (releaseMetadata === null || releaseMetadata === undefined) {
- throw new Error('Required parameter releaseMetadata was null or undefined when calling postDownloadStatusMetric.');
- }
- let useFormData = false;
- let requestOptions: request.Options = {
- method: 'POST',
- qs: queryParameters,
- headers: headerParams,
- uri: localVarPath,
- useQuerystring: this._useQuerystring,
- json: true,
- body: releaseMetadata,
- };
- this.authentications.default.applyToRequest(requestOptions);
- if (Object.keys(formParams).length) {
- if (useFormData) {
- (<any>requestOptions).formData = formParams;
- } else {
- requestOptions.form = formParams;
- }
- }
- return new Promise<{ response: http.ClientResponse; body?: any; }>((resolve, reject) => {
- request(requestOptions, (error, response, body) => {
- if (error) {
- reject(error);
- } else {
- if (response.statusCode >= 200 && response.statusCode <= 299) {
- resolve({ response: response, body: body });
- } else {
- reject({ response: response, body: body });
- }
- }
- });
- });
- }
- }
- export enum DeploymentsApiApiKeys {
- Bearer,
- }
- export class DeploymentsApi {
- protected _basePath = defaultBasePath;
- protected defaultHeaders : any = {};
- protected _useQuerystring : boolean = false;
- protected authentications = {
- 'default': <Authentication>new VoidAuth(),
- 'Bearer': new ApiKeyAuth('header', 'Authorization'),
- }
- constructor(basePath?: string);
- constructor(basePathOrUsername: string, password?: string, basePath?: string) {
- if (password) {
- if (basePath) {
- this.basePath = basePath;
- }
- } else {
- if (basePathOrUsername) {
- this.basePath = basePathOrUsername
- }
- }
- }
- set useQuerystring(value: boolean) {
- this._useQuerystring = value;
- }
- set basePath(basePath: string) {
- this._basePath = basePath;
- }
- get basePath() {
- return this._basePath;
- }
- public setDefaultAuthentication(auth: Authentication) {
- this.authentications.default = auth;
- }
- public setApiKey(key: DeploymentsApiApiKeys, value: string) {
- this.authentications[DeploymentsApiApiKeys[key]].apiKey = value;
- }
- /**
- * Deletes a CodePush Deployment for the given app
- * @param appId application id
- * @param deploymentName deployment name
- */
- public deleteDeployment (appId: string, deploymentName: string) : Promise<{ response: http.ClientResponse; body?: any; }> {
- const localVarPath = this.basePath + '/apps/{app_id}/deployments/{deployment_name}'
- .replace('{' + 'app_id' + '}', String(appId))
- .replace('{' + 'deployment_name' + '}', String(deploymentName));
- let queryParameters: any = {};
- let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
- let formParams: any = {};
- // verify required parameter 'appId' is not null or undefined
- if (appId === null || appId === undefined) {
- throw new Error('Required parameter appId was null or undefined when calling deleteDeployment.');
- }
- // verify required parameter 'deploymentName' is not null or undefined
- if (deploymentName === null || deploymentName === undefined) {
- throw new Error('Required parameter deploymentName was null or undefined when calling deleteDeployment.');
- }
- let useFormData = false;
- let requestOptions: request.Options = {
- method: 'DELETE',
- qs: queryParameters,
- headers: headerParams,
- uri: localVarPath,
- useQuerystring: this._useQuerystring,
- json: true,
- };
- this.authentications.Bearer.applyToRequest(requestOptions);
- this.authentications.default.applyToRequest(requestOptions);
- if (Object.keys(formParams).length) {
- if (useFormData) {
- (<any>requestOptions).formData = formParams;
- } else {
- requestOptions.form = formParams;
- }
- }
- return new Promise<{ response: http.ClientResponse; body?: any; }>((resolve, reject) => {
- request(requestOptions, (error, response, body) => {
- if (error) {
- reject(error);
- } else {
- if (response.statusCode >= 200 && response.statusCode <= 299) {
- resolve({ response: response, body: body });
- } else {
- reject({ response: response, body: body });
- }
- }
- });
- });
- }
- /**
- * Gets a CodePush Deployment for the given app
- * @param appId application id
- * @param deploymentName deployment name
- */
- public getDeployment (appId: string, deploymentName: string) : Promise<{ response: http.ClientResponse; body: Deployment; }> {
- const localVarPath = this.basePath + '/apps/{app_id}/deployments/{deployment_name}'
- .replace('{' + 'app_id' + '}', String(appId))
- .replace('{' + 'deployment_name' + '}', String(deploymentName));
- let queryParameters: any = {};
- let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
- let formParams: any = {};
- // verify required parameter 'appId' is not null or undefined
- if (appId === null || appId === undefined) {
- throw new Error('Required parameter appId was null or undefined when calling getDeployment.');
- }
- // verify required parameter 'deploymentName' is not null or undefined
- if (deploymentName === null || deploymentName === undefined) {
- throw new Error('Required parameter deploymentName was null or undefined when calling getDeployment.');
- }
- let useFormData = false;
- let requestOptions: request.Options = {
- method: 'GET',
- qs: queryParameters,
- headers: headerParams,
- uri: localVarPath,
- useQuerystring: this._useQuerystring,
- json: true,
- };
- this.authentications.Bearer.applyToRequest(requestOptions);
- this.authentications.default.applyToRequest(requestOptions);
- if (Object.keys(formParams).length) {
- if (useFormData) {
- (<any>requestOptions).formData = formParams;
- } else {
- requestOptions.form = formParams;
- }
- }
- return new Promise<{ response: http.ClientResponse; body: Deployment; }>((resolve, reject) => {
- request(requestOptions, (error, response, body) => {
- if (error) {
- reject(error);
- } else {
- if (response.statusCode >= 200 && response.statusCode <= 299) {
- resolve({ response: response, body: body });
- } else {
- reject({ response: response, body: body });
- }
- }
- });
- });
- }
- /**
- * Gets a list of CodePush deployments for the given app
- * @param appId application id
- */
- public getDeployments (appId: string) : Promise<{ response: http.ClientResponse; body: Array<Deployment>; }> {
- const localVarPath = this.basePath + '/apps/{app_id}/deployments'
- .replace('{' + 'app_id' + '}', String(appId));
- let queryParameters: any = {};
- let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
- let formParams: any = {};
- // verify required parameter 'appId' is not null or undefined
- if (appId === null || appId === undefined) {
- throw new Error('Required parameter appId was null or undefined when calling getDeployments.');
- }
- let useFormData = false;
- let requestOptions: request.Options = {
- method: 'GET',
- qs: queryParameters,
- headers: headerParams,
- uri: localVarPath,
- useQuerystring: this._useQuerystring,
- json: true,
- };
- this.authentications.Bearer.applyToRequest(requestOptions);
- this.authentications.default.applyToRequest(requestOptions);
- if (Object.keys(formParams).length) {
- if (useFormData) {
- (<any>requestOptions).formData = formParams;
- } else {
- requestOptions.form = formParams;
- }
- }
- return new Promise<{ response: http.ClientResponse; body: Array<Deployment>; }>((resolve, reject) => {
- request(requestOptions, (error, response, body) => {
- if (error) {
- reject(error);
- } else {
- if (response.statusCode >= 200 && response.statusCode <= 299) {
- resolve({ response: response, body: body });
- } else {
- reject({ response: response, body: body });
- }
- }
- });
- });
- }
- /**
- * Modifies a CodePush Deployment for the given app
- * @param appId application id
- * @param deploymentName deployment name
- * @param deployment Deployment modification. All fields are optional and only provided fields will get updated.
- */
- public patchDeployment (appId: string, deploymentName: string, deployment: DeploymentModification) : Promise<{ response: http.ClientResponse; body?: any; }> {
- const localVarPath = this.basePath + '/apps/{app_id}/deployments/{deployment_name}'
- .replace('{' + 'app_id' + '}', String(appId))
- .replace('{' + 'deployment_name' + '}', String(deploymentName));
- let queryParameters: any = {};
- let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
- let formParams: any = {};
- // verify required parameter 'appId' is not null or undefined
- if (appId === null || appId === undefined) {
- throw new Error('Required parameter appId was null or undefined when calling patchDeployment.');
- }
- // verify required parameter 'deploymentName' is not null or undefined
- if (deploymentName === null || deploymentName === undefined) {
- throw new Error('Required parameter deploymentName was null or undefined when calling patchDeployment.');
- }
- // verify required parameter 'deployment' is not null or undefined
- if (deployment === null || deployment === undefined) {
- throw new Error('Required parameter deployment was null or undefined when calling patchDeployment.');
- }
- let useFormData = false;
- let requestOptions: request.Options = {
- method: 'PATCH',
- qs: queryParameters,
- headers: headerParams,
- uri: localVarPath,
- useQuerystring: this._useQuerystring,
- json: true,
- body: deployment,
- };
- this.authentications.Bearer.applyToRequest(requestOptions);
- this.authentications.default.applyToRequest(requestOptions);
- if (Object.keys(formParams).length) {
- if (useFormData) {
- (<any>requestOptions).formData = formParams;
- } else {
- requestOptions.form = formParams;
- }
- }
- return new Promise<{ response: http.ClientResponse; body?: any; }>((resolve, reject) => {
- request(requestOptions, (error, response, body) => {
- if (error) {
- reject(error);
- } else {
- if (response.statusCode >= 200 && response.statusCode <= 299) {
- resolve({ response: response, body: body });
- } else {
- reject({ response: response, body: body });
- }
- }
- });
- });
- }
- /**
- * Creates a CodePush Deployment for the given app
- * @param appId application id
- * @param deployment Deployment to be created
- */
- public postDeployments (appId: string, deployment: Deployment) : Promise<{ response: http.ClientResponse; body: Deployment; }> {
- const localVarPath = this.basePath + '/apps/{app_id}/deployments'
- .replace('{' + 'app_id' + '}', String(appId));
- let queryParameters: any = {};
- let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
- let formParams: any = {};
- // verify required parameter 'appId' is not null or undefined
- if (appId === null || appId === undefined) {
- throw new Error('Required parameter appId was null or undefined when calling postDeployments.');
- }
- // verify required parameter 'deployment' is not null or undefined
- if (deployment === null || deployment === undefined) {
- throw new Error('Required parameter deployment was null or undefined when calling postDeployments.');
- }
- let useFormData = false;
- let requestOptions: request.Options = {
- method: 'POST',
- qs: queryParameters,
- headers: headerParams,
- uri: localVarPath,
- useQuerystring: this._useQuerystring,
- json: true,
- body: deployment,
- };
- this.authentications.Bearer.applyToRequest(requestOptions);
- this.authentications.default.applyToRequest(requestOptions);
- if (Object.keys(formParams).length) {
- if (useFormData) {
- (<any>requestOptions).formData = formParams;
- } else {
- requestOptions.form = formParams;
- }
- }
- return new Promise<{ response: http.ClientResponse; body: Deployment; }>((resolve, reject) => {
- request(requestOptions, (error, response, body) => {
- if (error) {
- reject(error);
- } else {
- if (response.statusCode >= 200 && response.statusCode <= 299) {
- resolve({ response: response, body: body });
- } else {
- reject({ response: response, body: body });
- }
- }
- });
- });
- }
- /**
- * Promote one release (default latest one) from one deployment to another
- * @param appId application id
- * @param deploymentName deployment name
- * @param promoteDeploymentName deployment name
- * @param internalUserEmail The ID of the user
- * @param release Release to be promoted, only needs to provide optional fields, description, label, disabled, mandatory, rollout, targetBinaryVersion
- */
- public promoteDeployment (appId: string, deploymentName: string, promoteDeploymentName: string, internalUserEmail: string, release?: CodePushReleasePromote) : Promise<{ response: http.ClientResponse; body: CodePushRelease; }> {
- const localVarPath = this.basePath + '/apps/{app_id}/deployments/{deployment_name}/promote_release/{promote_deployment_name}'
- .replace('{' + 'app_id' + '}', String(appId))
- .replace('{' + 'deployment_name' + '}', String(deploymentName))
- .replace('{' + 'promote_deployment_name' + '}', String(promoteDeploymentName));
- let queryParameters: any = {};
- let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
- let formParams: any = {};
- // verify required parameter 'appId' is not null or undefined
- if (appId === null || appId === undefined) {
- throw new Error('Required parameter appId was null or undefined when calling promoteDeployment.');
- }
- // verify required parameter 'deploymentName' is not null or undefined
- if (deploymentName === null || deploymentName === undefined) {
- throw new Error('Required parameter deploymentName was null or undefined when calling promoteDeployment.');
- }
- // verify required parameter 'promoteDeploymentName' is not null or undefined
- if (promoteDeploymentName === null || promoteDeploymentName === undefined) {
- throw new Error('Required parameter promoteDeploymentName was null or undefined when calling promoteDeployment.');
- }
- // verify required parameter 'internalUserEmail' is not null or undefined
- if (internalUserEmail === null || internalUserEmail === undefined) {
- throw new Error('Required parameter internalUserEmail was null or undefined when calling promoteDeployment.');
- }
- headerParams['internal-user-email'] = internalUserEmail;
- let useFormData = false;
- let requestOptions: request.Options = {
- method: 'POST',
- qs: queryParameters,
- headers: headerParams,
- uri: localVarPath,
- useQuerystring: this._useQuerystring,
- json: true,
- body: release,
- };
- this.authentications.Bearer.applyToRequest(requestOptions);
- this.authentications.default.applyToRequest(requestOptions);
- if (Object.keys(formParams).length) {
- if (useFormData) {
- (<any>requestOptions).formData = formParams;
- } else {
- requestOptions.form = formParams;
- }
- }
- return new Promise<{ response: http.ClientResponse; body: CodePushRelease; }>((resolve, reject) => {
- request(requestOptions, (error, response, body) => {
- if (error) {
- reject(error);
- } else {
- if (response.statusCode >= 200 && response.statusCode <= 299) {
- resolve({ response: response, body: body });
- } else {
- reject({ response: response, body: body });
- }
- }
- });
- });
- }
- }
- export enum DistributeApiApiKeys {
- Bearer,
- }
- export class DistributeApi {
- protected _basePath = defaultBasePath;
- protected defaultHeaders : any = {};
- protected _useQuerystring : boolean = false;
- protected authentications = {
- 'default': <Authentication>new VoidAuth(),
- 'Bearer': new ApiKeyAuth('header', 'Authorization'),
- }
- constructor(basePath?: string);
- constructor(basePathOrUsername: string, password?: string, basePath?: string) {
- if (password) {
- if (basePath) {
- this.basePath = basePath;
- }
- } else {
- if (basePathOrUsername) {
- this.basePath = basePathOrUsername
- }
- }
- }
- set useQuerystring(value: boolean) {
- this._useQuerystring = value;
- }
- set basePath(basePath: string) {
- this._basePath = basePath;
- }
- get basePath() {
- return this._basePath;
- }
- public setDefaultAuthentication(auth: Authentication) {
- this.authentications.default = auth;
- }
- public setApiKey(key: DistributeApiApiKeys, value: string) {
- this.authentications[DistributeApiApiKeys[key]].apiKey = value;
- }
- /**
- * Deletes every Code Push deployment and associated releases that was soft deleted before `maxDays` ago.
- * @param maxDays Delete every release that was soft deleted before `maxDays` ago. 60 is the minimum to avoid bugs that will cause unexpected deletion. max 365.
- */
- public purge (maxDays: number) : Promise<{ response: http.ClientResponse; body?: any; }> {
- const localVarPath = this.basePath + '/manage/codePush/purge';
- let queryParameters: any = {};
- let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
- let formParams: any = {};
- // verify required parameter 'maxDays' is not null or undefined
- if (maxDays === null || maxDays === undefined) {
- throw new Error('Required parameter maxDays was null or undefined when calling purge.');
- }
- if (maxDays !== undefined) {
- queryParameters['maxDays'] = maxDays;
- }
- let useFormData = false;
- let requestOptions: request.Options = {
- method: 'POST',
- qs: queryParameters,
- headers: headerParams,
- uri: localVarPath,
- useQuerystring: this._useQuerystring,
- json: true,
- };
- this.authentications.default.applyToRequest(requestOptions);
- if (Object.keys(formParams).length) {
- if (useFormData) {
- (<any>requestOptions).formData = formParams;
- } else {
- requestOptions.form = formParams;
- }
- }
- return new Promise<{ response: http.ClientResponse; body?: any; }>((resolve, reject) => {
- request(requestOptions, (error, response, body) => {
- if (error) {
- reject(error);
- } else {
- if (response.statusCode >= 200 && response.statusCode <= 299) {
- resolve({ response: response, body: body });
- } else {
- reject({ response: response, body: body });
- }
- }
- });
- });
- }
- }
- export enum ReleasesApiApiKeys {
- Bearer,
- }
- export class ReleasesApi {
- protected _basePath = defaultBasePath;
- protected defaultHeaders : any = {};
- protected _useQuerystring : boolean = false;
- protected authentications = {
- 'default': <Authentication>new VoidAuth(),
- 'Bearer': new ApiKeyAuth('header', 'Authorization'),
- }
- constructor(basePath?: string);
- constructor(basePathOrUsername: string, password?: string, basePath?: string) {
- if (password) {
- if (basePath) {
- this.basePath = basePath;
- }
- } else {
- if (basePathOrUsername) {
- this.basePath = basePathOrUsername
- }
- }
- }
- set useQuerystring(value: boolean) {
- this._useQuerystring = value;
- }
- set basePath(basePath: string) {
- this._basePath = basePath;
- }
- get basePath() {
- return this._basePath;
- }
- public setDefaultAuthentication(auth: Authentication) {
- this.authentications.default = auth;
- }
- public setApiKey(key: ReleasesApiApiKeys, value: string) {
- this.authentications[ReleasesApiApiKeys[key]].apiKey = value;
- }
- /**
- * Clears a Deployment of releases
- * @param appId application id
- * @param deploymentName deployment name
- */
- public deleteReleases (appId: string, deploymentName: string) : Promise<{ response: http.ClientResponse; body?: any; }> {
- const localVarPath = this.basePath + '/apps/{app_id}/deployments/{deployment_name}/releases'
- .replace('{' + 'app_id' + '}', String(appId))
- .replace('{' + 'deployment_name' + '}', String(deploymentName));
- let queryParameters: any = {};
- let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
- let formParams: any = {};
- // verify required parameter 'appId' is not null or undefined
- if (appId === null || appId === undefined) {
- throw new Error('Required parameter appId was null or undefined when calling deleteReleases.');
- }
- // verify required parameter 'deploymentName' is not null or undefined
- if (deploymentName === null || deploymentName === undefined) {
- throw new Error('Required parameter deploymentName was null or undefined when calling deleteReleases.');
- }
- let useFormData = false;
- let requestOptions: request.Options = {
- method: 'DELETE',
- qs: queryParameters,
- headers: headerParams,
- uri: localVarPath,
- useQuerystring: this._useQuerystring,
- json: true,
- };
- this.authentications.Bearer.applyToRequest(requestOptions);
- this.authentications.default.applyToRequest(requestOptions);
- if (Object.keys(formParams).length) {
- if (useFormData) {
- (<any>requestOptions).formData = formParams;
- } else {
- requestOptions.form = formParams;
- }
- }
- return new Promise<{ response: http.ClientResponse; body?: any; }>((resolve, reject) => {
- request(requestOptions, (error, response, body) => {
- if (error) {
- reject(error);
- } else {
- if (response.statusCode >= 200 && response.statusCode <= 299) {
- resolve({ response: response, body: body });
- } else {
- reject({ response: response, body: body });
- }
- }
- });
- });
- }
- /**
- * Gets all releases metrics for specified Deployment
- * @param appId application id
- * @param deploymentName deployment name
- */
- public getDeploymentMetrics (appId: string, deploymentName: string) : Promise<{ response: http.ClientResponse; body: Array<CodePushReleaseMetric>; }> {
- const localVarPath = this.basePath + '/apps/{app_id}/deployments/{deployment_name}/metrics'
- .replace('{' + 'app_id' + '}', String(appId))
- .replace('{' + 'deployment_name' + '}', String(deploymentName));
- let queryParameters: any = {};
- let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
- let formParams: any = {};
- // verify required parameter 'appId' is not null or undefined
- if (appId === null || appId === undefined) {
- throw new Error('Required parameter appId was null or undefined when calling getDeploymentMetrics.');
- }
- // verify required parameter 'deploymentName' is not null or undefined
- if (deploymentName === null || deploymentName === undefined) {
- throw new Error('Required parameter deploymentName was null or undefined when calling getDeploymentMetrics.');
- }
- let useFormData = false;
- let requestOptions: request.Options = {
- method: 'GET',
- qs: queryParameters,
- headers: headerParams,
- uri: localVarPath,
- useQuerystring: this._useQuerystring,
- json: true,
- };
- this.authentications.Bearer.applyToRequest(requestOptions);
- this.authentications.default.applyToRequest(requestOptions);
- if (Object.keys(formParams).length) {
- if (useFormData) {
- (<any>requestOptions).formData = formParams;
- } else {
- requestOptions.form = formParams;
- }
- }
- return new Promise<{ response: http.ClientResponse; body: Array<CodePushReleaseMetric>; }>((resolve, reject) => {
- request(requestOptions, (error, response, body) => {
- if (error) {
- reject(error);
- } else {
- if (response.statusCode >= 200 && response.statusCode <= 299) {
- resolve({ response: response, body: body });
- } else {
- reject({ response: response, body: body });
- }
- }
- });
- });
- }
- /**
- * Gets the history of releases on a Deployment
- * @param appId application id
- * @param deploymentName deployment name
- */
- public getReleases (appId: string, deploymentName: string) : Promise<{ response: http.ClientResponse; body: Array<CodePushRelease>; }> {
- const localVarPath = this.basePath + '/apps/{app_id}/deployments/{deployment_name}/releases'
- .replace('{' + 'app_id' + '}', String(appId))
- .replace('{' + 'deployment_name' + '}', String(deploymentName));
- let queryParameters: any = {};
- let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
- let formParams: any = {};
- // verify required parameter 'appId' is not null or undefined
- if (appId === null || appId === undefined) {
- throw new Error('Required parameter appId was null or undefined when calling getReleases.');
- }
- // verify required parameter 'deploymentName' is not null or undefined
- if (deploymentName === null || deploymentName === undefined) {
- throw new Error('Required parameter deploymentName was null or undefined when calling getReleases.');
- }
- let useFormData = false;
- let requestOptions: request.Options = {
- method: 'GET',
- qs: queryParameters,
- headers: headerParams,
- uri: localVarPath,
- useQuerystring: this._useQuerystring,
- json: true,
- };
- this.authentications.Bearer.applyToRequest(requestOptions);
- this.authentications.default.applyToRequest(requestOptions);
- if (Object.keys(formParams).length) {
- if (useFormData) {
- (<any>requestOptions).formData = formParams;
- } else {
- requestOptions.form = formParams;
- }
- }
- return new Promise<{ response: http.ClientResponse; body: Array<CodePushRelease>; }>((resolve, reject) => {
- request(requestOptions, (error, response, body) => {
- if (error) {
- reject(error);
- } else {
- if (response.statusCode >= 200 && response.statusCode <= 299) {
- resolve({ response: response, body: body });
- } else {
- reject({ response: response, body: body });
- }
- }
- });
- });
- }
- /**
- * Modifies a CodePush release metadata under the given Deployment
- * @param appId application id
- * @param deploymentName deployment name
- * @param releaseLabel release label
- * @param release Release modification. All fields are optional and only provided fields will get updated.
- */
- public patchRelease (appId: string, deploymentName: string, releaseLabel: string, release: CodePushReleaseModification) : Promise<{ response: http.ClientResponse; body: CodePushRelease; }> {
- const localVarPath = this.basePath + '/apps/{app_id}/deployments/{deployment_name}/releases/{release_label}'
- .replace('{' + 'app_id' + '}', String(appId))
- .replace('{' + 'deployment_name' + '}', String(deploymentName))
- .replace('{' + 'release_label' + '}', String(releaseLabel));
- let queryParameters: any = {};
- let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
- let formParams: any = {};
- // verify required parameter 'appId' is not null or undefined
- if (appId === null || appId === undefined) {
- throw new Error('Required parameter appId was null or undefined when calling patchRelease.');
- }
- // verify required parameter 'deploymentName' is not null or undefined
- if (deploymentName === null || deploymentName === undefined) {
- throw new Error('Required parameter deploymentName was null or undefined when calling patchRelease.');
- }
- // verify required parameter 'releaseLabel' is not null or undefined
- if (releaseLabel === null || releaseLabel === undefined) {
- throw new Error('Required parameter releaseLabel was null or undefined when calling patchRelease.');
- }
- // verify required parameter 'release' is not null or undefined
- if (release === null || release === undefined) {
- throw new Error('Required parameter release was null or undefined when calling patchRelease.');
- }
- let useFormData = false;
- let requestOptions: request.Options = {
- method: 'PATCH',
- qs: queryParameters,
- headers: headerParams,
- uri: localVarPath,
- useQuerystring: this._useQuerystring,
- json: true,
- body: release,
- };
- this.authentications.Bearer.applyToRequest(requestOptions);
- this.authentications.default.applyToRequest(requestOptions);
- if (Object.keys(formParams).length) {
- if (useFormData) {
- (<any>requestOptions).formData = formParams;
- } else {
- requestOptions.form = formParams;
- }
- }
- return new Promise<{ response: http.ClientResponse; body: CodePushRelease; }>((resolve, reject) => {
- request(requestOptions, (error, response, body) => {
- if (error) {
- reject(error);
- } else {
- if (response.statusCode >= 200 && response.statusCode <= 299) {
- resolve({ response: response, body: body });
- } else {
- reject({ response: response, body: body });
- }
- }
- });
- });
- }
- /**
- * Create a new CodePush release for the specified deployment
- * @param appId application id
- * @param deploymentName deployment name
- * @param internalUserId The ID of the user
- * @param internalUserEmail The email of the user
- * @param targetBinaryVersion the binary version of the application
- * @param _package The upload zip file
- * @param deploymentName2 This specifies which deployment you want to release the update to. Default is Staging.
- * @param description This provides an optional \"change log\" for the deployment.
- * @param disabled This specifies whether an update should be downloadable by end users or not.
- * @param mandatory This specifies whether the update should be considered mandatory or not (e.g. it includes a critical security fix).
- * @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.
- * @param rollout This specifies the percentage of users (as an integer between 1 and 100) that should be eligible to receive this update.
- */
- 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; }> {
- const localVarPath = this.basePath + '/apps/{app_id}/deployments/{deployment_name}/releases'
- .replace('{' + 'app_id' + '}', String(appId))
- .replace('{' + 'deployment_name' + '}', String(deploymentName));
- let queryParameters: any = {};
- let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
- let formParams: any = {};
- // verify required parameter 'appId' is not null or undefined
- if (appId === null || appId === undefined) {
- throw new Error('Required parameter appId was null or undefined when calling postRelease.');
- }
- // verify required parameter 'deploymentName' is not null or undefined
- if (deploymentName === null || deploymentName === undefined) {
- throw new Error('Required parameter deploymentName was null or undefined when calling postRelease.');
- }
- // verify required parameter 'internalUserId' is not null or undefined
- if (internalUserId === null || internalUserId === undefined) {
- throw new Error('Required parameter internalUserId was null or undefined when calling postRelease.');
- }
- // verify required parameter 'internalUserEmail' is not null or undefined
- if (internalUserEmail === null || internalUserEmail === undefined) {
- throw new Error('Required parameter internalUserEmail was null or undefined when calling postRelease.');
- }
- // verify required parameter 'targetBinaryVersion' is not null or undefined
- if (targetBinaryVersion === null || targetBinaryVersion === undefined) {
- throw new Error('Required parameter targetBinaryVersion was null or undefined when calling postRelease.');
- }
- headerParams['internal-user-id'] = internalUserId;
- headerParams['internal-user-email'] = internalUserEmail;
- let useFormData = false;
- if (_package !== undefined) {
- formParams['package'] = _package;
- }
- useFormData = true;
- if (targetBinaryVersion !== undefined) {
- formParams['targetBinaryVersion'] = targetBinaryVersion;
- }
- if (deploymentName2 !== undefined) {
- formParams['deploymentName'] = deploymentName2;
- }
- if (description !== undefined) {
- formParams['description'] = description;
- }
- if (disabled !== undefined) {
- formParams['disabled'] = disabled;
- }
- if (mandatory !== undefined) {
- formParams['mandatory'] = mandatory;
- }
- if (noDuplicateReleaseError !== undefined) {
- formParams['noDuplicateReleaseError'] = noDuplicateReleaseError;
- }
- if (rollout !== undefined) {
- formParams['rollout'] = rollout;
- }
- let requestOptions: request.Options = {
- method: 'POST',
- qs: queryParameters,
- headers: headerParams,
- uri: localVarPath,
- useQuerystring: this._useQuerystring,
- json: true,
- };
- this.authentications.Bearer.applyToRequest(requestOptions);
- this.authentications.default.applyToRequest(requestOptions);
- if (Object.keys(formParams).length) {
- if (useFormData) {
- (<any>requestOptions).formData = formParams;
- } else {
- requestOptions.form = formParams;
- }
- }
- return new Promise<{ response: http.ClientResponse; body: CodePushRelease; }>((resolve, reject) => {
- request(requestOptions, (error, response, body) => {
- if (error) {
- reject(error);
- } else {
- if (response.statusCode >= 200 && response.statusCode <= 299) {
- resolve({ response: response, body: body });
- } else {
- reject({ response: response, body: body });
- }
- }
- });
- });
- }
- /**
- * Rollback the latest or a specific release for an app deployment
- * @param appId application id
- * @param deploymentName deployment name
- * @param internalUserEmail The ID of the user
- * @param releaseLabel The specific release label that you want to rollback to
- */
- public postRollbackRelease (appId: string, deploymentName: string, internalUserEmail: string, releaseLabel?: CodePushReleaseLabel) : Promise<{ response: http.ClientResponse; body: CodePushRelease; }> {
- const localVarPath = this.basePath + '/apps/{app_id}/deployments/{deployment_name}/rollback_release'
- .replace('{' + 'app_id' + '}', String(appId))
- .replace('{' + 'deployment_name' + '}', String(deploymentName));
- let queryParameters: any = {};
- let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
- let formParams: any = {};
- // verify required parameter 'appId' is not null or undefined
- if (appId === null || appId === undefined) {
- throw new Error('Required parameter appId was null or undefined when calling postRollbackRelease.');
- }
- // verify required parameter 'deploymentName' is not null or undefined
- if (deploymentName === null || deploymentName === undefined) {
- throw new Error('Required parameter deploymentName was null or undefined when calling postRollbackRelease.');
- }
- // verify required parameter 'internalUserEmail' is not null or undefined
- if (internalUserEmail === null || internalUserEmail === undefined) {
- throw new Error('Required parameter internalUserEmail was null or undefined when calling postRollbackRelease.');
- }
- headerParams['internal-user-email'] = internalUserEmail;
- let useFormData = false;
- let requestOptions: request.Options = {
- method: 'POST',
- qs: queryParameters,
- headers: headerParams,
- uri: localVarPath,
- useQuerystring: this._useQuerystring,
- json: true,
- body: releaseLabel,
- };
- this.authentications.Bearer.applyToRequest(requestOptions);
- this.authentications.default.applyToRequest(requestOptions);
- if (Object.keys(formParams).length) {
- if (useFormData) {
- (<any>requestOptions).formData = formParams;
- } else {
- requestOptions.form = formParams;
- }
- }
- return new Promise<{ response: http.ClientResponse; body: CodePushRelease; }>((resolve, reject) => {
- request(requestOptions, (error, response, body) => {
- if (error) {
- reject(error);
- } else {
- if (response.statusCode >= 200 && response.statusCode <= 299) {
- resolve({ response: response, body: body });
- } else {
- reject({ response: response, body: body });
- }
- }
- });
- });
- }
- }
- export enum ServiceApiApiKeys {
- Bearer,
- }
- export class ServiceApi {
- protected _basePath = defaultBasePath;
- protected defaultHeaders : any = {};
- protected _useQuerystring : boolean = false;
- protected authentications = {
- 'default': <Authentication>new VoidAuth(),
- 'Bearer': new ApiKeyAuth('header', 'Authorization'),
- }
- constructor(basePath?: string);
- constructor(basePathOrUsername: string, password?: string, basePath?: string) {
- if (password) {
- if (basePath) {
- this.basePath = basePath;
- }
- } else {
- if (basePathOrUsername) {
- this.basePath = basePathOrUsername
- }
- }
- }
- set useQuerystring(value: boolean) {
- this._useQuerystring = value;
- }
- set basePath(basePath: string) {
- this._basePath = basePath;
- }
- get basePath() {
- return this._basePath;
- }
- public setDefaultAuthentication(auth: Authentication) {
- this.authentications.default = auth;
- }
- public setApiKey(key: ServiceApiApiKeys, value: string) {
- this.authentications[ServiceApiApiKeys[key]].apiKey = value;
- }
- /**
- * Returns the service status to the caller
- */
- public getStatus () : Promise<{ response: http.ClientResponse; body: StatusResponse; }> {
- const localVarPath = this.basePath + '/status';
- let queryParameters: any = {};
- let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
- let formParams: any = {};
- let useFormData = false;
- let requestOptions: request.Options = {
- method: 'GET',
- qs: queryParameters,
- headers: headerParams,
- uri: localVarPath,
- useQuerystring: this._useQuerystring,
- json: true,
- };
- this.authentications.default.applyToRequest(requestOptions);
- if (Object.keys(formParams).length) {
- if (useFormData) {
- (<any>requestOptions).formData = formParams;
- } else {
- requestOptions.form = formParams;
- }
- }
- return new Promise<{ response: http.ClientResponse; body: StatusResponse; }>((resolve, reject) => {
- request(requestOptions, (error, response, body) => {
- if (error) {
- reject(error);
- } else {
- if (response.statusCode >= 200 && response.statusCode <= 299) {
- resolve({ response: response, body: body });
- } else {
- reject({ response: response, body: body });
- }
- }
- });
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement