Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoPR @azure/arm-policy] [Hub Generated] Updating definition of subscriptionId parameter for resources APIs in stable/2021-04-01 #4873

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 16 additions & 25 deletions sdk/policy/arm-policy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,28 @@ npm install @azure/arm-policy
##### Install @azure/ms-rest-nodeauth

- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`.

```bash
npm install @azure/ms-rest-nodeauth@"^3.0.0"
```

##### Sample code

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

```typescript
const msRestNodeAuth = require("@azure/ms-rest-nodeauth");
const { PolicyClient } = require("@azure/arm-policy");
const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"];

msRestNodeAuth
.interactiveLogin()
.then((creds) => {
const client = new PolicyClient(creds, subscriptionId);
const policyMode = "testpolicyMode";
client.dataPolicyManifests.getByPolicyMode(policyMode).then((result) => {
console.log("The result is:");
console.log(result);
});
})
.catch((err) => {
console.error(err);
msRestNodeAuth.interactiveLogin().then((creds) => {
const client = new PolicyClient(creds, subscriptionId);
const policyMode = "testpolicyMode";
client.dataPolicyManifests.getByPolicyMode(policyMode).then((result) => {
console.log("The result is:");
console.log(result);
});
}).catch((err) => {
console.error(err);
});
```

#### browser - Authentication, client creation and getByPolicyMode dataPolicyManifests as an example written in JavaScript.
Expand All @@ -62,7 +57,6 @@ npm install @azure/ms-rest-browserauth
See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser.

- index.html

```html
<!DOCTYPE html>
<html lang="en">
Expand All @@ -85,16 +79,13 @@ See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to
}
const client = new Azure.ArmPolicy.PolicyClient(res.creds, subscriptionId);
const policyMode = "testpolicyMode";
client.dataPolicyManifests
.getByPolicyMode(policyMode)
.then((result) => {
console.log("The result is:");
console.log(result);
})
.catch((err) => {
console.log("An error occurred:");
console.error(err);
});
client.dataPolicyManifests.getByPolicyMode(policyMode).then((result) => {
console.log("The result is:");
console.log(result);
}).catch((err) => {
console.log("An error occurred:");
console.error(err);
});
});
</script>
</head>
Expand Down
10 changes: 8 additions & 2 deletions sdk/policy/arm-policy/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import sourcemaps from "rollup-plugin-sourcemaps";
*/
const config = {
input: "./esm/policyClient.js",
external: ["@azure/ms-rest-js", "@azure/ms-rest-azure-js"],
external: [
"@azure/ms-rest-js",
"@azure/ms-rest-azure-js"
],
output: {
file: "./dist/arm-policy.js",
format: "umd",
Expand All @@ -25,7 +28,10 @@ const config = {
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/`
},
plugins: [nodeResolve({ mainFields: ["module", "main"] }), sourcemaps()]
plugins: [
nodeResolve({ mainFields: ['module', 'main'] }),
sourcemaps()
]
};

export default config;
Loading