diff --git a/lib/services/cognitiveServicesManagement/lib/cognitiveServicesManagementClient.d.ts b/lib/services/cognitiveServicesManagement/lib/cognitiveServicesManagementClient.d.ts index ec8727544b..632f07c59c 100644 --- a/lib/services/cognitiveServicesManagement/lib/cognitiveServicesManagementClient.d.ts +++ b/lib/services/cognitiveServicesManagement/lib/cognitiveServicesManagementClient.d.ts @@ -10,9 +10,10 @@ import { ServiceClientCredentials } from 'ms-rest'; import { AzureServiceClient, AzureServiceClientOptions } from 'ms-rest-azure'; +import * as models from "./models"; import * as operations from "./operations"; -declare class CognitiveServicesManagementClient extends AzureServiceClient { +export default class CognitiveServicesManagementClient extends AzureServiceClient { /** * Initializes a new instance of the CognitiveServicesManagementClient class. * @constructor @@ -56,8 +57,9 @@ declare class CognitiveServicesManagementClient extends AzureServiceClient { // Operation groups accounts: operations.Accounts; + resourceSkus: operations.ResourceSkus; operations: operations.Operations; checkSkuAvailability: operations.CheckSkuAvailability; } -export = CognitiveServicesManagementClient; +export { CognitiveServicesManagementClient, models as CognitiveServicesManagementModels }; diff --git a/lib/services/cognitiveServicesManagement/lib/cognitiveServicesManagementClient.js b/lib/services/cognitiveServicesManagement/lib/cognitiveServicesManagementClient.js index 6390b22d76..94da73ce59 100644 --- a/lib/services/cognitiveServicesManagement/lib/cognitiveServicesManagementClient.js +++ b/lib/services/cognitiveServicesManagement/lib/cognitiveServicesManagementClient.js @@ -73,6 +73,7 @@ class CognitiveServicesManagementClient extends ServiceClient { this.generateClientRequestId = options.generateClientRequestId; } this.accounts = new operations.Accounts(this); + this.resourceSkus = new operations.ResourceSkus(this); this.operations = new operations.Operations(this); this.checkSkuAvailability = new operations.CheckSkuAvailability(this); this.models = models; @@ -82,3 +83,6 @@ class CognitiveServicesManagementClient extends ServiceClient { } module.exports = CognitiveServicesManagementClient; +module.exports['default'] = CognitiveServicesManagementClient; +module.exports.CognitiveServicesManagementClient = CognitiveServicesManagementClient; +module.exports.CognitiveServicesManagementModels = models; diff --git a/lib/services/cognitiveServicesManagement/lib/models/checkSkuAvailabilityParameter.js b/lib/services/cognitiveServicesManagement/lib/models/checkSkuAvailabilityParameter.js index c1ee9c0b7b..3282fe06e4 100644 --- a/lib/services/cognitiveServicesManagement/lib/models/checkSkuAvailabilityParameter.js +++ b/lib/services/cognitiveServicesManagement/lib/models/checkSkuAvailabilityParameter.js @@ -19,10 +19,11 @@ class CheckSkuAvailabilityParameter { * Create a CheckSkuAvailabilityParameter. * @member {array} skus The SKU of the resource. * @member {string} kind The Kind of the resource. Possible values include: - * 'Academic', 'Bing.Autosuggest', 'Bing.Search', 'Bing.Speech', - * 'Bing.SpellCheck', 'ComputerVision', 'ContentModerator', 'CustomSpeech', - * 'Emotion', 'Face', 'LUIS', 'Recommendations', 'SpeakerRecognition', - * 'Speech', 'SpeechTranslation', 'TextAnalytics', 'TextTranslation', 'WebLM' + * '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() { diff --git a/lib/services/cognitiveServicesManagement/lib/models/checkSkuAvailabilityResult.js b/lib/services/cognitiveServicesManagement/lib/models/checkSkuAvailabilityResult.js index cf3398d8f7..eac2cef4ab 100644 --- a/lib/services/cognitiveServicesManagement/lib/models/checkSkuAvailabilityResult.js +++ b/lib/services/cognitiveServicesManagement/lib/models/checkSkuAvailabilityResult.js @@ -18,10 +18,11 @@ class CheckSkuAvailabilityResult { /** * Create a CheckSkuAvailabilityResult. * @member {string} [kind] The Kind of the resource. Possible values include: - * 'Academic', 'Bing.Autosuggest', 'Bing.Search', 'Bing.Speech', - * 'Bing.SpellCheck', 'ComputerVision', 'ContentModerator', 'CustomSpeech', - * 'Emotion', 'Face', 'LUIS', 'Recommendations', 'SpeakerRecognition', - * 'Speech', 'SpeechTranslation', 'TextAnalytics', 'TextTranslation', 'WebLM' + * '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', diff --git a/lib/services/cognitiveServicesManagement/lib/models/cognitiveServicesAccount.js b/lib/services/cognitiveServicesManagement/lib/models/cognitiveServicesAccount.js index eae190daa3..74c075d771 100644 --- a/lib/services/cognitiveServicesManagement/lib/models/cognitiveServicesAccount.js +++ b/lib/services/cognitiveServicesManagement/lib/models/cognitiveServicesAccount.js @@ -28,7 +28,8 @@ class CognitiveServicesAccount extends models['BaseResource'] { * @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', 'Succeeded', 'Failed' + * 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. @@ -104,8 +105,7 @@ class CognitiveServicesAccount extends models['BaseResource'] { readOnly: true, serializedName: 'properties.provisioningState', type: { - name: 'Enum', - allowedValues: [ 'Creating', 'ResolvingDNS', 'Succeeded', 'Failed' ] + name: 'String' } }, endpoint: { diff --git a/lib/services/cognitiveServicesManagement/lib/models/cognitiveServicesAccountCreateParameters.js b/lib/services/cognitiveServicesManagement/lib/models/cognitiveServicesAccountCreateParameters.js index 0d445dd59e..346d0fae38 100644 --- a/lib/services/cognitiveServicesManagement/lib/models/cognitiveServicesAccountCreateParameters.js +++ b/lib/services/cognitiveServicesManagement/lib/models/cognitiveServicesAccountCreateParameters.js @@ -26,10 +26,11 @@ class CognitiveServicesAccountCreateParameters { * @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: 'Academic', 'Bing.Autosuggest', 'Bing.Search', - * 'Bing.Speech', 'Bing.SpellCheck', 'ComputerVision', 'ContentModerator', - * 'CustomSpeech', 'Emotion', 'Face', 'LUIS', 'Recommendations', - * 'SpeakerRecognition', 'Speech', 'SpeechTranslation', 'TextAnalytics', + * 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 diff --git a/lib/services/cognitiveServicesManagement/lib/models/index.d.ts b/lib/services/cognitiveServicesManagement/lib/models/index.d.ts index 68f7008696..44a0e22d24 100644 --- a/lib/services/cognitiveServicesManagement/lib/models/index.d.ts +++ b/lib/services/cognitiveServicesManagement/lib/models/index.d.ts @@ -46,10 +46,11 @@ export interface Sku { * @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: 'Academic', 'Bing.Autosuggest', 'Bing.Search', - * 'Bing.Speech', 'Bing.SpellCheck', 'ComputerVision', 'ContentModerator', - * 'CustomSpeech', 'Emotion', 'Face', 'LUIS', 'Recommendations', - * 'SpeakerRecognition', 'Speech', 'SpeechTranslation', 'TextAnalytics', + * 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 @@ -109,7 +110,8 @@ export interface CognitiveServicesAccountUpdateParameters { * @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', 'Succeeded', 'Failed' + * 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. @@ -198,6 +200,62 @@ 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. @@ -278,10 +336,11 @@ export interface OperationEntity { * * @member {array} skus The SKU of the resource. * @member {string} kind The Kind of the resource. Possible values include: - * 'Academic', 'Bing.Autosuggest', 'Bing.Search', 'Bing.Speech', - * 'Bing.SpellCheck', 'ComputerVision', 'ContentModerator', 'CustomSpeech', - * 'Emotion', 'Face', 'LUIS', 'Recommendations', 'SpeakerRecognition', - * 'Speech', 'SpeechTranslation', 'TextAnalytics', 'TextTranslation', 'WebLM' + * '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 { @@ -297,10 +356,11 @@ export interface CheckSkuAvailabilityParameter { * Check SKU availability result. * * @member {string} [kind] The Kind of the resource. Possible values include: - * 'Academic', 'Bing.Autosuggest', 'Bing.Search', 'Bing.Speech', - * 'Bing.SpellCheck', 'ComputerVision', 'ContentModerator', 'CustomSpeech', - * 'Emotion', 'Face', 'LUIS', 'Recommendations', 'SpeakerRecognition', - * 'Speech', 'SpeechTranslation', 'TextAnalytics', 'TextTranslation', 'WebLM' + * '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', @@ -331,6 +391,70 @@ export interface CheckSkuAvailabilityResultList { value?: CheckSkuAvailabilityResult[]; } +/** + * @class + * Initializes a new instance of the ResourceSkuRestrictionInfo class. + * @constructor + * @member {array} [locations] Locations where the SKU is restricted + * @member {array} [zones] List of availability zones where the SKU is + * restricted. + */ +export interface ResourceSkuRestrictionInfo { + readonly locations?: string[]; + readonly zones?: string[]; +} + +/** + * @class + * Initializes a new instance of the ResourceSkuRestrictions class. + * @constructor + * Describes restrictions of a SKU. + * + * @member {string} [type] The type of restrictions. Possible values include: + * 'Location', 'Zone' + * @member {array} [values] The value of restrictions. If the restriction type + * is set to location. This would be different locations where the SKU is + * restricted. + * @member {object} [restrictionInfo] The information about the restriction + * where the SKU cannot be used. + * @member {array} [restrictionInfo.locations] Locations where the SKU is + * restricted + * @member {array} [restrictionInfo.zones] List of availability zones where the + * SKU is restricted. + * @member {string} [reasonCode] The reason for restriction. Possible values + * include: 'QuotaId', 'NotAvailableForSubscription' + */ +export interface ResourceSkuRestrictions { + readonly type?: string; + readonly values?: string[]; + readonly restrictionInfo?: ResourceSkuRestrictionInfo; + readonly reasonCode?: string; +} + +/** + * @class + * Initializes a new instance of the ResourceSku class. + * @constructor + * Describes an available Cognitive Services SKU. + * + * @member {string} [resourceType] The type of resource the SKU applies to. + * @member {string} [name] The name of SKU. + * @member {string} [tier] Specifies the tier of Cognitive Services account. + * @member {string} [kind] The Kind of resources that are supported in this + * SKU. + * @member {array} [locations] The set of locations that the SKU is available. + * @member {array} [restrictions] The restrictions because of which SKU cannot + * be used. This is empty if there are no restrictions. + */ +export interface ResourceSku { + readonly resourceType?: string; + readonly name?: string; + readonly tier?: string; + readonly kind?: string; + readonly locations?: string[]; + readonly restrictions?: ResourceSkuRestrictions[]; +} + /** * @class @@ -344,6 +468,18 @@ export interface CognitiveServicesAccountListResult extends Array { + nextLink?: string; +} + /** * @class * Initializes a new instance of the OperationEntityListResult class. diff --git a/lib/services/cognitiveServicesManagement/lib/models/index.js b/lib/services/cognitiveServicesManagement/lib/models/index.js index 94ab6a5273..0ec9e6e9f3 100644 --- a/lib/services/cognitiveServicesManagement/lib/models/index.js +++ b/lib/services/cognitiveServicesManagement/lib/models/index.js @@ -26,6 +26,9 @@ 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'); @@ -33,5 +36,9 @@ exports.OperationEntity = require('./operationEntity'); exports.CheckSkuAvailabilityParameter = require('./checkSkuAvailabilityParameter'); exports.CheckSkuAvailabilityResult = require('./checkSkuAvailabilityResult'); exports.CheckSkuAvailabilityResultList = require('./checkSkuAvailabilityResultList'); +exports.ResourceSkuRestrictionInfo = require('./resourceSkuRestrictionInfo'); +exports.ResourceSkuRestrictions = require('./resourceSkuRestrictions'); +exports.ResourceSku = require('./resourceSku'); exports.CognitiveServicesAccountListResult = require('./cognitiveServicesAccountListResult'); +exports.ResourceSkusResult = require('./resourceSkusResult'); exports.OperationEntityListResult = require('./operationEntityListResult'); diff --git a/lib/services/cognitiveServicesManagement/lib/models/metricName.js b/lib/services/cognitiveServicesManagement/lib/models/metricName.js new file mode 100644 index 0000000000..03b48f02a4 --- /dev/null +++ b/lib/services/cognitiveServicesManagement/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/models/resourceSku.js b/lib/services/cognitiveServicesManagement/lib/models/resourceSku.js new file mode 100644 index 0000000000..d2bb44d5aa --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/models/resourceSku.js @@ -0,0 +1,118 @@ +/* + * 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'); + +/** + * Describes an available Cognitive Services SKU. + * + */ +class ResourceSku { + /** + * Create a ResourceSku. + * @member {string} [resourceType] The type of resource the SKU applies to. + * @member {string} [name] The name of SKU. + * @member {string} [tier] Specifies the tier of Cognitive Services account. + * @member {string} [kind] The Kind of resources that are supported in this + * SKU. + * @member {array} [locations] The set of locations that the SKU is + * available. + * @member {array} [restrictions] The restrictions because of which SKU + * cannot be used. This is empty if there are no restrictions. + */ + constructor() { + } + + /** + * Defines the metadata of ResourceSku + * + * @returns {object} metadata of ResourceSku + * + */ + mapper() { + return { + required: false, + serializedName: 'ResourceSku', + type: { + name: 'Composite', + className: 'ResourceSku', + modelProperties: { + resourceType: { + required: false, + readOnly: true, + serializedName: 'resourceType', + type: { + name: 'String' + } + }, + name: { + required: false, + readOnly: true, + serializedName: 'name', + type: { + name: 'String' + } + }, + tier: { + required: false, + readOnly: true, + serializedName: 'tier', + type: { + name: 'String' + } + }, + kind: { + required: false, + readOnly: true, + serializedName: 'kind', + type: { + name: 'String' + } + }, + locations: { + required: false, + readOnly: true, + serializedName: 'locations', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + restrictions: { + required: false, + readOnly: true, + serializedName: 'restrictions', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ResourceSkuRestrictionsElementType', + type: { + name: 'Composite', + className: 'ResourceSkuRestrictions' + } + } + } + } + } + } + }; + } +} + +module.exports = ResourceSku; diff --git a/lib/services/cognitiveServicesManagement/lib/models/resourceSkuRestrictionInfo.js b/lib/services/cognitiveServicesManagement/lib/models/resourceSkuRestrictionInfo.js new file mode 100644 index 0000000000..9772ff3185 --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/models/resourceSkuRestrictionInfo.js @@ -0,0 +1,76 @@ +/* + * 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'; + +/** + * Class representing a ResourceSkuRestrictionInfo. + */ +class ResourceSkuRestrictionInfo { + /** + * Create a ResourceSkuRestrictionInfo. + * @member {array} [locations] Locations where the SKU is restricted + * @member {array} [zones] List of availability zones where the SKU is + * restricted. + */ + constructor() { + } + + /** + * Defines the metadata of ResourceSkuRestrictionInfo + * + * @returns {object} metadata of ResourceSkuRestrictionInfo + * + */ + mapper() { + return { + required: false, + serializedName: 'ResourceSkuRestrictionInfo', + type: { + name: 'Composite', + className: 'ResourceSkuRestrictionInfo', + modelProperties: { + locations: { + required: false, + readOnly: true, + serializedName: 'locations', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + zones: { + required: false, + readOnly: true, + serializedName: 'zones', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + } + } + } + }; + } +} + +module.exports = ResourceSkuRestrictionInfo; diff --git a/lib/services/cognitiveServicesManagement/lib/models/resourceSkuRestrictions.js b/lib/services/cognitiveServicesManagement/lib/models/resourceSkuRestrictions.js new file mode 100644 index 0000000000..53d11db95d --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/models/resourceSkuRestrictions.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'; + +const models = require('./index'); + +/** + * Describes restrictions of a SKU. + * + */ +class ResourceSkuRestrictions { + /** + * Create a ResourceSkuRestrictions. + * @member {string} [type] The type of restrictions. Possible values include: + * 'Location', 'Zone' + * @member {array} [values] The value of restrictions. If the restriction + * type is set to location. This would be different locations where the SKU + * is restricted. + * @member {object} [restrictionInfo] The information about the restriction + * where the SKU cannot be used. + * @member {array} [restrictionInfo.locations] Locations where the SKU is + * restricted + * @member {array} [restrictionInfo.zones] List of availability zones where + * the SKU is restricted. + * @member {string} [reasonCode] The reason for restriction. Possible values + * include: 'QuotaId', 'NotAvailableForSubscription' + */ + constructor() { + } + + /** + * Defines the metadata of ResourceSkuRestrictions + * + * @returns {object} metadata of ResourceSkuRestrictions + * + */ + mapper() { + return { + required: false, + serializedName: 'ResourceSkuRestrictions', + type: { + name: 'Composite', + className: 'ResourceSkuRestrictions', + modelProperties: { + type: { + required: false, + readOnly: true, + serializedName: 'type', + type: { + name: 'Enum', + allowedValues: [ 'Location', 'Zone' ] + } + }, + values: { + required: false, + readOnly: true, + serializedName: 'values', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + restrictionInfo: { + required: false, + readOnly: true, + serializedName: 'restrictionInfo', + type: { + name: 'Composite', + className: 'ResourceSkuRestrictionInfo' + } + }, + reasonCode: { + required: false, + readOnly: true, + serializedName: 'reasonCode', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ResourceSkuRestrictions; diff --git a/lib/services/cognitiveServicesManagement/lib/models/resourceSkusResult.js b/lib/services/cognitiveServicesManagement/lib/models/resourceSkusResult.js new file mode 100644 index 0000000000..15219c5a14 --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/models/resourceSkusResult.js @@ -0,0 +1,67 @@ +/* + * 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 Get Skus operation response. + */ +class ResourceSkusResult extends Array { + /** + * Create a ResourceSkusResult. + * @member {string} [nextLink] The uri to fetch the next page of Skus. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ResourceSkusResult + * + * @returns {object} metadata of ResourceSkusResult + * + */ + mapper() { + return { + required: false, + serializedName: 'ResourceSkusResult', + type: { + name: 'Composite', + className: 'ResourceSkusResult', + modelProperties: { + value: { + required: true, + serializedName: '', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ResourceSkuElementType', + type: { + name: 'Composite', + className: 'ResourceSku' + } + } + } + }, + nextLink: { + required: false, + serializedName: 'nextLink', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ResourceSkusResult; diff --git a/lib/services/cognitiveServicesManagement/lib/models/usage.js b/lib/services/cognitiveServicesManagement/lib/models/usage.js new file mode 100644 index 0000000000..3d58370239 --- /dev/null +++ b/lib/services/cognitiveServicesManagement/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/models/usagesResult.js b/lib/services/cognitiveServicesManagement/lib/models/usagesResult.js new file mode 100644 index 0000000000..6fb6f8a22a --- /dev/null +++ b/lib/services/cognitiveServicesManagement/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/operations/accounts.js b/lib/services/cognitiveServicesManagement/lib/operations/accounts.js index b975f317aa..bb97a65ff5 100644 --- a/lib/services/cognitiveServicesManagement/lib/operations/accounts.js +++ b/lib/services/cognitiveServicesManagement/lib/operations/accounts.js @@ -35,10 +35,11 @@ const WebResource = msRest.WebResource; * '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: 'Academic', 'Bing.Autosuggest', - * 'Bing.Search', 'Bing.Speech', 'Bing.SpellCheck', 'ComputerVision', - * 'ContentModerator', 'CustomSpeech', 'Emotion', 'Face', 'LUIS', - * 'Recommendations', 'SpeakerRecognition', 'Speech', 'SpeechTranslation', + * 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 @@ -1546,6 +1547,178 @@ function _listSkus(resourceGroupName, accountName, options, callback) { }); } +/** + * 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 * @@ -1821,6 +1994,7 @@ class Accounts { this._listKeys = _listKeys; this._regenerateKey = _regenerateKey; this._listSkus = _listSkus; + this._getUsages = _getUsages; this._listByResourceGroupNext = _listByResourceGroupNext; this._listNext = _listNext; } @@ -1846,10 +2020,11 @@ class Accounts { * '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: 'Academic', 'Bing.Autosuggest', - * 'Bing.Search', 'Bing.Speech', 'Bing.SpellCheck', 'ComputerVision', - * 'ContentModerator', 'CustomSpeech', 'Emotion', 'Face', 'LUIS', - * 'Recommendations', 'SpeakerRecognition', 'Speech', 'SpeechTranslation', + * 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 @@ -1913,10 +2088,11 @@ class Accounts { * '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: 'Academic', 'Bing.Autosuggest', - * 'Bing.Search', 'Bing.Speech', 'Bing.SpellCheck', 'ComputerVision', - * 'ContentModerator', 'CustomSpeech', 'Emotion', 'Face', 'LUIS', - * 'Recommendations', 'SpeakerRecognition', 'Speech', 'SpeechTranslation', + * 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 @@ -2710,6 +2886,102 @@ class Accounts { } } + /** + * 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 * diff --git a/lib/services/cognitiveServicesManagement/lib/operations/checkSkuAvailability.js b/lib/services/cognitiveServicesManagement/lib/operations/checkSkuAvailability.js index bb40a84c32..c4104ec0e5 100644 --- a/lib/services/cognitiveServicesManagement/lib/operations/checkSkuAvailability.js +++ b/lib/services/cognitiveServicesManagement/lib/operations/checkSkuAvailability.js @@ -22,10 +22,11 @@ const WebResource = msRest.WebResource; * @param {array} skus The SKU of the resource. * * @param {string} kind The Kind of the resource. Possible values include: - * 'Academic', 'Bing.Autosuggest', 'Bing.Search', 'Bing.Speech', - * 'Bing.SpellCheck', 'ComputerVision', 'ContentModerator', 'CustomSpeech', - * 'Emotion', 'Face', 'LUIS', 'Recommendations', 'SpeakerRecognition', - * 'Speech', 'SpeechTranslation', 'TextAnalytics', 'TextTranslation', 'WebLM' + * '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. * @@ -218,10 +219,11 @@ class CheckSkuAvailability { * @param {array} skus The SKU of the resource. * * @param {string} kind The Kind of the resource. Possible values include: - * 'Academic', 'Bing.Autosuggest', 'Bing.Search', 'Bing.Speech', - * 'Bing.SpellCheck', 'ComputerVision', 'ContentModerator', 'CustomSpeech', - * 'Emotion', 'Face', 'LUIS', 'Recommendations', 'SpeakerRecognition', - * 'Speech', 'SpeechTranslation', 'TextAnalytics', 'TextTranslation', 'WebLM' + * '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. * @@ -258,10 +260,11 @@ class CheckSkuAvailability { * @param {array} skus The SKU of the resource. * * @param {string} kind The Kind of the resource. Possible values include: - * 'Academic', 'Bing.Autosuggest', 'Bing.Search', 'Bing.Speech', - * 'Bing.SpellCheck', 'ComputerVision', 'ContentModerator', 'CustomSpeech', - * 'Emotion', 'Face', 'LUIS', 'Recommendations', 'SpeakerRecognition', - * 'Speech', 'SpeechTranslation', 'TextAnalytics', 'TextTranslation', 'WebLM' + * '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. * diff --git a/lib/services/cognitiveServicesManagement/lib/operations/index.d.ts b/lib/services/cognitiveServicesManagement/lib/operations/index.d.ts index 6c027f8113..efb24cca8c 100644 --- a/lib/services/cognitiveServicesManagement/lib/operations/index.d.ts +++ b/lib/services/cognitiveServicesManagement/lib/operations/index.d.ts @@ -42,10 +42,11 @@ export interface Accounts { * '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: 'Academic', 'Bing.Autosuggest', - * 'Bing.Search', 'Bing.Speech', 'Bing.SpellCheck', 'ComputerVision', - * 'ContentModerator', 'CustomSpeech', 'Emotion', 'Face', 'LUIS', - * 'Recommendations', 'SpeakerRecognition', 'Speech', 'SpeechTranslation', + * 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 @@ -97,10 +98,11 @@ export interface Accounts { * '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: 'Academic', 'Bing.Autosuggest', - * 'Bing.Search', 'Bing.Speech', 'Bing.SpellCheck', 'ComputerVision', - * 'ContentModerator', 'CustomSpeech', 'Emotion', 'Face', 'LUIS', - * 'Recommendations', 'SpeakerRecognition', 'Speech', 'SpeechTranslation', + * 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 @@ -663,6 +665,75 @@ export interface Accounts { 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 * @@ -779,6 +850,127 @@ export interface Accounts { listNext(nextPageLink: string, options: { customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; } +/** + * @class + * ResourceSkus + * __NOTE__: An instance of this class is automatically created for an + * instance of the CognitiveServicesManagementClient. + */ +export interface ResourceSkus { + + + /** + * Gets the list of Microsoft.CognitiveServices SKUs available for your + * 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>; + + /** + * Gets the list of Microsoft.CognitiveServices SKUs available for your + * 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 {ResourceSkusResult} - 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. + * + * {ResourceSkusResult} [result] - The deserialized result object if an error did not occur. + * See {@link ResourceSkusResult} 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; + + + /** + * Gets the list of Microsoft.CognitiveServices SKUs available for your + * 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>; + + /** + * Gets the list of Microsoft.CognitiveServices SKUs available for your + * 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 {ResourceSkusResult} - 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. + * + * {ResourceSkusResult} [result] - The deserialized result object if an error did not occur. + * See {@link ResourceSkusResult} 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 @@ -915,10 +1107,11 @@ export interface CheckSkuAvailability { * @param {array} skus The SKU of the resource. * * @param {string} kind The Kind of the resource. Possible values include: - * 'Academic', 'Bing.Autosuggest', 'Bing.Search', 'Bing.Speech', - * 'Bing.SpellCheck', 'ComputerVision', 'ContentModerator', 'CustomSpeech', - * 'Emotion', 'Face', 'LUIS', 'Recommendations', 'SpeakerRecognition', - * 'Speech', 'SpeechTranslation', 'TextAnalytics', 'TextTranslation', 'WebLM' + * '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. * @@ -943,10 +1136,11 @@ export interface CheckSkuAvailability { * @param {array} skus The SKU of the resource. * * @param {string} kind The Kind of the resource. Possible values include: - * 'Academic', 'Bing.Autosuggest', 'Bing.Search', 'Bing.Speech', - * 'Bing.SpellCheck', 'ComputerVision', 'ContentModerator', 'CustomSpeech', - * 'Emotion', 'Face', 'LUIS', 'Recommendations', 'SpeakerRecognition', - * 'Speech', 'SpeechTranslation', 'TextAnalytics', 'TextTranslation', 'WebLM' + * '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. * diff --git a/lib/services/cognitiveServicesManagement/lib/operations/index.js b/lib/services/cognitiveServicesManagement/lib/operations/index.js index 53dc4c90dc..23332ec46b 100644 --- a/lib/services/cognitiveServicesManagement/lib/operations/index.js +++ b/lib/services/cognitiveServicesManagement/lib/operations/index.js @@ -15,5 +15,6 @@ 'use strict'; exports.Accounts = require('./accounts'); +exports.ResourceSkus = require('./resourceSkus'); exports.Operations = require('./operations'); exports.CheckSkuAvailability = require('./checkSkuAvailability'); diff --git a/lib/services/cognitiveServicesManagement/lib/operations/resourceSkus.js b/lib/services/cognitiveServicesManagement/lib/operations/resourceSkus.js new file mode 100644 index 0000000000..d2de2fa77b --- /dev/null +++ b/lib/services/cognitiveServicesManagement/lib/operations/resourceSkus.js @@ -0,0 +1,459 @@ +/* + * 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; + +/** + * Gets the list of Microsoft.CognitiveServices SKUs available for your + * 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 ResourceSkusResult} 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/skus'; + 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) { + 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['ResourceSkusResult']().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); + }); +} + +/** + * Gets the list of Microsoft.CognitiveServices SKUs available for your + * 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 ResourceSkusResult} 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['ResourceSkusResult']().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 ResourceSkus. */ +class ResourceSkus { + /** + * Create a ResourceSkus. + * @param {CognitiveServicesManagementClient} client Reference to the service client. + */ + constructor(client) { + this.client = client; + this._list = _list; + this._listNext = _listNext; + } + + /** + * Gets the list of Microsoft.CognitiveServices SKUs available for your + * 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; + }); + }); + } + + /** + * Gets the list of Microsoft.CognitiveServices SKUs available for your + * 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 {ResourceSkusResult} - 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 ResourceSkusResult} 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); + } + } + + /** + * Gets the list of Microsoft.CognitiveServices SKUs available for your + * 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; + }); + }); + } + + /** + * Gets the list of Microsoft.CognitiveServices SKUs available for your + * 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 {ResourceSkusResult} - 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 ResourceSkusResult} 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 = ResourceSkus;