Skip to content

Commit b3db28c

Browse files
author
SDKAuto
committed
CodeGen from PR 14705 in Azure/azure-rest-api-specs
Merge 88951818c7b5ab6e55b4165b56a0f9d85256902a into 86408a8777e623f5f41e260472ed831309b85086
1 parent ec4abba commit b3db28c

30 files changed

+7667
-1117
lines changed

sdk/machinelearningservices/arm-machinelearningservices/LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2020 Microsoft
3+
Copyright (c) 2021 Microsoft
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

sdk/machinelearningservices/arm-machinelearningservices/README.md

Lines changed: 53 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,97 @@
11
## Azure AzureMachineLearningWorkspaces SDK for JavaScript
22

3-
This package contains an isomorphic SDK for AzureMachineLearningWorkspaces.
3+
This package contains an isomorphic SDK (runs both in node.js and in browsers) for AzureMachineLearningWorkspaces.
44

55
### Currently supported environments
66

7-
- Node.js version 6.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

10-
### How to Install
10+
### Prerequisites
1111

12+
You must have an [Azure subscription](https://azure.microsoft.com/free/).
13+
14+
### How to install
15+
16+
To use this SDK in your project, you will need to install two packages.
17+
- `@azure/arm-machinelearningservices` that contains the client.
18+
- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory.
19+
20+
Install both packages using the below command:
1221
```bash
13-
npm install @azure/arm-machinelearningservices
22+
npm install --save @azure/arm-machinelearningservices @azure/identity
1423
```
24+
> **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.
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.
1526

1627
### How to use
1728

18-
#### nodejs - client creation and list operations as an example written in TypeScript.
29+
- If you are writing a client side browser application,
30+
- Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions.
31+
- Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below.
32+
- If you are writing a server side application,
33+
- [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples)
34+
- Complete the set up steps required by the credential if any.
35+
- Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below.
1936

20-
##### Install @azure/ms-rest-nodeauth
21-
22-
- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`.
23-
```bash
24-
npm install @azure/ms-rest-nodeauth@"^3.0.0"
25-
```
37+
In the below samples, we pass the credential and the Azure subscription id to instantiate the client.
38+
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.
39+
#### nodejs - Authentication, client creation, and list operations as an example written in JavaScript.
2640

2741
##### Sample code
2842

29-
While the below sample uses the interactive login, other authentication options can be found in the [README.md file of @azure/ms-rest-nodeauth](https://www.npmjs.com/package/@azure/ms-rest-nodeauth) package
30-
```typescript
31-
const msRestNodeAuth = require("@azure/ms-rest-nodeauth");
43+
```javascript
44+
const { DefaultAzureCredential } = require("@azure/identity");
3245
const { AzureMachineLearningWorkspaces } = require("@azure/arm-machinelearningservices");
3346
const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"];
3447

35-
msRestNodeAuth.interactiveLogin().then((creds) => {
36-
const client = new AzureMachineLearningWorkspaces(creds, subscriptionId);
37-
client.operations.list().then((result) => {
38-
console.log("The result is:");
39-
console.log(result);
40-
});
48+
// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples
49+
// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead.
50+
const creds = new DefaultAzureCredential();
51+
const client = new AzureMachineLearningWorkspaces(creds, subscriptionId);
52+
client.operations.list().then((result) => {
53+
console.log("The result is:");
54+
console.log(result);
4155
}).catch((err) => {
56+
console.log("An error occurred:");
4257
console.error(err);
4358
});
4459
```
4560

46-
#### browser - Authentication, client creation and list operations as an example written in JavaScript.
61+
#### browser - Authentication, client creation, and list operations as an example written in JavaScript.
4762

48-
##### Install @azure/ms-rest-browserauth
49-
50-
```bash
51-
npm install @azure/ms-rest-browserauth
52-
```
63+
In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser.
64+
- 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.
65+
- Note down the client Id from the previous step and use it in the browser sample below.
5366

5467
##### Sample code
5568

56-
See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser.
57-
5869
- index.html
70+
5971
```html
6072
<!DOCTYPE html>
6173
<html lang="en">
6274
<head>
6375
<title>@azure/arm-machinelearningservices sample</title>
64-
<script src="node_modules/@azure/ms-rest-js/dist/msRest.browser.js"></script>
6576
<script src="node_modules/@azure/ms-rest-azure-js/dist/msRestAzure.js"></script>
66-
<script src="node_modules/@azure/ms-rest-browserauth/dist/msAuth.js"></script>
77+
<script src="node_modules/@azure/identity/dist/index.js"></script>
6778
<script src="node_modules/@azure/arm-machinelearningservices/dist/arm-machinelearningservices.js"></script>
6879
<script type="text/javascript">
6980
const subscriptionId = "<Subscription_Id>";
70-
const authManager = new msAuth.AuthManager({
81+
// Create credentials using the `@azure/identity` package.
82+
// Please note that you can also use credentials from the `@azure/ms-rest-browserauth` package instead.
83+
const credential = new InteractiveBrowserCredential(
84+
{
7185
clientId: "<client id for your Azure AD app>",
7286
tenant: "<optional tenant for your organization>"
7387
});
74-
authManager.finalizeLogin().then((res) => {
75-
if (!res.isLoggedIn) {
76-
// may cause redirects
77-
authManager.login();
78-
}
79-
const client = new Azure.ArmMachinelearningservices.AzureMachineLearningWorkspaces(res.creds, subscriptionId);
80-
client.operations.list().then((result) => {
81-
console.log("The result is:");
82-
console.log(result);
83-
}).catch((err) => {
84-
console.log("An error occurred:");
85-
console.error(err);
86-
});
88+
const client = new Azure.ArmMachinelearningservices.AzureMachineLearningWorkspaces(creds, subscriptionId);
89+
client.operations.list().then((result) => {
90+
console.log("The result is:");
91+
console.log(result);
92+
}).catch((err) => {
93+
console.log("An error occurred:");
94+
console.error(err);
8795
});
8896
</script>
8997
</head>

sdk/machinelearningservices/arm-machinelearningservices/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
"description": "AzureMachineLearningWorkspaces Library with typescript type definitions for node.js and browser.",
55
"version": "4.0.0",
66
"dependencies": {
7-
"@azure/ms-rest-azure-js": "^2.0.1",
8-
"@azure/ms-rest-js": "^2.0.4",
7+
"@azure/ms-rest-azure-js": "^2.1.0",
8+
"@azure/ms-rest-js": "^2.2.0",
9+
"@azure/core-auth": "^1.1.4",
910
"tslib": "^1.10.0"
1011
},
1112
"keywords": [
@@ -20,13 +21,13 @@
2021
"module": "./esm/azureMachineLearningWorkspaces.js",
2122
"types": "./esm/azureMachineLearningWorkspaces.d.ts",
2223
"devDependencies": {
23-
"typescript": "^3.5.3",
24+
"typescript": "^3.6.0",
2425
"rollup": "^1.18.0",
2526
"rollup-plugin-node-resolve": "^5.2.0",
2627
"rollup-plugin-sourcemaps": "^0.4.2",
2728
"uglify-js": "^3.6.0"
2829
},
29-
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/machinelearningservices/arm-machinelearningservices",
30+
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/machinelearningservices/arm-machinelearningservices",
3031
"repository": {
3132
"type": "git",
3233
"url": "https://github.com/Azure/azure-sdk-for-js.git"

sdk/machinelearningservices/arm-machinelearningservices/src/azureMachineLearningWorkspaces.ts

Lines changed: 18 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
*/
99

1010
import * as msRest from "@azure/ms-rest-js";
11+
import { TokenCredential } from "@azure/core-auth";
1112
import * as Models from "./models";
1213
import * as Mappers from "./models/mappers";
13-
import * as Parameters from "./models/parameters";
1414
import * as operations from "./operations";
1515
import { AzureMachineLearningWorkspacesContext } from "./azureMachineLearningWorkspacesContext";
1616

@@ -20,137 +20,49 @@ class AzureMachineLearningWorkspaces extends AzureMachineLearningWorkspacesConte
2020
operations: operations.Operations;
2121
workspaces: operations.Workspaces;
2222
workspaceFeatures: operations.WorkspaceFeatures;
23-
notebooks: operations.Notebooks;
2423
usages: operations.Usages;
2524
virtualMachineSizes: operations.VirtualMachineSizes;
2625
quotas: operations.Quotas;
27-
workspaceConnections: operations.WorkspaceConnections;
2826
machineLearningCompute: operations.MachineLearningCompute;
27+
workspace: operations.WorkspaceOperations;
2928
privateEndpointConnections: operations.PrivateEndpointConnections;
3029
privateLinkResources: operations.PrivateLinkResources;
30+
machineLearningService: operations.MachineLearningService;
31+
notebooks: operations.Notebooks;
32+
storageAccount: operations.StorageAccount;
33+
workspaceConnections: operations.WorkspaceConnections;
3134

3235
/**
3336
* Initializes a new instance of the AzureMachineLearningWorkspaces class.
34-
* @param credentials Credentials needed for the client to connect to Azure.
37+
* @param credentials Credentials needed for the client to connect to Azure. Credentials
38+
* implementing the TokenCredential interface from the @azure/identity package are recommended. For
39+
* more information about these credentials, see
40+
* {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the
41+
* ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and
42+
* @azure/ms-rest-browserauth are also supported.
3543
* @param subscriptionId Azure subscription identifier.
3644
* @param [options] The parameter options
3745
*/
38-
constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.AzureMachineLearningWorkspacesOptions) {
46+
constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.AzureMachineLearningWorkspacesOptions) {
3947
super(credentials, subscriptionId, options);
4048
this.operations = new operations.Operations(this);
4149
this.workspaces = new operations.Workspaces(this);
4250
this.workspaceFeatures = new operations.WorkspaceFeatures(this);
43-
this.notebooks = new operations.Notebooks(this);
4451
this.usages = new operations.Usages(this);
4552
this.virtualMachineSizes = new operations.VirtualMachineSizes(this);
4653
this.quotas = new operations.Quotas(this);
47-
this.workspaceConnections = new operations.WorkspaceConnections(this);
4854
this.machineLearningCompute = new operations.MachineLearningCompute(this);
55+
this.workspace = new operations.WorkspaceOperations(this);
4956
this.privateEndpointConnections = new operations.PrivateEndpointConnections(this);
5057
this.privateLinkResources = new operations.PrivateLinkResources(this);
51-
}
52-
53-
/**
54-
* Lists all skus with associated features
55-
* @param [options] The optional parameters
56-
* @returns Promise<Models.ListSkusResponse>
57-
*/
58-
listSkus(options?: msRest.RequestOptionsBase): Promise<Models.ListSkusResponse>;
59-
/**
60-
* @param callback The callback
61-
*/
62-
listSkus(callback: msRest.ServiceCallback<Models.SkuListResult>): void;
63-
/**
64-
* @param options The optional parameters
65-
* @param callback The callback
66-
*/
67-
listSkus(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback<Models.SkuListResult>): void;
68-
listSkus(options?: msRest.RequestOptionsBase | msRest.ServiceCallback<Models.SkuListResult>, callback?: msRest.ServiceCallback<Models.SkuListResult>): Promise<Models.ListSkusResponse> {
69-
return this.sendOperationRequest(
70-
{
71-
options
72-
},
73-
listSkusOperationSpec,
74-
callback) as Promise<Models.ListSkusResponse>;
75-
}
76-
77-
/**
78-
* Lists all skus with associated features
79-
* @param nextPageLink The NextLink from the previous successful call to List operation.
80-
* @param [options] The optional parameters
81-
* @returns Promise<Models.ListSkusNextResponse>
82-
*/
83-
listSkusNext(nextPageLink: string, options?: msRest.RequestOptionsBase): Promise<Models.ListSkusNextResponse>;
84-
/**
85-
* @param nextPageLink The NextLink from the previous successful call to List operation.
86-
* @param callback The callback
87-
*/
88-
listSkusNext(nextPageLink: string, callback: msRest.ServiceCallback<Models.SkuListResult>): void;
89-
/**
90-
* @param nextPageLink The NextLink from the previous successful call to List operation.
91-
* @param options The optional parameters
92-
* @param callback The callback
93-
*/
94-
listSkusNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback<Models.SkuListResult>): void;
95-
listSkusNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback<Models.SkuListResult>, callback?: msRest.ServiceCallback<Models.SkuListResult>): Promise<Models.ListSkusNextResponse> {
96-
return this.sendOperationRequest(
97-
{
98-
nextPageLink,
99-
options
100-
},
101-
listSkusNextOperationSpec,
102-
callback) as Promise<Models.ListSkusNextResponse>;
58+
this.machineLearningService = new operations.MachineLearningService(this);
59+
this.notebooks = new operations.Notebooks(this);
60+
this.storageAccount = new operations.StorageAccount(this);
61+
this.workspaceConnections = new operations.WorkspaceConnections(this);
10362
}
10463
}
10564

10665
// Operation Specifications
107-
const serializer = new msRest.Serializer(Mappers);
108-
const listSkusOperationSpec: msRest.OperationSpec = {
109-
httpMethod: "GET",
110-
path: "subscriptions/{subscriptionId}/providers/Microsoft.MachineLearningServices/workspaces/skus",
111-
urlParameters: [
112-
Parameters.subscriptionId
113-
],
114-
queryParameters: [
115-
Parameters.apiVersion
116-
],
117-
headerParameters: [
118-
Parameters.acceptLanguage
119-
],
120-
responses: {
121-
200: {
122-
bodyMapper: Mappers.SkuListResult
123-
},
124-
default: {
125-
bodyMapper: Mappers.MachineLearningServiceError
126-
}
127-
},
128-
serializer
129-
};
130-
131-
const listSkusNextOperationSpec: msRest.OperationSpec = {
132-
httpMethod: "GET",
133-
baseUrl: "https://management.azure.com",
134-
path: "{nextLink}",
135-
urlParameters: [
136-
Parameters.nextPageLink
137-
],
138-
queryParameters: [
139-
Parameters.apiVersion
140-
],
141-
headerParameters: [
142-
Parameters.acceptLanguage
143-
],
144-
responses: {
145-
200: {
146-
bodyMapper: Mappers.SkuListResult
147-
},
148-
default: {
149-
bodyMapper: Mappers.MachineLearningServiceError
150-
}
151-
},
152-
serializer
153-
};
15466

15567
export {
15668
AzureMachineLearningWorkspaces,

0 commit comments

Comments
 (0)