Skip to content

Commit fecc3c4

Browse files
author
SDKAuto
committed
CodeGen from PR 14736 in Azure/azure-rest-api-specs
Merge 2290fefedc09ebcef566a51b9bfc99e3ece13257 into f7535f8211b7fe9a8d5e5ebdc09830677b55285c
1 parent 556da80 commit fecc3c4

15 files changed

+180
-106
lines changed

sdk/locks/arm-locks/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) 2019 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/locks/arm-locks/README.md

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

3-
This package contains an isomorphic SDK for ManagementLockClient.
3+
This package contains an isomorphic SDK (runs both in node.js and in browsers) for ManagementLockClient.
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-locks` 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-locks
22+
npm install --save @azure/arm-locks @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 - Authentication, client creation and list authorizationOperations 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-
```bash
23-
npm install @azure/ms-rest-nodeauth
24-
```
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 authorizationOperations as an example written in JavaScript.
2540

2641
##### Sample code
2742

28-
```typescript
29-
import * as msRest from "@azure/ms-rest-js";
30-
import * as msRestAzure from "@azure/ms-rest-azure-js";
31-
import * as msRestNodeAuth from "@azure/ms-rest-nodeauth";
32-
import { ManagementLockClient, ManagementLockModels, ManagementLockMappers } from "@azure/arm-locks";
43+
```javascript
44+
const { DefaultAzureCredential } = require("@azure/identity");
45+
const { ManagementLockClient } = require("@azure/arm-locks");
3346
const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"];
3447

35-
msRestNodeAuth.interactiveLogin().then((creds) => {
36-
const client = new ManagementLockClient(creds, subscriptionId);
37-
client.authorizationOperations.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 ManagementLockClient(creds, subscriptionId);
52+
client.authorizationOperations.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 authorizationOperations as an example written in JavaScript.
61+
#### browser - Authentication, client creation, and list authorizationOperations 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-locks 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-locks/dist/arm-locks.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.ArmLocks.ManagementLockClient(res.creds, subscriptionId);
80-
client.authorizationOperations.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.ArmLocks.ManagementLockClient(creds, subscriptionId);
89+
client.authorizationOperations.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>
@@ -95,4 +103,4 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to
95103

96104
- [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js)
97105

98-
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Flocks%2Farm-locks%2FREADME.png)
106+
![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js/sdk/locks/arm-locks/README.png)

sdk/locks/arm-locks/package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
"description": "ManagementLockClient Library with typescript type definitions for node.js and browser.",
55
"version": "1.1.0",
66
"dependencies": {
7-
"@azure/ms-rest-azure-js": "^1.3.2",
8-
"@azure/ms-rest-js": "^1.8.1",
9-
"tslib": "^1.9.3"
7+
"@azure/ms-rest-azure-js": "^2.1.0",
8+
"@azure/ms-rest-js": "^2.2.0",
9+
"@azure/core-auth": "^1.1.4",
10+
"tslib": "^1.10.0"
1011
},
1112
"keywords": [
1213
"node",
@@ -20,13 +21,13 @@
2021
"module": "./esm/managementLockClient.js",
2122
"types": "./esm/managementLockClient.d.ts",
2223
"devDependencies": {
23-
"typescript": "^3.1.1",
24-
"rollup": "^0.66.2",
25-
"rollup-plugin-node-resolve": "^3.4.0",
24+
"typescript": "^3.6.0",
25+
"rollup": "^1.18.0",
26+
"rollup-plugin-node-resolve": "^5.2.0",
2627
"rollup-plugin-sourcemaps": "^0.4.2",
27-
"uglify-js": "^3.4.9"
28+
"uglify-js": "^3.6.0"
2829
},
29-
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/locks/arm-locks",
30+
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/locks/arm-locks",
3031
"repository": {
3132
"type": "git",
3233
"url": "https://github.com/Azure/azure-sdk-for-js.git"

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ const config = {
2121
"@azure/ms-rest-azure-js": "msRestAzure"
2222
},
2323
banner: `/*
24-
* Copyright (c) Microsoft Corporation. All rights reserved.
25-
* Licensed under the MIT License. See License.txt in the project root for license information.
24+
* Copyright (c) Microsoft Corporation.
25+
* Licensed under the MIT License.
2626
*
2727
* Code generated by Microsoft (R) AutoRest Code Generator.
2828
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
2929
*/`
3030
},
3131
plugins: [
32-
nodeResolve({ module: true }),
32+
nodeResolve({ mainFields: ['module', 'main'] }),
3333
sourcemaps()
3434
]
3535
};

sdk/locks/arm-locks/src/managementLockClient.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/*
2-
* Copyright (c) Microsoft Corporation. All rights reserved.
3-
* Licensed under the MIT License. See License.txt in the project root for
4-
* license information.
2+
* Copyright (c) Microsoft Corporation.
3+
* Licensed under the MIT License.
54
*
65
* Code generated by Microsoft (R) AutoRest Code Generator.
76
* Changes may cause incorrect behavior and will be lost if the code is
87
* regenerated.
98
*/
109

1110
import * as msRest from "@azure/ms-rest-js";
11+
import { TokenCredential } from "@azure/core-auth";
1212
import * as Models from "./models";
1313
import * as Mappers from "./models/mappers";
1414
import * as operations from "./operations";
@@ -22,11 +22,16 @@ class ManagementLockClient extends ManagementLockClientContext {
2222

2323
/**
2424
* Initializes a new instance of the ManagementLockClient class.
25-
* @param credentials Credentials needed for the client to connect to Azure.
25+
* @param credentials Credentials needed for the client to connect to Azure. Credentials
26+
* implementing the TokenCredential interface from the @azure/identity package are recommended. For
27+
* more information about these credentials, see
28+
* {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the
29+
* ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and
30+
* @azure/ms-rest-browserauth are also supported.
2631
* @param subscriptionId The ID of the target subscription.
2732
* @param [options] The parameter options
2833
*/
29-
constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.ManagementLockClientOptions) {
34+
constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ManagementLockClientOptions) {
3035
super(credentials, subscriptionId, options);
3136
this.authorizationOperations = new operations.AuthorizationOperations(this);
3237
this.managementLocks = new operations.ManagementLocks(this);

sdk/locks/arm-locks/src/managementLockClientContext.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/*
2-
* Copyright (c) Microsoft Corporation. All rights reserved.
3-
* Licensed under the MIT License. See License.txt in the project root for
4-
* license information.
2+
* Copyright (c) Microsoft Corporation.
3+
* Licensed under the MIT License.
54
*
65
* Code generated by Microsoft (R) AutoRest Code Generator.
76
* Changes may cause incorrect behavior and will be lost if the code is
@@ -11,22 +10,28 @@
1110
import * as Models from "./models";
1211
import * as msRest from "@azure/ms-rest-js";
1312
import * as msRestAzure from "@azure/ms-rest-azure-js";
13+
import { TokenCredential } from "@azure/core-auth";
1414

1515
const packageName = "@azure/arm-locks";
1616
const packageVersion = "1.1.0";
1717

1818
export class ManagementLockClientContext extends msRestAzure.AzureServiceClient {
19-
credentials: msRest.ServiceClientCredentials;
19+
credentials: msRest.ServiceClientCredentials | TokenCredential;
2020
subscriptionId: string;
2121
apiVersion?: string;
2222

2323
/**
2424
* Initializes a new instance of the ManagementLockClient class.
25-
* @param credentials Credentials needed for the client to connect to Azure.
25+
* @param credentials Credentials needed for the client to connect to Azure. Credentials
26+
* implementing the TokenCredential interface from the @azure/identity package are recommended. For
27+
* more information about these credentials, see
28+
* {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the
29+
* ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and
30+
* @azure/ms-rest-browserauth are also supported.
2631
* @param subscriptionId The ID of the target subscription.
2732
* @param [options] The parameter options
2833
*/
29-
constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.ManagementLockClientOptions) {
34+
constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.ManagementLockClientOptions) {
3035
if (credentials == undefined) {
3136
throw new Error('\'credentials\' cannot be null.');
3237
}
@@ -37,7 +42,7 @@ export class ManagementLockClientContext extends msRestAzure.AzureServiceClient
3742
if (!options) {
3843
options = {};
3944
}
40-
if(!options.userAgent) {
45+
if (!options.userAgent) {
4146
const defaultUserAgent = msRestAzure.getDefaultUserAgentValue();
4247
options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`;
4348
}
@@ -52,10 +57,10 @@ export class ManagementLockClientContext extends msRestAzure.AzureServiceClient
5257
this.credentials = credentials;
5358
this.subscriptionId = subscriptionId;
5459

