diff --git a/lib/services/iotcentralManagement/lib/models/appAvailabilityInfo.js b/lib/services/iotcentralManagement/lib/models/appAvailabilityInfo.js new file mode 100644 index 0000000000..31988ffb95 --- /dev/null +++ b/lib/services/iotcentralManagement/lib/models/appAvailabilityInfo.js @@ -0,0 +1,73 @@ +/* + * 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'; + +/** + * The properties indicating whether a given IoT Central application name or + * subdomain is available. + * + */ +class AppAvailabilityInfo { + /** + * Create a AppAvailabilityInfo. + * @member {boolean} [nameAvailable] The value which indicates whether the + * provided name is available. + * @member {string} [reason] The reason for unavailability. + * @member {string} [message] The detailed reason message. + */ + constructor() { + } + + /** + * Defines the metadata of AppAvailabilityInfo + * + * @returns {object} metadata of AppAvailabilityInfo + * + */ + mapper() { + return { + required: false, + serializedName: 'AppAvailabilityInfo', + type: { + name: 'Composite', + className: 'AppAvailabilityInfo', + modelProperties: { + nameAvailable: { + required: false, + readOnly: true, + serializedName: 'nameAvailable', + type: { + name: 'Boolean' + } + }, + reason: { + required: false, + readOnly: true, + serializedName: 'reason', + type: { + name: 'String' + } + }, + message: { + required: false, + readOnly: true, + serializedName: 'message', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = AppAvailabilityInfo; diff --git a/lib/services/iotcentralManagement/lib/models/errorDetails.js b/lib/services/iotcentralManagement/lib/models/errorDetails.js index ecf7b7ce09..3f58f07184 100644 --- a/lib/services/iotcentralManagement/lib/models/errorDetails.js +++ b/lib/services/iotcentralManagement/lib/models/errorDetails.js @@ -20,6 +20,7 @@ class ErrorDetails { * @member {string} [code] The error code. * @member {string} [message] The error message. * @member {string} [target] The target of the particular error. + * @member {array} [details] A list of additional details about the error. */ constructor() { } @@ -41,7 +42,7 @@ class ErrorDetails { code: { required: false, readOnly: true, - serializedName: 'code', + serializedName: 'error.code', type: { name: 'String' } @@ -49,7 +50,7 @@ class ErrorDetails { message: { required: false, readOnly: true, - serializedName: 'message', + serializedName: 'error.message', type: { name: 'String' } @@ -57,10 +58,25 @@ class ErrorDetails { target: { required: false, readOnly: true, - serializedName: 'target', + serializedName: 'error.target', type: { name: 'String' } + }, + details: { + required: false, + serializedName: 'error.details', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ErrorResponseBodyElementType', + type: { + name: 'Composite', + className: 'ErrorResponseBody' + } + } + } } } } diff --git a/lib/services/iotcentralManagement/lib/models/errorResponseBody.js b/lib/services/iotcentralManagement/lib/models/errorResponseBody.js new file mode 100644 index 0000000000..66a098297a --- /dev/null +++ b/lib/services/iotcentralManagement/lib/models/errorResponseBody.js @@ -0,0 +1,87 @@ +/* + * 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'; + +/** + * Details of error response. + * + */ +class ErrorResponseBody { + /** + * Create a ErrorResponseBody. + * @member {string} [code] The error code. + * @member {string} [message] The error message. + * @member {string} [target] The target of the particular error. + * @member {array} [details] A list of additional details about the error. + */ + constructor() { + } + + /** + * Defines the metadata of ErrorResponseBody + * + * @returns {object} metadata of ErrorResponseBody + * + */ + mapper() { + return { + required: false, + serializedName: 'ErrorResponseBody', + type: { + name: 'Composite', + className: 'ErrorResponseBody', + modelProperties: { + code: { + required: false, + readOnly: true, + serializedName: 'code', + type: { + name: 'String' + } + }, + message: { + required: false, + readOnly: true, + serializedName: 'message', + type: { + name: 'String' + } + }, + target: { + required: false, + readOnly: true, + serializedName: 'target', + type: { + name: 'String' + } + }, + details: { + required: false, + serializedName: 'details', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ErrorResponseBodyElementType', + type: { + name: 'Composite', + className: 'ErrorResponseBody' + } + } + } + } + } + } + }; + } +} + +module.exports = ErrorResponseBody; diff --git a/lib/services/iotcentralManagement/lib/models/index.d.ts b/lib/services/iotcentralManagement/lib/models/index.d.ts index 8c01877536..81984e38d5 100644 --- a/lib/services/iotcentralManagement/lib/models/index.d.ts +++ b/lib/services/iotcentralManagement/lib/models/index.d.ts @@ -97,6 +97,24 @@ export interface AppPatch { template?: string; } +/** + * @class + * Initializes a new instance of the ErrorResponseBody class. + * @constructor + * Details of error response. + * + * @member {string} [code] The error code. + * @member {string} [message] The error message. + * @member {string} [target] The target of the particular error. + * @member {array} [details] A list of additional details about the error. + */ +export interface ErrorResponseBody { + readonly code?: string; + readonly message?: string; + readonly target?: string; + details?: ErrorResponseBody[]; +} + /** * @class * Initializes a new instance of the ErrorDetails class. @@ -106,11 +124,13 @@ export interface AppPatch { * @member {string} [code] The error code. * @member {string} [message] The error message. * @member {string} [target] The target of the particular error. + * @member {array} [details] A list of additional details about the error. */ export interface ErrorDetails { readonly code?: string; readonly message?: string; readonly target?: string; + details?: ErrorResponseBody[]; } /** @@ -159,28 +179,30 @@ export interface Operation { * * @member {string} name The name of the IoT Central application instance to * check. + * @member {string} [type] The type of the IoT Central resource to query. + * Default value: 'IoTApps' . */ export interface OperationInputs { name: string; + type?: string; } /** * @class - * Initializes a new instance of the AppNameAvailabilityInfo class. + * Initializes a new instance of the AppAvailabilityInfo class. * @constructor - * The properties indicating whether a given IoT Central application name is - * available. + * The properties indicating whether a given IoT Central application name or + * subdomain is available. * * @member {boolean} [nameAvailable] The value which indicates whether the * provided name is available. - * @member {string} [reason] The reason for unavailability. Possible values - * include: 'Invalid', 'AlreadyExists' + * @member {string} [reason] The reason for unavailability. * @member {string} [message] The detailed reason message. */ -export interface AppNameAvailabilityInfo { +export interface AppAvailabilityInfo { readonly nameAvailable?: boolean; readonly reason?: string; - message?: string; + readonly message?: string; } diff --git a/lib/services/iotcentralManagement/lib/models/index.js b/lib/services/iotcentralManagement/lib/models/index.js index cf2fc126b2..322f160775 100644 --- a/lib/services/iotcentralManagement/lib/models/index.js +++ b/lib/services/iotcentralManagement/lib/models/index.js @@ -22,10 +22,11 @@ exports.AppSkuInfo = require('./appSkuInfo'); exports.Resource = require('./resource'); exports.App = require('./app'); exports.AppPatch = require('./appPatch'); +exports.ErrorResponseBody = require('./errorResponseBody'); exports.ErrorDetails = require('./errorDetails'); exports.OperationDisplay = require('./operationDisplay'); exports.Operation = require('./operation'); exports.OperationInputs = require('./operationInputs'); -exports.AppNameAvailabilityInfo = require('./appNameAvailabilityInfo'); +exports.AppAvailabilityInfo = require('./appAvailabilityInfo'); exports.AppListResult = require('./appListResult'); exports.OperationListResult = require('./operationListResult'); diff --git a/lib/services/iotcentralManagement/lib/models/nameAvailabilityInputs.js b/lib/services/iotcentralManagement/lib/models/nameAvailabilityInputs.js new file mode 100644 index 0000000000..437b4b1b79 --- /dev/null +++ b/lib/services/iotcentralManagement/lib/models/nameAvailabilityInputs.js @@ -0,0 +1,66 @@ +/* + * 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'; + +/** + * Input values. + * + */ +class NameAvailabilityInputs { + /** + * Create a NameAvailabilityInputs. + * @member {string} name The name of the IoT Central application instance to + * check. + * @member {string} [type] The type of the IoT Central resource to query. + * Default value: 'IoTApps' . + */ + constructor() { + } + + /** + * Defines the metadata of NameAvailabilityInputs + * + * @returns {object} metadata of NameAvailabilityInputs + * + */ + mapper() { + return { + required: false, + serializedName: 'NameAvailabilityInputs', + type: { + name: 'Composite', + className: 'NameAvailabilityInputs', + modelProperties: { + name: { + required: true, + serializedName: 'name', + constraints: { + Pattern: '^[a-z0-9-]{1,63}$' + }, + type: { + name: 'String' + } + }, + type: { + required: false, + serializedName: 'type', + defaultValue: 'IoTApps', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = NameAvailabilityInputs; diff --git a/lib/services/iotcentralManagement/lib/models/operationInputs.js b/lib/services/iotcentralManagement/lib/models/operationInputs.js index 89fdea57b8..f3c21fabe8 100644 --- a/lib/services/iotcentralManagement/lib/models/operationInputs.js +++ b/lib/services/iotcentralManagement/lib/models/operationInputs.js @@ -19,6 +19,8 @@ class OperationInputs { * Create a OperationInputs. * @member {string} name The name of the IoT Central application instance to * check. + * @member {string} [type] The type of the IoT Central resource to query. + * Default value: 'IoTApps' . */ constructor() { } @@ -40,6 +42,17 @@ class OperationInputs { name: { required: true, serializedName: 'name', + constraints: { + Pattern: '^[a-z0-9-]{1,63}$' + }, + type: { + name: 'String' + } + }, + type: { + required: false, + serializedName: 'type', + defaultValue: 'IoTApps', type: { name: 'String' } diff --git a/lib/services/iotcentralManagement/lib/models/subdomainAvailabilityInputs.js b/lib/services/iotcentralManagement/lib/models/subdomainAvailabilityInputs.js new file mode 100644 index 0000000000..4f42d11545 --- /dev/null +++ b/lib/services/iotcentralManagement/lib/models/subdomainAvailabilityInputs.js @@ -0,0 +1,66 @@ +/* + * 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'; + +/** + * Input values. + * + */ +class SubdomainAvailabilityInputs { + /** + * Create a SubdomainAvailabilityInputs. + * @member {string} subdomain The subdomain of the IoT Central application + * instance to check. + * @member {string} [type] The type of the IoT Central resource to query. + * Default value: 'IoTApps' . + */ + constructor() { + } + + /** + * Defines the metadata of SubdomainAvailabilityInputs + * + * @returns {object} metadata of SubdomainAvailabilityInputs + * + */ + mapper() { + return { + required: false, + serializedName: 'SubdomainAvailabilityInputs', + type: { + name: 'Composite', + className: 'SubdomainAvailabilityInputs', + modelProperties: { + subdomain: { + required: true, + serializedName: 'subdomain', + constraints: { + Pattern: '^[a-z0-9-]{1,63}$' + }, + type: { + name: 'String' + } + }, + type: { + required: false, + serializedName: 'type', + defaultValue: 'IoTApps', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = SubdomainAvailabilityInputs; diff --git a/lib/services/iotcentralManagement/lib/operations/apps.js b/lib/services/iotcentralManagement/lib/operations/apps.js index 62e3b3ef1b..bdae84d0c9 100644 --- a/lib/services/iotcentralManagement/lib/operations/apps.js +++ b/lib/services/iotcentralManagement/lib/operations/apps.js @@ -703,9 +703,16 @@ function _listByResourceGroup(resourceGroupName, options, callback) { /** * Check if an IoT Central application name is available. * - * @param {string} name The name of the IoT Central application instance to + * @param {object} operationInputs Set the name parameter in the + * OperationInputs structure to the name of the IoT Central application to * check. * + * @param {string} operationInputs.name The name of the IoT Central application + * instance to check. + * + * @param {string} [operationInputs.type] The type of the IoT Central resource + * to query. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -718,14 +725,13 @@ function _listByResourceGroup(resourceGroupName, options, callback) { * {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 AppNameAvailabilityInfo} for more - * information. + * See {@link AppAvailabilityInfo} 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 _checkNameAvailability(name, options, callback) { +function _checkNameAvailability(operationInputs, options, callback) { /* jshint validthis: true */ let client = this.client; if(!callback && typeof options === 'function') { @@ -743,8 +749,8 @@ function _checkNameAvailability(name, options, callback) { if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); } - if (name === null || name === undefined || typeof name.valueOf() !== 'string') { - throw new Error('name cannot be null or undefined and it must be of type string.'); + if (operationInputs === null || operationInputs === undefined) { + throw new Error('operationInputs cannot be null or undefined.'); } if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { throw new Error('this.client.acceptLanguage must be of type string.'); @@ -752,11 +758,6 @@ function _checkNameAvailability(name, options, callback) { } catch (error) { return callback(error); } - let operationInputs; - if (name !== null && name !== undefined) { - operationInputs = new client.models['OperationInputs'](); - operationInputs.name = name; - } // Construct URL let baseUrl = this.client.baseUri; @@ -845,7 +846,168 @@ function _checkNameAvailability(name, options, callback) { parsedResponse = JSON.parse(responseBody); result = JSON.parse(responseBody); if (parsedResponse !== null && parsedResponse !== undefined) { - let resultMapper = new client.models['AppNameAvailabilityInfo']().mapper(); + let resultMapper = new client.models['AppAvailabilityInfo']().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); + }); +} + +/** + * Check if an IoT Central application subdomain is available. + * + * @param {object} operationInputs Set the name parameter in the + * OperationInputs structure to the subdomain of the IoT Central application to + * check. + * + * @param {string} operationInputs.name The name of the IoT Central application + * instance to check. + * + * @param {string} [operationInputs.type] The type of the IoT Central resource + * to query. + * + * @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 AppAvailabilityInfo} 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 _checkSubdomainAvailability(operationInputs, 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 (this.client.apiVersion === null || this.client.apiVersion === undefined || typeof this.client.apiVersion.valueOf() !== 'string') { + throw new Error('this.client.apiVersion cannot be null or undefined and it must be of type string.'); + } + if (this.client.subscriptionId === null || this.client.subscriptionId === undefined || typeof this.client.subscriptionId.valueOf() !== 'string') { + throw new Error('this.client.subscriptionId cannot be null or undefined and it must be of type string.'); + } + if (operationInputs === null || operationInputs === undefined) { + throw new Error('operationInputs cannot be null or undefined.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.IoTCentral/checkSubdomainAvailability'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // 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 (this.client.generateClientRequestId) { + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + 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 (operationInputs !== null && operationInputs !== undefined) { + let requestModelMapper = new client.models['OperationInputs']().mapper(); + requestModel = client.serialize(requestModelMapper, operationInputs, 'operationInputs'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(operationInputs, 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; + // 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['AppAvailabilityInfo']().mapper(); result = client.deserialize(resultMapper, parsedResponse, 'result'); } } catch (error) { @@ -1646,6 +1808,7 @@ class Apps { this._listBySubscription = _listBySubscription; this._listByResourceGroup = _listByResourceGroup; this._checkNameAvailability = _checkNameAvailability; + this._checkSubdomainAvailability = _checkSubdomainAvailability; this._beginCreateOrUpdate = _beginCreateOrUpdate; this._beginUpdate = _beginUpdate; this._beginDeleteMethod = _beginDeleteMethod; @@ -2253,9 +2416,16 @@ class Apps { /** * Check if an IoT Central application name is available. * - * @param {string} name The name of the IoT Central application instance to + * @param {object} operationInputs Set the name parameter in the + * OperationInputs structure to the name of the IoT Central application to * check. * + * @param {string} operationInputs.name The name of the IoT Central application + * instance to check. + * + * @param {string} [operationInputs.type] The type of the IoT Central resource + * to query. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -2263,15 +2433,15 @@ class Apps { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error} - The error object. */ - checkNameAvailabilityWithHttpOperationResponse(name, options) { + checkNameAvailabilityWithHttpOperationResponse(operationInputs, options) { let client = this.client; let self = this; return new Promise((resolve, reject) => { - self._checkNameAvailability(name, options, (err, result, request, response) => { + self._checkNameAvailability(operationInputs, options, (err, result, request, response) => { let httpOperationResponse = new msRest.HttpOperationResponse(request, response); httpOperationResponse.body = result; if (err) { reject(err); } @@ -2284,9 +2454,114 @@ class Apps { /** * Check if an IoT Central application name is available. * - * @param {string} name The name of the IoT Central application instance to + * @param {object} operationInputs Set the name parameter in the + * OperationInputs structure to the name of the IoT Central application to * check. * + * @param {string} operationInputs.name The name of the IoT Central application + * instance to check. + * + * @param {string} [operationInputs.type] The type of the IoT Central resource + * to query. + * + * @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 {AppAvailabilityInfo} - 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 AppAvailabilityInfo} 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. + */ + checkNameAvailability(operationInputs, 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._checkNameAvailability(operationInputs, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._checkNameAvailability(operationInputs, options, optionalCallback); + } + } + + /** + * Check if an IoT Central application subdomain is available. + * + * @param {object} operationInputs Set the name parameter in the + * OperationInputs structure to the subdomain of the IoT Central application to + * check. + * + * @param {string} operationInputs.name The name of the IoT Central application + * instance to check. + * + * @param {string} [operationInputs.type] The type of the IoT Central resource + * to query. + * + * @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} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + checkSubdomainAvailabilityWithHttpOperationResponse(operationInputs, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._checkSubdomainAvailability(operationInputs, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Check if an IoT Central application subdomain is available. + * + * @param {object} operationInputs Set the name parameter in the + * OperationInputs structure to the subdomain of the IoT Central application to + * check. + * + * @param {string} operationInputs.name The name of the IoT Central application + * instance to check. + * + * @param {string} [operationInputs.type] The type of the IoT Central resource + * to query. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -2299,7 +2574,7 @@ class Apps { * * {Promise} A promise is returned * - * @resolve {AppNameAvailabilityInfo} - The deserialized result object. + * @resolve {AppAvailabilityInfo} - The deserialized result object. * * @reject {Error} - The error object. * @@ -2308,14 +2583,13 @@ class Apps { * {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 AppNameAvailabilityInfo} for more - * information. + * See {@link AppAvailabilityInfo} 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. */ - checkNameAvailability(name, options, optionalCallback) { + checkSubdomainAvailability(operationInputs, options, optionalCallback) { let client = this.client; let self = this; if (!optionalCallback && typeof options === 'function') { @@ -2324,14 +2598,14 @@ class Apps { } if (!optionalCallback) { return new Promise((resolve, reject) => { - self._checkNameAvailability(name, options, (err, result, request, response) => { + self._checkSubdomainAvailability(operationInputs, options, (err, result, request, response) => { if (err) { reject(err); } else { resolve(result); } return; }); }); } else { - return self._checkNameAvailability(name, options, optionalCallback); + return self._checkSubdomainAvailability(operationInputs, options, optionalCallback); } } diff --git a/lib/services/iotcentralManagement/lib/operations/index.d.ts b/lib/services/iotcentralManagement/lib/operations/index.d.ts index bb999bb0e2..febaf74952 100644 --- a/lib/services/iotcentralManagement/lib/operations/index.d.ts +++ b/lib/services/iotcentralManagement/lib/operations/index.d.ts @@ -459,9 +459,16 @@ export interface Apps { /** * Check if an IoT Central application name is available. * - * @param {string} name The name of the IoT Central application instance to + * @param {object} operationInputs Set the name parameter in the + * OperationInputs structure to the name of the IoT Central application to * check. * + * @param {string} operationInputs.name The name of the IoT Central application + * instance to check. + * + * @param {string} [operationInputs.type] The type of the IoT Central resource + * to query. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -469,18 +476,96 @@ export interface Apps { * * @returns {Promise} A promise is returned * - * @resolve {HttpOperationResponse} - The deserialized result object. + * @resolve {HttpOperationResponse} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. */ - checkNameAvailabilityWithHttpOperationResponse(name: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + checkNameAvailabilityWithHttpOperationResponse(operationInputs: models.OperationInputs, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; /** * Check if an IoT Central application name is available. * - * @param {string} name The name of the IoT Central application instance to + * @param {object} operationInputs Set the name parameter in the + * OperationInputs structure to the name of the IoT Central application to * check. * + * @param {string} operationInputs.name The name of the IoT Central application + * instance to check. + * + * @param {string} [operationInputs.type] The type of the IoT Central resource + * to query. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|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 {AppAvailabilityInfo} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {AppAvailabilityInfo} [result] - The deserialized result object if an error did not occur. + * See {@link AppAvailabilityInfo} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + checkNameAvailability(operationInputs: models.OperationInputs, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + checkNameAvailability(operationInputs: models.OperationInputs, callback: ServiceCallback): void; + checkNameAvailability(operationInputs: models.OperationInputs, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Check if an IoT Central application subdomain is available. + * + * @param {object} operationInputs Set the name parameter in the + * OperationInputs structure to the subdomain of the IoT Central application to + * check. + * + * @param {string} operationInputs.name The name of the IoT Central application + * instance to check. + * + * @param {string} [operationInputs.type] The type of the IoT Central resource + * to query. + * + * @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} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + checkSubdomainAvailabilityWithHttpOperationResponse(operationInputs: models.OperationInputs, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Check if an IoT Central application subdomain is available. + * + * @param {object} operationInputs Set the name parameter in the + * OperationInputs structure to the subdomain of the IoT Central application to + * check. + * + * @param {string} operationInputs.name The name of the IoT Central application + * instance to check. + * + * @param {string} [operationInputs.type] The type of the IoT Central resource + * to query. + * * @param {object} [options] Optional Parameters. * * @param {object} [options.customHeaders] Headers that will be added to the @@ -493,7 +578,7 @@ export interface Apps { * * {Promise} A promise is returned. * - * @resolve {AppNameAvailabilityInfo} - The deserialized result object. + * @resolve {AppAvailabilityInfo} - The deserialized result object. * * @reject {Error|ServiceError} - The error object. * @@ -501,17 +586,16 @@ export interface Apps { * * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. * - * {AppNameAvailabilityInfo} [result] - The deserialized result object if an error did not occur. - * See {@link AppNameAvailabilityInfo} for more - * information. + * {AppAvailabilityInfo} [result] - The deserialized result object if an error did not occur. + * See {@link AppAvailabilityInfo} for more information. * * {WebResource} [request] - The HTTP Request object if an error did not occur. * * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. */ - checkNameAvailability(name: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; - checkNameAvailability(name: string, callback: ServiceCallback): void; - checkNameAvailability(name: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + checkSubdomainAvailability(operationInputs: models.OperationInputs, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + checkSubdomainAvailability(operationInputs: models.OperationInputs, callback: ServiceCallback): void; + checkSubdomainAvailability(operationInputs: models.OperationInputs, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; /** diff --git a/lib/services/iotcentralManagement/package.json b/lib/services/iotcentralManagement/package.json index 5d35a68dab..e2f3695e7b 100644 --- a/lib/services/iotcentralManagement/package.json +++ b/lib/services/iotcentralManagement/package.json @@ -2,7 +2,7 @@ "name": "azure-arm-iotcentral", "author": "Microsoft Corporation", "description": "IotCentralClient Library with typescript type definitions for node", - "version": "1.0.1-preview", + "version": "2.0.0-preview", "dependencies": { "ms-rest": "^2.3.3", "ms-rest-azure": "^2.5.5"