Skip to content

Commit a4ead6d

Browse files
author
SDKAuto
committed
CodeGen from PR 16431 in Azure/azure-rest-api-specs
Merge 55237cfe8ea393799b30c95c029cfee68aa09574 into 62ec79080af0d0d609650d67155ef4a93ae11482
1 parent 008ed54 commit a4ead6d

14 files changed

+739
-1037
lines changed

sdk/cognitiveservices/arm-cognitiveservices/README.md

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ This package contains an isomorphic SDK (runs both in node.js and in browsers) f
44

55
### Currently supported environments
66

7-
- Node.js version 8.x.x or higher
8-
- Browser JavaScript
7+
- [LTS versions of Node.js](https://nodejs.org/about/releases/)
8+
- Latest versions of Safari, Chrome, Edge and Firefox.
99

1010
### Prerequisites
1111

@@ -14,18 +14,15 @@ You must have an [Azure subscription](https://azure.microsoft.com/free/).
1414
### How to install
1515

1616
To use this SDK in your project, you will need to install two packages.
17-
1817
- `@azure/arm-cognitiveservices` that contains the client.
1918
- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory.
2019

2120
Install both packages using the below command:
22-
2321
```bash
2422
npm install --save @azure/arm-cognitiveservices @azure/identity
2523
```
26-
2724
> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features.
28-
> If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options.
25+
If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options.
2926

3027
### How to use
3128

@@ -39,7 +36,6 @@ npm install --save @azure/arm-cognitiveservices @azure/identity
3936

4037
In the below samples, we pass the credential and the Azure subscription id to instantiate the client.
4138
Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started.
42-
4339
#### nodejs - Authentication, client creation, and get accounts as an example written in JavaScript.
4440

4541
##### Sample code
@@ -55,24 +51,20 @@ const creds = new DefaultAzureCredential();
5551
const client = new CognitiveServicesManagementClient(creds, subscriptionId);
5652
const resourceGroupName = "testresourceGroupName";
5753
const accountName = "testaccountName";
58-
client.accounts
59-
.get(resourceGroupName, accountName)
60-
.then((result) => {
61-
console.log("The result is:");
62-
console.log(result);
63-
})
64-
.catch((err) => {
65-
console.log("An error occurred:");
66-
console.error(err);
67-
});
54+
client.accounts.get(resourceGroupName, accountName).then((result) => {
55+
console.log("The result is:");
56+
console.log(result);
57+
}).catch((err) => {
58+
console.log("An error occurred:");
59+
console.error(err);
60+
});
6861
```
6962

7063
#### browser - Authentication, client creation, and get accounts as an example written in JavaScript.
7164

7265
In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser.
73-
74-
- See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser.
75-
- Note down the client Id from the previous step and use it in the browser sample below.
66+
- See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser.
67+
- Note down the client Id from the previous step and use it in the browser sample below.
7668

7769
##### Sample code
7870

@@ -90,26 +82,21 @@ In browser applications, we recommend using the `InteractiveBrowserCredential` t
9082
const subscriptionId = "<Subscription_Id>";
9183
// Create credentials using the `@azure/identity` package.
9284
// Please note that you can also use credentials from the `@azure/ms-rest-browserauth` package instead.
93-
const credential = new InteractiveBrowserCredential({
85+
const credential = new InteractiveBrowserCredential(
86+
{
9487
clientId: "<client id for your Azure AD app>",
9588
tenant: "<optional tenant for your organization>"
9689
});
97-
const client = new Azure.ArmCognitiveservices.CognitiveServicesManagementClient(
98-
creds,
99-
subscriptionId
100-
);
90+
const client = new Azure.ArmCognitiveservices.CognitiveServicesManagementClient(creds, subscriptionId);
10191
const resourceGroupName = "testresourceGroupName";
10292
const accountName = "testaccountName";
103-
client.accounts
104-
.get(resourceGroupName, accountName)
105-
.then((result) => {
106-
console.log("The result is:");
107-
console.log(result);
108-
})
109-
.catch((err) => {
110-
console.log("An error occurred:");
111-
console.error(err);
112-
});
93+
client.accounts.get(resourceGroupName, accountName).then((result) => {
94+
console.log("The result is:");
95+
console.log(result);
96+
}).catch((err) => {
97+
console.log("An error occurred:");
98+
console.error(err);
99+
});
113100
</script>
114101
</head>
115102
<body></body>

sdk/cognitiveservices/arm-cognitiveservices/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"rollup-plugin-sourcemaps": "^0.4.2",
2828
"uglify-js": "^3.6.0"
2929
},
30-
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/feature/v4/sdk/cognitiveservices/arm-cognitiveservices",
30+
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/cognitiveservices/arm-cognitiveservices",
3131
"repository": {
3232
"type": "git",
3333
"url": "https://github.com/Azure/azure-sdk-for-js.git"

sdk/cognitiveservices/arm-cognitiveservices/rollup.config.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import sourcemaps from "rollup-plugin-sourcemaps";
77
*/
88
const config = {
99
input: "./esm/cognitiveServicesManagementClient.js",
10-
external: ["@azure/ms-rest-js", "@azure/ms-rest-azure-js"],
10+
external: [
11+
"@azure/ms-rest-js",
12+
"@azure/ms-rest-azure-js"
13+
],
1114
output: {
1215
file: "./dist/arm-cognitiveservices.js",
1316
format: "umd",
@@ -25,7 +28,10 @@ const config = {
2528
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
2629
*/`
2730
},
28-
plugins: [nodeResolve({ mainFields: ["module", "main"] }), sourcemaps()]
31+
plugins: [
32+
nodeResolve({ mainFields: ['module', 'main'] }),
33+
sourcemaps()
34+
]
2935
};
3036

