Skip to content

Commit b77a2a4

Browse files
colawwjdw511214992ramya-rao-a
authored
arm-eventgrid-release (#15791)
* arm-eventgrid-release * update package.json * Update sdk/eventgrid/arm-eventgrid/README.md Co-authored-by: Ramya Rao <[email protected]> Co-authored-by: Wei Dong <[email protected]> Co-authored-by: Ramya Rao <[email protected]>
1 parent bb833fc commit b77a2a4

25 files changed

+624
-514
lines changed

sdk/eventgrid/arm-eventgrid/README.md

Lines changed: 57 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,101 @@
11
## Azure EventGridManagementClient SDK for JavaScript
22

3-
This package contains an isomorphic SDK for EventGridManagementClient.
3+
This package contains an isomorphic SDK (runs both in Node.js and in browsers) for EventGridManagementClient.
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-eventgrid` 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-eventgrid
22+
npm install --save @azure/arm-eventgrid @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 get domains 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 get domains 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 { EventGridManagementClient } = require("@azure/arm-eventgrid");
3346
const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"];
3447

35-
msRestNodeAuth.interactiveLogin().then((creds) => {
36-
const client = new EventGridManagementClient(creds, subscriptionId);
37-
const resourceGroupName = "testresourceGroupName";
38-
const domainName = "testdomainName";
39-
client.domains.get(resourceGroupName, domainName).then((result) => {
40-
console.log("The result is:");
41-
console.log(result);
42-
});
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 EventGridManagementClient(creds, subscriptionId);
52+
const resourceGroupName = "testresourceGroupName";
53+
const domainName = "testdomainName";
54+
client.domains.get(resourceGroupName, domainName).then((result) => {
55+
console.log("The result is:");
56+
console.log(result);
4357
}).catch((err) => {
58+
console.log("An error occurred:");
4459
console.error(err);
4560
});
4661
```
4762

48-
#### browser - Authentication, client creation and get domains as an example written in JavaScript.
63+
#### browser - Authentication, client creation, and get domains as an example written in JavaScript.
4964

50-
##### Install @azure/ms-rest-browserauth
51-
52-
```bash
53-
npm install @azure/ms-rest-browserauth
54-
```
65+
In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser.
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.
5568

5669
##### Sample code
5770

58-
See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser.
59-
6071
- index.html
72+
6173
```html
6274
<!DOCTYPE html>
6375
<html lang="en">
6476
<head>
6577
<title>@azure/arm-eventgrid sample</title>
66-
<script src="node_modules/@azure/ms-rest-js/dist/msRest.browser.js"></script>
6778
<script src="node_modules/@azure/ms-rest-azure-js/dist/msRestAzure.js"></script>
68-
<script src="node_modules/@azure/ms-rest-browserauth/dist/msAuth.js"></script>
79+
<script src="node_modules/@azure/identity/dist/index.js"></script>
6980
<script src="node_modules/@azure/arm-eventgrid/dist/arm-eventgrid.js"></script>
7081
<script type="text/javascript">
7182
const subscriptionId = "<Subscription_Id>";
72-
const authManager = new msAuth.AuthManager({
83+
// Create credentials using the `@azure/identity` package.
84+
// Please note that you can also use credentials from the `@azure/ms-rest-browserauth` package instead.
85+
const credential = new InteractiveBrowserCredential(
86+
{
7387
clientId: "<client id for your Azure AD app>",
7488
tenant: "<optional tenant for your organization>"
7589
});
76-
authManager.finalizeLogin().then((res) => {
77-
if (!res.isLoggedIn) {
78-
// may cause redirects
79-
authManager.login();
80-
}
81-
const client = new Azure.ArmEventgrid.EventGridManagementClient(res.creds, subscriptionId);
82-
const resourceGroupName = "testresourceGroupName";
83-
const domainName = "testdomainName";
84-
client.domains.get(resourceGroupName, domainName).then((result) => {
85-
console.log("The result is:");
86-
console.log(result);
87-
}).catch((err) => {
88-
console.log("An error occurred:");
89-
console.error(err);
90-
});
90+
const client = new Azure.ArmEventgrid.EventGridManagementClient(creds, subscriptionId);
91+
const resourceGroupName = "testresourceGroupName";
92+
const domainName = "testdomainName";
93+
client.domains.get(resourceGroupName, domainName).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);
9199
});
92100
</script>
93101
</head>

sdk/eventgrid/arm-eventgrid/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
"name": "@azure/arm-eventgrid",
33
"author": "Microsoft Corporation",
44
"description": "EventGridManagementClient Library with typescript type definitions for node.js and browser.",
5-
"version": "10.0.0",
5+
"version": "11.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,7 +21,7 @@
2021
"module": "./esm/eventGridManagementClient.js",
2122
"types": "./esm/eventGridManagementClient.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",

sdk/eventgrid/arm-eventgrid/src/eventGridManagementClient.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
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";
1314
import * as operations from "./operations";
@@ -35,12 +36,17 @@ class EventGridManagementClient extends EventGridManagementClientContext {
3536

3637
/**
3738
* Initializes a new instance of the EventGridManagementClient class.
38-
* @param credentials Credentials needed for the client to connect to Azure.
39+
* @param credentials Credentials needed for the client to connect to Azure. Credentials
40+
* implementing the TokenCredential interface from the @azure/identity package are recommended. For
41+
* more information about these credentials, see
42+
* {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the
43+
* ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and
44+
* @azure/ms-rest-browserauth are also supported.
3945
* @param subscriptionId Subscription credentials that uniquely identify a Microsoft Azure
4046
* subscription. The subscription ID forms part of the URI for every service call.
4147
* @param [options] The parameter options
4248
*/
43-
constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.EventGridManagementClientOptions) {
49+
constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.EventGridManagementClientOptions) {
4450
super(credentials, subscriptionId, options);
4551
this.domains = new operations.Domains(this);
4652
this.domainTopics = new operations.DomainTopics(this);

sdk/eventgrid/arm-eventgrid/src/eventGridManagementClientContext.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,29 @@
1010
import * as Models from "./models";
1111
import * as msRest from "@azure/ms-rest-js";
1212
import * as msRestAzure from "@azure/ms-rest-azure-js";
13+
import { TokenCredential } from "@azure/core-auth";
1314

1415
const packageName = "@azure/arm-eventgrid";
15-
const packageVersion = "10.0.0";
16+
const packageVersion = "11.0.0";
1617

1718
export class EventGridManagementClientContext extends msRestAzure.AzureServiceClient {
18-
credentials: msRest.ServiceClientCredentials;
19+
credentials: msRest.ServiceClientCredentials | TokenCredential;
1920
subscriptionId: string;
2021
apiVersion?: string;
2122

2223
/**
2324
* Initializes a new instance of the EventGridManagementClient class.
24-
* @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.
2531
* @param subscriptionId Subscription credentials that uniquely identify a Microsoft Azure
2632
* subscription. The subscription ID forms part of the URI for every service call.
2733
* @param [options] The parameter options
2834
*/
29-
constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.EventGridManagementClientOptions) {
35+
constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.EventGridManagementClientOptions) {
3036
if (credentials == undefined) {
3137
throw new Error('\'credentials\' cannot be null.');
3238
}
@@ -44,7 +50,7 @@ export class EventGridManagementClientContext extends msRestAzure.AzureServiceCl
4450

4551
super(credentials, options);
4652

47-
this.apiVersion = '2020-10-15-preview';
53+
this.apiVersion = '2021-06-01-preview';
4854
this.acceptLanguage = 'en-US';
4955
this.longRunningOperationRetryTimeout = 30;
5056
this.baseUri = options.baseUri || this.baseUri || "https://management.azure.com";

sdk/eventgrid/arm-eventgrid/src/models/domainTopicsMappers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export {
5454
PartnerNamespace,
5555
PartnerRegistration,
5656
PartnerTopic,
57-
PartnerTopicType,
5857
PrivateEndpoint,
5958
PrivateEndpointConnection,
6059
Resource,

sdk/eventgrid/arm-eventgrid/src/models/domainsMappers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ export {
5757
PartnerNamespace,
5858
PartnerRegistration,
5959
PartnerTopic,
60-
PartnerTopicType,
6160
PrivateEndpoint,
6261
PrivateEndpointConnection,
6362
Resource,

sdk/eventgrid/arm-eventgrid/src/models/eventChannelsMappers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export {
5454
PartnerNamespace,
5555
PartnerRegistration,
5656
PartnerTopic,
57-
PartnerTopicType,
5857
PrivateEndpoint,
5958
PrivateEndpointConnection,
6059
Resource,

sdk/eventgrid/arm-eventgrid/src/models/eventSubscriptionsMappers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ export {
5757
PartnerNamespace,
5858
PartnerRegistration,
5959
PartnerTopic,
60-
PartnerTopicType,
6160
PrivateEndpoint,
6261
PrivateEndpointConnection,
6362
Resource,

sdk/eventgrid/arm-eventgrid/src/models/extensionTopicsMappers.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ export {
5353
PartnerNamespace,
5454
PartnerRegistration,
5555
PartnerTopic,
56-
PartnerTopicType,
5756
PrivateEndpoint,
5857
PrivateEndpointConnection,
5958
Resource,

0 commit comments

Comments
 (0)