Skip to content

Commit cae0a4e

Browse files
authored
arm-cognitiverervices-track1 (Azure#18709)
1 parent 8790454 commit cae0a4e

25 files changed

+2676
-1039
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
@@ -2,7 +2,7 @@
22
"name": "@azure/arm-cognitiveservices",
33
"author": "Microsoft Corporation",
44
"description": "CognitiveServicesManagementClient Library with typescript type definitions for node.js and browser.",
5-
"version": "6.0.1",
5+
"version": "6.1.0",
66
"dependencies": {
77
"@azure/ms-rest-azure-js": "^2.1.0",
88
"@azure/ms-rest-js": "^2.2.0",

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: 44 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@ 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;
2122
deletedAccounts: operations.DeletedAccounts;
2223
resourceSkus: operations.ResourceSkus;
2324
operations: operations.Operations;
25+
commitmentTiers: operations.CommitmentTiers;
2426
privateEndpointConnections: operations.PrivateEndpointConnections;
2527
privateLinkResources: operations.PrivateLinkResources;
28+
deployments: operations.Deployments;
29+
commitmentPlans: operations.CommitmentPlans;
2630

2731
/**
2832
* Initializes a new instance of the CognitiveServicesManagementClient class.
@@ -35,18 +39,17 @@ class CognitiveServicesManagementClient extends CognitiveServicesManagementClien
3539
* @param subscriptionId The ID of the target subscription.
3640
* @param [options] The parameter options
3741
*/
38-
constructor(
39-
credentials: msRest.ServiceClientCredentials | TokenCredential,
40-
subscriptionId: string,
41-
options?: Models.CognitiveServicesManagementClientOptions
42-
) {
42+
constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.CognitiveServicesManagementClientOptions) {
4343
super(credentials, subscriptionId, options);
4444
this.accounts = new operations.Accounts(this);
4545
this.deletedAccounts = new operations.DeletedAccounts(this);
4646
this.resourceSkus = new operations.ResourceSkus(this);
4747
this.operations = new operations.Operations(this);
48+
this.commitmentTiers = new operations.CommitmentTiers(this);
4849
this.privateEndpointConnections = new operations.PrivateEndpointConnections(this);
4950
this.privateLinkResources = new operations.PrivateLinkResources(this);
51+
this.deployments = new operations.Deployments(this);
52+
this.commitmentPlans = new operations.CommitmentPlans(this);
5053
}
5154

5255
/**
@@ -58,27 +61,15 @@ class CognitiveServicesManagementClient extends CognitiveServicesManagementClien
5861
* @param [options] The optional parameters
5962
* @returns Promise<Models.CheckSkuAvailabilityResponse>
6063
*/
61-
checkSkuAvailability(
62-
location: string,
63-
skus: string[],
64-
kind: string,
65-
type: string,
66-
options?: msRest.RequestOptionsBase
67-
): Promise<Models.CheckSkuAvailabilityResponse>;
64+
checkSkuAvailability(location: string, skus: string[], kind: string, type: string, options?: msRest.RequestOptionsBase): Promise<Models.CheckSkuAvailabilityResponse>;
6865
/**
6966
* @param location Resource location.
7067
* @param skus The SKU of the resource.
7168
* @param kind The Kind of the resource.
7269
* @param type The Type of the resource.
7370
* @param callback The callback
7471
*/
75-
checkSkuAvailability(
76-
location: string,
77-
skus: string[],
78-
kind: string,
79-
type: string,
80-
callback: msRest.ServiceCallback<Models.SkuAvailabilityListResult>
81-
): void;
72+
checkSkuAvailability(location: string, skus: string[], kind: string, type: string, callback: msRest.ServiceCallback<Models.SkuAvailabilityListResult>): void;
8273
/**
8374
* @param location Resource location.
8475
* @param skus The SKU of the resource.
@@ -87,22 +78,8 @@ class CognitiveServicesManagementClient extends CognitiveServicesManagementClien
8778
* @param options The optional parameters
8879
* @param callback The callback
8980
*/
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> {
81+
checkSkuAvailability(location: string, skus: string[], kind: string, type: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback<Models.SkuAvailabilityListResult>): void;
82+
checkSkuAvailability(location: string, skus: string[], kind: string, type: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback<Models.SkuAvailabilityListResult>, callback?: msRest.ServiceCallback<Models.SkuAvailabilityListResult>): Promise<Models.CheckSkuAvailabilityResponse> {
10683
return this.sendOperationRequest(
10784
{
10885
location,
@@ -112,8 +89,7 @@ class CognitiveServicesManagementClient extends CognitiveServicesManagementClien
11289
options
11390
},
11491
checkSkuAvailabilityOperationSpec,
115-
callback
116-
) as Promise<Models.CheckSkuAvailabilityResponse>;
92+
callback) as Promise<Models.CheckSkuAvailabilityResponse>;
11793
}
11894

11995
/**
@@ -123,60 +99,47 @@ class CognitiveServicesManagementClient extends CognitiveServicesManagementClien
12399
* @param [options] The optional parameters
124100
* @returns Promise<Models.CheckDomainAvailabilityResponse>
125101
*/
126-
checkDomainAvailability(
127-
subdomainName: string,
128-
type: string,
129-
options?: msRest.RequestOptionsBase
130-
): Promise<Models.CheckDomainAvailabilityResponse>;
102+
checkDomainAvailability(subdomainName: string, type: string, options?: Models.CognitiveServicesManagementClientCheckDomainAvailabilityOptionalParams): Promise<Models.CheckDomainAvailabilityResponse>;
131103
/**
132104
* @param subdomainName The subdomain name to use.
133105
* @param type The Type of the resource.
134106
* @param callback The callback
135107
*/
136-
checkDomainAvailability(
137-
subdomainName: string,
138-
type: string,
139-
callback: msRest.ServiceCallback<Models.DomainAvailability>
140-
): void;
108+
checkDomainAvailability(subdomainName: string, type: string, callback: msRest.ServiceCallback<Models.DomainAvailability>): void;
141109
/**
142110
* @param subdomainName The subdomain name to use.
143111
* @param type The Type of the resource.
144112
* @param options The optional parameters
145113
* @param callback The callback
146114
*/
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> {
115+
checkDomainAvailability(subdomainName: string, type: string, options: Models.CognitiveServicesManagementClientCheckDomainAvailabilityOptionalParams, callback: msRest.ServiceCallback<Models.DomainAvailability>): void;
116+
checkDomainAvailability(subdomainName: string, type: string, options?: Models.CognitiveServicesManagementClientCheckDomainAvailabilityOptionalParams | msRest.ServiceCallback<Models.DomainAvailability>, callback?: msRest.ServiceCallback<Models.DomainAvailability>): Promise<Models.CheckDomainAvailabilityResponse> {
159117
return this.sendOperationRequest(
160118
{
161119
subdomainName,
162120
type,
163121
options
164122
},
165123
checkDomainAvailabilityOperationSpec,
166-
callback
167-
) as Promise<Models.CheckDomainAvailabilityResponse>;
124+
callback) as Promise<Models.CheckDomainAvailabilityResponse>;
168125
}
169126
}
170127

171128
// Operation Specifications
172129
const serializer = new msRest.Serializer(Mappers);
173130
const checkSkuAvailabilityOperationSpec: msRest.OperationSpec = {
174131
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],
132+
path: "subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/locations/{location}/checkSkuAvailability",
133+
urlParameters: [
134+
Parameters.subscriptionId,
135+
Parameters.location
136+
],
137+
queryParameters: [
138+
Parameters.apiVersion
139+
],
140+
headerParameters: [
141+
Parameters.acceptLanguage
142+
],
180143
requestBody: {
181144
parameterPath: {
182145
skus: "skus",
@@ -201,15 +164,24 @@ const checkSkuAvailabilityOperationSpec: msRest.OperationSpec = {
201164

202165
const checkDomainAvailabilityOperationSpec: msRest.OperationSpec = {
203166
httpMethod: "POST",
204-
path:
205-
"subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/checkDomainAvailability",
206-
urlParameters: [Parameters.subscriptionId],
207-
queryParameters: [Parameters.apiVersion],
208-
headerParameters: [Parameters.acceptLanguage],
167+
path: "subscriptions/{subscriptionId}/providers/Microsoft.CognitiveServices/checkDomainAvailability",
168+
urlParameters: [
169+
Parameters.subscriptionId
170+
],
171+
queryParameters: [
172+
Parameters.apiVersion
173+
],
174+
headerParameters: [
175+
Parameters.acceptLanguage
176+
],
209177
requestBody: {
210178
parameterPath: {
211179
subdomainName: "subdomainName",
212-
type: "type"
180+
type: "type",
181+
kind: [
182+
"options",
183+
"kind"
184+
]
213185
},
214186
mapper: {
215187
...Mappers.CheckDomainAvailabilityParameter,

0 commit comments

Comments
 (0)