Skip to content

Commit f8a900a

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

15 files changed

+1342
-135
lines changed

sdk/features/arm-features/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/features/arm-features/README.md

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

3-
This package contains an isomorphic SDK for FeatureClient.
3+
This package contains an isomorphic SDK (runs both in node.js and in browsers) for FeatureClient.
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-features` 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-features
22+
npm install --save @azure/arm-features @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 listOperations 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 listOperations 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 { FeatureClient, FeatureModels, FeatureMappers } from "@azure/arm-features";
43+
```javascript
44+
const { DefaultAzureCredential } = require("@azure/identity");
45+
const { FeatureClient } = require("@azure/arm-features");
3346
const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"];
3447

35-
msRestNodeAuth.interactiveLogin().then((creds) => {
36-
const client = new FeatureClient(creds, subscriptionId);
37-
client.listOperations().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 FeatureClient(creds, subscriptionId);
52+
const apiVersion = "testapiVersion";
53+
client.listOperations(apiVersion).then((result) => {
54+
console.log("The result is:");
55+
console.log(result);
4156
}).catch((err) => {
57+
console.log("An error occurred:");
4258
console.error(err);
4359
});
4460
```
4561

46-
#### browser - Authentication, client creation and listOperations as an example written in JavaScript.
62+
#### browser - Authentication, client creation, and listOperations as an example written in JavaScript.
4763

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

5468
##### Sample code
5569

56-
See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser.
57-
5870
- index.html
71+
5972
```html
6073
<!DOCTYPE html>
6174
<html lang="en">
6275
<head>
6376
<title>@azure/arm-features sample</title>
64-
<script src="node_modules/@azure/ms-rest-js/dist/msRest.browser.js"></script>
6577
<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>
78+
<script src="node_modules/@azure/identity/dist/index.js"></script>
6779
<script src="node_modules/@azure/arm-features/dist/arm-features.js"></script>
6880
<script type="text/javascript">
6981
const subscriptionId = "<Subscription_Id>";
70-
const authManager = new msAuth.AuthManager({
82+
// Create credentials using the `@azure/identity` package.
83+
// Please note that you can also use credentials from the `@azure/ms-rest-browserauth` package instead.
84+
const credential = new InteractiveBrowserCredential(
85+
{
7186
clientId: "<client id for your Azure AD app>",
7287
tenant: "<optional tenant for your organization>"
7388
});
74-
authManager.finalizeLogin().then((res) => {
75-
if (!res.isLoggedIn) {
76-
// may cause redirects
77-
authManager.login();
78-
}
79-
const client = new Azure.ArmFeatures.FeatureClient(res.creds, subscriptionId);
80-
client.listOperations().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-
});
89+
const client = new Azure.ArmFeatures.FeatureClient(creds, subscriptionId);
90+
const apiVersion = "testapiVersion";
91+
client.listOperations(apiVersion).then((result) => {
92+
console.log("The result is:");
93+
console.log(result);
94+
}).catch((err) => {
95+
console.log("An error occurred:");
96+
console.error(err);
8797
});
8898
</script>
8999
</head>
@@ -95,4 +105,4 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to
95105

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

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

sdk/features/arm-features/package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
"description": "FeatureClient Library with typescript type definitions for node.js and browser.",
55
"version": "1.0.3",
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/featureClient.js",
2122
"types": "./esm/featureClient.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/features/arm-features",
30+
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/features/arm-features",
3031
"repository": {
3132
"type": "git",
3233
"url": "https://github.com/Azure/azure-sdk-for-js.git"

sdk/features/arm-features/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/features/arm-features/src/featureClient.ts

Lines changed: 36 additions & 17 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 Parameters from "./models/parameters";
@@ -19,36 +19,48 @@ import { FeatureClientContext } from "./featureClientContext";
1919
class FeatureClient extends FeatureClientContext {
2020
// Operation groups
2121
features: operations.Features;
22+
subscriptionFeatureRegistrations: operations.SubscriptionFeatureRegistrations;
2223

2324
/**
2425
* Initializes a new instance of the FeatureClient class.
25-
* @param credentials Credentials needed for the client to connect to Azure.
26-
* @param subscriptionId The ID of the target subscription.
26+
* @param credentials Credentials needed for the client to connect to Azure. Credentials
27+
* implementing the TokenCredential interface from the @azure/identity package are recommended. For
28+
* more information about these credentials, see
29+
* {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the
30+
* ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and
31+
* @azure/ms-rest-browserauth are also supported.
32+
* @param subscriptionId The Azure subscription ID.
33+
* @param providerNamespace The provider namespace.
2734
* @param [options] The parameter options
2835
*/
29-
constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.FeatureClientOptions) {
30-
super(credentials, subscriptionId, options);
36+
constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, providerNamespace: string, options?: Models.FeatureClientOptions) {
37+
super(credentials, subscriptionId, providerNamespace, options);
3138
this.features = new operations.Features(this);
39+
this.subscriptionFeatureRegistrations = new operations.SubscriptionFeatureRegistrations(this);
3240
}
3341

3442
/**
3543
* Lists all of the available Microsoft.Features REST API operations.
44+
* @param apiVersion The API version to use for this operation.
3645
* @param [options] The optional parameters
3746
* @returns Promise<Models.ListOperationsResponse>
3847
*/
39-
listOperations(options?: msRest.RequestOptionsBase): Promise<Models.ListOperationsResponse>;
48+
listOperations(apiVersion: string, options?: msRest.RequestOptionsBase): Promise<Models.ListOperationsResponse>;
4049
/**
50+
* @param apiVersion The API version to use for this operation.
4151
* @param callback The callback
4252
*/
43-
listOperations(callback: msRest.ServiceCallback<Models.OperationListResult>): void;
53+
listOperations(apiVersion: string, callback: msRest.ServiceCallback<Models.OperationListResult>): void;
4454
/**
55+
* @param apiVersion The API version to use for this operation.
4556
* @param options The optional parameters
4657
* @param callback The callback
4758
*/
48-
listOperations(options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback<Models.OperationListResult>): void;
49-
listOperations(options?: msRest.RequestOptionsBase | msRest.ServiceCallback<Models.OperationListResult>, callback?: msRest.ServiceCallback<Models.OperationListResult>): Promise<Models.ListOperationsResponse> {
59+
listOperations(apiVersion: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback<Models.OperationListResult>): void;
60+
listOperations(apiVersion: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback<Models.OperationListResult>, callback?: msRest.ServiceCallback<Models.OperationListResult>): Promise<Models.ListOperationsResponse> {
5061
return this.sendOperationRequest(
5162
{
63+
apiVersion,
5264
options
5365
},
5466
listOperationsOperationSpec,
@@ -58,25 +70,29 @@ class FeatureClient extends FeatureClientContext {
5870
/**
5971
* Lists all of the available Microsoft.Features REST API operations.
6072
* @param nextPageLink The NextLink from the previous successful call to List operation.
73+
* @param apiVersion The API version to use for this operation.
6174
* @param [options] The optional parameters
6275
* @returns Promise<Models.ListOperationsNextResponse>
6376
*/
64-
listOperationsNext(nextPageLink: string, options?: msRest.RequestOptionsBase): Promise<Models.ListOperationsNextResponse>;
77+
listOperationsNext(nextPageLink: string, apiVersion: string, options?: msRest.RequestOptionsBase): Promise<Models.ListOperationsNextResponse>;
6578
/**
6679
* @param nextPageLink The NextLink from the previous successful call to List operation.
80+
* @param apiVersion The API version to use for this operation.
6781
* @param callback The callback
6882
*/
69-
listOperationsNext(nextPageLink: string, callback: msRest.ServiceCallback<Models.OperationListResult>): void;
83+
listOperationsNext(nextPageLink: string, apiVersion: string, callback: msRest.ServiceCallback<Models.OperationListResult>): void;
7084
/**
7185
* @param nextPageLink The NextLink from the previous successful call to List operation.
86+
* @param apiVersion The API version to use for this operation.
7287
* @param options The optional parameters
7388
* @param callback The callback
7489
*/
75-
listOperationsNext(nextPageLink: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback<Models.OperationListResult>): void;
76-
listOperationsNext(nextPageLink: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback<Models.OperationListResult>, callback?: msRest.ServiceCallback<Models.OperationListResult>): Promise<Models.ListOperationsNextResponse> {
90+
listOperationsNext(nextPageLink: string, apiVersion: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback<Models.OperationListResult>): void;
91+
listOperationsNext(nextPageLink: string, apiVersion: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback<Models.OperationListResult>, callback?: msRest.ServiceCallback<Models.OperationListResult>): Promise<Models.ListOperationsNextResponse> {
7792
return this.sendOperationRequest(
7893
{
7994
nextPageLink,
95+
apiVersion,
8096
options
8197
},
8298
listOperationsNextOperationSpec,
@@ -100,7 +116,7 @@ const listOperationsOperationSpec: msRest.OperationSpec = {
100116
bodyMapper: Mappers.OperationListResult
101117
},
102118
default: {
103-
bodyMapper: Mappers.CloudError
119+
bodyMapper: Mappers.ErrorResponse
104120
}
105121
},
106122
serializer
@@ -113,6 +129,9 @@ const listOperationsNextOperationSpec: msRest.OperationSpec = {
113129
urlParameters: [
114130
Parameters.nextPageLink
115131
],
132+
queryParameters: [
133+
Parameters.apiVersion
134+
],
116135
headerParameters: [
117136
Parameters.acceptLanguage
118137
],
@@ -121,7 +140,7 @@ const listOperationsNextOperationSpec: msRest.OperationSpec = {
121140
bodyMapper: Mappers.OperationListResult
122141
},
123142
default: {
124-
bodyMapper: Mappers.CloudError
143+
bodyMapper: Mappers.ErrorResponse
125144
}
126145
},
127146
serializer

0 commit comments

Comments
 (0)