55-
if(options.acceptLanguage !== null && options.acceptLanguage !== undefined) {
60+
if (options.acceptLanguage !== null && options.acceptLanguage !== undefined) {
5661
this.acceptLanguage = options.acceptLanguage;
5762
}
58-
if(options.longRunningOperationRetryTimeout !== null && options.longRunningOperationRetryTimeout !== undefined) {
63+
if (options.longRunningOperationRetryTimeout !== null && options.longRunningOperationRetryTimeout !== undefined) {
5964
this.longRunningOperationRetryTimeout = options.longRunningOperationRetryTimeout;
6065
}
6166
}

sdk/locks/arm-locks/src/models/authorizationOperationsMappers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) Microsoft Corporation. All rights reserved.
3-
* Licensed under the MIT License. See License.txt in the project root for license information.
2+
* Copyright (c) Microsoft Corporation.
3+
* Licensed under the MIT License.
44
*
55
* Code generated by Microsoft (R) AutoRest Code Generator.
66
* Changes may cause incorrect behavior and will be lost if the code is regenerated.

sdk/locks/arm-locks/src/models/index.ts

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) Microsoft Corporation. All rights reserved.
3-
* Licensed under the MIT License. See License.txt in the project root for license information.
2+
* Copyright (c) Microsoft Corporation.
3+
* Licensed under the MIT License.
44
*
55
* Code generated by Microsoft (R) AutoRest Code Generator.
66
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
@@ -129,6 +129,46 @@ export interface ManagementLocksListByScopeOptionalParams extends msRest.Request
129129
filter?: string;
130130
}
131131

