UNPKG

appcenter-cli

Version:

Command line tool for Visual Studio App Center

1,260 lines (1,224 loc) 47 kB
/* * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for * license information. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is * regenerated. */ 'use strict'; const msRest = require('ms-rest'); const WebResource = msRest.WebResource; /** * Return the store details for specified store name. * * @param {string} storeName The name of the store * * @param {string} ownerName The name of the owner * * @param {string} appName The name of the application * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @param {function} callback - The callback. * * @returns {function} callback(err, result, request, response) * * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. * See {@link ExternalStoreResponse} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _get(storeName, ownerName, appName, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { callback = options; options = null; } if (!callback) { throw new Error('callback cannot be null.'); } // Validate try { if (storeName === null || storeName === undefined || typeof storeName.valueOf() !== 'string') { throw new Error('storeName cannot be null or undefined and it must be of type string.'); } if (ownerName === null || ownerName === undefined || typeof ownerName.valueOf() !== 'string') { throw new Error('ownerName cannot be null or undefined and it must be of type string.'); } if (appName === null || appName === undefined || typeof appName.valueOf() !== 'string') { throw new Error('appName cannot be null or undefined and it must be of type string.'); } } catch (error) { return callback(error); } // Construct URL let baseUrl = this.client.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/apps/{owner_name}/{app_name}/distribution_stores/{store_name}'; requestUrl = requestUrl.replace('{store_name}', encodeURIComponent(storeName)); requestUrl = requestUrl.replace('{owner_name}', encodeURIComponent(ownerName)); requestUrl = requestUrl.replace('{app_name}', encodeURIComponent(appName)); // Create HTTP transport objects let httpRequest = new WebResource(); httpRequest.method = 'GET'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if(options) { for(let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } } } httpRequest.body = null; // Send Request return client.pipeline(httpRequest, (err, response, responseBody) => { if (err) { return callback(err); } let statusCode = response.statusCode; if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); error.response = msRest.stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { parsedErrorResponse = JSON.parse(responseBody); if (parsedErrorResponse) { let internalError = null; if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; error.code = internalError ? internalError.code : parsedErrorResponse.code; error.message = internalError ? internalError.message : parsedErrorResponse.message; } if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { let resultMapper = new client.models['ErrorDetails']().mapper(); error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); } // Create Result let result = null; if (responseBody === '') responseBody = null; // Deserialize Response if (statusCode === 200) { let parsedResponse = null; try { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { let resultMapper = new client.models['ExternalStoreResponse']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); deserializationError.request = msRest.stripRequest(httpRequest); deserializationError.response = msRest.stripResponse(response); return callback(deserializationError); } } return callback(null, result, httpRequest, response); }); } /** * Update the store. * * @param {string} storeName The name of the store * * @param {string} ownerName The name of the owner * * @param {string} appName The name of the application * * @param {string} serviceConnectionId Service connection id to updated. * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @param {function} callback - The callback. * * @returns {function} callback(err, result, request, response) * * {Error} err - The Error object if an error occurred, null otherwise. * * {null} [result] - The deserialized result object if an error did not occur. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _patch(storeName, ownerName, appName, serviceConnectionId, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { callback = options; options = null; } if (!callback) { throw new Error('callback cannot be null.'); } // Validate try { if (storeName === null || storeName === undefined || typeof storeName.valueOf() !== 'string') { throw new Error('storeName cannot be null or undefined and it must be of type string.'); } if (ownerName === null || ownerName === undefined || typeof ownerName.valueOf() !== 'string') { throw new Error('ownerName cannot be null or undefined and it must be of type string.'); } if (appName === null || appName === undefined || typeof appName.valueOf() !== 'string') { throw new Error('appName cannot be null or undefined and it must be of type string.'); } if (serviceConnectionId === null || serviceConnectionId === undefined || typeof serviceConnectionId.valueOf() !== 'string') { throw new Error('serviceConnectionId cannot be null or undefined and it must be of type string.'); } } catch (error) { return callback(error); } let body; if (serviceConnectionId !== null && serviceConnectionId !== undefined) { body = new client.models['StorePatchRequest'](); body.serviceConnectionId = serviceConnectionId; } // Construct URL let baseUrl = this.client.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/apps/{owner_name}/{app_name}/distribution_stores/{store_name}'; requestUrl = requestUrl.replace('{store_name}', encodeURIComponent(storeName)); requestUrl = requestUrl.replace('{owner_name}', encodeURIComponent(ownerName)); requestUrl = requestUrl.replace('{app_name}', encodeURIComponent(appName)); // Create HTTP transport objects let httpRequest = new WebResource(); httpRequest.method = 'PATCH'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if(options) { for(let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } } } // Serialize Request let requestContent = null; let requestModel = null; try { if (body !== null && body !== undefined) { let requestModelMapper = new client.models['StorePatchRequest']().mapper(); requestModel = client.serialize(requestModelMapper, body, 'body'); requestContent = JSON.stringify(requestModel); } } catch (error) { let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + `payload - ${JSON.stringify(body, null, 2)}.`); return callback(serializationError); } httpRequest.body = requestContent; // Send Request return client.pipeline(httpRequest, (err, response, responseBody) => { if (err) { return callback(err); } let statusCode = response.statusCode; if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); error.response = msRest.stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { parsedErrorResponse = JSON.parse(responseBody); if (parsedErrorResponse) { let internalError = null; if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; error.code = internalError ? internalError.code : parsedErrorResponse.code; error.message = internalError ? internalError.message : parsedErrorResponse.message; } if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { let resultMapper = new client.models['ErrorDetails']().mapper(); error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); } // Create Result let result = null; if (responseBody === '') responseBody = null; return callback(null, result, httpRequest, response); }); } /** * delete the store based on specific store name. * * @param {string} storeName The name of the store * * @param {string} ownerName The name of the owner * * @param {string} appName The name of the application * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @param {function} callback - The callback. * * @returns {function} callback(err, result, request, response) * * {Error} err - The Error object if an error occurred, null otherwise. * * {null} [result] - The deserialized result object if an error did not occur. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _deleteMethod(storeName, ownerName, appName, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { callback = options; options = null; } if (!callback) { throw new Error('callback cannot be null.'); } // Validate try { if (storeName === null || storeName === undefined || typeof storeName.valueOf() !== 'string') { throw new Error('storeName cannot be null or undefined and it must be of type string.'); } if (ownerName === null || ownerName === undefined || typeof ownerName.valueOf() !== 'string') { throw new Error('ownerName cannot be null or undefined and it must be of type string.'); } if (appName === null || appName === undefined || typeof appName.valueOf() !== 'string') { throw new Error('appName cannot be null or undefined and it must be of type string.'); } } catch (error) { return callback(error); } // Construct URL let baseUrl = this.client.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/apps/{owner_name}/{app_name}/distribution_stores/{store_name}'; requestUrl = requestUrl.replace('{store_name}', encodeURIComponent(storeName)); requestUrl = requestUrl.replace('{owner_name}', encodeURIComponent(ownerName)); requestUrl = requestUrl.replace('{app_name}', encodeURIComponent(appName)); // Create HTTP transport objects let httpRequest = new WebResource(); httpRequest.method = 'DELETE'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if(options) { for(let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } } } httpRequest.body = null; // Send Request return client.pipeline(httpRequest, (err, response, responseBody) => { if (err) { return callback(err); } let statusCode = response.statusCode; if (statusCode !== 204) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); error.response = msRest.stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { parsedErrorResponse = JSON.parse(responseBody); if (parsedErrorResponse) { let internalError = null; if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; error.code = internalError ? internalError.code : parsedErrorResponse.code; error.message = internalError ? internalError.message : parsedErrorResponse.message; } if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { let resultMapper = new client.models['ErrorDetails']().mapper(); error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); } // Create Result let result = null; if (responseBody === '') responseBody = null; return callback(null, result, httpRequest, response); }); } /** * Create a new external store for the specified application. * * @param {object} body The store request * * @param {string} [body.type] store Type. Possible values include: * 'googleplay', 'intune', 'apple' * * @param {string} [body.name] name of the store. In case of googleplay, and * Apple store this is fixed to Production. * * @param {string} [body.track] track of the store. Can be production, alpha & * beta for googleplay. Can be production, testflight-internal & * testflight-external for Apple Store. Possible values include: 'production', * 'alpha', 'beta', 'testflight-internal', 'testflight-external' * * @param {object} [body.intuneDetails] * * @param {object} [body.intuneDetails.secretJson] * * @param {string} [body.intuneDetails.secretJson.idToken] the id token of user * * @param {string} [body.intuneDetails.secretJson.refreshToken] the refresh * token for user * * @param {string} [body.intuneDetails.secretJson.refreshTokenExpiry] the * expiry of refresh token * * @param {object} [body.intuneDetails.targetAudience] * * @param {string} [body.intuneDetails.targetAudience.name] display name for * the target audience/group * * @param {object} [body.intuneDetails.appCategory] * * @param {string} [body.intuneDetails.appCategory.name] display name for the * app category * * @param {string} [body.intuneDetails.tenantId] tenant id of the intune store * * @param {string} [body.serviceConnectionId] Id for the shared service * connection. In case of Apple AppStore, this connection will be used to * create and connect to the Apple AppStore in Mobile Center. * * @param {string} ownerName The name of the owner * * @param {string} appName The name of the application * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @param {function} callback - The callback. * * @returns {function} callback(err, result, request, response) * * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. * See {@link ExternalStoreResponse} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _create(body, ownerName, appName, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { callback = options; options = null; } if (!callback) { throw new Error('callback cannot be null.'); } // Validate try { if (body === null || body === undefined) { throw new Error('body cannot be null or undefined.'); } if (ownerName === null || ownerName === undefined || typeof ownerName.valueOf() !== 'string') { throw new Error('ownerName cannot be null or undefined and it must be of type string.'); } if (appName === null || appName === undefined || typeof appName.valueOf() !== 'string') { throw new Error('appName cannot be null or undefined and it must be of type string.'); } } catch (error) { return callback(error); } // Construct URL let baseUrl = this.client.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/apps/{owner_name}/{app_name}/distribution_stores'; requestUrl = requestUrl.replace('{owner_name}', encodeURIComponent(ownerName)); requestUrl = requestUrl.replace('{app_name}', encodeURIComponent(appName)); // Create HTTP transport objects let httpRequest = new WebResource(); httpRequest.method = 'POST'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if(options) { for(let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } } } // Serialize Request let requestContent = null; let requestModel = null; try { if (body !== null && body !== undefined) { let requestModelMapper = new client.models['ExternalStoreRequest']().mapper(); requestModel = client.serialize(requestModelMapper, body, 'body'); requestContent = JSON.stringify(requestModel); } } catch (error) { let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + `payload - ${JSON.stringify(body, null, 2)}.`); return callback(serializationError); } httpRequest.body = requestContent; // Send Request return client.pipeline(httpRequest, (err, response, responseBody) => { if (err) { return callback(err); } let statusCode = response.statusCode; if (statusCode !== 201) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); error.response = msRest.stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { parsedErrorResponse = JSON.parse(responseBody); if (parsedErrorResponse) { let internalError = null; if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; error.code = internalError ? internalError.code : parsedErrorResponse.code; error.message = internalError ? internalError.message : parsedErrorResponse.message; } if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { let resultMapper = new client.models['ErrorDetails']().mapper(); error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); } // Create Result let result = null; if (responseBody === '') responseBody = null; // Deserialize Response if (statusCode === 201) { let parsedResponse = null; try { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { let resultMapper = new client.models['ExternalStoreResponse']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); deserializationError.request = msRest.stripRequest(httpRequest); deserializationError.response = msRest.stripResponse(response); return callback(deserializationError); } } return callback(null, result, httpRequest, response); }); } /** * Get all the store details from Storage store table for a particular * application. * * @param {string} ownerName The name of the owner * * @param {string} appName The name of the application * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @param {function} callback - The callback. * * @returns {function} callback(err, result, request, response) * * {Error} err - The Error object if an error occurred, null otherwise. * * {array} [result] - The deserialized result object if an error did not occur. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ function _list(ownerName, appName, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { callback = options; options = null; } if (!callback) { throw new Error('callback cannot be null.'); } // Validate try { if (ownerName === null || ownerName === undefined || typeof ownerName.valueOf() !== 'string') { throw new Error('ownerName cannot be null or undefined and it must be of type string.'); } if (appName === null || appName === undefined || typeof appName.valueOf() !== 'string') { throw new Error('appName cannot be null or undefined and it must be of type string.'); } } catch (error) { return callback(error); } // Construct URL let baseUrl = this.client.baseUri; let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'v0.1/apps/{owner_name}/{app_name}/distribution_stores'; requestUrl = requestUrl.replace('{owner_name}', encodeURIComponent(ownerName)); requestUrl = requestUrl.replace('{app_name}', encodeURIComponent(appName)); // Create HTTP transport objects let httpRequest = new WebResource(); httpRequest.method = 'GET'; httpRequest.url = requestUrl; httpRequest.headers = {}; // Set Headers httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; if(options) { for(let headerName in options['customHeaders']) { if (options['customHeaders'].hasOwnProperty(headerName)) { httpRequest.headers[headerName] = options['customHeaders'][headerName]; } } } httpRequest.body = null; // Send Request return client.pipeline(httpRequest, (err, response, responseBody) => { if (err) { return callback(err); } let statusCode = response.statusCode; if (statusCode !== 200) { let error = new Error(responseBody); error.statusCode = response.statusCode; error.request = msRest.stripRequest(httpRequest); error.response = msRest.stripResponse(response); if (responseBody === '') responseBody = null; let parsedErrorResponse; try { parsedErrorResponse = JSON.parse(responseBody); if (parsedErrorResponse) { let internalError = null; if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; error.code = internalError ? internalError.code : parsedErrorResponse.code; error.message = internalError ? internalError.message : parsedErrorResponse.message; } } catch (defaultError) { error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + `- "${responseBody}" for the default response.`; return callback(error); } return callback(error); } // Create Result let result = null; if (responseBody === '') responseBody = null; // Deserialize Response if (statusCode === 200) { let parsedResponse = null; try { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { let resultMapper = { required: false, serializedName: 'parsedResponse', type: { name: 'Sequence', element: { required: false, serializedName: 'ExternalStoreResponseElementType', type: { name: 'Composite', className: 'ExternalStoreResponse' } } } }; result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); deserializationError.request = msRest.stripRequest(httpRequest); deserializationError.response = msRest.stripResponse(response); return callback(deserializationError); } } return callback(null, result, httpRequest, response); }); } /** Class representing a Stores. */ class Stores { /** * Create a Stores. * @param {AppCenterClient} client Reference to the service client. */ constructor(client) { this.client = client; this._get = _get; this._patch = _patch; this._deleteMethod = _deleteMethod; this._create = _create; this._list = _list; } /** * Return the store details for specified store name. * * @param {string} storeName The name of the store * * @param {string} ownerName The name of the owner * * @param {string} appName The name of the application * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * * @resolve {HttpOperationResponse<ExternalStoreResponse>} - The deserialized result object. * * @reject {Error} - The error object. */ getWithHttpOperationResponse(storeName, ownerName, appName, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { self._get(storeName, ownerName, appName, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } else { resolve(httpOperationResponse); } return; }); }); } /** * Return the store details for specified store name. * * @param {string} storeName The name of the store * * @param {string} ownerName The name of the owner * * @param {string} appName The name of the application * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @param {function} [optionalCallback] - The optional callback. * * @returns {function|Promise} If a callback was passed as the last parameter * then it returns the callback else returns a Promise. * * {Promise} A promise is returned * * @resolve {ExternalStoreResponse} - The deserialized result object. * * @reject {Error} - The error object. * * {function} optionalCallback(err, result, request, response) * * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. * See {@link ExternalStoreResponse} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ get(storeName, ownerName, appName, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { optionalCallback = options; options = null; } if (!optionalCallback) { return new Promise((resolve, reject) => { self._get(storeName, ownerName, appName, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { return self._get(storeName, ownerName, appName, options, optionalCallback); } } /** * Update the store. * * @param {string} storeName The name of the store * * @param {string} ownerName The name of the owner * * @param {string} appName The name of the application * * @param {string} serviceConnectionId Service connection id to updated. * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * * @resolve {HttpOperationResponse<null>} - The deserialized result object. * * @reject {Error} - The error object. */ patchWithHttpOperationResponse(storeName, ownerName, appName, serviceConnectionId, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { self._patch(storeName, ownerName, appName, serviceConnectionId, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } else { resolve(httpOperationResponse); } return; }); }); } /** * Update the store. * * @param {string} storeName The name of the store * * @param {string} ownerName The name of the owner * * @param {string} appName The name of the application * * @param {string} serviceConnectionId Service connection id to updated. * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @param {function} [optionalCallback] - The optional callback. * * @returns {function|Promise} If a callback was passed as the last parameter * then it returns the callback else returns a Promise. * * {Promise} A promise is returned * * @resolve {null} - The deserialized result object. * * @reject {Error} - The error object. * * {function} optionalCallback(err, result, request, response) * * {Error} err - The Error object if an error occurred, null otherwise. * * {null} [result] - The deserialized result object if an error did not occur. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ patch(storeName, ownerName, appName, serviceConnectionId, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { optionalCallback = options; options = null; } if (!optionalCallback) { return new Promise((resolve, reject) => { self._patch(storeName, ownerName, appName, serviceConnectionId, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { return self._patch(storeName, ownerName, appName, serviceConnectionId, options, optionalCallback); } } /** * delete the store based on specific store name. * * @param {string} storeName The name of the store * * @param {string} ownerName The name of the owner * * @param {string} appName The name of the application * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * * @resolve {HttpOperationResponse<null>} - The deserialized result object. * * @reject {Error} - The error object. */ deleteMethodWithHttpOperationResponse(storeName, ownerName, appName, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { self._deleteMethod(storeName, ownerName, appName, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } else { resolve(httpOperationResponse); } return; }); }); } /** * delete the store based on specific store name. * * @param {string} storeName The name of the store * * @param {string} ownerName The name of the owner * * @param {string} appName The name of the application * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @param {function} [optionalCallback] - The optional callback. * * @returns {function|Promise} If a callback was passed as the last parameter * then it returns the callback else returns a Promise. * * {Promise} A promise is returned * * @resolve {null} - The deserialized result object. * * @reject {Error} - The error object. * * {function} optionalCallback(err, result, request, response) * * {Error} err - The Error object if an error occurred, null otherwise. * * {null} [result] - The deserialized result object if an error did not occur. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ deleteMethod(storeName, ownerName, appName, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { optionalCallback = options; options = null; } if (!optionalCallback) { return new Promise((resolve, reject) => { self._deleteMethod(storeName, ownerName, appName, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { return self._deleteMethod(storeName, ownerName, appName, options, optionalCallback); } } /** * Create a new external store for the specified application. * * @param {object} body The store request * * @param {string} [body.type] store Type. Possible values include: * 'googleplay', 'intune', 'apple' * * @param {string} [body.name] name of the store. In case of googleplay, and * Apple store this is fixed to Production. * * @param {string} [body.track] track of the store. Can be production, alpha & * beta for googleplay. Can be production, testflight-internal & * testflight-external for Apple Store. Possible values include: 'production', * 'alpha', 'beta', 'testflight-internal', 'testflight-external' * * @param {object} [body.intuneDetails] * * @param {object} [body.intuneDetails.secretJson] * * @param {string} [body.intuneDetails.secretJson.idToken] the id token of user * * @param {string} [body.intuneDetails.secretJson.refreshToken] the refresh * token for user * * @param {string} [body.intuneDetails.secretJson.refreshTokenExpiry] the * expiry of refresh token * * @param {object} [body.intuneDetails.targetAudience] * * @param {string} [body.intuneDetails.targetAudience.name] display name for * the target audience/group * * @param {object} [body.intuneDetails.appCategory] * * @param {string} [body.intuneDetails.appCategory.name] display name for the * app category * * @param {string} [body.intuneDetails.tenantId] tenant id of the intune store * * @param {string} [body.serviceConnectionId] Id for the shared service * connection. In case of Apple AppStore, this connection will be used to * create and connect to the Apple AppStore in Mobile Center. * * @param {string} ownerName The name of the owner * * @param {string} appName The name of the application * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * * @resolve {HttpOperationResponse<ExternalStoreResponse>} - The deserialized result object. * * @reject {Error} - The error object. */ createWithHttpOperationResponse(body, ownerName, appName, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { self._create(body, ownerName, appName, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } else { resolve(httpOperationResponse); } return; }); }); } /** * Create a new external store for the specified application. * * @param {object} body The store request * * @param {string} [body.type] store Type. Possible values include: * 'googleplay', 'intune', 'apple' * * @param {string} [body.name] name of the store. In case of googleplay, and * Apple store this is fixed to Production. * * @param {string} [body.track] track of the store. Can be production, alpha & * beta for googleplay. Can be production, testflight-internal & * testflight-external for Apple Store. Possible values include: 'production', * 'alpha', 'beta', 'testflight-internal', 'testflight-external' * * @param {object} [body.intuneDetails] * * @param {object} [body.intuneDetails.secretJson] * * @param {string} [body.intuneDetails.secretJson.idToken] the id token of user * * @param {string} [body.intuneDetails.secretJson.refreshToken] the refresh * token for user * * @param {string} [body.intuneDetails.secretJson.refreshTokenExpiry] the * expiry of refresh token * * @param {object} [body.intuneDetails.targetAudience] * * @param {string} [body.intuneDetails.targetAudience.name] display name for * the target audience/group * * @param {object} [body.intuneDetails.appCategory] * * @param {string} [body.intuneDetails.appCategory.name] display name for the * app category * * @param {string} [body.intuneDetails.tenantId] tenant id of the intune store * * @param {string} [body.serviceConnectionId] Id for the shared service * connection. In case of Apple AppStore, this connection will be used to * create and connect to the Apple AppStore in Mobile Center. * * @param {string} ownerName The name of the owner * * @param {string} appName The name of the application * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @param {function} [optionalCallback] - The optional callback. * * @returns {function|Promise} If a callback was passed as the last parameter * then it returns the callback else returns a Promise. * * {Promise} A promise is returned * * @resolve {ExternalStoreResponse} - The deserialized result object. * * @reject {Error} - The error object. * * {function} optionalCallback(err, result, request, response) * * {Error} err - The Error object if an error occurred, null otherwise. * * {object} [result] - The deserialized result object if an error did not occur. * See {@link ExternalStoreResponse} for more information. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ create(body, ownerName, appName, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { optionalCallback = options; options = null; } if (!optionalCallback) { return new Promise((resolve, reject) => { self._create(body, ownerName, appName, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { return self._create(body, ownerName, appName, options, optionalCallback); } } /** * Get all the store details from Storage store table for a particular * application. * * @param {string} ownerName The name of the owner * * @param {string} appName The name of the application * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @returns {Promise} A promise is returned * * @resolve {HttpOperationResponse<Array>} - The deserialized result object. * * @reject {Error} - The error object. */ listWithHttpOperationResponse(ownerName, appName, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { self._list(ownerName, appName, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } else { resolve(httpOperationResponse); } return; }); }); } /** * Get all the store details from Storage store table for a particular * application. * * @param {string} ownerName The name of the owner * * @param {string} appName The name of the application * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the * request * * @param {function} [optionalCallback] - The optional callback. * * @returns {function|Promise} If a callback was passed as the last parameter * then it returns the callback else returns a Promise. * * {Promise} A promise is returned * * @resolve {Array} - The deserialized result object. * * @reject {Error} - The error object. * * {function} optionalCallback(err, result, request, response) * * {Error} err - The Error object if an error occurred, null otherwise. * * {array} [result] - The deserialized result object if an error did not occur. * * {object} [request] - The HTTP Request object if an error did not occur. * * {stream} [response] - The HTTP Response stream if an error did not occur. */ list(ownerName, appName, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { optionalCallback = options; options = null; } if (!optionalCallback) { return new Promise((resolve, reject) => { self._list(ownerName, appName, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { return self._list(ownerName, appName, options, optionalCallback); } } } module.exports = Stores;