3137
export default config;

sdk/cognitiveservices/arm-cognitiveservices/src/cognitiveServicesManagementClient.ts

Lines changed: 33 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import * as Parameters from "./models/parameters";
1515
import * as operations from "./operations";
1616
import { CognitiveServicesManagementClientContext } from "./cognitiveServicesManagementClientContext";
1717

18+
1819
class CognitiveServicesManagementClient extends CognitiveServicesManagementClientContext {
1920
// Operation groups
2021
accounts: operations.Accounts;
@@ -35,11 +36,7 @@ class CognitiveServicesManagementClient extends CognitiveServicesManagementClien
3536
* @param subscriptionId The ID of the target subscription.
3637
* @param [options] The parameter options
3738
*/
38-
constructor(
39-
credentials: msRest.ServiceClientCredentials | TokenCredential,
40-
subscriptionId: string,
41-
options?: Models.CognitiveServicesManagementClientOptions
42-
) {
39+
constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.CognitiveServicesManagementClientOptions) {
4340
super(credentials, subscriptionId, options);
4441
this.accounts = new operations.Accounts(this);
4542
this.deletedAccounts = new operations.DeletedAccounts(this);
@@ -58,27 +55,15 @@ class CognitiveServicesManagementClient extends CognitiveServicesManagementClien
5855
* @param [options] The optional parameters
5956
* @returns Promise<Models.CheckSkuAvailabilityResponse>
6057
*/
61-
checkSkuAvailability(
62-
location: string,
63-
skus: string[],
64-
kind: string,
65-
type: string,
66-
options?: msRest.RequestOptionsBase
67-
): Promise<Models.CheckSkuAvailabilityResponse>;
58+
checkSkuAvailability(location: string, skus: string[], kind: string, type: string, options?: msRest.RequestOptionsBase): Promise<Models.CheckSkuAvailabilityResponse>;
6859
/**
6960
* @param location Resource location.
7061
* @param skus The SKU of the resource.
7162
* @param kind The Kind of the resource.
7263
* @param type The Type of the resource.
7364
* @param callback The callback
7465
*/
75-
checkSkuAvailability(
76-
location: string,
77-
skus: string[],
78-
kind: string,
79-
type: string,
80-
callback: msRest.ServiceCallback<Models.SkuAvailabilityListResult>
81-
): void;
66+
checkSkuAvailability(location: string, skus: string[], kind: string, type: string, callback: msRest.ServiceCallback<Models.SkuAvailabilityListResult>): void;
8267
/**
8368
* @param location Resource location.
8469
* @param skus The SKU of the resource.
@@ -87,22 +72,8 @@ class CognitiveServicesManagementClient extends CognitiveServicesManagementClien
8772
* @param options The optional parameters
8873
* @param callback The callback
8974
*/
90-
checkSkuAvailability(
91-
location: string,
92-
skus: string[],
93-
kind: string,
94-
type: string,
95-
options: msRest.RequestOptionsBase,
96-
callback: msRest.ServiceCallback<Models.SkuAvailabilityListResult>
97-
): void;
98-
checkSkuAvailability(
99-
location: string,
100-
skus: string[],
101-
kind: string,
102-
type: string,
103-
options?: msRest.RequestOptionsBase | msRest.ServiceCallback<Models.SkuAvailabilityListResult>,
104-
callback?: msRest.ServiceCallback<Models.SkuAvailabilityListResult>
105-
): Promise<Models.CheckSkuAvailabilityResponse> {
75+
checkSkuAvailability(location: string, skus: string[], kind: string, type: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback<Models.SkuAvailabilityListResult>): void;
76+
checkSkuAvailability(location: string, skus: string[], kind: string, type: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback<Models.SkuAvailabilityListResult>, callback?: msRest.ServiceCallback<Models.SkuAvailabilityListResult>): Promise<Models.CheckSkuAvailabilityResponse> {
10677
return this.sendOperationRequest(
10778
{
10879
location,
@@ -112,8 +83,7 @@ class CognitiveServicesManagementClient extends CognitiveServicesManagementClien
11283
options
11384
},
11485
checkSkuAvailabilityOperationSpec,
115-
callback
116-
) as Promise<Models.CheckSkuAvailabilityResponse>;
86+
callback) as Promise<Models.CheckSkuAvailabilityResponse>;
11787
}
11888

11989
/**
@@ -123,60 +93,47 @@ class CognitiveServicesManagementClient extends CognitiveServicesManagementClien
12393
* @param [options] The optional parameters
12494
* @returns Promise<Models.CheckDomainAvailabilityResponse>
12595
*/
126-
checkDomainAvailability(
127-
subdomainName: string,
128-
type: string,
129-
options?: msRest.RequestOptionsBase
130-
): Promise<Models.CheckDomainAvailabilityResponse>;
96+
checkDomainAvailability(subdomainName: string, type: string, options?: msRest.RequestOptionsBase): Promise<Models.CheckDomainAvailabilityResponse>;
13197
/**
13298
* @param subdomainName The subdomain name to use.
13399
* @param type The Type of the resource.
134100
* @param callback The callback
135101
*/
136-
checkDomainAvailability(
137-
subdomainName: string,
138-
type: string,
139-
callback: msRest.ServiceCallback<Models.DomainAvailability>
140-
): void;
102+
checkDomainAvailability(subdomainName: string, type: string, callback: msRest.ServiceCallback<Models.DomainAvailability>): void;
141103
/**
142104
* @param subdomainName The subdomain name to use.
143105
* @param type The Type of the resource.
144106
* @param options The optional parameters
145107
* @param callback The callback
146108
*/
147-
checkDomainAvailability(
148-
subdomainName: string,
149-
type: string,
150-
options: msRest.RequestOptionsBase,
151-
callback: msRest.ServiceCallback<Models.DomainAvailability>
152-
): void;
153-
checkDomainAvailability(
154-
subdomainName: string,
155-
type: string,
156-
options?: msRest.RequestOptionsBase | msRest.ServiceCallback<Models.DomainAvailability>,
157-
callback?: msRest.ServiceCallback<Models.DomainAvailability>
158-
): Promise<Models.CheckDomainAvailabilityResponse> {
109+
checkDomainAvailability(subdomainName: string, type: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback<Models.DomainAvailability>): void;
110+
checkDomainAvailability(subdomainName: string, type: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback<Models.DomainAvailability>, callback?: msRest.ServiceCallback<Models.DomainAvailability>): Promise<Models.CheckDomainAvailabilityResponse> {
159111
return this.sendOperationRequest(
160112
{
161113
subdomainName,
162114
type,
163115
options
164116
},
165117
checkDomainAvailabilityOperationSpec,
166-
callback
167-
) as Promise<Models.CheckDomainAvailabilityResponse>;
118+
callback) as Promise<Models.CheckDomainAvailabilityResponse>;
168119
}
169120
}
170121

171122
// Operation Specifications
172123
const serializer = new msRest.Serializer(Mappers);
173124
const checkSkuAvailabilityOperationSpec: msRest.OperationSpec = {
174125
httpMethod: "POST",
175-
path:
176-
"subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/checkSkuAvailability",
177-
urlParameters: [Parameters.subscriptionId, Parameters.location],
178-
queryParameters: [Parameters.apiVersion],
179-
headerParameters: [Parameters.acceptLanguage],
126+
path: "subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/checkSkuAvailability",
127+
urlParameters: [
128+
Parameters.subscriptionId,
129+
Parameters.location
130+
],
131+
queryParameters: [
132+
Parameters.apiVersion
133+
],
134+
headerParameters: [
135+
Parameters.acceptLanguage
136+
],
180137
requestBody: {
181138
parameterPath: {
182139
skus: "skus",
@@ -201,11 +158,16 @@ const checkSkuAvailabilityOperationSpec: msRest.OperationSpec = {
201158

202159
const checkDomainAvailabilityOperationSpec: msRest.OperationSpec = {
203160
httpMethod: "POST",
204-
path:
205-
"subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/checkDomainAvailability",
206-
urlParameters: [Parameters.subscriptionId],
207-
queryParameters: [Parameters.apiVersion],
208-
headerParameters: [Parameters.acceptLanguage],
161+
path: "subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/checkDomainAvailability",
162+
urlParameters: [
163+
Parameters.subscriptionId
164+
],
165+
queryParameters: [
166+
Parameters.apiVersion
167+
],
168+
headerParameters: [
169+
Parameters.acceptLanguage
170+
],
209171
requestBody: {
210172
parameterPath: {
211173
subdomainName: "subdomainName",

sdk/cognitiveservices/arm-cognitiveservices/src/cognitiveServicesManagementClientContext.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,12 @@ export class CognitiveServicesManagementClientContext extends msRestAzure.AzureS
3131
* @param subscriptionId The ID of the target subscription.
3232
* @param [options] The parameter options
3333
*/
34-
constructor(
35-
credentials: msRest.ServiceClientCredentials | TokenCredential,
36-
subscriptionId: string,
37-
options?: Models.CognitiveServicesManagementClientOptions
38-
) {
34+
constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.CognitiveServicesManagementClientOptions) {
3935
if (credentials == undefined) {
40-
throw new Error("'credentials' cannot be null.");
36+
throw new Error('\'credentials\' cannot be null.');
4137
}
4238
if (subscriptionId == undefined) {
43-
throw new Error("'subscriptionId' cannot be null.");
39+
throw new Error('\'subscriptionId\' cannot be null.');
4440
}
4541

4642
if (!options) {
@@ -53,8 +49,8 @@ export class CognitiveServicesManagementClientContext extends msRestAzure.AzureS
5349

5450
super(credentials, options);
5551

56-
this.apiVersion = "2021-04-30";
57-
this.acceptLanguage = "en-US";
52+
this.apiVersion = '2021-04-30';
53+
this.acceptLanguage = 'en-US';
5854
this.longRunningOperationRetryTimeout = 30;
5955
this.baseUri = options.baseUri || this.baseUri || "https://management.azure.com";
6056
this.requestContentType = "application/json; charset=utf-8";
@@ -64,10 +60,7 @@ export class CognitiveServicesManagementClientContext extends msRestAzure.AzureS
6460
if (options.acceptLanguage !== null && options.acceptLanguage !== undefined) {
6561
this.acceptLanguage = options.acceptLanguage;
6662
}
67-
if (
68-
options.longRunningOperationRetryTimeout !== null &&
69-
options.longRunningOperationRetryTimeout !== undefined
70-
) {
63+
if (options.longRunningOperationRetryTimeout !== null && options.longRunningOperationRetryTimeout !== undefined) {
7164
this.longRunningOperationRetryTimeout = options.longRunningOperationRetryTimeout;
7265
}
7366
}

0 commit comments

Comments
 (0)