diff --git a/lib/services/cognitiveServicesManagement/lib/LICENSE.txt b/lib/services/cognitiveServicesManagement/lib/LICENSE.txt new file mode 100644 index 0000000000..5431ba98b9 --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2018 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/lib/services/cognitiveServicesManagement/lib/lib/cognitiveServicesManagementClient.d.ts b/lib/services/cognitiveServicesManagement/lib/lib/cognitiveServicesManagementClient.d.ts new file mode 100644 index 0000000000..056269da2e --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/cognitiveServicesManagementClient.d.ts @@ -0,0 +1,64 @@ +/* + * 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. + */ + +import { ServiceClientCredentials } from 'ms-rest'; +import { AzureServiceClient, AzureServiceClientOptions } from 'ms-rest-azure'; +import * as models from "./models"; +import * as operations from "./operations"; + +export default class CognitiveServicesManagementClient extends AzureServiceClient { + /** + * Initializes a new instance of the CognitiveServicesManagementClient class. + * @constructor + * + * @class + * @param {credentials} credentials - Credentials needed for the client to connect to Azure. + * + * @param {string} subscriptionId - Azure Subscription ID. + * + * @param {string} [baseUri] - The base URI of the service. + * + * @param {object} [options] - The parameter options + * + * @param {Array} [options.filters] - Filters to be added to the request pipeline + * + * @param {object} [options.requestOptions] - Options for the underlying request object + * {@link https://github.com/request/request#requestoptions-callback Options doc} + * + * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy + * + * @param {string} [options.acceptLanguage] - Gets or sets the preferred language for the response. + * + * @param {number} [options.longRunningOperationRetryTimeout] - Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @param {boolean} [options.generateClientRequestId] - When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + */ + constructor(credentials: ServiceClientCredentials, subscriptionId: string, baseUri?: string, options?: AzureServiceClientOptions); + + credentials: ServiceClientCredentials; + + subscriptionId: string; + + apiVersion: string; + + acceptLanguage: string; + + longRunningOperationRetryTimeout: number; + + generateClientRequestId: boolean; + + // Operation groups + accounts: operations.Accounts; + operations: operations.Operations; + checkSkuAvailability: operations.CheckSkuAvailability; +} + +export { CognitiveServicesManagementClient, models as CognitiveServicesManagementModels }; diff --git a/lib/services/cognitiveServicesManagement/lib/lib/cognitiveServicesManagementClient.js b/lib/services/cognitiveServicesManagement/lib/lib/cognitiveServicesManagementClient.js new file mode 100644 index 0000000000..4a2ad817ef --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/cognitiveServicesManagementClient.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. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +const msRest = require('ms-rest'); +const msRestAzure = require('ms-rest-azure'); +const ServiceClient = msRestAzure.AzureServiceClient; + +const models = require('./models'); +const operations = require('./operations'); + + +/** Class representing a CognitiveServicesManagementClient. */ +class CognitiveServicesManagementClient extends ServiceClient { + /** + * Create a CognitiveServicesManagementClient. + * @param {credentials} credentials - Credentials needed for the client to connect to Azure. + * @param {string} subscriptionId - Azure Subscription ID. + * @param {string} [baseUri] - The base URI of the service. + * @param {object} [options] - The parameter options + * @param {Array} [options.filters] - Filters to be added to the request pipeline + * @param {object} [options.requestOptions] - Options for the underlying request object + * {@link https://github.com/request/request#requestoptions-callback Options doc} + * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy + * @param {string} [options.acceptLanguage] - Gets or sets the preferred language for the response. + * @param {number} [options.longRunningOperationRetryTimeout] - Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * @param {boolean} [options.generateClientRequestId] - When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + */ + constructor(credentials, subscriptionId, baseUri, options) { + if (credentials === null || credentials === undefined) { + throw new Error('\'credentials\' cannot be null.'); + } + if (subscriptionId === null || subscriptionId === undefined) { + throw new Error('\'subscriptionId\' cannot be null.'); + } + + if (!options) options = {}; + + super(credentials, options); + + this.apiVersion = '2017-04-18'; + this.acceptLanguage = 'en-US'; + this.longRunningOperationRetryTimeout = 30; + this.generateClientRequestId = true; + this.baseUri = baseUri; + if (!this.baseUri) { + this.baseUri = 'https://management.azure.com'; + } + this.credentials = credentials; + this.subscriptionId = subscriptionId; + + let packageInfo = this.getPackageJsonInfo(__dirname); + this.addUserAgentInfo(`${packageInfo.name}/${packageInfo.version}`); + if(options.acceptLanguage !== null && options.acceptLanguage !== undefined) { + this.acceptLanguage = options.acceptLanguage; + } + if(options.longRunningOperationRetryTimeout !== null && options.longRunningOperationRetryTimeout !== undefined) { + this.longRunningOperationRetryTimeout = options.longRunningOperationRetryTimeout; + } + if(options.generateClientRequestId !== null && options.generateClientRequestId !== undefined) { + this.generateClientRequestId = options.generateClientRequestId; + } + this.accounts = new operations.Accounts(this); + this.operations = new operations.Operations(this); + this.checkSkuAvailability = new operations.CheckSkuAvailability(this); + this.models = models; + msRest.addSerializationMixin(this); + } + +} + +module.exports = CognitiveServicesManagementClient; +module.exports['default'] = CognitiveServicesManagementClient; +module.exports.CognitiveServicesManagementClient = CognitiveServicesManagementClient; +module.exports.CognitiveServicesManagementModels = models; diff --git a/lib/services/cognitiveServicesManagement/lib/lib/models/checkSkuAvailabilityParameter.js b/lib/services/cognitiveServicesManagement/lib/lib/models/checkSkuAvailabilityParameter.js new file mode 100644 index 0000000000..3282fe06e4 --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/models/checkSkuAvailabilityParameter.js @@ -0,0 +1,80 @@ +/* + * 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'; + +/** + * Check SKU availability parameter. + * + */ +class CheckSkuAvailabilityParameter { + /** + * Create a CheckSkuAvailabilityParameter. + * @member {array} skus The SKU of the resource. + * @member {string} kind The Kind of the resource. Possible values include: + * 'Bing.Autosuggest.v7', 'Bing.CustomSearch', 'Bing.Search.v7', + * 'Bing.Speech', 'Bing.SpellCheck.v7', 'ComputerVision', 'ContentModerator', + * 'CustomSpeech', 'CustomVision.Prediction', 'CustomVision.Training', + * 'Emotion', 'Face', 'LUIS', 'QnAMaker', 'SpeakerRecognition', + * 'SpeechTranslation', 'TextAnalytics', 'TextTranslation', 'WebLM' + * @member {string} type The Type of the resource. + */ + constructor() { + } + + /** + * Defines the metadata of CheckSkuAvailabilityParameter + * + * @returns {object} metadata of CheckSkuAvailabilityParameter + * + */ + mapper() { + return { + required: false, + serializedName: 'CheckSkuAvailabilityParameter', + type: { + name: 'Composite', + className: 'CheckSkuAvailabilityParameter', + modelProperties: { + skus: { + required: true, + serializedName: 'skus', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + kind: { + required: true, + serializedName: 'kind', + type: { + name: 'String' + } + }, + type: { + required: true, + serializedName: 'type', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = CheckSkuAvailabilityParameter; diff --git a/lib/services/cognitiveServicesManagement/lib/lib/models/checkSkuAvailabilityResult.js b/lib/services/cognitiveServicesManagement/lib/lib/models/checkSkuAvailabilityResult.js new file mode 100644 index 0000000000..eac2cef4ab --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/models/checkSkuAvailabilityResult.js @@ -0,0 +1,100 @@ +/* + * 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'; + +/** + * Check SKU availability result. + * + */ +class CheckSkuAvailabilityResult { + /** + * Create a CheckSkuAvailabilityResult. + * @member {string} [kind] The Kind of the resource. Possible values include: + * 'Bing.Autosuggest.v7', 'Bing.CustomSearch', 'Bing.Search.v7', + * 'Bing.Speech', 'Bing.SpellCheck.v7', 'ComputerVision', 'ContentModerator', + * 'CustomSpeech', 'CustomVision.Prediction', 'CustomVision.Training', + * 'Emotion', 'Face', 'LUIS', 'QnAMaker', 'SpeakerRecognition', + * 'SpeechTranslation', 'TextAnalytics', 'TextTranslation', 'WebLM' + * @member {string} [type] The Type of the resource. + * @member {string} [skuName] The SKU of Cognitive Services account. Possible + * values include: 'F0', 'P0', 'P1', 'P2', 'S0', 'S1', 'S2', 'S3', 'S4', + * 'S5', 'S6' + * @member {boolean} [skuAvailable] Indicates the given SKU is available or + * not. + * @member {string} [reason] Reason why the SKU is not available. + * @member {string} [message] Additional error message. + */ + constructor() { + } + + /** + * Defines the metadata of CheckSkuAvailabilityResult + * + * @returns {object} metadata of CheckSkuAvailabilityResult + * + */ + mapper() { + return { + required: false, + serializedName: 'CheckSkuAvailabilityResult', + type: { + name: 'Composite', + className: 'CheckSkuAvailabilityResult', + modelProperties: { + kind: { + required: false, + serializedName: 'kind', + type: { + name: 'String' + } + }, + type: { + required: false, + serializedName: 'type', + type: { + name: 'String' + } + }, + skuName: { + required: false, + serializedName: 'skuName', + type: { + name: 'String' + } + }, + skuAvailable: { + required: false, + serializedName: 'skuAvailable', + type: { + name: 'Boolean' + } + }, + reason: { + required: false, + serializedName: 'reason', + type: { + name: 'String' + } + }, + message: { + required: false, + serializedName: 'message', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = CheckSkuAvailabilityResult; diff --git a/lib/services/cognitiveServicesManagement/lib/lib/models/checkSkuAvailabilityResultList.js b/lib/services/cognitiveServicesManagement/lib/lib/models/checkSkuAvailabilityResultList.js new file mode 100644 index 0000000000..1a2d14b1e4 --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/models/checkSkuAvailabilityResultList.js @@ -0,0 +1,62 @@ +/* + * 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 models = require('./index'); + +/** + * Check SKU availability result list. + * + */ +class CheckSkuAvailabilityResultList { + /** + * Create a CheckSkuAvailabilityResultList. + * @member {array} [value] Check SKU availability result list. + */ + constructor() { + } + + /** + * Defines the metadata of CheckSkuAvailabilityResultList + * + * @returns {object} metadata of CheckSkuAvailabilityResultList + * + */ + mapper() { + return { + required: false, + serializedName: 'CheckSkuAvailabilityResultList', + type: { + name: 'Composite', + className: 'CheckSkuAvailabilityResultList', + modelProperties: { + value: { + required: false, + serializedName: 'value', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'CheckSkuAvailabilityResultElementType', + type: { + name: 'Composite', + className: 'CheckSkuAvailabilityResult' + } + } + } + } + } + } + }; + } +} + +module.exports = CheckSkuAvailabilityResultList; diff --git a/lib/services/cognitiveServicesManagement/lib/lib/models/cognitiveServicesAccount.js b/lib/services/cognitiveServicesManagement/lib/lib/models/cognitiveServicesAccount.js new file mode 100644 index 0000000000..74c075d771 --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/models/cognitiveServicesAccount.js @@ -0,0 +1,161 @@ +/* + * 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 models = require('./index'); + +/** + * Cognitive Services Account is an Azure resource representing the provisioned + * account, its type, location and SKU. + * + * @extends models['BaseResource'] + */ +class CognitiveServicesAccount extends models['BaseResource'] { + /** + * Create a CognitiveServicesAccount. + * @member {string} [etag] Entity Tag + * @member {string} [id] The id of the created account + * @member {string} [kind] Type of cognitive service account. + * @member {string} [location] The location of the resource + * @member {string} [name] The name of the created account + * @member {string} [provisioningState] Gets the status of the cognitive + * services account at the time the operation was called. Possible values + * include: 'Creating', 'ResolvingDNS', 'Moving', 'Deleting', 'Succeeded', + * 'Failed' + * @member {string} [endpoint] Endpoint of the created account. + * @member {string} [internalId] The internal identifier. + * @member {object} [sku] The SKU of Cognitive Services account. + * @member {string} [sku.name] Gets or sets the sku name. Required for + * account creation, optional for update. Possible values include: 'F0', + * 'P0', 'P1', 'P2', 'S0', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6' + * @member {string} [sku.tier] Gets the sku tier. This is based on the SKU + * name. Possible values include: 'Free', 'Standard', 'Premium' + * @member {object} [tags] Gets or sets a list of key value pairs that + * describe the resource. These tags can be used in viewing and grouping this + * resource (across resource groups). A maximum of 15 tags can be provided + * for a resource. Each tag must have a key no greater than 128 characters + * and value no greater than 256 characters. + * @member {string} [type] Resource type + */ + constructor() { + super(); + } + + /** + * Defines the metadata of CognitiveServicesAccount + * + * @returns {object} metadata of CognitiveServicesAccount + * + */ + mapper() { + return { + required: false, + serializedName: 'CognitiveServicesAccount', + type: { + name: 'Composite', + className: 'CognitiveServicesAccount', + modelProperties: { + etag: { + required: false, + serializedName: 'etag', + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + kind: { + required: false, + serializedName: 'kind', + type: { + name: 'String' + } + }, + location: { + required: false, + serializedName: 'location', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + provisioningState: { + required: false, + readOnly: true, + serializedName: 'properties.provisioningState', + type: { + name: 'String' + } + }, + endpoint: { + required: false, + serializedName: 'properties.endpoint', + type: { + name: 'String' + } + }, + internalId: { + required: false, + serializedName: 'properties.internalId', + type: { + name: 'String' + } + }, + sku: { + required: false, + serializedName: 'sku', + type: { + name: 'Composite', + className: 'Sku' + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = CognitiveServicesAccount; diff --git a/lib/services/cognitiveServicesManagement/lib/lib/models/cognitiveServicesAccountCreateParameters.js b/lib/services/cognitiveServicesManagement/lib/lib/models/cognitiveServicesAccountCreateParameters.js new file mode 100644 index 0000000000..346d0fae38 --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/models/cognitiveServicesAccountCreateParameters.js @@ -0,0 +1,114 @@ +/* + * 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 models = require('./index'); + +/** + * The parameters to provide for the account. + * + */ +class CognitiveServicesAccountCreateParameters { + /** + * Create a CognitiveServicesAccountCreateParameters. + * @member {object} sku Required. Gets or sets the SKU of the resource. + * @member {string} [sku.name] Gets or sets the sku name. Required for + * account creation, optional for update. Possible values include: 'F0', + * 'P0', 'P1', 'P2', 'S0', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6' + * @member {string} [sku.tier] Gets the sku tier. This is based on the SKU + * name. Possible values include: 'Free', 'Standard', 'Premium' + * @member {string} kind Required. Gets or sets the Kind of the resource. + * Possible values include: 'Bing.Autosuggest.v7', 'Bing.CustomSearch', + * 'Bing.Search.v7', 'Bing.Speech', 'Bing.SpellCheck.v7', 'ComputerVision', + * 'ContentModerator', 'CustomSpeech', 'CustomVision.Prediction', + * 'CustomVision.Training', 'Emotion', 'Face', 'LUIS', 'QnAMaker', + * 'SpeakerRecognition', 'SpeechTranslation', 'TextAnalytics', + * 'TextTranslation', 'WebLM' + * @member {string} location Required. Gets or sets the location of the + * resource. This will be one of the supported and registered Azure Geo + * Regions (e.g. West US, East US, Southeast Asia, etc.). The geo region of a + * resource cannot be changed once it is created, but if an identical geo + * region is specified on update the request will succeed. + * @member {object} [tags] Gets or sets a list of key value pairs that + * describe the resource. These tags can be used in viewing and grouping this + * resource (across resource groups). A maximum of 15 tags can be provided + * for a resource. Each tag must have a key no greater than 128 characters + * and value no greater than 256 characters. + * @member {object} properties Must exist in the request. Must be an empty + * object. Must not be null. + */ + constructor() { + } + + /** + * Defines the metadata of CognitiveServicesAccountCreateParameters + * + * @returns {object} metadata of CognitiveServicesAccountCreateParameters + * + */ + mapper() { + return { + required: false, + serializedName: 'CognitiveServicesAccountCreateParameters', + type: { + name: 'Composite', + className: 'CognitiveServicesAccountCreateParameters', + modelProperties: { + sku: { + required: true, + serializedName: 'sku', + type: { + name: 'Composite', + className: 'Sku' + } + }, + kind: { + required: true, + serializedName: 'kind', + type: { + name: 'String' + } + }, + location: { + required: true, + serializedName: 'location', + type: { + name: 'String' + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + properties: { + required: true, + serializedName: 'properties', + type: { + name: 'Object' + } + } + } + } + }; + } +} + +module.exports = CognitiveServicesAccountCreateParameters; diff --git a/lib/services/cognitiveServicesManagement/lib/lib/models/cognitiveServicesAccountEnumerateSkusResult.js b/lib/services/cognitiveServicesManagement/lib/lib/models/cognitiveServicesAccountEnumerateSkusResult.js new file mode 100644 index 0000000000..26e53b533c --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/models/cognitiveServicesAccountEnumerateSkusResult.js @@ -0,0 +1,64 @@ +/* + * 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 models = require('./index'); + +/** + * The list of cognitive services accounts operation response. + * + */ +class CognitiveServicesAccountEnumerateSkusResult { + /** + * Create a CognitiveServicesAccountEnumerateSkusResult. + * @member {array} [value] Gets the list of Cognitive Services accounts and + * their properties. + */ + constructor() { + } + + /** + * Defines the metadata of CognitiveServicesAccountEnumerateSkusResult + * + * @returns {object} metadata of CognitiveServicesAccountEnumerateSkusResult + * + */ + mapper() { + return { + required: false, + serializedName: 'CognitiveServicesAccountEnumerateSkusResult', + type: { + name: 'Composite', + className: 'CognitiveServicesAccountEnumerateSkusResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: 'value', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'CognitiveServicesResourceAndSkuElementType', + type: { + name: 'Composite', + className: 'CognitiveServicesResourceAndSku' + } + } + } + } + } + } + }; + } +} + +module.exports = CognitiveServicesAccountEnumerateSkusResult; diff --git a/lib/services/cognitiveServicesManagement/lib/lib/models/cognitiveServicesAccountKeys.js b/lib/services/cognitiveServicesManagement/lib/lib/models/cognitiveServicesAccountKeys.js new file mode 100644 index 0000000000..d7259e4817 --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/models/cognitiveServicesAccountKeys.js @@ -0,0 +1,60 @@ +/* + * 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 access keys for the cognitive services account. + * + */ +class CognitiveServicesAccountKeys { + /** + * Create a CognitiveServicesAccountKeys. + * @member {string} [key1] Gets the value of key 1. + * @member {string} [key2] Gets the value of key 2. + */ + constructor() { + } + + /** + * Defines the metadata of CognitiveServicesAccountKeys + * + * @returns {object} metadata of CognitiveServicesAccountKeys + * + */ + mapper() { + return { + required: false, + serializedName: 'CognitiveServicesAccountKeys', + type: { + name: 'Composite', + className: 'CognitiveServicesAccountKeys', + modelProperties: { + key1: { + required: false, + serializedName: 'key1', + type: { + name: 'String' + } + }, + key2: { + required: false, + serializedName: 'key2', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = CognitiveServicesAccountKeys; diff --git a/lib/services/cognitiveServicesManagement/lib/lib/models/cognitiveServicesAccountListResult.js b/lib/services/cognitiveServicesManagement/lib/lib/models/cognitiveServicesAccountListResult.js new file mode 100644 index 0000000000..34391de9f5 --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/models/cognitiveServicesAccountListResult.js @@ -0,0 +1,69 @@ +/* + * 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 list of cognitive services accounts operation response. + */ +class CognitiveServicesAccountListResult extends Array { + /** + * Create a CognitiveServicesAccountListResult. + * @member {string} [nextLink] The link used to get the next page of + * accounts. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of CognitiveServicesAccountListResult + * + * @returns {object} metadata of CognitiveServicesAccountListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'CognitiveServicesAccountListResult', + type: { + name: 'Composite', + className: 'CognitiveServicesAccountListResult', + modelProperties: { + nextLink: { + required: false, + serializedName: 'nextLink', + type: { + name: 'String' + } + }, + value: { + required: false, + readOnly: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'CognitiveServicesAccountElementType', + type: { + name: 'Composite', + className: 'CognitiveServicesAccount' + } + } + } + } + } + } + }; + } +} + +module.exports = CognitiveServicesAccountListResult; diff --git a/lib/services/cognitiveServicesManagement/lib/lib/models/cognitiveServicesAccountUpdateParameters.js b/lib/services/cognitiveServicesManagement/lib/lib/models/cognitiveServicesAccountUpdateParameters.js new file mode 100644 index 0000000000..c47234c4ba --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/models/cognitiveServicesAccountUpdateParameters.js @@ -0,0 +1,79 @@ +/* + * 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 models = require('./index'); + +/** + * The parameters to provide for the account. + * + */ +class CognitiveServicesAccountUpdateParameters { + /** + * Create a CognitiveServicesAccountUpdateParameters. + * @member {object} [sku] Gets or sets the SKU of the resource. + * @member {string} [sku.name] Gets or sets the sku name. Required for + * account creation, optional for update. Possible values include: 'F0', + * 'P0', 'P1', 'P2', 'S0', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6' + * @member {string} [sku.tier] Gets the sku tier. This is based on the SKU + * name. Possible values include: 'Free', 'Standard', 'Premium' + * @member {object} [tags] Gets or sets a list of key value pairs that + * describe the resource. These tags can be used in viewing and grouping this + * resource (across resource groups). A maximum of 15 tags can be provided + * for a resource. Each tag must have a key no greater than 128 characters + * and value no greater than 256 characters. + */ + constructor() { + } + + /** + * Defines the metadata of CognitiveServicesAccountUpdateParameters + * + * @returns {object} metadata of CognitiveServicesAccountUpdateParameters + * + */ + mapper() { + return { + required: false, + serializedName: 'CognitiveServicesAccountUpdateParameters', + type: { + name: 'Composite', + className: 'CognitiveServicesAccountUpdateParameters', + modelProperties: { + sku: { + required: false, + serializedName: 'sku', + type: { + name: 'Composite', + className: 'Sku' + } + }, + tags: { + required: false, + serializedName: 'tags', + type: { + name: 'Dictionary', + value: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = CognitiveServicesAccountUpdateParameters; diff --git a/lib/services/cognitiveServicesManagement/lib/lib/models/cognitiveServicesResourceAndSku.js b/lib/services/cognitiveServicesManagement/lib/lib/models/cognitiveServicesResourceAndSku.js new file mode 100644 index 0000000000..ffb115e3b0 --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/models/cognitiveServicesResourceAndSku.js @@ -0,0 +1,68 @@ +/* + * 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 models = require('./index'); + +/** + * Cognitive Services resource type and SKU. + * + */ +class CognitiveServicesResourceAndSku { + /** + * Create a CognitiveServicesResourceAndSku. + * @member {string} [resourceType] Resource Namespace and Type + * @member {object} [sku] The SKU of Cognitive Services account. + * @member {string} [sku.name] Gets or sets the sku name. Required for + * account creation, optional for update. Possible values include: 'F0', + * 'P0', 'P1', 'P2', 'S0', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6' + * @member {string} [sku.tier] Gets the sku tier. This is based on the SKU + * name. Possible values include: 'Free', 'Standard', 'Premium' + */ + constructor() { + } + + /** + * Defines the metadata of CognitiveServicesResourceAndSku + * + * @returns {object} metadata of CognitiveServicesResourceAndSku + * + */ + mapper() { + return { + required: false, + serializedName: 'CognitiveServicesResourceAndSku', + type: { + name: 'Composite', + className: 'CognitiveServicesResourceAndSku', + modelProperties: { + resourceType: { + required: false, + serializedName: 'resourceType', + type: { + name: 'String' + } + }, + sku: { + required: false, + serializedName: 'sku', + type: { + name: 'Composite', + className: 'Sku' + } + } + } + } + }; + } +} + +module.exports = CognitiveServicesResourceAndSku; diff --git a/lib/services/cognitiveServicesManagement/lib/lib/models/errorBody.js b/lib/services/cognitiveServicesManagement/lib/lib/models/errorBody.js new file mode 100644 index 0000000000..207a8ec98e --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/models/errorBody.js @@ -0,0 +1,60 @@ +/* + * 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'; + +/** + * Cognitive Services error body. + * + */ +class ErrorBody { + /** + * Create a ErrorBody. + * @member {string} code error code + * @member {string} message error message + */ + constructor() { + } + + /** + * Defines the metadata of ErrorBody + * + * @returns {object} metadata of ErrorBody + * + */ + mapper() { + return { + required: false, + serializedName: 'ErrorBody', + type: { + name: 'Composite', + className: 'ErrorBody', + modelProperties: { + code: { + required: true, + serializedName: 'code', + type: { + name: 'String' + } + }, + message: { + required: true, + serializedName: 'message', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ErrorBody; diff --git a/lib/services/cognitiveServicesManagement/lib/lib/models/errorModel.js b/lib/services/cognitiveServicesManagement/lib/lib/models/errorModel.js new file mode 100644 index 0000000000..8f7e45826c --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/models/errorModel.js @@ -0,0 +1,57 @@ +/* + * 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 models = require('./index'); + +/** + * Cognitive Services error object. + * + */ +class ErrorModel { + /** + * Create a ErrorModel. + * @member {object} [error] The error body. + * @member {string} [error.code] error code + * @member {string} [error.message] error message + */ + constructor() { + } + + /** + * Defines the metadata of ErrorModel + * + * @returns {object} metadata of ErrorModel + * + */ + mapper() { + return { + required: false, + serializedName: 'Error', + type: { + name: 'Composite', + className: 'ErrorModel', + modelProperties: { + error: { + required: false, + serializedName: 'error', + type: { + name: 'Composite', + className: 'ErrorBody' + } + } + } + } + }; + } +} + +module.exports = ErrorModel; diff --git a/lib/services/cognitiveServicesManagement/lib/lib/models/index.d.ts b/lib/services/cognitiveServicesManagement/lib/lib/models/index.d.ts new file mode 100644 index 0000000000..39db2497f9 --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/models/index.d.ts @@ -0,0 +1,418 @@ +/* + * 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. + */ + +import { BaseResource } from 'ms-rest-azure'; +import { CloudError } from 'ms-rest-azure'; +import * as moment from 'moment'; + +export { BaseResource } from 'ms-rest-azure'; +export { CloudError } from 'ms-rest-azure'; + + +/** + * @class + * Initializes a new instance of the Sku class. + * @constructor + * The SKU of the cognitive services account. + * + * @member {string} name Gets or sets the sku name. Required for account + * creation, optional for update. Possible values include: 'F0', 'P0', 'P1', + * 'P2', 'S0', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6' + * @member {string} [tier] Gets the sku tier. This is based on the SKU name. + * Possible values include: 'Free', 'Standard', 'Premium' + */ +export interface Sku { + name: string; + readonly tier?: string; +} + +/** + * @class + * Initializes a new instance of the CognitiveServicesAccountCreateParameters class. + * @constructor + * The parameters to provide for the account. + * + * @member {object} sku Required. Gets or sets the SKU of the resource. + * @member {string} [sku.name] Gets or sets the sku name. Required for account + * creation, optional for update. Possible values include: 'F0', 'P0', 'P1', + * 'P2', 'S0', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6' + * @member {string} [sku.tier] Gets the sku tier. This is based on the SKU + * name. Possible values include: 'Free', 'Standard', 'Premium' + * @member {string} kind Required. Gets or sets the Kind of the resource. + * Possible values include: 'Bing.Autosuggest.v7', 'Bing.CustomSearch', + * 'Bing.Search.v7', 'Bing.Speech', 'Bing.SpellCheck.v7', 'ComputerVision', + * 'ContentModerator', 'CustomSpeech', 'CustomVision.Prediction', + * 'CustomVision.Training', 'Emotion', 'Face', 'LUIS', 'QnAMaker', + * 'SpeakerRecognition', 'SpeechTranslation', 'TextAnalytics', + * 'TextTranslation', 'WebLM' + * @member {string} location Required. Gets or sets the location of the + * resource. This will be one of the supported and registered Azure Geo Regions + * (e.g. West US, East US, Southeast Asia, etc.). The geo region of a resource + * cannot be changed once it is created, but if an identical geo region is + * specified on update the request will succeed. + * @member {object} [tags] Gets or sets a list of key value pairs that describe + * the resource. These tags can be used in viewing and grouping this resource + * (across resource groups). A maximum of 15 tags can be provided for a + * resource. Each tag must have a key no greater than 128 characters and value + * no greater than 256 characters. + * @member {object} properties Must exist in the request. Must be an empty + * object. Must not be null. + */ +export interface CognitiveServicesAccountCreateParameters { + sku: Sku; + kind: string; + location: string; + tags?: { [propertyName: string]: string }; + properties: any; +} + +/** + * @class + * Initializes a new instance of the CognitiveServicesAccountUpdateParameters class. + * @constructor + * The parameters to provide for the account. + * + * @member {object} [sku] Gets or sets the SKU of the resource. + * @member {string} [sku.name] Gets or sets the sku name. Required for account + * creation, optional for update. Possible values include: 'F0', 'P0', 'P1', + * 'P2', 'S0', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6' + * @member {string} [sku.tier] Gets the sku tier. This is based on the SKU + * name. Possible values include: 'Free', 'Standard', 'Premium' + * @member {object} [tags] Gets or sets a list of key value pairs that describe + * the resource. These tags can be used in viewing and grouping this resource + * (across resource groups). A maximum of 15 tags can be provided for a + * resource. Each tag must have a key no greater than 128 characters and value + * no greater than 256 characters. + */ +export interface CognitiveServicesAccountUpdateParameters { + sku?: Sku; + tags?: { [propertyName: string]: string }; +} + +/** + * @class + * Initializes a new instance of the CognitiveServicesAccount class. + * @constructor + * Cognitive Services Account is an Azure resource representing the provisioned + * account, its type, location and SKU. + * + * @member {string} [etag] Entity Tag + * @member {string} [id] The id of the created account + * @member {string} [kind] Type of cognitive service account. + * @member {string} [location] The location of the resource + * @member {string} [name] The name of the created account + * @member {string} [provisioningState] Gets the status of the cognitive + * services account at the time the operation was called. Possible values + * include: 'Creating', 'ResolvingDNS', 'Moving', 'Deleting', 'Succeeded', + * 'Failed' + * @member {string} [endpoint] Endpoint of the created account. + * @member {string} [internalId] The internal identifier. + * @member {object} [sku] The SKU of Cognitive Services account. + * @member {string} [sku.name] Gets or sets the sku name. Required for account + * creation, optional for update. Possible values include: 'F0', 'P0', 'P1', + * 'P2', 'S0', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6' + * @member {string} [sku.tier] Gets the sku tier. This is based on the SKU + * name. Possible values include: 'Free', 'Standard', 'Premium' + * @member {object} [tags] Gets or sets a list of key value pairs that describe + * the resource. These tags can be used in viewing and grouping this resource + * (across resource groups). A maximum of 15 tags can be provided for a + * resource. Each tag must have a key no greater than 128 characters and value + * no greater than 256 characters. + * @member {string} [type] Resource type + */ +export interface CognitiveServicesAccount extends BaseResource { + etag?: string; + readonly id?: string; + kind?: string; + location?: string; + readonly name?: string; + readonly provisioningState?: string; + endpoint?: string; + internalId?: string; + sku?: Sku; + tags?: { [propertyName: string]: string }; + readonly type?: string; +} + +/** + * @class + * Initializes a new instance of the CognitiveServicesAccountKeys class. + * @constructor + * The access keys for the cognitive services account. + * + * @member {string} [key1] Gets the value of key 1. + * @member {string} [key2] Gets the value of key 2. + */ +export interface CognitiveServicesAccountKeys { + key1?: string; + key2?: string; +} + +/** + * @class + * Initializes a new instance of the RegenerateKeyParameters class. + * @constructor + * Regenerate key parameters. + * + * @member {string} keyName key name to generate (Key1|Key2). Possible values + * include: 'Key1', 'Key2' + */ +export interface RegenerateKeyParameters { + keyName: string; +} + +/** + * @class + * Initializes a new instance of the CognitiveServicesResourceAndSku class. + * @constructor + * Cognitive Services resource type and SKU. + * + * @member {string} [resourceType] Resource Namespace and Type + * @member {object} [sku] The SKU of Cognitive Services account. + * @member {string} [sku.name] Gets or sets the sku name. Required for account + * creation, optional for update. Possible values include: 'F0', 'P0', 'P1', + * 'P2', 'S0', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6' + * @member {string} [sku.tier] Gets the sku tier. This is based on the SKU + * name. Possible values include: 'Free', 'Standard', 'Premium' + */ +export interface CognitiveServicesResourceAndSku { + resourceType?: string; + sku?: Sku; +} + +/** + * @class + * Initializes a new instance of the CognitiveServicesAccountEnumerateSkusResult class. + * @constructor + * The list of cognitive services accounts operation response. + * + * @member {array} [value] Gets the list of Cognitive Services accounts and + * their properties. + */ +export interface CognitiveServicesAccountEnumerateSkusResult { + readonly value?: CognitiveServicesResourceAndSku[]; +} + +/** + * @class + * Initializes a new instance of the MetricName class. + * @constructor + * A metric name. + * + * @member {string} [value] The name of the metric. + * @member {string} [localizedValue] The friendly name of the metric. + */ +export interface MetricName { + readonly value?: string; + readonly localizedValue?: string; +} + +/** + * @class + * Initializes a new instance of the Usage class. + * @constructor + * The usage data for a usage request. + * + * @member {string} [unit] The unit of the metric. Possible values include: + * 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', 'BytesPerSecond', + * 'Milliseconds' + * @member {object} [name] The name information for the metric. + * @member {string} [name.value] The name of the metric. + * @member {string} [name.localizedValue] The friendly name of the metric. + * @member {string} [quotaPeriod] The quota period used to summarize the usage + * values. + * @member {number} [limit] Maximum value for this metric. + * @member {number} [currentValue] Current value for this metric. + * @member {string} [nextResetTime] Next reset time for current quota. + * @member {string} [status] Cognitive Services account quota usage status. + * Possible values include: 'Included', 'Blocked', 'InOverage', 'Unknown' + */ +export interface Usage { + unit?: string; + readonly name?: MetricName; + readonly quotaPeriod?: string; + readonly limit?: number; + readonly currentValue?: number; + readonly nextResetTime?: string; + status?: string; +} + +/** + * @class + * Initializes a new instance of the UsagesResult class. + * @constructor + * The response to a list usage request. + * + * @member {array} [value] The list of usages for Cognitive Service account. + */ +export interface UsagesResult { + readonly value?: Usage[]; +} + +/** + * @class + * Initializes a new instance of the ErrorBody class. + * @constructor + * Cognitive Services error body. + * + * @member {string} code error code + * @member {string} message error message + */ +export interface ErrorBody { + code: string; + message: string; +} + +/** + * @class + * Initializes a new instance of the ErrorModel class. + * @constructor + * Cognitive Services error object. + * + * @member {object} [error] The error body. + * @member {string} [error.code] error code + * @member {string} [error.message] error message + */ +export interface ErrorModel { + error?: ErrorBody; +} + +/** + * @class + * Initializes a new instance of the OperationDisplayInfo class. + * @constructor + * The operation supported by Cognitive Services. + * + * @member {string} [description] The description of the operation. + * @member {string} [operation] The action that users can perform, based on + * their permission level. + * @member {string} [provider] Service provider: Microsoft Cognitive Services. + * @member {string} [resource] Resource on which the operation is performed. + */ +export interface OperationDisplayInfo { + description?: string; + operation?: string; + provider?: string; + resource?: string; +} + +/** + * @class + * Initializes a new instance of the OperationEntity class. + * @constructor + * The operation supported by Cognitive Services. + * + * @member {string} [name] Operation name: {provider}/{resource}/{operation}. + * @member {object} [display] The operation supported by Cognitive Services. + * @member {string} [display.description] The description of the operation. + * @member {string} [display.operation] The action that users can perform, + * based on their permission level. + * @member {string} [display.provider] Service provider: Microsoft Cognitive + * Services. + * @member {string} [display.resource] Resource on which the operation is + * performed. + * @member {string} [origin] The origin of the operation. + * @member {object} [properties] Additional properties. + */ +export interface OperationEntity { + name?: string; + display?: OperationDisplayInfo; + origin?: string; + properties?: any; +} + +/** + * @class + * Initializes a new instance of the CheckSkuAvailabilityParameter class. + * @constructor + * Check SKU availability parameter. + * + * @member {array} skus The SKU of the resource. + * @member {string} kind The Kind of the resource. Possible values include: + * 'Bing.Autosuggest.v7', 'Bing.CustomSearch', 'Bing.Search.v7', 'Bing.Speech', + * 'Bing.SpellCheck.v7', 'ComputerVision', 'ContentModerator', 'CustomSpeech', + * 'CustomVision.Prediction', 'CustomVision.Training', 'Emotion', 'Face', + * 'LUIS', 'QnAMaker', 'SpeakerRecognition', 'SpeechTranslation', + * 'TextAnalytics', 'TextTranslation', 'WebLM' + * @member {string} type The Type of the resource. + */ +export interface CheckSkuAvailabilityParameter { + skus: string[]; + kind: string; + type: string; +} + +/** + * @class + * Initializes a new instance of the CheckSkuAvailabilityResult class. + * @constructor + * Check SKU availability result. + * + * @member {string} [kind] The Kind of the resource. Possible values include: + * 'Bing.Autosuggest.v7', 'Bing.CustomSearch', 'Bing.Search.v7', 'Bing.Speech', + * 'Bing.SpellCheck.v7', 'ComputerVision', 'ContentModerator', 'CustomSpeech', + * 'CustomVision.Prediction', 'CustomVision.Training', 'Emotion', 'Face', + * 'LUIS', 'QnAMaker', 'SpeakerRecognition', 'SpeechTranslation', + * 'TextAnalytics', 'TextTranslation', 'WebLM' + * @member {string} [type] The Type of the resource. + * @member {string} [skuName] The SKU of Cognitive Services account. Possible + * values include: 'F0', 'P0', 'P1', 'P2', 'S0', 'S1', 'S2', 'S3', 'S4', 'S5', + * 'S6' + * @member {boolean} [skuAvailable] Indicates the given SKU is available or + * not. + * @member {string} [reason] Reason why the SKU is not available. + * @member {string} [message] Additional error message. + */ +export interface CheckSkuAvailabilityResult { + kind?: string; + type?: string; + skuName?: string; + skuAvailable?: boolean; + reason?: string; + message?: string; +} + +/** + * @class + * Initializes a new instance of the CheckSkuAvailabilityResultList class. + * @constructor + * Check SKU availability result list. + * + * @member {array} [value] Check SKU availability result list. + */ +export interface CheckSkuAvailabilityResultList { + value?: CheckSkuAvailabilityResult[]; +} + + +/** + * @class + * Initializes a new instance of the CognitiveServicesAccountListResult class. + * @constructor + * The list of cognitive services accounts operation response. + * + * @member {string} [nextLink] The link used to get the next page of accounts. + */ +export interface CognitiveServicesAccountListResult extends Array { + nextLink?: string; +} + +/** + * @class + * Initializes a new instance of the OperationEntityListResult class. + * @constructor + * The list of cognitive services accounts operation response. + * + * @member {string} [nextLink] The link used to get the next page of + * operations. + */ +export interface OperationEntityListResult extends Array { + nextLink?: string; +} diff --git a/lib/services/cognitiveServicesManagement/lib/lib/models/index.js b/lib/services/cognitiveServicesManagement/lib/lib/models/index.js new file mode 100644 index 0000000000..94cd5bd2cd --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/models/index.js @@ -0,0 +1,40 @@ +/* + * 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. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +var msRestAzure = require('ms-rest-azure'); + +exports.BaseResource = msRestAzure.BaseResource; +exports.CloudError = msRestAzure.CloudError; +exports.Sku = require('./sku'); +exports.CognitiveServicesAccountCreateParameters = require('./cognitiveServicesAccountCreateParameters'); +exports.CognitiveServicesAccountUpdateParameters = require('./cognitiveServicesAccountUpdateParameters'); +exports.CognitiveServicesAccount = require('./cognitiveServicesAccount'); +exports.CognitiveServicesAccountKeys = require('./cognitiveServicesAccountKeys'); +exports.RegenerateKeyParameters = require('./regenerateKeyParameters'); +exports.CognitiveServicesResourceAndSku = require('./cognitiveServicesResourceAndSku'); +exports.CognitiveServicesAccountEnumerateSkusResult = require('./cognitiveServicesAccountEnumerateSkusResult'); +exports.MetricName = require('./metricName'); +exports.Usage = require('./usage'); +exports.UsagesResult = require('./usagesResult'); +exports.ErrorBody = require('./errorBody'); +exports.ErrorModel = require('./errorModel'); +exports.OperationDisplayInfo = require('./operationDisplayInfo'); +exports.OperationEntity = require('./operationEntity'); +exports.CheckSkuAvailabilityParameter = require('./checkSkuAvailabilityParameter'); +exports.CheckSkuAvailabilityResult = require('./checkSkuAvailabilityResult'); +exports.CheckSkuAvailabilityResultList = require('./checkSkuAvailabilityResultList'); +exports.CognitiveServicesAccountListResult = require('./cognitiveServicesAccountListResult'); +exports.OperationEntityListResult = require('./operationEntityListResult'); diff --git a/lib/services/cognitiveServicesManagement/lib/lib/models/metricName.js b/lib/services/cognitiveServicesManagement/lib/lib/models/metricName.js new file mode 100644 index 0000000000..03b48f02a4 --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/models/metricName.js @@ -0,0 +1,62 @@ +/* + * 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'; + +/** + * A metric name. + * + */ +class MetricName { + /** + * Create a MetricName. + * @member {string} [value] The name of the metric. + * @member {string} [localizedValue] The friendly name of the metric. + */ + constructor() { + } + + /** + * Defines the metadata of MetricName + * + * @returns {object} metadata of MetricName + * + */ + mapper() { + return { + required: false, + serializedName: 'MetricName', + type: { + name: 'Composite', + className: 'MetricName', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: 'value', + type: { + name: 'String' + } + }, + localizedValue: { + required: false, + readOnly: true, + serializedName: 'localizedValue', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = MetricName; diff --git a/lib/services/cognitiveServicesManagement/lib/lib/models/operationDisplayInfo.js b/lib/services/cognitiveServicesManagement/lib/lib/models/operationDisplayInfo.js new file mode 100644 index 0000000000..e842b06d53 --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/models/operationDisplayInfo.js @@ -0,0 +1,78 @@ +/* + * 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 operation supported by Cognitive Services. + * + */ +class OperationDisplayInfo { + /** + * Create a OperationDisplayInfo. + * @member {string} [description] The description of the operation. + * @member {string} [operation] The action that users can perform, based on + * their permission level. + * @member {string} [provider] Service provider: Microsoft Cognitive + * Services. + * @member {string} [resource] Resource on which the operation is performed. + */ + constructor() { + } + + /** + * Defines the metadata of OperationDisplayInfo + * + * @returns {object} metadata of OperationDisplayInfo + * + */ + mapper() { + return { + required: false, + serializedName: 'OperationDisplayInfo', + type: { + name: 'Composite', + className: 'OperationDisplayInfo', + modelProperties: { + description: { + required: false, + serializedName: 'description', + type: { + name: 'String' + } + }, + operation: { + required: false, + serializedName: 'operation', + type: { + name: 'String' + } + }, + provider: { + required: false, + serializedName: 'provider', + type: { + name: 'String' + } + }, + resource: { + required: false, + serializedName: 'resource', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = OperationDisplayInfo; diff --git a/lib/services/cognitiveServicesManagement/lib/lib/models/operationEntity.js b/lib/services/cognitiveServicesManagement/lib/lib/models/operationEntity.js new file mode 100644 index 0000000000..42e0ec8e86 --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/models/operationEntity.js @@ -0,0 +1,86 @@ +/* + * 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 models = require('./index'); + +/** + * The operation supported by Cognitive Services. + * + */ +class OperationEntity { + /** + * Create a OperationEntity. + * @member {string} [name] Operation name: {provider}/{resource}/{operation}. + * @member {object} [display] The operation supported by Cognitive Services. + * @member {string} [display.description] The description of the operation. + * @member {string} [display.operation] The action that users can perform, + * based on their permission level. + * @member {string} [display.provider] Service provider: Microsoft Cognitive + * Services. + * @member {string} [display.resource] Resource on which the operation is + * performed. + * @member {string} [origin] The origin of the operation. + * @member {object} [properties] Additional properties. + */ + constructor() { + } + + /** + * Defines the metadata of OperationEntity + * + * @returns {object} metadata of OperationEntity + * + */ + mapper() { + return { + required: false, + serializedName: 'OperationEntity', + type: { + name: 'Composite', + className: 'OperationEntity', + modelProperties: { + name: { + required: false, + serializedName: 'name', + type: { + name: 'String' + } + }, + display: { + required: false, + serializedName: 'display', + type: { + name: 'Composite', + className: 'OperationDisplayInfo' + } + }, + origin: { + required: false, + serializedName: 'origin', + type: { + name: 'String' + } + }, + properties: { + required: false, + serializedName: 'properties', + type: { + name: 'Object' + } + } + } + } + }; + } +} + +module.exports = OperationEntity; diff --git a/lib/services/cognitiveServicesManagement/lib/lib/models/operationEntityListResult.js b/lib/services/cognitiveServicesManagement/lib/lib/models/operationEntityListResult.js new file mode 100644 index 0000000000..6a62f1306f --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/models/operationEntityListResult.js @@ -0,0 +1,68 @@ +/* + * 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 list of cognitive services accounts operation response. + */ +class OperationEntityListResult extends Array { + /** + * Create a OperationEntityListResult. + * @member {string} [nextLink] The link used to get the next page of + * operations. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of OperationEntityListResult + * + * @returns {object} metadata of OperationEntityListResult + * + */ + mapper() { + return { + required: false, + serializedName: 'OperationEntityListResult', + type: { + name: 'Composite', + className: 'OperationEntityListResult', + modelProperties: { + nextLink: { + required: false, + serializedName: 'nextLink', + type: { + name: 'String' + } + }, + value: { + required: false, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'OperationEntityElementType', + type: { + name: 'Composite', + className: 'OperationEntity' + } + } + } + } + } + } + }; + } +} + +module.exports = OperationEntityListResult; diff --git a/lib/services/cognitiveServicesManagement/lib/lib/models/regenerateKeyParameters.js b/lib/services/cognitiveServicesManagement/lib/lib/models/regenerateKeyParameters.js new file mode 100644 index 0000000000..b4e7b06a35 --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/models/regenerateKeyParameters.js @@ -0,0 +1,54 @@ +/* + * 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'; + +/** + * Regenerate key parameters. + * + */ +class RegenerateKeyParameters { + /** + * Create a RegenerateKeyParameters. + * @member {string} keyName key name to generate (Key1|Key2). Possible values + * include: 'Key1', 'Key2' + */ + constructor() { + } + + /** + * Defines the metadata of RegenerateKeyParameters + * + * @returns {object} metadata of RegenerateKeyParameters + * + */ + mapper() { + return { + required: false, + serializedName: 'RegenerateKeyParameters', + type: { + name: 'Composite', + className: 'RegenerateKeyParameters', + modelProperties: { + keyName: { + required: true, + serializedName: 'keyName', + type: { + name: 'Enum', + allowedValues: [ 'Key1', 'Key2' ] + } + } + } + } + }; + } +} + +module.exports = RegenerateKeyParameters; diff --git a/lib/services/cognitiveServicesManagement/lib/lib/models/sku.js b/lib/services/cognitiveServicesManagement/lib/lib/models/sku.js new file mode 100644 index 0000000000..a6f270b1a0 --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/models/sku.js @@ -0,0 +1,65 @@ +/* + * 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 SKU of the cognitive services account. + * + */ +class Sku { + /** + * Create a Sku. + * @member {string} name Gets or sets the sku name. Required for account + * creation, optional for update. Possible values include: 'F0', 'P0', 'P1', + * 'P2', 'S0', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6' + * @member {string} [tier] Gets the sku tier. This is based on the SKU name. + * Possible values include: 'Free', 'Standard', 'Premium' + */ + constructor() { + } + + /** + * Defines the metadata of Sku + * + * @returns {object} metadata of Sku + * + */ + mapper() { + return { + required: false, + serializedName: 'Sku', + type: { + name: 'Composite', + className: 'Sku', + modelProperties: { + name: { + required: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + tier: { + required: false, + readOnly: true, + serializedName: 'tier', + type: { + name: 'Enum', + allowedValues: [ 'Free', 'Standard', 'Premium' ] + } + } + } + } + }; + } +} + +module.exports = Sku; diff --git a/lib/services/cognitiveServicesManagement/lib/lib/models/usage.js b/lib/services/cognitiveServicesManagement/lib/lib/models/usage.js new file mode 100644 index 0000000000..3d58370239 --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/models/usage.js @@ -0,0 +1,114 @@ +/* + * 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 models = require('./index'); + +/** + * The usage data for a usage request. + * + */ +class Usage { + /** + * Create a Usage. + * @member {string} [unit] The unit of the metric. Possible values include: + * 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', + * 'BytesPerSecond', 'Milliseconds' + * @member {object} [name] The name information for the metric. + * @member {string} [name.value] The name of the metric. + * @member {string} [name.localizedValue] The friendly name of the metric. + * @member {string} [quotaPeriod] The quota period used to summarize the + * usage values. + * @member {number} [limit] Maximum value for this metric. + * @member {number} [currentValue] Current value for this metric. + * @member {string} [nextResetTime] Next reset time for current quota. + * @member {string} [status] Cognitive Services account quota usage status. + * Possible values include: 'Included', 'Blocked', 'InOverage', 'Unknown' + */ + constructor() { + } + + /** + * Defines the metadata of Usage + * + * @returns {object} metadata of Usage + * + */ + mapper() { + return { + required: false, + serializedName: 'Usage', + type: { + name: 'Composite', + className: 'Usage', + modelProperties: { + unit: { + required: false, + serializedName: 'unit', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'Composite', + className: 'MetricName' + } + }, + quotaPeriod: { + required: false, + readOnly: true, + serializedName: 'quotaPeriod', + type: { + name: 'String' + } + }, + limit: { + required: false, + readOnly: true, + serializedName: 'limit', + type: { + name: 'Number' + } + }, + currentValue: { + required: false, + readOnly: true, + serializedName: 'currentValue', + type: { + name: 'Number' + } + }, + nextResetTime: { + required: false, + readOnly: true, + serializedName: 'nextResetTime', + type: { + name: 'String' + } + }, + status: { + required: false, + serializedName: 'status', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = Usage; diff --git a/lib/services/cognitiveServicesManagement/lib/lib/models/usagesResult.js b/lib/services/cognitiveServicesManagement/lib/lib/models/usagesResult.js new file mode 100644 index 0000000000..6fb6f8a22a --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/models/usagesResult.js @@ -0,0 +1,63 @@ +/* + * 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 models = require('./index'); + +/** + * The response to a list usage request. + * + */ +class UsagesResult { + /** + * Create a UsagesResult. + * @member {array} [value] The list of usages for Cognitive Service account. + */ + constructor() { + } + + /** + * Defines the metadata of UsagesResult + * + * @returns {object} metadata of UsagesResult + * + */ + mapper() { + return { + required: false, + serializedName: 'UsagesResult', + type: { + name: 'Composite', + className: 'UsagesResult', + modelProperties: { + value: { + required: false, + readOnly: true, + serializedName: 'value', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'UsageElementType', + type: { + name: 'Composite', + className: 'Usage' + } + } + } + } + } + } + }; + } +} + +module.exports = UsagesResult; diff --git a/lib/services/cognitiveServicesManagement/lib/lib/operations/accounts.js b/lib/services/cognitiveServicesManagement/lib/lib/operations/accounts.js new file mode 100644 index 0000000000..bb97a65ff5 --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/operations/accounts.js @@ -0,0 +1,3157 @@ +/* + * 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 msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Create Cognitive Services Account. Accounts is a resource group wide + * resource type. It holds the keys for developer to access intelligent APIs. + * It's also the resource type for billing. + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @param {object} parameters The parameters to provide for the created + * account. + * + * @param {object} parameters.sku Required. Gets or sets the SKU of the + * resource. + * + * @param {string} parameters.sku.name Gets or sets the sku name. Required for + * account creation, optional for update. Possible values include: 'F0', 'P0', + * 'P1', 'P2', 'S0', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6' + * + * @param {string} parameters.kind Required. Gets or sets the Kind of the + * resource. Possible values include: 'Bing.Autosuggest.v7', + * 'Bing.CustomSearch', 'Bing.Search.v7', 'Bing.Speech', 'Bing.SpellCheck.v7', + * 'ComputerVision', 'ContentModerator', 'CustomSpeech', + * 'CustomVision.Prediction', 'CustomVision.Training', 'Emotion', 'Face', + * 'LUIS', 'QnAMaker', 'SpeakerRecognition', 'SpeechTranslation', + * 'TextAnalytics', 'TextTranslation', 'WebLM' + * + * @param {string} parameters.location Required. Gets or sets the location of + * the resource. This will be one of the supported and registered Azure Geo + * Regions (e.g. West US, East US, Southeast Asia, etc.). The geo region of a + * resource cannot be changed once it is created, but if an identical geo + * region is specified on update the request will succeed. + * + * @param {object} [parameters.tags] Gets or sets a list of key value pairs + * that describe the resource. These tags can be used in viewing and grouping + * this resource (across resource groups). A maximum of 15 tags can be provided + * for a resource. Each tag must have a key no greater than 128 characters and + * value no greater than 256 characters. + * + * @param {object} parameters.properties Must exist in the request. Must be an + * empty object. Must not be null. + * + * @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 CognitiveServicesAccount} 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(resourceGroupName, accountName, parameters, 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 (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') { + throw new Error('accountName cannot be null or undefined and it must be of type string.'); + } + if (accountName !== null && accountName !== undefined) { + if (accountName.length > 64) + { + throw new Error('"accountName" should satisfy the constraint - "MaxLength": 64'); + } + if (accountName.length < 2) + { + throw new Error('"accountName" should satisfy the constraint - "MinLength": 2'); + } + if (accountName.match(/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/) === null) + { + throw new Error('"accountName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/'); + } + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + 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 (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}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{accountName}', encodeURIComponent(accountName)); + 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 = 'PUT'; + 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 (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['CognitiveServicesAccountCreateParameters']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, 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 && 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['ErrorModel']().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['CognitiveServicesAccount']().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); + } + } + // 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['CognitiveServicesAccount']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError1 = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError1.request = msRest.stripRequest(httpRequest); + deserializationError1.response = msRest.stripResponse(response); + return callback(deserializationError1); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** + * Updates a Cognitive Services account + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.sku] Gets or sets the SKU of the resource. + * + * @param {string} options.sku.name Gets or sets the sku name. Required for + * account creation, optional for update. Possible values include: 'F0', 'P0', + * 'P1', 'P2', 'S0', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6' + * + * @param {object} [options.tags] Gets or sets a list of key value pairs that + * describe the resource. These tags can be used in viewing and grouping this + * resource (across resource groups). A maximum of 15 tags can be provided for + * a resource. Each tag must have a key no greater than 128 characters and + * value no greater than 256 characters. + * + * @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 CognitiveServicesAccount} 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 _update(resourceGroupName, accountName, 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.'); + } + let sku = (options && options.sku !== undefined) ? options.sku : undefined; + let tags = (options && options.tags !== undefined) ? options.tags : undefined; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') { + throw new Error('accountName cannot be null or undefined and it must be of type string.'); + } + if (accountName !== null && accountName !== undefined) { + if (accountName.length > 64) + { + throw new Error('"accountName" should satisfy the constraint - "MaxLength": 64'); + } + if (accountName.length < 2) + { + throw new Error('"accountName" should satisfy the constraint - "MinLength": 2'); + } + if (accountName.match(/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/) === null) + { + throw new Error('"accountName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/'); + } + } + 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 (tags && typeof tags === 'object') { + for(let valueElement in tags) { + if (tags[valueElement] !== null && tags[valueElement] !== undefined && typeof tags[valueElement].valueOf() !== 'string') { + throw new Error('tags[valueElement] must be of type string.'); + } + } + } + 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); + } + let parameters; + if ((sku !== null && sku !== undefined) || (tags !== null && tags !== undefined)) { + parameters = new client.models['CognitiveServicesAccountUpdateParameters'](); + parameters.sku = sku; + parameters.tags = tags; + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{accountName}', encodeURIComponent(accountName)); + 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 = 'PATCH'; + 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 (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['CognitiveServicesAccountUpdateParameters']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, 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['ErrorModel']().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['CognitiveServicesAccount']().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); + }); +} + +/** + * Deletes a Cognitive Services account from the resource group. + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @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(resourceGroupName, accountName, 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 (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') { + throw new Error('accountName cannot be null or undefined and it must be of type string.'); + } + if (accountName !== null && accountName !== undefined) { + if (accountName.length > 64) + { + throw new Error('"accountName" should satisfy the constraint - "MaxLength": 64'); + } + if (accountName.length < 2) + { + throw new Error('"accountName" should satisfy the constraint - "MinLength": 2'); + } + if (accountName.match(/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/) === null) + { + throw new Error('"accountName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/'); + } + } + 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 (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}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{accountName}', encodeURIComponent(accountName)); + 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 = 'DELETE'; + 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]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200 && 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['ErrorModel']().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); + }); +} + +/** + * Returns a Cognitive Services account specified by the parameters. + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @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 CognitiveServicesAccount} 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 _getProperties(resourceGroupName, accountName, 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 (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') { + throw new Error('accountName cannot be null or undefined and it must be of type string.'); + } + if (accountName !== null && accountName !== undefined) { + if (accountName.length > 64) + { + throw new Error('"accountName" should satisfy the constraint - "MaxLength": 64'); + } + if (accountName.length < 2) + { + throw new Error('"accountName" should satisfy the constraint - "MinLength": 2'); + } + if (accountName.match(/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/) === null) + { + throw new Error('"accountName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/'); + } + } + 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 (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}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{accountName}', encodeURIComponent(accountName)); + 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 = 'GET'; + 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]; + } + } + } + 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['ErrorModel']().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['CognitiveServicesAccount']().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); + }); +} + +/** + * Returns all the resources of a particular type belonging to a resource group + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @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 CognitiveServicesAccountListResult} 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 _listByResourceGroup(resourceGroupName, 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 (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName 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 (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.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}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + 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 = 'GET'; + 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]; + } + } + } + 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['ErrorModel']().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['CognitiveServicesAccountListResult']().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); + }); +} + +/** + * Returns all the resources of a particular type belonging to a subscription. + * + * @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 CognitiveServicesAccountListResult} 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 _list(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 (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.CognitiveServices/accounts'; + 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 = 'GET'; + 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]; + } + } + } + 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['ErrorModel']().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['CognitiveServicesAccountListResult']().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); + }); +} + +/** + * Lists the account keys for the specified Cognitive Services account. + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @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 CognitiveServicesAccountKeys} 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 _listKeys(resourceGroupName, accountName, 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 (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') { + throw new Error('accountName cannot be null or undefined and it must be of type string.'); + } + if (accountName !== null && accountName !== undefined) { + if (accountName.length > 64) + { + throw new Error('"accountName" should satisfy the constraint - "MaxLength": 64'); + } + if (accountName.length < 2) + { + throw new Error('"accountName" should satisfy the constraint - "MinLength": 2'); + } + if (accountName.match(/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/) === null) + { + throw new Error('"accountName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/'); + } + } + 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 (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}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/listKeys'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{accountName}', encodeURIComponent(accountName)); + 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]; + } + } + } + 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['ErrorModel']().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['CognitiveServicesAccountKeys']().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); + }); +} + +/** + * Regenerates the specified account key for the specified Cognitive Services + * account. + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @param {string} keyName key name to generate (Key1|Key2). Possible values + * include: 'Key1', 'Key2' + * + * @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 CognitiveServicesAccountKeys} 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 _regenerateKey(resourceGroupName, accountName, keyName, 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 (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') { + throw new Error('accountName cannot be null or undefined and it must be of type string.'); + } + if (accountName !== null && accountName !== undefined) { + if (accountName.length > 64) + { + throw new Error('"accountName" should satisfy the constraint - "MaxLength": 64'); + } + if (accountName.length < 2) + { + throw new Error('"accountName" should satisfy the constraint - "MinLength": 2'); + } + if (accountName.match(/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/) === null) + { + throw new Error('"accountName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/'); + } + } + 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 (keyName) { + let allowedValues = [ 'Key1', 'Key2' ]; + if (!allowedValues.some( function(item) { return item === keyName; })) { + throw new Error(keyName + ' is not a valid value. The valid values are: ' + allowedValues); + } + } else { + throw new Error('keyName 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); + } + let parameters; + if (keyName !== null && keyName !== undefined) { + parameters = new client.models['RegenerateKeyParameters'](); + parameters.keyName = keyName; + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/regenerateKey'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{accountName}', encodeURIComponent(accountName)); + 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 (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['RegenerateKeyParameters']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, 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['ErrorModel']().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['CognitiveServicesAccountKeys']().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); + }); +} + +/** + * List available SKUs for the requested Cognitive Services account + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @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 CognitiveServicesAccountEnumerateSkusResult} + * 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 _listSkus(resourceGroupName, accountName, 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 (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') { + throw new Error('accountName cannot be null or undefined and it must be of type string.'); + } + if (accountName !== null && accountName !== undefined) { + if (accountName.length > 64) + { + throw new Error('"accountName" should satisfy the constraint - "MaxLength": 64'); + } + if (accountName.length < 2) + { + throw new Error('"accountName" should satisfy the constraint - "MinLength": 2'); + } + if (accountName.match(/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/) === null) + { + throw new Error('"accountName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/'); + } + } + 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 (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}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/skus'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{accountName}', encodeURIComponent(accountName)); + 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 = 'GET'; + 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]; + } + } + } + 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['ErrorModel']().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['CognitiveServicesAccountEnumerateSkusResult']().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 usages for the requested Cognitive Services account + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] An OData filter expression that describes a + * subset of usages to return. The supported parameter is name.value (name of + * the metric, can have an or of multiple names). + * + * @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 UsagesResult} 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 _getUsages(resourceGroupName, accountName, 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.'); + } + let filter = (options && options.filter !== undefined) ? options.filter : undefined; + // Validate + try { + if (resourceGroupName === null || resourceGroupName === undefined || typeof resourceGroupName.valueOf() !== 'string') { + throw new Error('resourceGroupName cannot be null or undefined and it must be of type string.'); + } + if (accountName === null || accountName === undefined || typeof accountName.valueOf() !== 'string') { + throw new Error('accountName cannot be null or undefined and it must be of type string.'); + } + if (accountName !== null && accountName !== undefined) { + if (accountName.length > 64) + { + throw new Error('"accountName" should satisfy the constraint - "MaxLength": 64'); + } + if (accountName.length < 2) + { + throw new Error('"accountName" should satisfy the constraint - "MinLength": 2'); + } + if (accountName.match(/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/) === null) + { + throw new Error('"accountName" should satisfy the constraint - "Pattern": /^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/'); + } + } + 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 (filter !== null && filter !== undefined && typeof filter.valueOf() !== 'string') { + throw new Error('filter must be of type string.'); + } + 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.CognitiveServices/accounts/{accountName}/usages'; + requestUrl = requestUrl.replace('{resourceGroupName}', encodeURIComponent(resourceGroupName)); + requestUrl = requestUrl.replace('{accountName}', encodeURIComponent(accountName)); + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + let queryParameters = []; + queryParameters.push('api-version=' + encodeURIComponent(this.client.apiVersion)); + if (filter !== null && filter !== undefined) { + queryParameters.push('$filter=' + encodeURIComponent(filter)); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // 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 (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]; + } + } + } + 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['ErrorModel']().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['UsagesResult']().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); + }); +} + +/** + * Returns all the resources of a particular type belonging to a resource group + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @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 CognitiveServicesAccountListResult} 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 _listByResourceGroupNext(nextPageLink, 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 (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + 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 requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // 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 (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]; + } + } + } + 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['ErrorModel']().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['CognitiveServicesAccountListResult']().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); + }); +} + +/** + * Returns all the resources of a particular type belonging to a subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @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 CognitiveServicesAccountListResult} 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 _listNext(nextPageLink, 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 (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + 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 requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // 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 (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]; + } + } + } + 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['ErrorModel']().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['CognitiveServicesAccountListResult']().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); + }); +} + +/** Class representing a Accounts. */ +class Accounts { + /** + * Create a Accounts. + * @param {CognitiveServicesManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._create = _create; + this._update = _update; + this._deleteMethod = _deleteMethod; + this._getProperties = _getProperties; + this._listByResourceGroup = _listByResourceGroup; + this._list = _list; + this._listKeys = _listKeys; + this._regenerateKey = _regenerateKey; + this._listSkus = _listSkus; + this._getUsages = _getUsages; + this._listByResourceGroupNext = _listByResourceGroupNext; + this._listNext = _listNext; + } + + /** + * Create Cognitive Services Account. Accounts is a resource group wide + * resource type. It holds the keys for developer to access intelligent APIs. + * It's also the resource type for billing. + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @param {object} parameters The parameters to provide for the created + * account. + * + * @param {object} parameters.sku Required. Gets or sets the SKU of the + * resource. + * + * @param {string} parameters.sku.name Gets or sets the sku name. Required for + * account creation, optional for update. Possible values include: 'F0', 'P0', + * 'P1', 'P2', 'S0', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6' + * + * @param {string} parameters.kind Required. Gets or sets the Kind of the + * resource. Possible values include: 'Bing.Autosuggest.v7', + * 'Bing.CustomSearch', 'Bing.Search.v7', 'Bing.Speech', 'Bing.SpellCheck.v7', + * 'ComputerVision', 'ContentModerator', 'CustomSpeech', + * 'CustomVision.Prediction', 'CustomVision.Training', 'Emotion', 'Face', + * 'LUIS', 'QnAMaker', 'SpeakerRecognition', 'SpeechTranslation', + * 'TextAnalytics', 'TextTranslation', 'WebLM' + * + * @param {string} parameters.location Required. Gets or sets the location of + * the resource. This will be one of the supported and registered Azure Geo + * Regions (e.g. West US, East US, Southeast Asia, etc.). The geo region of a + * resource cannot be changed once it is created, but if an identical geo + * region is specified on update the request will succeed. + * + * @param {object} [parameters.tags] Gets or sets a list of key value pairs + * that describe the resource. These tags can be used in viewing and grouping + * this resource (across resource groups). A maximum of 15 tags can be provided + * for a resource. Each tag must have a key no greater than 128 characters and + * value no greater than 256 characters. + * + * @param {object} parameters.properties Must exist in the request. Must be an + * empty object. Must not be null. + * + * @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. + */ + createWithHttpOperationResponse(resourceGroupName, accountName, parameters, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._create(resourceGroupName, accountName, parameters, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Create Cognitive Services Account. Accounts is a resource group wide + * resource type. It holds the keys for developer to access intelligent APIs. + * It's also the resource type for billing. + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @param {object} parameters The parameters to provide for the created + * account. + * + * @param {object} parameters.sku Required. Gets or sets the SKU of the + * resource. + * + * @param {string} parameters.sku.name Gets or sets the sku name. Required for + * account creation, optional for update. Possible values include: 'F0', 'P0', + * 'P1', 'P2', 'S0', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6' + * + * @param {string} parameters.kind Required. Gets or sets the Kind of the + * resource. Possible values include: 'Bing.Autosuggest.v7', + * 'Bing.CustomSearch', 'Bing.Search.v7', 'Bing.Speech', 'Bing.SpellCheck.v7', + * 'ComputerVision', 'ContentModerator', 'CustomSpeech', + * 'CustomVision.Prediction', 'CustomVision.Training', 'Emotion', 'Face', + * 'LUIS', 'QnAMaker', 'SpeakerRecognition', 'SpeechTranslation', + * 'TextAnalytics', 'TextTranslation', 'WebLM' + * + * @param {string} parameters.location Required. Gets or sets the location of + * the resource. This will be one of the supported and registered Azure Geo + * Regions (e.g. West US, East US, Southeast Asia, etc.). The geo region of a + * resource cannot be changed once it is created, but if an identical geo + * region is specified on update the request will succeed. + * + * @param {object} [parameters.tags] Gets or sets a list of key value pairs + * that describe the resource. These tags can be used in viewing and grouping + * this resource (across resource groups). A maximum of 15 tags can be provided + * for a resource. Each tag must have a key no greater than 128 characters and + * value no greater than 256 characters. + * + * @param {object} parameters.properties Must exist in the request. Must be an + * empty object. Must not be null. + * + * @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 {CognitiveServicesAccount} - 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 CognitiveServicesAccount} 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(resourceGroupName, accountName, parameters, 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(resourceGroupName, accountName, parameters, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._create(resourceGroupName, accountName, parameters, options, optionalCallback); + } + } + + /** + * Updates a Cognitive Services account + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.sku] Gets or sets the SKU of the resource. + * + * @param {string} options.sku.name Gets or sets the sku name. Required for + * account creation, optional for update. Possible values include: 'F0', 'P0', + * 'P1', 'P2', 'S0', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6' + * + * @param {object} [options.tags] Gets or sets a list of key value pairs that + * describe the resource. These tags can be used in viewing and grouping this + * resource (across resource groups). A maximum of 15 tags can be provided for + * a resource. Each tag must have a key no greater than 128 characters and + * value no greater than 256 characters. + * + * @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. + */ + updateWithHttpOperationResponse(resourceGroupName, accountName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._update(resourceGroupName, accountName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Updates a Cognitive Services account + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.sku] Gets or sets the SKU of the resource. + * + * @param {string} options.sku.name Gets or sets the sku name. Required for + * account creation, optional for update. Possible values include: 'F0', 'P0', + * 'P1', 'P2', 'S0', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6' + * + * @param {object} [options.tags] Gets or sets a list of key value pairs that + * describe the resource. These tags can be used in viewing and grouping this + * resource (across resource groups). A maximum of 15 tags can be provided for + * a resource. Each tag must have a key no greater than 128 characters and + * value no greater than 256 characters. + * + * @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 {CognitiveServicesAccount} - 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 CognitiveServicesAccount} 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. + */ + update(resourceGroupName, accountName, 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._update(resourceGroupName, accountName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._update(resourceGroupName, accountName, options, optionalCallback); + } + } + + /** + * Deletes a Cognitive Services account from the resource group. + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @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. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName, accountName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._deleteMethod(resourceGroupName, accountName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Deletes a Cognitive Services account from the resource group. + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @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(resourceGroupName, accountName, 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(resourceGroupName, accountName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._deleteMethod(resourceGroupName, accountName, options, optionalCallback); + } + } + + /** + * Returns a Cognitive Services account specified by the parameters. + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @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. + */ + getPropertiesWithHttpOperationResponse(resourceGroupName, accountName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._getProperties(resourceGroupName, accountName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Returns a Cognitive Services account specified by the parameters. + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @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 {CognitiveServicesAccount} - 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 CognitiveServicesAccount} 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. + */ + getProperties(resourceGroupName, accountName, 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._getProperties(resourceGroupName, accountName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._getProperties(resourceGroupName, accountName, options, optionalCallback); + } + } + + /** + * Returns all the resources of a particular type belonging to a resource group + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @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. + */ + listByResourceGroupWithHttpOperationResponse(resourceGroupName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Returns all the resources of a particular type belonging to a resource group + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @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 {CognitiveServicesAccountListResult} - 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 CognitiveServicesAccountListResult} 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. + */ + listByResourceGroup(resourceGroupName, 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._listByResourceGroup(resourceGroupName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByResourceGroup(resourceGroupName, options, optionalCallback); + } + } + + /** + * Returns all the resources of a particular type belonging to a subscription. + * + * @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. + */ + listWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Returns all the resources of a particular type belonging to a subscription. + * + * @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 {CognitiveServicesAccountListResult} - 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 CognitiveServicesAccountListResult} 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. + */ + list(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(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(options, optionalCallback); + } + } + + /** + * Lists the account keys for the specified Cognitive Services account. + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @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. + */ + listKeysWithHttpOperationResponse(resourceGroupName, accountName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listKeys(resourceGroupName, accountName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists the account keys for the specified Cognitive Services account. + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @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 {CognitiveServicesAccountKeys} - 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 CognitiveServicesAccountKeys} 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. + */ + listKeys(resourceGroupName, accountName, 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._listKeys(resourceGroupName, accountName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listKeys(resourceGroupName, accountName, options, optionalCallback); + } + } + + /** + * Regenerates the specified account key for the specified Cognitive Services + * account. + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @param {string} keyName key name to generate (Key1|Key2). Possible values + * include: 'Key1', 'Key2' + * + * @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. + */ + regenerateKeyWithHttpOperationResponse(resourceGroupName, accountName, keyName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._regenerateKey(resourceGroupName, accountName, keyName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Regenerates the specified account key for the specified Cognitive Services + * account. + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @param {string} keyName key name to generate (Key1|Key2). Possible values + * include: 'Key1', 'Key2' + * + * @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 {CognitiveServicesAccountKeys} - 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 CognitiveServicesAccountKeys} 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. + */ + regenerateKey(resourceGroupName, accountName, keyName, 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._regenerateKey(resourceGroupName, accountName, keyName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._regenerateKey(resourceGroupName, accountName, keyName, options, optionalCallback); + } + } + + /** + * List available SKUs for the requested Cognitive Services account + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @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. + */ + listSkusWithHttpOperationResponse(resourceGroupName, accountName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listSkus(resourceGroupName, accountName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * List available SKUs for the requested Cognitive Services account + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @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 {CognitiveServicesAccountEnumerateSkusResult} - 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 CognitiveServicesAccountEnumerateSkusResult} + * 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. + */ + listSkus(resourceGroupName, accountName, 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._listSkus(resourceGroupName, accountName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listSkus(resourceGroupName, accountName, options, optionalCallback); + } + } + + /** + * Get usages for the requested Cognitive Services account + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] An OData filter expression that describes a + * subset of usages to return. The supported parameter is name.value (name of + * the metric, can have an or of multiple names). + * + * @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. + */ + getUsagesWithHttpOperationResponse(resourceGroupName, accountName, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._getUsages(resourceGroupName, accountName, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Get usages for the requested Cognitive Services account + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] An OData filter expression that describes a + * subset of usages to return. The supported parameter is name.value (name of + * the metric, can have an or of multiple names). + * + * @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 {UsagesResult} - 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 UsagesResult} 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. + */ + getUsages(resourceGroupName, accountName, 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._getUsages(resourceGroupName, accountName, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._getUsages(resourceGroupName, accountName, options, optionalCallback); + } + } + + /** + * Returns all the resources of a particular type belonging to a resource group + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @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. + */ + listByResourceGroupNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listByResourceGroupNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Returns all the resources of a particular type belonging to a resource group + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @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 {CognitiveServicesAccountListResult} - 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 CognitiveServicesAccountListResult} 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. + */ + listByResourceGroupNext(nextPageLink, 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._listByResourceGroupNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listByResourceGroupNext(nextPageLink, options, optionalCallback); + } + } + + /** + * Returns all the resources of a particular type belonging to a subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @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. + */ + listNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Returns all the resources of a particular type belonging to a subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @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 {CognitiveServicesAccountListResult} - 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 CognitiveServicesAccountListResult} 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. + */ + listNext(nextPageLink, 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._listNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = Accounts; diff --git a/lib/services/cognitiveServicesManagement/lib/lib/operations/checkSkuAvailability.js b/lib/services/cognitiveServicesManagement/lib/lib/operations/checkSkuAvailability.js new file mode 100644 index 0000000000..c4104ec0e5 --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/operations/checkSkuAvailability.js @@ -0,0 +1,321 @@ +/* + * 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 msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Check available SKUs. + * + * @param {string} location Resource location. + * + * @param {array} skus The SKU of the resource. + * + * @param {string} kind The Kind of the resource. Possible values include: + * 'Bing.Autosuggest.v7', 'Bing.CustomSearch', 'Bing.Search.v7', 'Bing.Speech', + * 'Bing.SpellCheck.v7', 'ComputerVision', 'ContentModerator', 'CustomSpeech', + * 'CustomVision.Prediction', 'CustomVision.Training', 'Emotion', 'Face', + * 'LUIS', 'QnAMaker', 'SpeakerRecognition', 'SpeechTranslation', + * 'TextAnalytics', 'TextTranslation', 'WebLM' + * + * @param {string} type The Type of the resource. + * + * @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 CheckSkuAvailabilityResultList} 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 _list(location, skus, kind, type, 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.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 (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 (location === null || location === undefined || typeof location.valueOf() !== 'string') { + throw new Error('location cannot be null or undefined and it must be of type string.'); + } + if (!Array.isArray(skus)) { + throw new Error('skus cannot be null or undefined and it must be of type array.'); + } + for (let i = 0; i < skus.length; i++) { + if (skus[i] !== null && skus[i] !== undefined && typeof skus[i].valueOf() !== 'string') { + throw new Error('skus[i] must be of type string.'); + } + } + if (kind === null || kind === undefined || typeof kind.valueOf() !== 'string') { + throw new Error('kind cannot be null or undefined and it must be of type string.'); + } + if (type === null || type === undefined || typeof type.valueOf() !== 'string') { + throw new Error('type cannot be null or undefined and it must be of type string.'); + } + 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); + } + let parameters; + if ((skus !== null && skus !== undefined) || (kind !== null && kind !== undefined) || (type !== null && type !== undefined)) { + parameters = new client.models['CheckSkuAvailabilityParameter'](); + parameters.skus = skus; + parameters.kind = kind; + parameters.type = type; + } + + // Construct URL + let baseUrl = this.client.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/checkSkuAvailability'; + requestUrl = requestUrl.replace('{subscriptionId}', encodeURIComponent(this.client.subscriptionId)); + requestUrl = requestUrl.replace('{location}', encodeURIComponent(location)); + 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 (parameters !== null && parameters !== undefined) { + let requestModelMapper = new client.models['CheckSkuAvailabilityParameter']().mapper(); + requestModel = client.serialize(requestModelMapper, parameters, 'parameters'); + requestContent = JSON.stringify(requestModel); + } + } catch (error) { + let serializationError = new Error(`Error "${error.message}" occurred in serializing the ` + + `payload - ${JSON.stringify(parameters, 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) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().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['CheckSkuAvailabilityResultList']().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); + }); +} + +/** Class representing a CheckSkuAvailability. */ +class CheckSkuAvailability { + /** + * Create a CheckSkuAvailability. + * @param {CognitiveServicesManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + } + + /** + * Check available SKUs. + * + * @param {string} location Resource location. + * + * @param {array} skus The SKU of the resource. + * + * @param {string} kind The Kind of the resource. Possible values include: + * 'Bing.Autosuggest.v7', 'Bing.CustomSearch', 'Bing.Search.v7', 'Bing.Speech', + * 'Bing.SpellCheck.v7', 'ComputerVision', 'ContentModerator', 'CustomSpeech', + * 'CustomVision.Prediction', 'CustomVision.Training', 'Emotion', 'Face', + * 'LUIS', 'QnAMaker', 'SpeakerRecognition', 'SpeechTranslation', + * 'TextAnalytics', 'TextTranslation', 'WebLM' + * + * @param {string} type The Type of the resource. + * + * @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. + */ + listWithHttpOperationResponse(location, skus, kind, type, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(location, skus, kind, type, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Check available SKUs. + * + * @param {string} location Resource location. + * + * @param {array} skus The SKU of the resource. + * + * @param {string} kind The Kind of the resource. Possible values include: + * 'Bing.Autosuggest.v7', 'Bing.CustomSearch', 'Bing.Search.v7', 'Bing.Speech', + * 'Bing.SpellCheck.v7', 'ComputerVision', 'ContentModerator', 'CustomSpeech', + * 'CustomVision.Prediction', 'CustomVision.Training', 'Emotion', 'Face', + * 'LUIS', 'QnAMaker', 'SpeakerRecognition', 'SpeechTranslation', + * 'TextAnalytics', 'TextTranslation', 'WebLM' + * + * @param {string} type The Type of the resource. + * + * @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 {CheckSkuAvailabilityResultList} - 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 CheckSkuAvailabilityResultList} 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. + */ + list(location, skus, kind, type, 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(location, skus, kind, type, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(location, skus, kind, type, options, optionalCallback); + } + } + +} + +module.exports = CheckSkuAvailability; diff --git a/lib/services/cognitiveServicesManagement/lib/lib/operations/index.d.ts b/lib/services/cognitiveServicesManagement/lib/lib/operations/index.d.ts new file mode 100644 index 0000000000..087b1658f8 --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/operations/index.d.ts @@ -0,0 +1,1057 @@ +/* + * 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. +*/ + +import { ServiceClientOptions, RequestOptions, ServiceCallback, HttpOperationResponse } from 'ms-rest'; +import * as models from '../models'; + + +/** + * @class + * Accounts + * __NOTE__: An instance of this class is automatically created for an + * instance of the CognitiveServicesManagementClient. + */ +export interface Accounts { + + + /** + * Create Cognitive Services Account. Accounts is a resource group wide + * resource type. It holds the keys for developer to access intelligent APIs. + * It's also the resource type for billing. + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @param {object} parameters The parameters to provide for the created + * account. + * + * @param {object} parameters.sku Required. Gets or sets the SKU of the + * resource. + * + * @param {string} parameters.sku.name Gets or sets the sku name. Required for + * account creation, optional for update. Possible values include: 'F0', 'P0', + * 'P1', 'P2', 'S0', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6' + * + * @param {string} parameters.kind Required. Gets or sets the Kind of the + * resource. Possible values include: 'Bing.Autosuggest.v7', + * 'Bing.CustomSearch', 'Bing.Search.v7', 'Bing.Speech', 'Bing.SpellCheck.v7', + * 'ComputerVision', 'ContentModerator', 'CustomSpeech', + * 'CustomVision.Prediction', 'CustomVision.Training', 'Emotion', 'Face', + * 'LUIS', 'QnAMaker', 'SpeakerRecognition', 'SpeechTranslation', + * 'TextAnalytics', 'TextTranslation', 'WebLM' + * + * @param {string} parameters.location Required. Gets or sets the location of + * the resource. This will be one of the supported and registered Azure Geo + * Regions (e.g. West US, East US, Southeast Asia, etc.). The geo region of a + * resource cannot be changed once it is created, but if an identical geo + * region is specified on update the request will succeed. + * + * @param {object} [parameters.tags] Gets or sets a list of key value pairs + * that describe the resource. These tags can be used in viewing and grouping + * this resource (across resource groups). A maximum of 15 tags can be provided + * for a resource. Each tag must have a key no greater than 128 characters and + * value no greater than 256 characters. + * + * @param {object} parameters.properties Must exist in the request. Must be an + * empty object. Must not be null. + * + * @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. + */ + createWithHttpOperationResponse(resourceGroupName: string, accountName: string, parameters: models.CognitiveServicesAccountCreateParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Create Cognitive Services Account. Accounts is a resource group wide + * resource type. It holds the keys for developer to access intelligent APIs. + * It's also the resource type for billing. + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @param {object} parameters The parameters to provide for the created + * account. + * + * @param {object} parameters.sku Required. Gets or sets the SKU of the + * resource. + * + * @param {string} parameters.sku.name Gets or sets the sku name. Required for + * account creation, optional for update. Possible values include: 'F0', 'P0', + * 'P1', 'P2', 'S0', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6' + * + * @param {string} parameters.kind Required. Gets or sets the Kind of the + * resource. Possible values include: 'Bing.Autosuggest.v7', + * 'Bing.CustomSearch', 'Bing.Search.v7', 'Bing.Speech', 'Bing.SpellCheck.v7', + * 'ComputerVision', 'ContentModerator', 'CustomSpeech', + * 'CustomVision.Prediction', 'CustomVision.Training', 'Emotion', 'Face', + * 'LUIS', 'QnAMaker', 'SpeakerRecognition', 'SpeechTranslation', + * 'TextAnalytics', 'TextTranslation', 'WebLM' + * + * @param {string} parameters.location Required. Gets or sets the location of + * the resource. This will be one of the supported and registered Azure Geo + * Regions (e.g. West US, East US, Southeast Asia, etc.). The geo region of a + * resource cannot be changed once it is created, but if an identical geo + * region is specified on update the request will succeed. + * + * @param {object} [parameters.tags] Gets or sets a list of key value pairs + * that describe the resource. These tags can be used in viewing and grouping + * this resource (across resource groups). A maximum of 15 tags can be provided + * for a resource. Each tag must have a key no greater than 128 characters and + * value no greater than 256 characters. + * + * @param {object} parameters.properties Must exist in the request. Must be an + * empty object. Must not be null. + * + * @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 {CognitiveServicesAccount} - 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. + * + * {CognitiveServicesAccount} [result] - The deserialized result object if an error did not occur. + * See {@link CognitiveServicesAccount} 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. + */ + create(resourceGroupName: string, accountName: string, parameters: models.CognitiveServicesAccountCreateParameters, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + create(resourceGroupName: string, accountName: string, parameters: models.CognitiveServicesAccountCreateParameters, callback: ServiceCallback): void; + create(resourceGroupName: string, accountName: string, parameters: models.CognitiveServicesAccountCreateParameters, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Updates a Cognitive Services account + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.sku] Gets or sets the SKU of the resource. + * + * @param {string} options.sku.name Gets or sets the sku name. Required for + * account creation, optional for update. Possible values include: 'F0', 'P0', + * 'P1', 'P2', 'S0', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6' + * + * @param {object} [options.tags] Gets or sets a list of key value pairs that + * describe the resource. These tags can be used in viewing and grouping this + * resource (across resource groups). A maximum of 15 tags can be provided for + * a resource. Each tag must have a key no greater than 128 characters and + * value no greater than 256 characters. + * + * @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. + */ + updateWithHttpOperationResponse(resourceGroupName: string, accountName: string, options?: { sku? : models.Sku, tags? : { [propertyName: string]: string }, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Updates a Cognitive Services account + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @param {object} [options] Optional Parameters. + * + * @param {object} [options.sku] Gets or sets the SKU of the resource. + * + * @param {string} options.sku.name Gets or sets the sku name. Required for + * account creation, optional for update. Possible values include: 'F0', 'P0', + * 'P1', 'P2', 'S0', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6' + * + * @param {object} [options.tags] Gets or sets a list of key value pairs that + * describe the resource. These tags can be used in viewing and grouping this + * resource (across resource groups). A maximum of 15 tags can be provided for + * a resource. Each tag must have a key no greater than 128 characters and + * value no greater than 256 characters. + * + * @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 {CognitiveServicesAccount} - 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. + * + * {CognitiveServicesAccount} [result] - The deserialized result object if an error did not occur. + * See {@link CognitiveServicesAccount} 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. + */ + update(resourceGroupName: string, accountName: string, options?: { sku? : models.Sku, tags? : { [propertyName: string]: string }, customHeaders? : { [headerName: string]: string; } }): Promise; + update(resourceGroupName: string, accountName: string, callback: ServiceCallback): void; + update(resourceGroupName: string, accountName: string, options: { sku? : models.Sku, tags? : { [propertyName: string]: string }, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Deletes a Cognitive Services account from the resource group. + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @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. + */ + deleteMethodWithHttpOperationResponse(resourceGroupName: string, accountName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Deletes a Cognitive Services account from the resource group. + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @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 {null} - 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. + * + * {null} [result] - The deserialized result object if an error did not occur. + * + * {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. + */ + deleteMethod(resourceGroupName: string, accountName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + deleteMethod(resourceGroupName: string, accountName: string, callback: ServiceCallback): void; + deleteMethod(resourceGroupName: string, accountName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Returns a Cognitive Services account specified by the parameters. + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @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. + */ + getPropertiesWithHttpOperationResponse(resourceGroupName: string, accountName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Returns a Cognitive Services account specified by the parameters. + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @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 {CognitiveServicesAccount} - 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. + * + * {CognitiveServicesAccount} [result] - The deserialized result object if an error did not occur. + * See {@link CognitiveServicesAccount} 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. + */ + getProperties(resourceGroupName: string, accountName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + getProperties(resourceGroupName: string, accountName: string, callback: ServiceCallback): void; + getProperties(resourceGroupName: string, accountName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Returns all the resources of a particular type belonging to a resource group + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @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. + */ + listByResourceGroupWithHttpOperationResponse(resourceGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Returns all the resources of a particular type belonging to a resource group + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @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 {CognitiveServicesAccountListResult} - 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. + * + * {CognitiveServicesAccountListResult} [result] - The deserialized result object if an error did not occur. + * See {@link CognitiveServicesAccountListResult} 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. + */ + listByResourceGroup(resourceGroupName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByResourceGroup(resourceGroupName: string, callback: ServiceCallback): void; + listByResourceGroup(resourceGroupName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Returns all the resources of a particular type belonging to a subscription. + * + * @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. + */ + listWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Returns all the resources of a particular type belonging to a subscription. + * + * @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 {CognitiveServicesAccountListResult} - 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. + * + * {CognitiveServicesAccountListResult} [result] - The deserialized result object if an error did not occur. + * See {@link CognitiveServicesAccountListResult} 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. + */ + list(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists the account keys for the specified Cognitive Services account. + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @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. + */ + listKeysWithHttpOperationResponse(resourceGroupName: string, accountName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists the account keys for the specified Cognitive Services account. + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @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 {CognitiveServicesAccountKeys} - 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. + * + * {CognitiveServicesAccountKeys} [result] - The deserialized result object if an error did not occur. + * See {@link CognitiveServicesAccountKeys} 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. + */ + listKeys(resourceGroupName: string, accountName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listKeys(resourceGroupName: string, accountName: string, callback: ServiceCallback): void; + listKeys(resourceGroupName: string, accountName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Regenerates the specified account key for the specified Cognitive Services + * account. + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @param {string} keyName key name to generate (Key1|Key2). Possible values + * include: 'Key1', 'Key2' + * + * @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. + */ + regenerateKeyWithHttpOperationResponse(resourceGroupName: string, accountName: string, keyName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Regenerates the specified account key for the specified Cognitive Services + * account. + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @param {string} keyName key name to generate (Key1|Key2). Possible values + * include: 'Key1', 'Key2' + * + * @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 {CognitiveServicesAccountKeys} - 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. + * + * {CognitiveServicesAccountKeys} [result] - The deserialized result object if an error did not occur. + * See {@link CognitiveServicesAccountKeys} 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. + */ + regenerateKey(resourceGroupName: string, accountName: string, keyName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + regenerateKey(resourceGroupName: string, accountName: string, keyName: string, callback: ServiceCallback): void; + regenerateKey(resourceGroupName: string, accountName: string, keyName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * List available SKUs for the requested Cognitive Services account + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @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. + */ + listSkusWithHttpOperationResponse(resourceGroupName: string, accountName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * List available SKUs for the requested Cognitive Services account + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @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 {CognitiveServicesAccountEnumerateSkusResult} - 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. + * + * {CognitiveServicesAccountEnumerateSkusResult} [result] - The deserialized result object if an error did not occur. + * See {@link CognitiveServicesAccountEnumerateSkusResult} + * 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. + */ + listSkus(resourceGroupName: string, accountName: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listSkus(resourceGroupName: string, accountName: string, callback: ServiceCallback): void; + listSkus(resourceGroupName: string, accountName: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Get usages for the requested Cognitive Services account + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] An OData filter expression that describes a + * subset of usages to return. The supported parameter is name.value (name of + * the metric, can have an or of multiple names). + * + * @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. + */ + getUsagesWithHttpOperationResponse(resourceGroupName: string, accountName: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Get usages for the requested Cognitive Services account + * + * @param {string} resourceGroupName The name of the resource group within the + * user's subscription. + * + * @param {string} accountName The name of Cognitive Services account. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.filter] An OData filter expression that describes a + * subset of usages to return. The supported parameter is name.value (name of + * the metric, can have an or of multiple names). + * + * @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 {UsagesResult} - 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. + * + * {UsagesResult} [result] - The deserialized result object if an error did not occur. + * See {@link UsagesResult} 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. + */ + getUsages(resourceGroupName: string, accountName: string, options?: { filter? : string, customHeaders? : { [headerName: string]: string; } }): Promise; + getUsages(resourceGroupName: string, accountName: string, callback: ServiceCallback): void; + getUsages(resourceGroupName: string, accountName: string, options: { filter? : string, customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Returns all the resources of a particular type belonging to a resource group + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @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. + */ + listByResourceGroupNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Returns all the resources of a particular type belonging to a resource group + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @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 {CognitiveServicesAccountListResult} - 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. + * + * {CognitiveServicesAccountListResult} [result] - The deserialized result object if an error did not occur. + * See {@link CognitiveServicesAccountListResult} 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. + */ + listByResourceGroupNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listByResourceGroupNext(nextPageLink: string, callback: ServiceCallback): void; + listByResourceGroupNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Returns all the resources of a particular type belonging to a subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @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. + */ + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Returns all the resources of a particular type belonging to a subscription. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @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 {CognitiveServicesAccountListResult} - 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. + * + * {CognitiveServicesAccountListResult} [result] - The deserialized result object if an error did not occur. + * See {@link CognitiveServicesAccountListResult} 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. + */ + listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listNext(nextPageLink: string, callback: ServiceCallback): void; + listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * Operations + * __NOTE__: An instance of this class is automatically created for an + * instance of the CognitiveServicesManagementClient. + */ +export interface Operations { + + + /** + * Lists all the available Cognitive Services account operations. + * + * @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. + */ + listWithHttpOperationResponse(options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all the available Cognitive Services account operations. + * + * @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 {OperationEntityListResult} - 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. + * + * {OperationEntityListResult} [result] - The deserialized result object if an error did not occur. + * See {@link OperationEntityListResult} 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. + */ + list(options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(callback: ServiceCallback): void; + list(options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; + + + /** + * Lists all the available Cognitive Services account operations. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @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. + */ + listNextWithHttpOperationResponse(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Lists all the available Cognitive Services account operations. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @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 {OperationEntityListResult} - 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. + * + * {OperationEntityListResult} [result] - The deserialized result object if an error did not occur. + * See {@link OperationEntityListResult} 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. + */ + listNext(nextPageLink: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + listNext(nextPageLink: string, callback: ServiceCallback): void; + listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +/** + * @class + * CheckSkuAvailability + * __NOTE__: An instance of this class is automatically created for an + * instance of the CognitiveServicesManagementClient. + */ +export interface CheckSkuAvailability { + + + /** + * Check available SKUs. + * + * @param {string} location Resource location. + * + * @param {array} skus The SKU of the resource. + * + * @param {string} kind The Kind of the resource. Possible values include: + * 'Bing.Autosuggest.v7', 'Bing.CustomSearch', 'Bing.Search.v7', 'Bing.Speech', + * 'Bing.SpellCheck.v7', 'ComputerVision', 'ContentModerator', 'CustomSpeech', + * 'CustomVision.Prediction', 'CustomVision.Training', 'Emotion', 'Face', + * 'LUIS', 'QnAMaker', 'SpeakerRecognition', 'SpeechTranslation', + * 'TextAnalytics', 'TextTranslation', 'WebLM' + * + * @param {string} type The Type of the resource. + * + * @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. + */ + listWithHttpOperationResponse(location: string, skus: string[], kind: string, type: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * Check available SKUs. + * + * @param {string} location Resource location. + * + * @param {array} skus The SKU of the resource. + * + * @param {string} kind The Kind of the resource. Possible values include: + * 'Bing.Autosuggest.v7', 'Bing.CustomSearch', 'Bing.Search.v7', 'Bing.Speech', + * 'Bing.SpellCheck.v7', 'ComputerVision', 'ContentModerator', 'CustomSpeech', + * 'CustomVision.Prediction', 'CustomVision.Training', 'Emotion', 'Face', + * 'LUIS', 'QnAMaker', 'SpeakerRecognition', 'SpeechTranslation', + * 'TextAnalytics', 'TextTranslation', 'WebLM' + * + * @param {string} type The Type of the resource. + * + * @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 {CheckSkuAvailabilityResultList} - 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. + * + * {CheckSkuAvailabilityResultList} [result] - The deserialized result object if an error did not occur. + * See {@link CheckSkuAvailabilityResultList} 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. + */ + list(location: string, skus: string[], kind: string, type: string, options?: { customHeaders? : { [headerName: string]: string; } }): Promise; + list(location: string, skus: string[], kind: string, type: string, callback: ServiceCallback): void; + list(location: string, skus: string[], kind: string, type: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} diff --git a/lib/services/cognitiveServicesManagement/lib/lib/operations/index.js b/lib/services/cognitiveServicesManagement/lib/lib/operations/index.js new file mode 100644 index 0000000000..53dc4c90dc --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/operations/index.js @@ -0,0 +1,19 @@ +/* + * 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. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +exports.Accounts = require('./accounts'); +exports.Operations = require('./operations'); +exports.CheckSkuAvailability = require('./checkSkuAvailability'); diff --git a/lib/services/cognitiveServicesManagement/lib/lib/operations/operations.js b/lib/services/cognitiveServicesManagement/lib/lib/operations/operations.js new file mode 100644 index 0000000000..6ad14507a3 --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/lib/operations/operations.js @@ -0,0 +1,453 @@ +/* + * 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 msRestAzure = require('ms-rest-azure'); +const WebResource = msRest.WebResource; + +/** + * Lists all the available Cognitive Services account operations. + * + * @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 OperationEntityListResult} 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 _list(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.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('/') ? '' : '/') + 'providers/Microsoft.CognitiveServices/operations'; + 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 = 'GET'; + 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]; + } + } + } + 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) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().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['OperationEntityListResult']().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); + }); +} + +/** + * Lists all the available Cognitive Services account operations. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @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 OperationEntityListResult} 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 _listNext(nextPageLink, 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 (nextPageLink === null || nextPageLink === undefined || typeof nextPageLink.valueOf() !== 'string') { + throw new Error('nextPageLink cannot be null or undefined and it must be of type string.'); + } + 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 requestUrl = '{nextLink}'; + requestUrl = requestUrl.replace('{nextLink}', nextPageLink); + + // 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 (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]; + } + } + } + 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) { + if (parsedErrorResponse.error) parsedErrorResponse = parsedErrorResponse.error; + if (parsedErrorResponse.code) error.code = parsedErrorResponse.code; + if (parsedErrorResponse.message) error.message = parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['CloudError']().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['OperationEntityListResult']().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); + }); +} + +/** Class representing a Operations. */ +class Operations { + /** + * Create a Operations. + * @param {CognitiveServicesManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listNext = _listNext; + } + + /** + * Lists all the available Cognitive Services account operations. + * + * @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. + */ + listWithHttpOperationResponse(options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._list(options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all the available Cognitive Services account operations. + * + * @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 {OperationEntityListResult} - 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 OperationEntityListResult} 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. + */ + list(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(options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._list(options, optionalCallback); + } + } + + /** + * Lists all the available Cognitive Services account operations. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @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. + */ + listNextWithHttpOperationResponse(nextPageLink, options) { + let client = this.client; + let self = this; + return new Promise((resolve, reject) => { + self._listNext(nextPageLink, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * Lists all the available Cognitive Services account operations. + * + * @param {string} nextPageLink The NextLink from the previous successful call + * to List operation. + * + * @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 {OperationEntityListResult} - 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 OperationEntityListResult} 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. + */ + listNext(nextPageLink, 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._listNext(nextPageLink, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._listNext(nextPageLink, options, optionalCallback); + } + } + +} + +module.exports = Operations; diff --git a/lib/services/cognitiveServicesManagement/lib/package.json b/lib/services/cognitiveServicesManagement/lib/package.json new file mode 100644 index 0000000000..ba3a9e3f28 --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/package.json @@ -0,0 +1,22 @@ +{ + "name": "azure-arm-cognitiveservices", + "author": "Microsoft Corporation", + "description": "CognitiveServicesManagementClient Library with typescript type definitions for node", + "version": "", + "dependencies": { + "ms-rest": "^2.3.3", + "ms-rest-azure": "^2.5.5" + }, + "keywords": [ "node", "azure" ], + "license": "MIT", + "main": "./lib/cognitiveServicesManagementClient.js", + "types": "./lib/cognitiveServicesManagementClient.d.ts", + "homepage": "http://github.com/azure/azure-sdk-for-node", + "repository": { + "type": "git", + "url": "https://github.com/azure/azure-sdk-for-node.git" + }, + "bugs": { + "url": "http://github.com/Azure/azure-sdk-for-node/issues" + } +}