132+
/**
133+
* Optional Parameters.
134+
*/
135+
export interface ManagementLocksListAtResourceGroupLevelNextOptionalParams extends msRest.RequestOptionsBase {
136+
/**
137+
* The filter to apply on the operation.
138+
*/
139+
filter?: string;
140+
}
141+
142+
/**
143+
* Optional Parameters.
144+
*/
145+
export interface ManagementLocksListAtResourceLevelNextOptionalParams extends msRest.RequestOptionsBase {
146+
/**
147+
* The filter to apply on the operation.
148+
*/
149+
filter?: string;
150+
}
151+
152+
/**
153+
* Optional Parameters.
154+
*/
155+
export interface ManagementLocksListAtSubscriptionLevelNextOptionalParams extends msRest.RequestOptionsBase {
156+
/**
157+
* The filter to apply on the operation.
158+
*/
159+
filter?: string;
160+
}
161+
162+
/**
163+
* Optional Parameters.
164+
*/
165+
export interface ManagementLocksListByScopeNextOptionalParams extends msRest.RequestOptionsBase {
166+
/**
167+
* The filter to apply on the operation.
168+
*/
169+
filter?: string;
170+
}
171+
132172
/**
133173
* An interface representing ManagementLockClientOptions.
134174
*/

sdk/locks/arm-locks/src/models/managementLocksMappers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) Microsoft Corporation. All rights reserved.
3-
* Licensed under the MIT License. See License.txt in the project root for license information.
2+
* Copyright (c) Microsoft Corporation.
3+
* Licensed under the MIT License.
44
*
55
* Code generated by Microsoft (R) AutoRest Code Generator.
66
* Changes may cause incorrect behavior and will be lost if the code is regenerated.

sdk/locks/arm-locks/src/models/mappers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (c) Microsoft Corporation. All rights reserved.
3-
* Licensed under the MIT License. See License.txt in the project root for license information.
2+
* Copyright (c) Microsoft Corporation.
3+
* Licensed under the MIT License.
44
*
55
* Code generated by Microsoft (R) AutoRest Code Generator.
66
* Changes may cause incorrect behavior and will be lost if the code is regenerated.

0 commit comments

Comments
 (0)