diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 6b58dab8c319..035065ca35d2 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -1957,22 +1957,6 @@ packages: rollup: 2.79.1 dev: false - /@rollup/plugin-node-resolve/8.4.0_rollup@2.79.1: - resolution: {integrity: sha512-LFqKdRLn0ShtQyf6SBYO69bGE1upV6wUhBX0vFOUnLAyzx5cwp8svA0eHUnu8+YU57XOkrMtfG63QOpQx25pHQ==} - engines: {node: '>= 8.0.0'} - peerDependencies: - rollup: ^1.20.0||^2.0.0 - dependencies: - '@rollup/pluginutils': 3.1.0_rollup@2.79.1 - '@types/resolve': 1.17.1 - builtin-modules: 3.3.0 - deep-freeze: 0.0.1 - deepmerge: 4.3.0 - is-module: 1.0.0 - resolve: 1.22.1 - rollup: 2.79.1 - dev: false - /@rollup/plugin-replace/2.4.2_rollup@2.79.1: resolution: {integrity: sha512-IGcu+cydlUMZ5En85jxHH4qj2hta/11BHq95iHEyb2sbgiN0eCdzvUcHw5gt9pBL5lTi4JDYJ1acCoMGpTvEZg==} peerDependencies: @@ -3775,10 +3759,6 @@ packages: engines: {node: '>=4.0.0'} dev: false - /deep-freeze/0.0.1: - resolution: {integrity: sha512-Z+z8HiAvsGwmjqlphnHW5oz6yWlOwu6EQfFTjmeTWlDeda3FS2yv3jhq35TX/ewmsnqB+RX2IdsIOyjJCQN5tg==} - dev: false - /deep-is/0.1.4: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} dev: false @@ -3914,7 +3894,7 @@ packages: dependencies: semver: 7.3.8 shelljs: 0.8.5 - typescript: 5.0.0-dev.20230207 + typescript: 5.0.0-dev.20230208 dev: false /downlevel-dts/0.7.0: @@ -8799,8 +8779,8 @@ packages: hasBin: true dev: false - /typescript/5.0.0-dev.20230207: - resolution: {integrity: sha512-MBas9Ly9cx5yODCQZFKjteVtRa8//VshqSThNpX8D3XxPQEG+yBhtizEUPwrc2kLx33xnr7qGABEifZeepuKwg==} + /typescript/5.0.0-dev.20230208: + resolution: {integrity: sha512-FkUy5kJ7XmLYxej9g9Lq4FMw3P6YjKuesa+1YoLvz2lHZuRuf91VxLsj9DWtknGCmjOVvyu+eefaeVknGTiI/Q==} engines: {node: '>=4.2.0'} hasBin: true dev: false @@ -10347,23 +10327,31 @@ packages: dev: false file:projects/arm-authorization.tgz: - resolution: {integrity: sha512-a279eju1IqROwR2QZTVCiOFVazJCP5W4jh3htV1oDJxbsP8fLYMy62M1Lk8wWNd+bZiUuq0kMwdDQL3mWGgNtg==, tarball: file:projects/arm-authorization.tgz} + resolution: {integrity: sha512-0yeFid/o7ubq+sZInyR+7LavWTe8N/rR5jGl7Fy8d9gkRf92RdFAgRbgBix8kJip5tdAXYbzPhnkEVmP3EWjVw==, tarball: file:projects/arm-authorization.tgz} name: '@rush-temp/arm-authorization' version: 0.0.0 dependencies: - '@microsoft/api-extractor': 7.34.3 + '@azure/identity': 2.1.0 + '@microsoft/api-extractor': 7.34.3_@types+node@14.18.36 '@rollup/plugin-commonjs': 21.1.0_rollup@2.79.1 '@rollup/plugin-json': 4.1.0_rollup@2.79.1 - '@rollup/plugin-multi-entry': 3.0.1_rollup@2.79.1 - '@rollup/plugin-node-resolve': 8.4.0_rollup@2.79.1 + '@rollup/plugin-multi-entry': 4.1.0_rollup@2.79.1 + '@rollup/plugin-node-resolve': 13.3.0_rollup@2.79.1 + '@types/chai': 4.3.4 + '@types/node': 14.18.36 + chai: 4.3.7 + cross-env: 7.0.3 + dotenv: 8.6.0 mkdirp: 1.0.4 + mocha: 7.2.0 + rimraf: 3.0.2 rollup: 2.79.1 - rollup-plugin-sourcemaps: 0.6.3_rollup@2.79.1 + rollup-plugin-sourcemaps: 0.6.3_p2gydaekoyjvl5wd3ixslt7iq4 tslib: 2.5.0 - typescript: 4.2.4 + typescript: 4.8.4 uglify-js: 3.17.4 transitivePeerDependencies: - - '@types/node' + - supports-color dev: false file:projects/arm-automanage.tgz: @@ -16582,7 +16570,7 @@ packages: dev: false file:projects/cosmos.tgz: - resolution: {integrity: sha512-dXVFPuOZHo4tN5g/MQLa2PrQ+XohVF/rQzsVd4F0bQYLGSaVN5LX9D9398fbBdPphbKZREveEeuvROBTGH+yjA==, tarball: file:projects/cosmos.tgz} + resolution: {integrity: sha512-eRIXj9ZOIB+2R29nFpAx8TzLwZQQZ96HeBk5lhek323XM5B2hKGHdJ+cl48aaWqcw7jt2QMgedJWrRfJjOMfAw==, tarball: file:projects/cosmos.tgz} name: '@rush-temp/cosmos' version: 0.0.0 dependencies: diff --git a/sdk/authorization/arm-authorization/CHANGELOG.md b/sdk/authorization/arm-authorization/CHANGELOG.md index 95bb2ca96bb0..ce8e02a7f0ba 100644 --- a/sdk/authorization/arm-authorization/CHANGELOG.md +++ b/sdk/authorization/arm-authorization/CHANGELOG.md @@ -1,38 +1,11 @@ # Release History + +## 9.0.0-beta.4 (2023-02-08) -## 9.0.0-beta.4 (Unreleased) +The package of @azure/arm-authorization is using our next generation design principles since version 9.0.0-beta.4, which contains breaking changes. -### Features Added +To understand the detail of the change, please refer to [Changelog](https://aka.ms/js-track2-changelog). -### Breaking Changes +To migrate the existing applications to the latest version, please refer to [Migration Guide](https://aka.ms/js-track2-migration-guide). -### Bugs Fixed - -### Other Changes - -## 9.0.0-beta.3 (2022-10-08) - -**Bugs Fixed** - - - revert credential scopes - -## 9.0.0-beta.2 (2022-09-30) - -**Bugs Fixed** - - - fix better user experience of credential scopes in government cloud - -## 9.0.0-beta.1 (2021-10-09) - -This is the first preview for the new version of the `@azure/arm-authorization` package that follows the new [guidelines for TypeScript SDKs](https://azure.github.io/azure-sdk/typescript_introduction.html) for Azure services. - -While this package remains auto generated, the SDK generator itself has undergone changes to comply with the above guidelines in order to generate packages that are idiomatic to the JavaScript/TypeScript ecosystem and consistent with other packages for Azure services. For more on this, please see [State of the Azure SDK 2021](https://devblogs.microsoft.com/azure-sdk/state-of-the-azure-sdk-2021/). - -Please note that this version has breaking changes, all of which were made after careful consideration during the authoring of the guidelines and user studies. - -**Noteworthy changes and features** -- Authentication: The packages `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` are no longer supported. Use package [@azure/identity](https://www.npmjs.com/package/@azure/identity) instead. Select a credential from Azure Identity examples based on the authentication method of your choice. -- Callbacks: Method overloads that used callbacks have been removed and the use of promises is encouraged instead. -- List operations now return an iterable result that follows the `PagedAsyncIterableIterator` interface as opposed to the previous model where you had to make a new request using the link to the next page. -- Long running operations i.e. the Lro related object returned by methods whose names started with `begin`, now uses `pollUntilDone` to check whether the request is finished, instead of `pollUntilFinished`. To get the final result, use the corresponding method that will have the suffix `AndWait`. -- The SDK only supports ECMAScript 2015 (ES6) and beyond, all projects that referenced this SDK should be upgraded to use ES6. +To learn more, please refer to our documentation [Quick Start](https://aka.ms/js-track2-quickstart). diff --git a/sdk/authorization/arm-authorization/LICENSE b/sdk/authorization/arm-authorization/LICENSE index ccb63b166732..3a1d9b6f24f7 100644 --- a/sdk/authorization/arm-authorization/LICENSE +++ b/sdk/authorization/arm-authorization/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2021 Microsoft +Copyright (c) 2023 Microsoft Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/sdk/authorization/arm-authorization/README.md b/sdk/authorization/arm-authorization/README.md index 5170f33005f0..4b8d5fc6879b 100644 --- a/sdk/authorization/arm-authorization/README.md +++ b/sdk/authorization/arm-authorization/README.md @@ -6,7 +6,7 @@ Role based access control provides you a way to apply granular level policy admi [Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/authorization/arm-authorization) | [Package (NPM)](https://www.npmjs.com/package/@azure/arm-authorization) | -[API reference documentation](https://docs.microsoft.com/javascript/api/@azure/arm-authorization) | +[API reference documentation](https://docs.microsoft.com/javascript/api/@azure/arm-authorization?view=azure-node-preview) | [Samples](https://github.com/Azure-Samples/azure-samples-js-management) ## Getting started @@ -16,6 +16,8 @@ Role based access control provides you a way to apply granular level policy admi - [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule) - Latest versions of Safari, Chrome, Edge and Firefox. +See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details. + ### Prerequisites - An [Azure subscription][azure_sub]. @@ -33,9 +35,9 @@ npm install @azure/arm-authorization To create a client object to access the Azure AuthorizationManagement API, you will need the `endpoint` of your Azure AuthorizationManagement resource and a `credential`. The Azure AuthorizationManagement client can use Azure Active Directory credentials to authenticate. You can find the endpoint for your Azure AuthorizationManagement resource in the [Azure Portal][azure_portal]. -#### Using an Azure Active Directory Credential +You can authenticate with Azure Active Directory using a credential from the [@azure/identity][azure_identity] library or [an existing AAD Token](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token). -You can authenticate with Azure Active Directory using the [Azure Identity library][azure_identity]. To use the [DefaultAzureCredential][defaultazurecredential] provider shown below, or other credential providers provided with the Azure SDK, please install the `@azure/identity` package: +To use the [DefaultAzureCredential][defaultazurecredential] provider shown below, or other credential providers provided with the Azure SDK, please install the `@azure/identity` package: ```bash npm install @azure/identity @@ -45,13 +47,27 @@ You will also need to **register a new AAD application and grant access to Azure Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`. For more information about how to create an Azure AD Application check out [this guide](https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal). + ```javascript const { AuthorizationManagementClient } = require("@azure/arm-authorization"); const { DefaultAzureCredential } = require("@azure/identity"); +// For client-side applications running in the browser, use InteractiveBrowserCredential instead of DefaultAzureCredential. See https://aka.ms/azsdk/js/identity/examples for more details. + const subscriptionId = "00000000-0000-0000-0000-000000000000"; const client = new AuthorizationManagementClient(new DefaultAzureCredential(), subscriptionId); + +// For client-side applications running in the browser, use this code instead: +// const credential = new InteractiveBrowserCredential({ +// tenantId: "", +// clientId: "" +// }); +// const client = new AuthorizationManagementClient(credential, subscriptionId); ``` + +### JavaScript Bundle +To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling). + ## Key concepts ### AuthorizationManagementClient diff --git a/sdk/authorization/arm-authorization/_meta.json b/sdk/authorization/arm-authorization/_meta.json index d11bfb4ce957..aa1a48333626 100644 --- a/sdk/authorization/arm-authorization/_meta.json +++ b/sdk/authorization/arm-authorization/_meta.json @@ -1,7 +1,8 @@ { "commit": "f9e4843e2ed3494e8bd66a92c3e7f65655f58f46", - "readme": "specification/authorization/resource-manager/readme.md", - "autorest_command": "autorest --version=3.1.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --typescript-sdks-folder=D:\\mydev\\azure-sdk-for-js ../azure-rest-api-specs/specification/authorization/resource-manager/readme.md --use=@autorest/typescript@6.0.0-beta.12", + "readme": "specification\\authorization\\resource-manager\\readme.md", + "autorest_command": "autorest --version=3.9.3 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\Git\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\authorization\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-rc.7 --tag=package-2020-10-01-preview --generate-sample=true~", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "use": "@autorest/typescript@6.0.0-beta.12" + "release_tool": "@azure-tools/js-sdk-release-tools@2.6.1", + "use": "@autorest/typescript@6.0.0-rc.7" } \ No newline at end of file diff --git a/sdk/authorization/arm-authorization/api-extractor.json b/sdk/authorization/arm-authorization/api-extractor.json index 721910fd40b8..7c284110c453 100644 --- a/sdk/authorization/arm-authorization/api-extractor.json +++ b/sdk/authorization/arm-authorization/api-extractor.json @@ -1,18 +1,31 @@ { "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", - "mainEntryPointFilePath": "./dist-esm/index.d.ts", - "docModel": { "enabled": true }, - "apiReport": { "enabled": true, "reportFolder": "./review" }, + "mainEntryPointFilePath": "./dist-esm/src/index.d.ts", + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, "dtsRollup": { "enabled": true, "untrimmedFilePath": "", "publicTrimmedFilePath": "./types/arm-authorization.d.ts" }, "messages": { - "tsdocMessageReporting": { "default": { "logLevel": "none" } }, + "tsdocMessageReporting": { + "default": { + "logLevel": "none" + } + }, "extractorMessageReporting": { - "ae-missing-release-tag": { "logLevel": "none" }, - "ae-unresolved-link": { "logLevel": "none" } + "ae-missing-release-tag": { + "logLevel": "none" + }, + "ae-unresolved-link": { + "logLevel": "none" + } } } -} +} \ No newline at end of file diff --git a/sdk/authorization/arm-authorization/package.json b/sdk/authorization/arm-authorization/package.json index 6fd334475ff4..0842abdfef31 100644 --- a/sdk/authorization/arm-authorization/package.json +++ b/sdk/authorization/arm-authorization/package.json @@ -8,10 +8,10 @@ "node": ">=14.0.0" }, "dependencies": { - "@azure/core-paging": "^1.1.1", - "@azure/core-client": "^1.0.0", + "@azure/core-paging": "^1.2.0", + "@azure/core-client": "^1.6.1", "@azure/core-auth": "^1.3.0", - "@azure/core-rest-pipeline": "^1.1.0", + "@azure/core-rest-pipeline": "^1.8.0", "tslib": "^2.2.0" }, "keywords": [ @@ -23,21 +23,31 @@ ], "license": "MIT", "main": "./dist/index.js", - "module": "./dist-esm/index.js", + "module": "./dist-esm/src/index.js", "types": "./types/arm-authorization.d.ts", "devDependencies": { "@microsoft/api-extractor": "^7.31.1", "@rollup/plugin-commonjs": "^21.0.1", - "@rollup/plugin-json": "^4.0.0", - "@rollup/plugin-multi-entry": "^3.0.0", - "@rollup/plugin-node-resolve": "^8.0.0", + "@rollup/plugin-json": "^4.1.0", + "@rollup/plugin-multi-entry": "^4.1.0", + "@rollup/plugin-node-resolve": "^13.1.3", "mkdirp": "^1.0.4", - "rollup": "^2.0.0", + "rollup": "^2.66.1", "rollup-plugin-sourcemaps": "^0.6.3", - "typescript": "~4.2.0", - "uglify-js": "^3.4.9" + "typescript": "~4.8.0", + "uglify-js": "^3.4.9", + "rimraf": "^3.0.0", + "dotenv": "^8.2.0", + "@azure/identity": "^2.0.1", + "@azure-tools/test-recorder": "^2.0.0", + "@azure-tools/test-credential": "^1.0.0", + "mocha": "^7.1.1", + "@types/chai": "^4.2.8", + "chai": "^4.2.0", + "cross-env": "^7.0.2", + "@types/node": "^14.0.0", + "@azure/dev-tool": "^1.0.0" }, - "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/authorization/arm-authorization", "repository": { "type": "git", "url": "https://github.com/Azure/azure-sdk-for-js.git" @@ -64,14 +74,14 @@ "types/*" ], "scripts": { - "build": "tsc && rollup -c 2>&1 && npm run minify && mkdirp ./review && npm run extract-api", + "build": "npm run clean && tsc && rollup -c 2>&1 && npm run minify && mkdirp ./review && npm run extract-api", "minify": "uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js", "prepack": "npm run build", "pack": "npm pack 2>&1", "extract-api": "api-extractor run --local", "lint": "echo skipped", "audit": "echo skipped", - "clean": "echo skipped", + "clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log", "build:node": "echo skipped", "build:browser": "echo skipped", "build:test": "echo skipped", @@ -79,18 +89,33 @@ "check-format": "echo skipped", "execute:samples": "echo skipped", "format": "echo skipped", - "test": "echo skipped", - "prebuild": "echo skipped", + "test": "npm run integration-test", "test:node": "echo skipped", "test:browser": "echo skipped", - "unit-test": "echo skipped", - "unit-test:node": "echo skipped", + "unit-test": "npm run unit-test:node && npm run unit-test:browser", + "unit-test:node": "cross-env TEST_MODE=playback npm run integration-test:node", "unit-test:browser": "echo skipped", - "integration-test:browser": "echo skipped", - "integration-test:node": "echo skipped", - "integration-test": "echo skipped", - "docs": "echo skipped" + "integration-test": "npm run integration-test:node && npm run integration-test:browser", + "integration-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 'test/*.ts'", + "integration-test:browser": "echo skipped" }, "sideEffects": false, - "autoPublish": true -} + "//metadata": { + "constantPaths": [ + { + "path": "src/authorizationManagementClient.ts", + "prefix": "packageDetails" + } + ] + }, + "autoPublish": true, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/authorization/arm-authorization", + "//sampleConfiguration": { + "productName": "", + "productSlugs": [ + "azure" + ], + "disableDocsMs": true, + "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-authorization?view=azure-node-preview" + } +} \ No newline at end of file diff --git a/sdk/authorization/arm-authorization/recordings/node/my_test/recording_sample_test.json b/sdk/authorization/arm-authorization/recordings/node/my_test/recording_sample_test.json new file mode 100644 index 000000000000..f721723386d8 --- /dev/null +++ b/sdk/authorization/arm-authorization/recordings/node/my_test/recording_sample_test.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} diff --git a/sdk/authorization/arm-authorization/review/arm-authorization.api.md b/sdk/authorization/arm-authorization/review/arm-authorization.api.md index c3712ab2a018..dd8fa53215be 100644 --- a/sdk/authorization/arm-authorization/review/arm-authorization.api.md +++ b/sdk/authorization/arm-authorization/review/arm-authorization.api.md @@ -34,9 +34,13 @@ export interface ApprovalStage { export type AssignmentType = string; // @public (undocumented) -export class AuthorizationManagementClient extends AuthorizationManagementClientContext { +export class AuthorizationManagementClient extends coreClient.ServiceClient { + // (undocumented) + $host: string; constructor(credentials: coreAuth.TokenCredential, subscriptionId: string, options?: AuthorizationManagementClientOptionalParams); // (undocumented) + apiVersion: string; + // (undocumented) eligibleChildResources: EligibleChildResources; // (undocumented) roleAssignments: RoleAssignments; @@ -56,15 +60,6 @@ export class AuthorizationManagementClient extends AuthorizationManagementClient roleManagementPolicies: RoleManagementPolicies; // (undocumented) roleManagementPolicyAssignments: RoleManagementPolicyAssignments; -} - -// @public (undocumented) -export class AuthorizationManagementClientContext extends coreClient.ServiceClient { - // (undocumented) - $host: string; - constructor(credentials: coreAuth.TokenCredential, subscriptionId: string, options?: AuthorizationManagementClientOptionalParams); - // (undocumented) - apiVersion: string; // (undocumented) subscriptionId: string; } @@ -101,7 +96,6 @@ export interface EligibleChildResources { // @public export interface EligibleChildResourcesGetNextOptionalParams extends coreClient.OperationOptions { - filter?: string; } // @public @@ -173,197 +167,129 @@ export interface ExpandedPropertiesScope { type?: string; } +// @public +export function getContinuationToken(page: unknown): string | undefined; + // @public export enum KnownApprovalMode { - // (undocumented) NoApproval = "NoApproval", - // (undocumented) Parallel = "Parallel", - // (undocumented) Serial = "Serial", - // (undocumented) SingleStage = "SingleStage" } // @public export enum KnownAssignmentType { - // (undocumented) Activated = "Activated", - // (undocumented) Assigned = "Assigned" } // @public export enum KnownEnablementRules { - // (undocumented) Justification = "Justification", - // (undocumented) MultiFactorAuthentication = "MultiFactorAuthentication", - // (undocumented) Ticketing = "Ticketing" } // @public export enum KnownMemberType { - // (undocumented) Direct = "Direct", - // (undocumented) Group = "Group", - // (undocumented) Inherited = "Inherited" } // @public export enum KnownNotificationDeliveryMechanism { - // (undocumented) Email = "Email" } // @public export enum KnownNotificationLevel { - // (undocumented) All = "All", - // (undocumented) Critical = "Critical", - // (undocumented) None = "None" } // @public export enum KnownPrincipalType { - // (undocumented) Application = "Application", - // (undocumented) Device = "Device", - // (undocumented) DirectoryObjectOrGroup = "DirectoryObjectOrGroup", - // (undocumented) DirectoryRoleTemplate = "DirectoryRoleTemplate", - // (undocumented) Everyone = "Everyone", - // (undocumented) ForeignGroup = "ForeignGroup", - // (undocumented) Group = "Group", - // (undocumented) MSI = "MSI", - // (undocumented) ServicePrincipal = "ServicePrincipal", - // (undocumented) Unknown = "Unknown", - // (undocumented) User = "User" } // @public export enum KnownRecipientType { - // (undocumented) Admin = "Admin", - // (undocumented) Approver = "Approver", - // (undocumented) Requestor = "Requestor" } // @public export enum KnownRequestType { - // (undocumented) AdminAssign = "AdminAssign", - // (undocumented) AdminExtend = "AdminExtend", - // (undocumented) AdminRemove = "AdminRemove", - // (undocumented) AdminRenew = "AdminRenew", - // (undocumented) AdminUpdate = "AdminUpdate", - // (undocumented) SelfActivate = "SelfActivate", - // (undocumented) SelfDeactivate = "SelfDeactivate", - // (undocumented) SelfExtend = "SelfExtend", - // (undocumented) SelfRenew = "SelfRenew" } // @public export enum KnownRoleManagementPolicyRuleType { - // (undocumented) RoleManagementPolicyApprovalRule = "RoleManagementPolicyApprovalRule", - // (undocumented) RoleManagementPolicyAuthenticationContextRule = "RoleManagementPolicyAuthenticationContextRule", - // (undocumented) RoleManagementPolicyEnablementRule = "RoleManagementPolicyEnablementRule", - // (undocumented) RoleManagementPolicyExpirationRule = "RoleManagementPolicyExpirationRule", - // (undocumented) RoleManagementPolicyNotificationRule = "RoleManagementPolicyNotificationRule" } // @public export enum KnownStatus { - // (undocumented) Accepted = "Accepted", - // (undocumented) AdminApproved = "AdminApproved", - // (undocumented) AdminDenied = "AdminDenied", - // (undocumented) Canceled = "Canceled", - // (undocumented) Denied = "Denied", - // (undocumented) Failed = "Failed", - // (undocumented) FailedAsResourceIsLocked = "FailedAsResourceIsLocked", - // (undocumented) Granted = "Granted", - // (undocumented) Invalid = "Invalid", - // (undocumented) PendingAdminDecision = "PendingAdminDecision", - // (undocumented) PendingApproval = "PendingApproval", - // (undocumented) PendingApprovalProvisioning = "PendingApprovalProvisioning", - // (undocumented) PendingEvaluation = "PendingEvaluation", - // (undocumented) PendingExternalProvisioning = "PendingExternalProvisioning", - // (undocumented) PendingProvisioning = "PendingProvisioning", - // (undocumented) PendingRevocation = "PendingRevocation", - // (undocumented) PendingScheduleCreation = "PendingScheduleCreation", - // (undocumented) Provisioned = "Provisioned", - // (undocumented) ProvisioningStarted = "ProvisioningStarted", - // (undocumented) Revoked = "Revoked", - // (undocumented) ScheduleCreated = "ScheduleCreated", - // (undocumented) TimedOut = "TimedOut" } // @public export enum KnownType { - // (undocumented) AfterDateTime = "AfterDateTime", - // (undocumented) AfterDuration = "AfterDuration", - // (undocumented) NoExpiration = "NoExpiration" } // @public export enum KnownUserType { - // (undocumented) Group = "Group", - // (undocumented) User = "User" } @@ -578,7 +504,6 @@ export type RoleAssignmentScheduleInstancesGetResponse = RoleAssignmentScheduleI // @public export interface RoleAssignmentScheduleInstancesListForScopeNextOptionalParams extends coreClient.OperationOptions { - filter?: string; } // @public @@ -684,7 +609,6 @@ export type RoleAssignmentScheduleRequestsGetResponse = RoleAssignmentScheduleRe // @public export interface RoleAssignmentScheduleRequestsListForScopeNextOptionalParams extends coreClient.OperationOptions { - filter?: string; } // @public @@ -713,7 +637,6 @@ export type RoleAssignmentSchedulesGetResponse = RoleAssignmentSchedule; // @public export interface RoleAssignmentSchedulesListForScopeNextOptionalParams extends coreClient.OperationOptions { - filter?: string; } // @public @@ -775,8 +698,6 @@ export type RoleAssignmentsGetResponse = RoleAssignment; // @public export interface RoleAssignmentsListForResourceGroupNextOptionalParams extends coreClient.OperationOptions { - filter?: string; - tenantId?: string; } // @public @@ -793,8 +714,6 @@ export type RoleAssignmentsListForResourceGroupResponse = RoleAssignmentListResu // @public export interface RoleAssignmentsListForResourceNextOptionalParams extends coreClient.OperationOptions { - filter?: string; - tenantId?: string; } // @public @@ -811,8 +730,6 @@ export type RoleAssignmentsListForResourceResponse = RoleAssignmentListResult; // @public export interface RoleAssignmentsListForScopeNextOptionalParams extends coreClient.OperationOptions { - filter?: string; - tenantId?: string; } // @public @@ -829,8 +746,6 @@ export type RoleAssignmentsListForScopeResponse = RoleAssignmentListResult; // @public export interface RoleAssignmentsListForSubscriptionNextOptionalParams extends coreClient.OperationOptions { - filter?: string; - tenantId?: string; } // @public @@ -936,7 +851,6 @@ export type RoleEligibilityScheduleInstancesGetResponse = RoleEligibilitySchedul // @public export interface RoleEligibilityScheduleInstancesListForScopeNextOptionalParams extends coreClient.OperationOptions { - filter?: string; } // @public @@ -1041,7 +955,6 @@ export type RoleEligibilityScheduleRequestsGetResponse = RoleEligibilitySchedule // @public export interface RoleEligibilityScheduleRequestsListForScopeNextOptionalParams extends coreClient.OperationOptions { - filter?: string; } // @public @@ -1070,7 +983,6 @@ export type RoleEligibilitySchedulesGetResponse = RoleEligibilitySchedule; // @public export interface RoleEligibilitySchedulesListForScopeNextOptionalParams extends coreClient.OperationOptions { - filter?: string; } // @public @@ -1141,10 +1053,10 @@ export interface RoleManagementPolicy { } // @public -export type RoleManagementPolicyApprovalRule = RoleManagementPolicyRule & { +export interface RoleManagementPolicyApprovalRule extends RoleManagementPolicyRule { ruleType: "RoleManagementPolicyApprovalRule"; setting?: ApprovalSettings; -}; +} // @public export interface RoleManagementPolicyAssignment { @@ -1204,24 +1116,24 @@ export interface RoleManagementPolicyAssignmentsListForScopeOptionalParams exten export type RoleManagementPolicyAssignmentsListForScopeResponse = RoleManagementPolicyAssignmentListResult; // @public -export type RoleManagementPolicyAuthenticationContextRule = RoleManagementPolicyRule & { - ruleType: "RoleManagementPolicyAuthenticationContextRule"; - isEnabled?: boolean; +export interface RoleManagementPolicyAuthenticationContextRule extends RoleManagementPolicyRule { claimValue?: string; -}; + isEnabled?: boolean; + ruleType: "RoleManagementPolicyAuthenticationContextRule"; +} // @public -export type RoleManagementPolicyEnablementRule = RoleManagementPolicyRule & { - ruleType: "RoleManagementPolicyEnablementRule"; +export interface RoleManagementPolicyEnablementRule extends RoleManagementPolicyRule { enabledRules?: EnablementRules[]; -}; + ruleType: "RoleManagementPolicyEnablementRule"; +} // @public -export type RoleManagementPolicyExpirationRule = RoleManagementPolicyRule & { - ruleType: "RoleManagementPolicyExpirationRule"; +export interface RoleManagementPolicyExpirationRule extends RoleManagementPolicyRule { isExpirationRequired?: boolean; maximumDuration?: string; -}; + ruleType: "RoleManagementPolicyExpirationRule"; +} // @public export interface RoleManagementPolicyListResult { @@ -1230,14 +1142,14 @@ export interface RoleManagementPolicyListResult { } // @public -export type RoleManagementPolicyNotificationRule = RoleManagementPolicyRule & { - ruleType: "RoleManagementPolicyNotificationRule"; - notificationType?: NotificationDeliveryMechanism; +export interface RoleManagementPolicyNotificationRule extends RoleManagementPolicyRule { + isDefaultRecipientsEnabled?: boolean; notificationLevel?: NotificationLevel; - recipientType?: RecipientType; notificationRecipients?: string[]; - isDefaultRecipientsEnabled?: boolean; -}; + notificationType?: NotificationDeliveryMechanism; + recipientType?: RecipientType; + ruleType: "RoleManagementPolicyNotificationRule"; +} // @public export interface RoleManagementPolicyRule { @@ -1291,7 +1203,6 @@ export interface ValidationResponseErrorInfo { readonly message?: string; } - // (No @packageDocumentation comment for this package) ``` diff --git a/sdk/authorization/arm-authorization/rollup.config.js b/sdk/authorization/arm-authorization/rollup.config.js index 9be1955eb7f1..3f89d7309da5 100644 --- a/sdk/authorization/arm-authorization/rollup.config.js +++ b/sdk/authorization/arm-authorization/rollup.config.js @@ -14,62 +14,14 @@ import json from "@rollup/plugin-json"; import nodeBuiltins from "builtin-modules"; -/** - * Gets the proper configuration needed for rollup's commonJS plugin for @opentelemetry/api. - * - * NOTE: this manual configuration is only needed because OpenTelemetry uses an - * __exportStar downleveled helper function to declare its exports which confuses - * rollup's automatic discovery mechanism. - * - * @returns an object reference that can be `...`'d into your cjs() configuration. - */ -export function openTelemetryCommonJs() { - const namedExports = {}; - - for (const key of [ - "@opentelemetry/api", - "@azure/core-tracing/node_modules/@opentelemetry/api" - ]) { - namedExports[key] = [ - "SpanKind", - "TraceFlags", - "getSpan", - "setSpan", - "SpanStatusCode", - "getSpanContext", - "setSpanContext" - ]; - } - - const releasedOpenTelemetryVersions = ["0.10.2", "1.0.0-rc.0"]; - - for (const version of releasedOpenTelemetryVersions) { - namedExports[ - // working around a limitation in the rollup common.js plugin - it's not able to resolve these modules so the named exports listed above will not get applied. We have to drill down to the actual path. - `../../../common/temp/node_modules/.pnpm/@opentelemetry/api@${version}/node_modules/@opentelemetry/api/build/src/index.js` - ] = [ - "SpanKind", - "TraceFlags", - "getSpan", - "setSpan", - "StatusCode", - "CanonicalCode", - "getSpanContext", - "setSpanContext" - ]; - } - - return namedExports; -} - // #region Warning Handler /** - * A function that can determine whether a rollupwarning should be ignored. If + * A function that can determine whether a rollup warning should be ignored. If * the function returns `true`, then the warning will not be displayed. */ -function ignoreNiseSinonEvalWarnings(warning) { +function ignoreNiseSinonEval(warning) { return ( warning.code === "EVAL" && warning.id && @@ -78,17 +30,14 @@ function ignoreNiseSinonEvalWarnings(warning) { ); } -function ignoreChaiCircularDependencyWarnings(warning) { +function ignoreChaiCircularDependency(warning) { return ( warning.code === "CIRCULAR_DEPENDENCY" && warning.importer && warning.importer.includes("node_modules/chai") === true ); } -const warningInhibitors = [ - ignoreChaiCircularDependencyWarnings, - ignoreNiseSinonEvalWarnings -]; +const warningInhibitors = [ignoreChaiCircularDependency, ignoreNiseSinonEval]; /** * Construct a warning handler for the shared rollup configuration @@ -122,22 +71,7 @@ function makeBrowserTestConfig() { nodeResolve({ mainFields: ["module", "browser"] }), - cjs({ - namedExports: { - // Chai's strange internal architecture makes it impossible to statically - // analyze its exports. - chai: [ - "version", - "use", - "util", - "config", - "expect", - "should", - "assert" - ], - ...openTelemetryCommonJs() - } - }), + cjs(), json(), sourcemaps() //viz({ filename: "dist-test/browser-stats.html", sourcemap: true }) @@ -173,7 +107,7 @@ export function makeConfig(pkg, options) { ], output: { file: "dist/index.js", format: "cjs", sourcemap: true }, preserveSymlinks: false, - plugins: [sourcemaps(), nodeResolve(), cjs()] + plugins: [sourcemaps(), nodeResolve()] }; const config = [baseConfig]; diff --git a/sdk/authorization/arm-authorization/sample.env b/sdk/authorization/arm-authorization/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/authorization/arm-authorization/sample.env @@ -0,0 +1,4 @@ +# App registration secret for AAD authentication +AZURE_CLIENT_SECRET= +AZURE_CLIENT_ID= +AZURE_TENANT_ID= \ No newline at end of file diff --git a/sdk/authorization/arm-authorization/samples-dev/eligibleChildResourcesGetSample.ts b/sdk/authorization/arm-authorization/samples-dev/eligibleChildResourcesGetSample.ts new file mode 100644 index 000000000000..78433606341b --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/eligibleChildResourcesGetSample.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + EligibleChildResourcesGetOptionalParams, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get the child resources of a resource on which user has eligible access + * + * @summary Get the child resources of a resource on which user has eligible access + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetEligibleChildResourcesByScope.json + */ +async function getEligibleChildResourcesByScope() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const filter = "resourceType+eq+'resourcegroup'"; + const options: EligibleChildResourcesGetOptionalParams = { filter }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.eligibleChildResources.list(scope, options)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getEligibleChildResourcesByScope(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleAssignmentScheduleInstancesGetSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentScheduleInstancesGetSample.ts new file mode 100644 index 000000000000..5859ad796c11 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentScheduleInstancesGetSample.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified role assignment schedule instance. + * + * @summary Gets the specified role assignment schedule instance. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentScheduleInstanceByName.json + */ +async function getRoleAssignmentScheduleInstanceByName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleAssignmentScheduleInstanceName = + "ed9b8180-cef7-4c77-a63c-b8566ecfc412"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignmentScheduleInstances.get( + scope, + roleAssignmentScheduleInstanceName + ); + console.log(result); +} + +async function main() { + getRoleAssignmentScheduleInstanceByName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleAssignmentScheduleInstancesListForScopeSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentScheduleInstancesListForScopeSample.ts new file mode 100644 index 000000000000..60c6c596c8cc --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentScheduleInstancesListForScopeSample.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleAssignmentScheduleInstancesListForScopeOptionalParams, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets role assignment schedule instances of a role assignment schedule. + * + * @summary Gets role assignment schedule instances of a role assignment schedule. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentScheduleInstancesByScope.json + */ +async function getRoleAssignmentScheduleInstancesByScope() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const filter = "assignedTo('a3bb8764-cb92-4276-9d2a-ca1e895e55ea')"; + const options: RoleAssignmentScheduleInstancesListForScopeOptionalParams = { + filter + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleAssignmentScheduleInstances.listForScope( + scope, + options + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getRoleAssignmentScheduleInstancesByScope(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleAssignmentScheduleRequestsCancelSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentScheduleRequestsCancelSample.ts new file mode 100644 index 000000000000..39586a9dfa06 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentScheduleRequestsCancelSample.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Cancels a pending role assignment schedule request. + * + * @summary Cancels a pending role assignment schedule request. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/CancelRoleAssignmentScheduleRequestByName.json + */ +async function cancelRoleAssignmentScheduleRequestByName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleAssignmentScheduleRequestName = + "fea7a502-9a96-4806-a26f-eee560e52045"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignmentScheduleRequests.cancel( + scope, + roleAssignmentScheduleRequestName + ); + console.log(result); +} + +async function main() { + cancelRoleAssignmentScheduleRequestByName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleAssignmentScheduleRequestsCreateSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentScheduleRequestsCreateSample.ts new file mode 100644 index 000000000000..01d1032dc5cd --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentScheduleRequestsCreateSample.ts @@ -0,0 +1,66 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleAssignmentScheduleRequest, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates a role assignment schedule request. + * + * @summary Creates a role assignment schedule request. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/PutRoleAssignmentScheduleRequest.json + */ +async function putRoleAssignmentScheduleRequest() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleAssignmentScheduleRequestName = + "fea7a502-9a96-4806-a26f-eee560e52045"; + const parameters: RoleAssignmentScheduleRequest = { + condition: + "@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'", + conditionVersion: "1.0", + linkedRoleEligibilityScheduleId: "b1477448-2cc6-4ceb-93b4-54a202a89413", + principalId: "a3bb8764-cb92-4276-9d2a-ca1e895e55ea", + requestType: "SelfActivate", + roleDefinitionId: + "/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/roleDefinitions/c8d4ff99-41c3-41a8-9f60-21dfdad59608", + scheduleInfo: { + expiration: { + type: "AfterDuration", + duration: "PT8H", + endDateTime: undefined + }, + startDateTime: new Date("2020-09-09T21:35:27.91Z") + } + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignmentScheduleRequests.create( + scope, + roleAssignmentScheduleRequestName, + parameters + ); + console.log(result); +} + +async function main() { + putRoleAssignmentScheduleRequest(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleAssignmentScheduleRequestsGetSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentScheduleRequestsGetSample.ts new file mode 100644 index 000000000000..b3ced6a7d1fc --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentScheduleRequestsGetSample.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get the specified role assignment schedule request. + * + * @summary Get the specified role assignment schedule request. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentScheduleRequestByName.json + */ +async function getRoleAssignmentScheduleRequestByName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleAssignmentScheduleRequestName = + "fea7a502-9a96-4806-a26f-eee560e52045"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignmentScheduleRequests.get( + scope, + roleAssignmentScheduleRequestName + ); + console.log(result); +} + +async function main() { + getRoleAssignmentScheduleRequestByName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleAssignmentScheduleRequestsListForScopeSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentScheduleRequestsListForScopeSample.ts new file mode 100644 index 000000000000..283b3ef5df9b --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentScheduleRequestsListForScopeSample.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleAssignmentScheduleRequestsListForScopeOptionalParams, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets role assignment schedule requests for a scope. + * + * @summary Gets role assignment schedule requests for a scope. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentScheduleRequestByScope.json + */ +async function getRoleAssignmentScheduleRequestByScope() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const filter = "assignedTo('A3BB8764-CB92-4276-9D2A-CA1E895E55EA')"; + const options: RoleAssignmentScheduleRequestsListForScopeOptionalParams = { + filter + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleAssignmentScheduleRequests.listForScope( + scope, + options + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getRoleAssignmentScheduleRequestByScope(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleAssignmentSchedulesGetSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentSchedulesGetSample.ts new file mode 100644 index 000000000000..52c5ef87b6d6 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentSchedulesGetSample.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get the specified role assignment schedule for a resource scope + * + * @summary Get the specified role assignment schedule for a resource scope + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentScheduleByName.json + */ +async function getRoleAssignmentScheduleByName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleAssignmentScheduleName = "c9e264ff-3133-4776-a81a-ebc7c33c8ec6"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignmentSchedules.get( + scope, + roleAssignmentScheduleName + ); + console.log(result); +} + +async function main() { + getRoleAssignmentScheduleByName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleAssignmentSchedulesListForScopeSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentSchedulesListForScopeSample.ts new file mode 100644 index 000000000000..a8a03a0076f9 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentSchedulesListForScopeSample.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleAssignmentSchedulesListForScopeOptionalParams, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets role assignment schedules for a resource scope. + * + * @summary Gets role assignment schedules for a resource scope. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentSchedulesByScope.json + */ +async function getRoleAssignmentSchedulesByScope() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const filter = "assignedTo('a3bb8764-cb92-4276-9d2a-ca1e895e55ea')"; + const options: RoleAssignmentSchedulesListForScopeOptionalParams = { filter }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleAssignmentSchedules.listForScope( + scope, + options + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getRoleAssignmentSchedulesByScope(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsCreateByIdSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsCreateByIdSample.ts new file mode 100644 index 000000000000..5660d6d7abc9 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsCreateByIdSample.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleAssignmentCreateParameters, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Create or update a role assignment by ID. + * + * @summary Create or update a role assignment by ID. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_CreateById.json + */ +async function createOrUpdateRoleAssignmentById() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const roleAssignmentId = + "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleAssignments/b0f43c54-e787-4862-89b1-a653fa9cf747"; + const parameters: RoleAssignmentCreateParameters = { + principalId: "ce2ce14e-85d7-4629-bdbc-454d0519d987", + principalType: "User", + roleDefinitionId: + "/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d" + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.createById( + roleAssignmentId, + parameters + ); + console.log(result); +} + +async function main() { + createOrUpdateRoleAssignmentById(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsCreateSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsCreateSample.ts new file mode 100644 index 000000000000..b210e0bc6780 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsCreateSample.ts @@ -0,0 +1,112 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleAssignmentCreateParameters, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Create or update a role assignment by scope and name. + * + * @summary Create or update a role assignment by scope and name. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_CreateForResource.json + */ +async function createRoleAssignmentForResource() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.DocumentDb/databaseAccounts/test-db-account"; + const roleAssignmentName = "05c5a614-a7d6-4502-b150-c2fb455033ff"; + const parameters: RoleAssignmentCreateParameters = { + principalId: "ce2ce14e-85d7-4629-bdbc-454d0519d987", + principalType: "User", + roleDefinitionId: + "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d" + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.create( + scope, + roleAssignmentName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Create or update a role assignment by scope and name. + * + * @summary Create or update a role assignment by scope and name. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_CreateForResourceGroup.json + */ +async function createRoleAssignmentForResourceGroup() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg"; + const roleAssignmentName = "05c5a614-a7d6-4502-b150-c2fb455033ff"; + const parameters: RoleAssignmentCreateParameters = { + principalId: "ce2ce14e-85d7-4629-bdbc-454d0519d987", + principalType: "User", + roleDefinitionId: + "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d" + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.create( + scope, + roleAssignmentName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Create or update a role assignment by scope and name. + * + * @summary Create or update a role assignment by scope and name. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_CreateForSubscription.json + */ +async function createRoleAssignmentForSubscription() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + const roleAssignmentName = "05c5a614-a7d6-4502-b150-c2fb455033ff"; + const parameters: RoleAssignmentCreateParameters = { + principalId: "ce2ce14e-85d7-4629-bdbc-454d0519d987", + principalType: "User", + roleDefinitionId: + "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d" + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.create( + scope, + roleAssignmentName, + parameters + ); + console.log(result); +} + +async function main() { + createRoleAssignmentForResource(); + createRoleAssignmentForResourceGroup(); + createRoleAssignmentForSubscription(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsDeleteByIdSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsDeleteByIdSample.ts new file mode 100644 index 000000000000..3a7837a7b88d --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsDeleteByIdSample.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Delete a role assignment by ID. + * + * @summary Delete a role assignment by ID. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_DeleteById.json + */ +async function deleteRoleAssignmentById() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const roleAssignmentId = + "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleAssignments/b0f43c54-e787-4862-89b1-a653fa9cf747"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.deleteById(roleAssignmentId); + console.log(result); +} + +async function main() { + deleteRoleAssignmentById(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsDeleteSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsDeleteSample.ts new file mode 100644 index 000000000000..9c0c3ccbc7bc --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsDeleteSample.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Delete a role assignment by scope and name. + * + * @summary Delete a role assignment by scope and name. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_Delete.json + */ +async function deleteRoleAssignment() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + const roleAssignmentName = "b0f43c54-e787-4862-89b1-a653fa9cf747"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.delete(scope, roleAssignmentName); + console.log(result); +} + +async function main() { + deleteRoleAssignment(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsGetByIdSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsGetByIdSample.ts new file mode 100644 index 000000000000..9f58610c613b --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsGetByIdSample.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get a role assignment by ID. + * + * @summary Get a role assignment by ID. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_GetById.json + */ +async function getRoleAssignmentById() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const roleAssignmentId = + "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleAssignments/b0f43c54-e787-4862-89b1-a653fa9cf747"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.getById(roleAssignmentId); + console.log(result); +} + +async function main() { + getRoleAssignmentById(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsGetSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsGetSample.ts new file mode 100644 index 000000000000..d1af0d296d08 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsGetSample.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get a role assignment by scope and name. + * + * @summary Get a role assignment by scope and name. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_Get.json + */ +async function getRoleAssignmentByScopeAndName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + const roleAssignmentName = "b0f43c54-e787-4862-89b1-a653fa9cf747"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.get(scope, roleAssignmentName); + console.log(result); +} + +async function main() { + getRoleAssignmentByScopeAndName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsListForResourceGroupSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsListForResourceGroupSample.ts new file mode 100644 index 000000000000..7be2a762c477 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsListForResourceGroupSample.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List all role assignments that apply to a resource group. + * + * @summary List all role assignments that apply to a resource group. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ListForResourceGroup.json + */ +async function listRoleAssignmentsForResourceGroup() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + const resourceGroupName = + process.env["AUTHORIZATION_RESOURCE_GROUP"] || "testrg"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleAssignments.listForResourceGroup( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listRoleAssignmentsForResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsListForResourceSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsListForResourceSample.ts new file mode 100644 index 000000000000..ff2bc90da89c --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsListForResourceSample.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List all role assignments that apply to a resource. + * + * @summary List all role assignments that apply to a resource. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ListForResource.json + */ +async function listRoleAssignmentsForAResource() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + const resourceGroupName = + process.env["AUTHORIZATION_RESOURCE_GROUP"] || "testrg"; + const resourceProviderNamespace = "Microsoft.DocumentDb"; + const resourceType = "databaseAccounts"; + const resourceName = "test-db-account"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleAssignments.listForResource( + resourceGroupName, + resourceProviderNamespace, + resourceType, + resourceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listRoleAssignmentsForAResource(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsListForScopeSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsListForScopeSample.ts new file mode 100644 index 000000000000..3d3731ec0862 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsListForScopeSample.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List all role assignments that apply to a scope. + * + * @summary List all role assignments that apply to a scope. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ListForScope.json + */ +async function listRoleAssignmentsForScope() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleAssignments.listForScope(scope)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listRoleAssignmentsForScope(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsListForSubscriptionSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsListForSubscriptionSample.ts new file mode 100644 index 000000000000..11c76fed583c --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsListForSubscriptionSample.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List all role assignments that apply to a subscription. + * + * @summary List all role assignments that apply to a subscription. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ListForSubscription.json + */ +async function listRoleAssignmentsForSubscription() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleAssignments.listForSubscription()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listRoleAssignmentsForSubscription(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsValidateByIdSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsValidateByIdSample.ts new file mode 100644 index 000000000000..3c76372cd765 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsValidateByIdSample.ts @@ -0,0 +1,79 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleAssignmentCreateParameters, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Validate a role assignment create or update operation by ID. + * + * @summary Validate a role assignment create or update operation by ID. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ValidateByIdInvalid.json + */ +async function validateARoleAssignmentCreateOrUpdateOperationByIdWithFailedValidation() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const roleAssignmentId = + "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleAssignments/b0f43c54-e787-4862-89b1-a653fa9cf747"; + const parameters: RoleAssignmentCreateParameters = { + principalId: "ce2ce14e-85d7-4629-bdbc-454d0519d987", + principalType: "User", + roleDefinitionId: + "/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d" + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.validateById( + roleAssignmentId, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Validate a role assignment create or update operation by ID. + * + * @summary Validate a role assignment create or update operation by ID. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ValidateByIdValid.json + */ +async function validateARoleAssignmentCreateOrUpdateOperationByIdWithSuccessfulValidation() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const roleAssignmentId = + "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleAssignments/b0f43c54-e787-4862-89b1-a653fa9cf747"; + const parameters: RoleAssignmentCreateParameters = { + principalId: "ce2ce14e-85d7-4629-bdbc-454d0519d987", + principalType: "User", + roleDefinitionId: + "/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d" + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.validateById( + roleAssignmentId, + parameters + ); + console.log(result); +} + +async function main() { + validateARoleAssignmentCreateOrUpdateOperationByIdWithFailedValidation(); + validateARoleAssignmentCreateOrUpdateOperationByIdWithSuccessfulValidation(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsValidateSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsValidateSample.ts new file mode 100644 index 000000000000..1966dbf7367c --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleAssignmentsValidateSample.ts @@ -0,0 +1,81 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleAssignmentCreateParameters, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Validate a role assignment create or update operation by scope and name. + * + * @summary Validate a role assignment create or update operation by scope and name. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ValidateInvalid.json + */ +async function validateARoleAssignmentCreateOrUpdateOperationWithFailedValidation() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + const roleAssignmentName = "05c5a614-a7d6-4502-b150-c2fb455033ff"; + const parameters: RoleAssignmentCreateParameters = { + principalId: "ce2ce14e-85d7-4629-bdbc-454d0519d987", + principalType: "User", + roleDefinitionId: + "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d" + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.validate( + scope, + roleAssignmentName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Validate a role assignment create or update operation by scope and name. + * + * @summary Validate a role assignment create or update operation by scope and name. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ValidateValid.json + */ +async function validateARoleAssignmentCreateOrUpdateOperationWithSuccessfulValidation() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + const roleAssignmentName = "05c5a614-a7d6-4502-b150-c2fb455033ff"; + const parameters: RoleAssignmentCreateParameters = { + principalId: "ce2ce14e-85d7-4629-bdbc-454d0519d987", + principalType: "User", + roleDefinitionId: + "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d" + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.validate( + scope, + roleAssignmentName, + parameters + ); + console.log(result); +} + +async function main() { + validateARoleAssignmentCreateOrUpdateOperationWithFailedValidation(); + validateARoleAssignmentCreateOrUpdateOperationWithSuccessfulValidation(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleEligibilityScheduleInstancesGetSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleEligibilityScheduleInstancesGetSample.ts new file mode 100644 index 000000000000..4f1607896f1b --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleEligibilityScheduleInstancesGetSample.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified role eligibility schedule instance. + * + * @summary Gets the specified role eligibility schedule instance. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilityScheduleInstanceByName.json + */ +async function getRoleEligibilityScheduleInstanceByName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleEligibilityScheduleInstanceName = + "21e4b59a-0499-4fe0-a3c3-43a3055b773a"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleEligibilityScheduleInstances.get( + scope, + roleEligibilityScheduleInstanceName + ); + console.log(result); +} + +async function main() { + getRoleEligibilityScheduleInstanceByName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleEligibilityScheduleInstancesListForScopeSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleEligibilityScheduleInstancesListForScopeSample.ts new file mode 100644 index 000000000000..b8974b01d726 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleEligibilityScheduleInstancesListForScopeSample.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleEligibilityScheduleInstancesListForScopeOptionalParams, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets role eligibility schedule instances of a role eligibility schedule. + * + * @summary Gets role eligibility schedule instances of a role eligibility schedule. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilityScheduleInstancesByScope.json + */ +async function getRoleEligibilityScheduleInstancesByScope() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const filter = "assignedTo('a3bb8764-cb92-4276-9d2a-ca1e895e55ea')"; + const options: RoleEligibilityScheduleInstancesListForScopeOptionalParams = { + filter + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleEligibilityScheduleInstances.listForScope( + scope, + options + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getRoleEligibilityScheduleInstancesByScope(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleEligibilityScheduleRequestsCancelSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleEligibilityScheduleRequestsCancelSample.ts new file mode 100644 index 000000000000..d1564bf1fcd7 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleEligibilityScheduleRequestsCancelSample.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Cancels a pending role eligibility schedule request. + * + * @summary Cancels a pending role eligibility schedule request. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/CancelRoleEligibilityScheduleRequestByName.json + */ +async function cancelRoleEligibilityScheduleRequestByName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleEligibilityScheduleRequestName = + "64caffb6-55c0-4deb-a585-68e948ea1ad6"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleEligibilityScheduleRequests.cancel( + scope, + roleEligibilityScheduleRequestName + ); + console.log(result); +} + +async function main() { + cancelRoleEligibilityScheduleRequestByName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleEligibilityScheduleRequestsCreateSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleEligibilityScheduleRequestsCreateSample.ts new file mode 100644 index 000000000000..2f34bce6c370 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleEligibilityScheduleRequestsCreateSample.ts @@ -0,0 +1,65 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleEligibilityScheduleRequest, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates a role eligibility schedule request. + * + * @summary Creates a role eligibility schedule request. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/PutRoleEligibilityScheduleRequest.json + */ +async function putRoleEligibilityScheduleRequest() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleEligibilityScheduleRequestName = + "64caffb6-55c0-4deb-a585-68e948ea1ad6"; + const parameters: RoleEligibilityScheduleRequest = { + condition: + "@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'", + conditionVersion: "1.0", + principalId: "a3bb8764-cb92-4276-9d2a-ca1e895e55ea", + requestType: "AdminAssign", + roleDefinitionId: + "/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/roleDefinitions/c8d4ff99-41c3-41a8-9f60-21dfdad59608", + scheduleInfo: { + expiration: { + type: "AfterDuration", + duration: "P365D", + endDateTime: undefined + }, + startDateTime: new Date("2020-09-09T21:31:27.91Z") + } + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleEligibilityScheduleRequests.create( + scope, + roleEligibilityScheduleRequestName, + parameters + ); + console.log(result); +} + +async function main() { + putRoleEligibilityScheduleRequest(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleEligibilityScheduleRequestsGetSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleEligibilityScheduleRequestsGetSample.ts new file mode 100644 index 000000000000..1a338db3c6be --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleEligibilityScheduleRequestsGetSample.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get the specified role eligibility schedule request. + * + * @summary Get the specified role eligibility schedule request. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilityScheduleRequestByName.json + */ +async function getRoleEligibilityScheduleRequestByName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleEligibilityScheduleRequestName = + "64caffb6-55c0-4deb-a585-68e948ea1ad6"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleEligibilityScheduleRequests.get( + scope, + roleEligibilityScheduleRequestName + ); + console.log(result); +} + +async function main() { + getRoleEligibilityScheduleRequestByName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleEligibilityScheduleRequestsListForScopeSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleEligibilityScheduleRequestsListForScopeSample.ts new file mode 100644 index 000000000000..74a3159644e0 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleEligibilityScheduleRequestsListForScopeSample.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleEligibilityScheduleRequestsListForScopeOptionalParams, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets role eligibility schedule requests for a scope. + * + * @summary Gets role eligibility schedule requests for a scope. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilityScheduleRequestByScope.json + */ +async function getRoleEligibilityScheduleRequestByScope() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const filter = "assignedTo('A3BB8764-CB92-4276-9D2A-CA1E895E55EA')"; + const options: RoleEligibilityScheduleRequestsListForScopeOptionalParams = { + filter + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleEligibilityScheduleRequests.listForScope( + scope, + options + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getRoleEligibilityScheduleRequestByScope(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleEligibilitySchedulesGetSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleEligibilitySchedulesGetSample.ts new file mode 100644 index 000000000000..dc4feaff5062 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleEligibilitySchedulesGetSample.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get the specified role eligibility schedule for a resource scope + * + * @summary Get the specified role eligibility schedule for a resource scope + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilityScheduleByName.json + */ +async function getRoleEligibilityScheduleByName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleEligibilityScheduleName = "b1477448-2cc6-4ceb-93b4-54a202a89413"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleEligibilitySchedules.get( + scope, + roleEligibilityScheduleName + ); + console.log(result); +} + +async function main() { + getRoleEligibilityScheduleByName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleEligibilitySchedulesListForScopeSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleEligibilitySchedulesListForScopeSample.ts new file mode 100644 index 000000000000..ae4098aedf8f --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleEligibilitySchedulesListForScopeSample.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleEligibilitySchedulesListForScopeOptionalParams, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets role eligibility schedules for a resource scope. + * + * @summary Gets role eligibility schedules for a resource scope. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilitySchedulesByScope.json + */ +async function getRoleEligibilitySchedulesByScope() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const filter = "assignedTo('a3bb8764-cb92-4276-9d2a-ca1e895e55ea')"; + const options: RoleEligibilitySchedulesListForScopeOptionalParams = { + filter + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleEligibilitySchedules.listForScope( + scope, + options + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getRoleEligibilitySchedulesByScope(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleManagementPoliciesDeleteSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleManagementPoliciesDeleteSample.ts new file mode 100644 index 000000000000..e681abd9c737 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleManagementPoliciesDeleteSample.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Delete a role management policy + * + * @summary Delete a role management policy + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/DeleteRoleManagementPolicy.json + */ +async function deleteRoleManagementPolicy() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + const roleManagementPolicyName = "570c3619-7688-4b34-b290-2b8bb3ccab2a"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleManagementPolicies.delete( + scope, + roleManagementPolicyName + ); + console.log(result); +} + +async function main() { + deleteRoleManagementPolicy(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleManagementPoliciesGetSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleManagementPoliciesGetSample.ts new file mode 100644 index 000000000000..ec8c129b6652 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleManagementPoliciesGetSample.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get the specified role management policy for a resource scope + * + * @summary Get the specified role management policy for a resource scope + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleManagementPolicyByName.json + */ +async function getRoleManagementPolicyByName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + const roleManagementPolicyName = "570c3619-7688-4b34-b290-2b8bb3ccab2a"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleManagementPolicies.get( + scope, + roleManagementPolicyName + ); + console.log(result); +} + +async function main() { + getRoleManagementPolicyByName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleManagementPoliciesListForScopeSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleManagementPoliciesListForScopeSample.ts new file mode 100644 index 000000000000..d9477bd3b940 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleManagementPoliciesListForScopeSample.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets role management policies for a resource scope. + * + * @summary Gets role management policies for a resource scope. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleManagementPolicyByScope.json + */ +async function getRoleManagementPolicyByRoleDefinitionFilter() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleManagementPolicies.listForScope(scope)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getRoleManagementPolicyByRoleDefinitionFilter(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleManagementPoliciesUpdateSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleManagementPoliciesUpdateSample.ts new file mode 100644 index 000000000000..7adab756d255 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleManagementPoliciesUpdateSample.ts @@ -0,0 +1,403 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleManagementPolicy, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Update a role management policy + * + * @summary Update a role management policy + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/PatchPartialRoleManagementPolicy.json + */ +async function patchPartialRoleManagementPolicy() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + const roleManagementPolicyName = "570c3619-7688-4b34-b290-2b8bb3ccab2a"; + const parameters: RoleManagementPolicy = { + rules: [ + { + id: "Expiration_Admin_Eligibility", + isExpirationRequired: false, + maximumDuration: "P180D", + ruleType: "RoleManagementPolicyExpirationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Eligibility", + targetObjects: [], + operations: ["All"] + } + }, + { + id: "Notification_Admin_Admin_Eligibility", + isDefaultRecipientsEnabled: false, + notificationLevel: "Critical", + notificationRecipients: ["admin_admin_eligible@test.com"], + notificationType: "Email", + recipientType: "Admin", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Eligibility", + targetObjects: [], + operations: ["All"] + } + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleManagementPolicies.update( + scope, + roleManagementPolicyName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Update a role management policy + * + * @summary Update a role management policy + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/PatchRoleManagementPolicy.json + */ +async function patchRoleManagementPolicy() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + const roleManagementPolicyName = "570c3619-7688-4b34-b290-2b8bb3ccab2a"; + const parameters: RoleManagementPolicy = { + rules: [ + { + id: "Expiration_Admin_Eligibility", + isExpirationRequired: false, + maximumDuration: "P180D", + ruleType: "RoleManagementPolicyExpirationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Eligibility", + targetObjects: [], + operations: ["All"] + } + }, + { + id: "Notification_Admin_Admin_Eligibility", + isDefaultRecipientsEnabled: false, + notificationLevel: "Critical", + notificationRecipients: ["admin_admin_eligible@test.com"], + notificationType: "Email", + recipientType: "Admin", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Eligibility", + targetObjects: [], + operations: ["All"] + } + }, + { + id: "Notification_Requestor_Admin_Eligibility", + isDefaultRecipientsEnabled: false, + notificationLevel: "Critical", + notificationRecipients: ["requestor_admin_eligible@test.com"], + notificationType: "Email", + recipientType: "Requestor", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Eligibility", + targetObjects: [], + operations: ["All"] + } + }, + { + id: "Notification_Approver_Admin_Eligibility", + isDefaultRecipientsEnabled: false, + notificationLevel: "Critical", + notificationRecipients: ["approver_admin_eligible@test.com"], + notificationType: "Email", + recipientType: "Approver", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Eligibility", + targetObjects: [], + operations: ["All"] + } + }, + { + enabledRules: [], + id: "Enablement_Admin_Eligibility", + ruleType: "RoleManagementPolicyEnablementRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Eligibility", + targetObjects: [], + operations: ["All"] + } + }, + { + id: "Expiration_Admin_Assignment", + isExpirationRequired: false, + maximumDuration: "P90D", + ruleType: "RoleManagementPolicyExpirationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"] + } + }, + { + enabledRules: ["Justification", "MultiFactorAuthentication"], + id: "Enablement_Admin_Assignment", + ruleType: "RoleManagementPolicyEnablementRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"] + } + }, + { + id: "Notification_Admin_Admin_Assignment", + isDefaultRecipientsEnabled: false, + notificationLevel: "Critical", + notificationRecipients: ["admin_admin_member@test.com"], + notificationType: "Email", + recipientType: "Admin", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"] + } + }, + { + id: "Notification_Requestor_Admin_Assignment", + isDefaultRecipientsEnabled: false, + notificationLevel: "Critical", + notificationRecipients: ["requestor_admin_member@test.com"], + notificationType: "Email", + recipientType: "Requestor", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"] + } + }, + { + id: "Notification_Approver_Admin_Assignment", + isDefaultRecipientsEnabled: false, + notificationLevel: "Critical", + notificationRecipients: ["approver_admin_member@test.com"], + notificationType: "Email", + recipientType: "Approver", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"] + } + }, + { + id: "Expiration_EndUser_Assignment", + isExpirationRequired: true, + maximumDuration: "PT7H", + ruleType: "RoleManagementPolicyExpirationRule", + target: { + caller: "EndUser", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"] + } + }, + { + enabledRules: [ + "Justification", + "MultiFactorAuthentication", + "Ticketing" + ], + id: "Enablement_EndUser_Assignment", + ruleType: "RoleManagementPolicyEnablementRule", + target: { + caller: "EndUser", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"] + } + }, + { + id: "Approval_EndUser_Assignment", + ruleType: "RoleManagementPolicyApprovalRule", + setting: { + approvalMode: "SingleStage", + approvalStages: [ + { + approvalStageTimeOutInDays: 1, + escalationApprovers: [], + escalationTimeInMinutes: 0, + isApproverJustificationRequired: true, + isEscalationEnabled: false, + primaryApprovers: [ + { + description: "amansw_new_group", + id: "2385b0f3-5fa9-43cf-8ca4-b01dc97298cd", + isBackup: false, + userType: "Group" + }, + { + description: "amansw_group", + id: "2f4913c9-d15b-406a-9946-1d66a28f2690", + isBackup: false, + userType: "Group" + } + ] + } + ], + isApprovalRequired: true, + isApprovalRequiredForExtension: false, + isRequestorJustificationRequired: true + }, + target: { + caller: "EndUser", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"] + } + }, + { + claimValue: "", + id: "AuthenticationContext_EndUser_Assignment", + isEnabled: false, + ruleType: "RoleManagementPolicyAuthenticationContextRule", + target: { + caller: "EndUser", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"] + } + }, + { + id: "Notification_Admin_EndUser_Assignment", + isDefaultRecipientsEnabled: false, + notificationLevel: "Critical", + notificationRecipients: ["admin_enduser_member@test.com"], + notificationType: "Email", + recipientType: "Admin", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "EndUser", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"] + } + }, + { + id: "Notification_Requestor_EndUser_Assignment", + isDefaultRecipientsEnabled: false, + notificationLevel: "Critical", + notificationRecipients: ["requestor_enduser_member@test.com"], + notificationType: "Email", + recipientType: "Requestor", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "EndUser", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"] + } + }, + { + id: "Notification_Approver_EndUser_Assignment", + isDefaultRecipientsEnabled: true, + notificationLevel: "Critical", + notificationRecipients: [], + notificationType: "Email", + recipientType: "Approver", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "EndUser", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"] + } + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleManagementPolicies.update( + scope, + roleManagementPolicyName, + parameters + ); + console.log(result); +} + +async function main() { + patchPartialRoleManagementPolicy(); + patchRoleManagementPolicy(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleManagementPolicyAssignmentsCreateSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleManagementPolicyAssignmentsCreateSample.ts new file mode 100644 index 000000000000..713df394e36e --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleManagementPolicyAssignmentsCreateSample.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleManagementPolicyAssignment, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Create a role management policy assignment + * + * @summary Create a role management policy assignment + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/PutRoleManagementPolicyAssignment.json + */ +async function getConfigurations() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + const roleManagementPolicyAssignmentName = + "b959d571-f0b5-4042-88a7-01be6cb22db9_a1705bd2-3a8f-45a5-8683-466fcfd5cc24"; + const parameters: RoleManagementPolicyAssignment = { + policyId: + "/providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368/providers/Microsoft.Authorization/roleManagementPolicies/b959d571-f0b5-4042-88a7-01be6cb22db9", + roleDefinitionId: + "/subscriptions/129ff972-28f8-46b8-a726-e497be039368/providers/Microsoft.Authorization/roleDefinitions/a1705bd2-3a8f-45a5-8683-466fcfd5cc24", + scope: "/subscriptions/129ff972-28f8-46b8-a726-e497be039368" + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleManagementPolicyAssignments.create( + scope, + roleManagementPolicyAssignmentName, + parameters + ); + console.log(result); +} + +async function main() { + getConfigurations(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleManagementPolicyAssignmentsDeleteSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleManagementPolicyAssignmentsDeleteSample.ts new file mode 100644 index 000000000000..ef5b410f6b80 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleManagementPolicyAssignmentsDeleteSample.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Delete a role management policy assignment + * + * @summary Delete a role management policy assignment + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/DeleteRoleManagementPolicyAssignment.json + */ +async function getConfigurations() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + const roleManagementPolicyAssignmentName = + "b959d571-f0b5-4042-88a7-01be6cb22db9_a1705bd2-3a8f-45a5-8683-466fcfd5cc24"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleManagementPolicyAssignments.delete( + scope, + roleManagementPolicyAssignmentName + ); + console.log(result); +} + +async function main() { + getConfigurations(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleManagementPolicyAssignmentsGetSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleManagementPolicyAssignmentsGetSample.ts new file mode 100644 index 000000000000..351f27d44fbb --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleManagementPolicyAssignmentsGetSample.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get the specified role management policy assignment for a resource scope + * + * @summary Get the specified role management policy assignment for a resource scope + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleManagementPolicyAssignmentByName.json + */ +async function getConfigurations() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + const roleManagementPolicyAssignmentName = + "b959d571-f0b5-4042-88a7-01be6cb22db9_a1705bd2-3a8f-45a5-8683-466fcfd5cc24"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleManagementPolicyAssignments.get( + scope, + roleManagementPolicyAssignmentName + ); + console.log(result); +} + +async function main() { + getConfigurations(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples-dev/roleManagementPolicyAssignmentsListForScopeSample.ts b/sdk/authorization/arm-authorization/samples-dev/roleManagementPolicyAssignmentsListForScopeSample.ts new file mode 100644 index 000000000000..084aa147d1cd --- /dev/null +++ b/sdk/authorization/arm-authorization/samples-dev/roleManagementPolicyAssignmentsListForScopeSample.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets role management assignment policies for a resource scope. + * + * @summary Gets role management assignment policies for a resource scope. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleManagementPolicyAssignmentByScope.json + */ +async function getConfigurations() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleManagementPolicyAssignments.listForScope( + scope + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getConfigurations(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/README.md b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/README.md new file mode 100644 index 000000000000..254a6ba2a82f --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/README.md @@ -0,0 +1,122 @@ +# client library samples for JavaScript (Beta) + +These sample programs show how to use the JavaScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [eligibleChildResourcesGetSample.js][eligiblechildresourcesgetsample] | Get the child resources of a resource on which user has eligible access x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetEligibleChildResourcesByScope.json | +| [roleAssignmentScheduleInstancesGetSample.js][roleassignmentscheduleinstancesgetsample] | Gets the specified role assignment schedule instance. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentScheduleInstanceByName.json | +| [roleAssignmentScheduleInstancesListForScopeSample.js][roleassignmentscheduleinstanceslistforscopesample] | Gets role assignment schedule instances of a role assignment schedule. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentScheduleInstancesByScope.json | +| [roleAssignmentScheduleRequestsCancelSample.js][roleassignmentschedulerequestscancelsample] | Cancels a pending role assignment schedule request. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/CancelRoleAssignmentScheduleRequestByName.json | +| [roleAssignmentScheduleRequestsCreateSample.js][roleassignmentschedulerequestscreatesample] | Creates a role assignment schedule request. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/PutRoleAssignmentScheduleRequest.json | +| [roleAssignmentScheduleRequestsGetSample.js][roleassignmentschedulerequestsgetsample] | Get the specified role assignment schedule request. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentScheduleRequestByName.json | +| [roleAssignmentScheduleRequestsListForScopeSample.js][roleassignmentschedulerequestslistforscopesample] | Gets role assignment schedule requests for a scope. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentScheduleRequestByScope.json | +| [roleAssignmentSchedulesGetSample.js][roleassignmentschedulesgetsample] | Get the specified role assignment schedule for a resource scope x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentScheduleByName.json | +| [roleAssignmentSchedulesListForScopeSample.js][roleassignmentscheduleslistforscopesample] | Gets role assignment schedules for a resource scope. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentSchedulesByScope.json | +| [roleAssignmentsCreateByIdSample.js][roleassignmentscreatebyidsample] | Create or update a role assignment by ID. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_CreateById.json | +| [roleAssignmentsCreateSample.js][roleassignmentscreatesample] | Create or update a role assignment by scope and name. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_CreateForResource.json | +| [roleAssignmentsDeleteByIdSample.js][roleassignmentsdeletebyidsample] | Delete a role assignment by ID. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_DeleteById.json | +| [roleAssignmentsDeleteSample.js][roleassignmentsdeletesample] | Delete a role assignment by scope and name. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_Delete.json | +| [roleAssignmentsGetByIdSample.js][roleassignmentsgetbyidsample] | Get a role assignment by ID. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_GetById.json | +| [roleAssignmentsGetSample.js][roleassignmentsgetsample] | Get a role assignment by scope and name. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_Get.json | +| [roleAssignmentsListForResourceGroupSample.js][roleassignmentslistforresourcegroupsample] | List all role assignments that apply to a resource group. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ListForResourceGroup.json | +| [roleAssignmentsListForResourceSample.js][roleassignmentslistforresourcesample] | List all role assignments that apply to a resource. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ListForResource.json | +| [roleAssignmentsListForScopeSample.js][roleassignmentslistforscopesample] | List all role assignments that apply to a scope. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ListForScope.json | +| [roleAssignmentsListForSubscriptionSample.js][roleassignmentslistforsubscriptionsample] | List all role assignments that apply to a subscription. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ListForSubscription.json | +| [roleAssignmentsValidateByIdSample.js][roleassignmentsvalidatebyidsample] | Validate a role assignment create or update operation by ID. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ValidateByIdInvalid.json | +| [roleAssignmentsValidateSample.js][roleassignmentsvalidatesample] | Validate a role assignment create or update operation by scope and name. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ValidateInvalid.json | +| [roleEligibilityScheduleInstancesGetSample.js][roleeligibilityscheduleinstancesgetsample] | Gets the specified role eligibility schedule instance. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilityScheduleInstanceByName.json | +| [roleEligibilityScheduleInstancesListForScopeSample.js][roleeligibilityscheduleinstanceslistforscopesample] | Gets role eligibility schedule instances of a role eligibility schedule. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilityScheduleInstancesByScope.json | +| [roleEligibilityScheduleRequestsCancelSample.js][roleeligibilityschedulerequestscancelsample] | Cancels a pending role eligibility schedule request. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/CancelRoleEligibilityScheduleRequestByName.json | +| [roleEligibilityScheduleRequestsCreateSample.js][roleeligibilityschedulerequestscreatesample] | Creates a role eligibility schedule request. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/PutRoleEligibilityScheduleRequest.json | +| [roleEligibilityScheduleRequestsGetSample.js][roleeligibilityschedulerequestsgetsample] | Get the specified role eligibility schedule request. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilityScheduleRequestByName.json | +| [roleEligibilityScheduleRequestsListForScopeSample.js][roleeligibilityschedulerequestslistforscopesample] | Gets role eligibility schedule requests for a scope. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilityScheduleRequestByScope.json | +| [roleEligibilitySchedulesGetSample.js][roleeligibilityschedulesgetsample] | Get the specified role eligibility schedule for a resource scope x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilityScheduleByName.json | +| [roleEligibilitySchedulesListForScopeSample.js][roleeligibilityscheduleslistforscopesample] | Gets role eligibility schedules for a resource scope. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilitySchedulesByScope.json | +| [roleManagementPoliciesDeleteSample.js][rolemanagementpoliciesdeletesample] | Delete a role management policy x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/DeleteRoleManagementPolicy.json | +| [roleManagementPoliciesGetSample.js][rolemanagementpoliciesgetsample] | Get the specified role management policy for a resource scope x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleManagementPolicyByName.json | +| [roleManagementPoliciesListForScopeSample.js][rolemanagementpolicieslistforscopesample] | Gets role management policies for a resource scope. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleManagementPolicyByScope.json | +| [roleManagementPoliciesUpdateSample.js][rolemanagementpoliciesupdatesample] | Update a role management policy x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/PatchPartialRoleManagementPolicy.json | +| [roleManagementPolicyAssignmentsCreateSample.js][rolemanagementpolicyassignmentscreatesample] | Create a role management policy assignment x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/PutRoleManagementPolicyAssignment.json | +| [roleManagementPolicyAssignmentsDeleteSample.js][rolemanagementpolicyassignmentsdeletesample] | Delete a role management policy assignment x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/DeleteRoleManagementPolicyAssignment.json | +| [roleManagementPolicyAssignmentsGetSample.js][rolemanagementpolicyassignmentsgetsample] | Get the specified role management policy assignment for a resource scope x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleManagementPolicyAssignmentByName.json | +| [roleManagementPolicyAssignmentsListForScopeSample.js][rolemanagementpolicyassignmentslistforscopesample] | Gets role management assignment policies for a resource scope. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleManagementPolicyAssignmentByScope.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). + +You need [an Azure subscription][freesub] to run these sample programs. + +Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. + +Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. + +## Setup + +To run the samples using the published version of the package: + +1. Install the dependencies using `npm`: + +```bash +npm install +``` + +2. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. + +3. Run whichever samples you like (note that some samples may require additional setup, see the table above): + +```bash +node eligibleChildResourcesGetSample.js +``` + +Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): + +```bash +npx cross-env AUTHORIZATION_SUBSCRIPTION_ID="" node eligibleChildResourcesGetSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[eligiblechildresourcesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/eligibleChildResourcesGetSample.js +[roleassignmentscheduleinstancesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentScheduleInstancesGetSample.js +[roleassignmentscheduleinstanceslistforscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentScheduleInstancesListForScopeSample.js +[roleassignmentschedulerequestscancelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentScheduleRequestsCancelSample.js +[roleassignmentschedulerequestscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentScheduleRequestsCreateSample.js +[roleassignmentschedulerequestsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentScheduleRequestsGetSample.js +[roleassignmentschedulerequestslistforscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentScheduleRequestsListForScopeSample.js +[roleassignmentschedulesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentSchedulesGetSample.js +[roleassignmentscheduleslistforscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentSchedulesListForScopeSample.js +[roleassignmentscreatebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsCreateByIdSample.js +[roleassignmentscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsCreateSample.js +[roleassignmentsdeletebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsDeleteByIdSample.js +[roleassignmentsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsDeleteSample.js +[roleassignmentsgetbyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsGetByIdSample.js +[roleassignmentsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsGetSample.js +[roleassignmentslistforresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsListForResourceGroupSample.js +[roleassignmentslistforresourcesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsListForResourceSample.js +[roleassignmentslistforscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsListForScopeSample.js +[roleassignmentslistforsubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsListForSubscriptionSample.js +[roleassignmentsvalidatebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsValidateByIdSample.js +[roleassignmentsvalidatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsValidateSample.js +[roleeligibilityscheduleinstancesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilityScheduleInstancesGetSample.js +[roleeligibilityscheduleinstanceslistforscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilityScheduleInstancesListForScopeSample.js +[roleeligibilityschedulerequestscancelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilityScheduleRequestsCancelSample.js +[roleeligibilityschedulerequestscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilityScheduleRequestsCreateSample.js +[roleeligibilityschedulerequestsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilityScheduleRequestsGetSample.js +[roleeligibilityschedulerequestslistforscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilityScheduleRequestsListForScopeSample.js +[roleeligibilityschedulesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilitySchedulesGetSample.js +[roleeligibilityscheduleslistforscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilitySchedulesListForScopeSample.js +[rolemanagementpoliciesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPoliciesDeleteSample.js +[rolemanagementpoliciesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPoliciesGetSample.js +[rolemanagementpolicieslistforscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPoliciesListForScopeSample.js +[rolemanagementpoliciesupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPoliciesUpdateSample.js +[rolemanagementpolicyassignmentscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPolicyAssignmentsCreateSample.js +[rolemanagementpolicyassignmentsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPolicyAssignmentsDeleteSample.js +[rolemanagementpolicyassignmentsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPolicyAssignmentsGetSample.js +[rolemanagementpolicyassignmentslistforscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPolicyAssignmentsListForScopeSample.js +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-authorization?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/authorization/arm-authorization/README.md diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/eligibleChildResourcesGetSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/eligibleChildResourcesGetSample.js new file mode 100644 index 000000000000..29e4a68735ca --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/eligibleChildResourcesGetSample.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Get the child resources of a resource on which user has eligible access + * + * @summary Get the child resources of a resource on which user has eligible access + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetEligibleChildResourcesByScope.json + */ +async function getEligibleChildResourcesByScope() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const filter = "resourceType+eq+'resourcegroup'"; + const options = { filter }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.eligibleChildResources.list(scope, options)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getEligibleChildResourcesByScope(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/package.json b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/package.json new file mode 100644 index 000000000000..1040ab508719 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/package.json @@ -0,0 +1,32 @@ +{ + "name": "@azure-samples/arm-authorization-js-beta", + "private": true, + "version": "1.0.0", + "description": " client library samples for JavaScript (Beta)", + "engines": { + "node": ">=14.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/authorization/arm-authorization" + }, + "keywords": [ + "node", + "azure", + "typescript", + "browser", + "isomorphic" + ], + "author": "Microsoft Corporation", + "license": "MIT", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/authorization/arm-authorization", + "dependencies": { + "@azure/arm-authorization": "next", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + } +} diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentScheduleInstancesGetSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentScheduleInstancesGetSample.js new file mode 100644 index 000000000000..3ffde8d23b44 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentScheduleInstancesGetSample.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the specified role assignment schedule instance. + * + * @summary Gets the specified role assignment schedule instance. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentScheduleInstanceByName.json + */ +async function getRoleAssignmentScheduleInstanceByName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleAssignmentScheduleInstanceName = "ed9b8180-cef7-4c77-a63c-b8566ecfc412"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignmentScheduleInstances.get( + scope, + roleAssignmentScheduleInstanceName + ); + console.log(result); +} + +async function main() { + getRoleAssignmentScheduleInstanceByName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentScheduleInstancesListForScopeSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentScheduleInstancesListForScopeSample.js new file mode 100644 index 000000000000..5eb706b88fe1 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentScheduleInstancesListForScopeSample.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets role assignment schedule instances of a role assignment schedule. + * + * @summary Gets role assignment schedule instances of a role assignment schedule. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentScheduleInstancesByScope.json + */ +async function getRoleAssignmentScheduleInstancesByScope() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const filter = "assignedTo('a3bb8764-cb92-4276-9d2a-ca1e895e55ea')"; + const options = { + filter, + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleAssignmentScheduleInstances.listForScope(scope, options)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getRoleAssignmentScheduleInstancesByScope(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentScheduleRequestsCancelSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentScheduleRequestsCancelSample.js new file mode 100644 index 000000000000..107f905568a0 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentScheduleRequestsCancelSample.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Cancels a pending role assignment schedule request. + * + * @summary Cancels a pending role assignment schedule request. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/CancelRoleAssignmentScheduleRequestByName.json + */ +async function cancelRoleAssignmentScheduleRequestByName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleAssignmentScheduleRequestName = "fea7a502-9a96-4806-a26f-eee560e52045"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignmentScheduleRequests.cancel( + scope, + roleAssignmentScheduleRequestName + ); + console.log(result); +} + +async function main() { + cancelRoleAssignmentScheduleRequestByName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentScheduleRequestsCreateSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentScheduleRequestsCreateSample.js new file mode 100644 index 000000000000..5deac02cc91c --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentScheduleRequestsCreateSample.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Creates a role assignment schedule request. + * + * @summary Creates a role assignment schedule request. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/PutRoleAssignmentScheduleRequest.json + */ +async function putRoleAssignmentScheduleRequest() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleAssignmentScheduleRequestName = "fea7a502-9a96-4806-a26f-eee560e52045"; + const parameters = { + condition: + "@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'", + conditionVersion: "1.0", + linkedRoleEligibilityScheduleId: "b1477448-2cc6-4ceb-93b4-54a202a89413", + principalId: "a3bb8764-cb92-4276-9d2a-ca1e895e55ea", + requestType: "SelfActivate", + roleDefinitionId: + "/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/roleDefinitions/c8d4ff99-41c3-41a8-9f60-21dfdad59608", + scheduleInfo: { + expiration: { + type: "AfterDuration", + duration: "PT8H", + endDateTime: undefined, + }, + startDateTime: new Date("2020-09-09T21:35:27.91Z"), + }, + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignmentScheduleRequests.create( + scope, + roleAssignmentScheduleRequestName, + parameters + ); + console.log(result); +} + +async function main() { + putRoleAssignmentScheduleRequest(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentScheduleRequestsGetSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentScheduleRequestsGetSample.js new file mode 100644 index 000000000000..d1b53c59331c --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentScheduleRequestsGetSample.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Get the specified role assignment schedule request. + * + * @summary Get the specified role assignment schedule request. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentScheduleRequestByName.json + */ +async function getRoleAssignmentScheduleRequestByName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleAssignmentScheduleRequestName = "fea7a502-9a96-4806-a26f-eee560e52045"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignmentScheduleRequests.get( + scope, + roleAssignmentScheduleRequestName + ); + console.log(result); +} + +async function main() { + getRoleAssignmentScheduleRequestByName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentScheduleRequestsListForScopeSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentScheduleRequestsListForScopeSample.js new file mode 100644 index 000000000000..6df2b0a72e07 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentScheduleRequestsListForScopeSample.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets role assignment schedule requests for a scope. + * + * @summary Gets role assignment schedule requests for a scope. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentScheduleRequestByScope.json + */ +async function getRoleAssignmentScheduleRequestByScope() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const filter = "assignedTo('A3BB8764-CB92-4276-9D2A-CA1E895E55EA')"; + const options = { + filter, + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleAssignmentScheduleRequests.listForScope(scope, options)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getRoleAssignmentScheduleRequestByScope(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentSchedulesGetSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentSchedulesGetSample.js new file mode 100644 index 000000000000..8fc35b100685 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentSchedulesGetSample.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Get the specified role assignment schedule for a resource scope + * + * @summary Get the specified role assignment schedule for a resource scope + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentScheduleByName.json + */ +async function getRoleAssignmentScheduleByName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleAssignmentScheduleName = "c9e264ff-3133-4776-a81a-ebc7c33c8ec6"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignmentSchedules.get(scope, roleAssignmentScheduleName); + console.log(result); +} + +async function main() { + getRoleAssignmentScheduleByName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentSchedulesListForScopeSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentSchedulesListForScopeSample.js new file mode 100644 index 000000000000..4bb658bc6d64 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentSchedulesListForScopeSample.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets role assignment schedules for a resource scope. + * + * @summary Gets role assignment schedules for a resource scope. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentSchedulesByScope.json + */ +async function getRoleAssignmentSchedulesByScope() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const filter = "assignedTo('a3bb8764-cb92-4276-9d2a-ca1e895e55ea')"; + const options = { filter }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleAssignmentSchedules.listForScope(scope, options)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getRoleAssignmentSchedulesByScope(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsCreateByIdSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsCreateByIdSample.js new file mode 100644 index 000000000000..99491312be60 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsCreateByIdSample.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Create or update a role assignment by ID. + * + * @summary Create or update a role assignment by ID. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_CreateById.json + */ +async function createOrUpdateRoleAssignmentById() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const roleAssignmentId = + "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleAssignments/b0f43c54-e787-4862-89b1-a653fa9cf747"; + const parameters = { + principalId: "ce2ce14e-85d7-4629-bdbc-454d0519d987", + principalType: "User", + roleDefinitionId: + "/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d", + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.createById(roleAssignmentId, parameters); + console.log(result); +} + +async function main() { + createOrUpdateRoleAssignmentById(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsCreateSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsCreateSample.js new file mode 100644 index 000000000000..da98754418a7 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsCreateSample.js @@ -0,0 +1,91 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Create or update a role assignment by scope and name. + * + * @summary Create or update a role assignment by scope and name. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_CreateForResource.json + */ +async function createRoleAssignmentForResource() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.DocumentDb/databaseAccounts/test-db-account"; + const roleAssignmentName = "05c5a614-a7d6-4502-b150-c2fb455033ff"; + const parameters = { + principalId: "ce2ce14e-85d7-4629-bdbc-454d0519d987", + principalType: "User", + roleDefinitionId: + "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d", + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.create(scope, roleAssignmentName, parameters); + console.log(result); +} + +/** + * This sample demonstrates how to Create or update a role assignment by scope and name. + * + * @summary Create or update a role assignment by scope and name. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_CreateForResourceGroup.json + */ +async function createRoleAssignmentForResourceGroup() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg"; + const roleAssignmentName = "05c5a614-a7d6-4502-b150-c2fb455033ff"; + const parameters = { + principalId: "ce2ce14e-85d7-4629-bdbc-454d0519d987", + principalType: "User", + roleDefinitionId: + "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d", + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.create(scope, roleAssignmentName, parameters); + console.log(result); +} + +/** + * This sample demonstrates how to Create or update a role assignment by scope and name. + * + * @summary Create or update a role assignment by scope and name. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_CreateForSubscription.json + */ +async function createRoleAssignmentForSubscription() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + const roleAssignmentName = "05c5a614-a7d6-4502-b150-c2fb455033ff"; + const parameters = { + principalId: "ce2ce14e-85d7-4629-bdbc-454d0519d987", + principalType: "User", + roleDefinitionId: + "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d", + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.create(scope, roleAssignmentName, parameters); + console.log(result); +} + +async function main() { + createRoleAssignmentForResource(); + createRoleAssignmentForResourceGroup(); + createRoleAssignmentForSubscription(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsDeleteByIdSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsDeleteByIdSample.js new file mode 100644 index 000000000000..90acbdb4588b --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsDeleteByIdSample.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Delete a role assignment by ID. + * + * @summary Delete a role assignment by ID. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_DeleteById.json + */ +async function deleteRoleAssignmentById() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const roleAssignmentId = + "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleAssignments/b0f43c54-e787-4862-89b1-a653fa9cf747"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.deleteById(roleAssignmentId); + console.log(result); +} + +async function main() { + deleteRoleAssignmentById(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsDeleteSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsDeleteSample.js new file mode 100644 index 000000000000..ab32e37dc7ae --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsDeleteSample.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Delete a role assignment by scope and name. + * + * @summary Delete a role assignment by scope and name. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_Delete.json + */ +async function deleteRoleAssignment() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + const roleAssignmentName = "b0f43c54-e787-4862-89b1-a653fa9cf747"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.delete(scope, roleAssignmentName); + console.log(result); +} + +async function main() { + deleteRoleAssignment(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsGetByIdSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsGetByIdSample.js new file mode 100644 index 000000000000..3d742a01bb8a --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsGetByIdSample.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Get a role assignment by ID. + * + * @summary Get a role assignment by ID. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_GetById.json + */ +async function getRoleAssignmentById() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const roleAssignmentId = + "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleAssignments/b0f43c54-e787-4862-89b1-a653fa9cf747"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.getById(roleAssignmentId); + console.log(result); +} + +async function main() { + getRoleAssignmentById(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsGetSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsGetSample.js new file mode 100644 index 000000000000..54d40b64946c --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsGetSample.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Get a role assignment by scope and name. + * + * @summary Get a role assignment by scope and name. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_Get.json + */ +async function getRoleAssignmentByScopeAndName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + const roleAssignmentName = "b0f43c54-e787-4862-89b1-a653fa9cf747"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.get(scope, roleAssignmentName); + console.log(result); +} + +async function main() { + getRoleAssignmentByScopeAndName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsListForResourceGroupSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsListForResourceGroupSample.js new file mode 100644 index 000000000000..538889b08925 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsListForResourceGroupSample.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to List all role assignments that apply to a resource group. + * + * @summary List all role assignments that apply to a resource group. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ListForResourceGroup.json + */ +async function listRoleAssignmentsForResourceGroup() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + const resourceGroupName = process.env["AUTHORIZATION_RESOURCE_GROUP"] || "testrg"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleAssignments.listForResourceGroup(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listRoleAssignmentsForResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsListForResourceSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsListForResourceSample.js new file mode 100644 index 000000000000..31197988ad4a --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsListForResourceSample.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to List all role assignments that apply to a resource. + * + * @summary List all role assignments that apply to a resource. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ListForResource.json + */ +async function listRoleAssignmentsForAResource() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + const resourceGroupName = process.env["AUTHORIZATION_RESOURCE_GROUP"] || "testrg"; + const resourceProviderNamespace = "Microsoft.DocumentDb"; + const resourceType = "databaseAccounts"; + const resourceName = "test-db-account"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleAssignments.listForResource( + resourceGroupName, + resourceProviderNamespace, + resourceType, + resourceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listRoleAssignmentsForAResource(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsListForScopeSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsListForScopeSample.js new file mode 100644 index 000000000000..a001e0ae7a67 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsListForScopeSample.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to List all role assignments that apply to a scope. + * + * @summary List all role assignments that apply to a scope. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ListForScope.json + */ +async function listRoleAssignmentsForScope() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleAssignments.listForScope(scope)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listRoleAssignmentsForScope(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsListForSubscriptionSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsListForSubscriptionSample.js new file mode 100644 index 000000000000..dc38db4a498e --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsListForSubscriptionSample.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to List all role assignments that apply to a subscription. + * + * @summary List all role assignments that apply to a subscription. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ListForSubscription.json + */ +async function listRoleAssignmentsForSubscription() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleAssignments.listForSubscription()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listRoleAssignmentsForSubscription(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsValidateByIdSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsValidateByIdSample.js new file mode 100644 index 000000000000..a857d8c15df5 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsValidateByIdSample.js @@ -0,0 +1,66 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Validate a role assignment create or update operation by ID. + * + * @summary Validate a role assignment create or update operation by ID. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ValidateByIdInvalid.json + */ +async function validateARoleAssignmentCreateOrUpdateOperationByIdWithFailedValidation() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const roleAssignmentId = + "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleAssignments/b0f43c54-e787-4862-89b1-a653fa9cf747"; + const parameters = { + principalId: "ce2ce14e-85d7-4629-bdbc-454d0519d987", + principalType: "User", + roleDefinitionId: + "/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d", + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.validateById(roleAssignmentId, parameters); + console.log(result); +} + +/** + * This sample demonstrates how to Validate a role assignment create or update operation by ID. + * + * @summary Validate a role assignment create or update operation by ID. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ValidateByIdValid.json + */ +async function validateARoleAssignmentCreateOrUpdateOperationByIdWithSuccessfulValidation() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const roleAssignmentId = + "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleAssignments/b0f43c54-e787-4862-89b1-a653fa9cf747"; + const parameters = { + principalId: "ce2ce14e-85d7-4629-bdbc-454d0519d987", + principalType: "User", + roleDefinitionId: + "/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d", + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.validateById(roleAssignmentId, parameters); + console.log(result); +} + +async function main() { + validateARoleAssignmentCreateOrUpdateOperationByIdWithFailedValidation(); + validateARoleAssignmentCreateOrUpdateOperationByIdWithSuccessfulValidation(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsValidateSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsValidateSample.js new file mode 100644 index 000000000000..8ad2a78a88e3 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleAssignmentsValidateSample.js @@ -0,0 +1,66 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Validate a role assignment create or update operation by scope and name. + * + * @summary Validate a role assignment create or update operation by scope and name. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ValidateInvalid.json + */ +async function validateARoleAssignmentCreateOrUpdateOperationWithFailedValidation() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + const roleAssignmentName = "05c5a614-a7d6-4502-b150-c2fb455033ff"; + const parameters = { + principalId: "ce2ce14e-85d7-4629-bdbc-454d0519d987", + principalType: "User", + roleDefinitionId: + "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d", + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.validate(scope, roleAssignmentName, parameters); + console.log(result); +} + +/** + * This sample demonstrates how to Validate a role assignment create or update operation by scope and name. + * + * @summary Validate a role assignment create or update operation by scope and name. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ValidateValid.json + */ +async function validateARoleAssignmentCreateOrUpdateOperationWithSuccessfulValidation() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + const roleAssignmentName = "05c5a614-a7d6-4502-b150-c2fb455033ff"; + const parameters = { + principalId: "ce2ce14e-85d7-4629-bdbc-454d0519d987", + principalType: "User", + roleDefinitionId: + "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d", + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.validate(scope, roleAssignmentName, parameters); + console.log(result); +} + +async function main() { + validateARoleAssignmentCreateOrUpdateOperationWithFailedValidation(); + validateARoleAssignmentCreateOrUpdateOperationWithSuccessfulValidation(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilityScheduleInstancesGetSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilityScheduleInstancesGetSample.js new file mode 100644 index 000000000000..876952a15b89 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilityScheduleInstancesGetSample.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the specified role eligibility schedule instance. + * + * @summary Gets the specified role eligibility schedule instance. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilityScheduleInstanceByName.json + */ +async function getRoleEligibilityScheduleInstanceByName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleEligibilityScheduleInstanceName = "21e4b59a-0499-4fe0-a3c3-43a3055b773a"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleEligibilityScheduleInstances.get( + scope, + roleEligibilityScheduleInstanceName + ); + console.log(result); +} + +async function main() { + getRoleEligibilityScheduleInstanceByName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilityScheduleInstancesListForScopeSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilityScheduleInstancesListForScopeSample.js new file mode 100644 index 000000000000..20c5d14e04db --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilityScheduleInstancesListForScopeSample.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets role eligibility schedule instances of a role eligibility schedule. + * + * @summary Gets role eligibility schedule instances of a role eligibility schedule. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilityScheduleInstancesByScope.json + */ +async function getRoleEligibilityScheduleInstancesByScope() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const filter = "assignedTo('a3bb8764-cb92-4276-9d2a-ca1e895e55ea')"; + const options = { + filter, + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleEligibilityScheduleInstances.listForScope(scope, options)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getRoleEligibilityScheduleInstancesByScope(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilityScheduleRequestsCancelSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilityScheduleRequestsCancelSample.js new file mode 100644 index 000000000000..24cbef5dcc1e --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilityScheduleRequestsCancelSample.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Cancels a pending role eligibility schedule request. + * + * @summary Cancels a pending role eligibility schedule request. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/CancelRoleEligibilityScheduleRequestByName.json + */ +async function cancelRoleEligibilityScheduleRequestByName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleEligibilityScheduleRequestName = "64caffb6-55c0-4deb-a585-68e948ea1ad6"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleEligibilityScheduleRequests.cancel( + scope, + roleEligibilityScheduleRequestName + ); + console.log(result); +} + +async function main() { + cancelRoleEligibilityScheduleRequestByName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilityScheduleRequestsCreateSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilityScheduleRequestsCreateSample.js new file mode 100644 index 000000000000..247ad4abf45b --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilityScheduleRequestsCreateSample.js @@ -0,0 +1,58 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Creates a role eligibility schedule request. + * + * @summary Creates a role eligibility schedule request. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/PutRoleEligibilityScheduleRequest.json + */ +async function putRoleEligibilityScheduleRequest() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleEligibilityScheduleRequestName = "64caffb6-55c0-4deb-a585-68e948ea1ad6"; + const parameters = { + condition: + "@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'", + conditionVersion: "1.0", + principalId: "a3bb8764-cb92-4276-9d2a-ca1e895e55ea", + requestType: "AdminAssign", + roleDefinitionId: + "/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/roleDefinitions/c8d4ff99-41c3-41a8-9f60-21dfdad59608", + scheduleInfo: { + expiration: { + type: "AfterDuration", + duration: "P365D", + endDateTime: undefined, + }, + startDateTime: new Date("2020-09-09T21:31:27.91Z"), + }, + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleEligibilityScheduleRequests.create( + scope, + roleEligibilityScheduleRequestName, + parameters + ); + console.log(result); +} + +async function main() { + putRoleEligibilityScheduleRequest(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilityScheduleRequestsGetSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilityScheduleRequestsGetSample.js new file mode 100644 index 000000000000..42a87001236a --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilityScheduleRequestsGetSample.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Get the specified role eligibility schedule request. + * + * @summary Get the specified role eligibility schedule request. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilityScheduleRequestByName.json + */ +async function getRoleEligibilityScheduleRequestByName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleEligibilityScheduleRequestName = "64caffb6-55c0-4deb-a585-68e948ea1ad6"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleEligibilityScheduleRequests.get( + scope, + roleEligibilityScheduleRequestName + ); + console.log(result); +} + +async function main() { + getRoleEligibilityScheduleRequestByName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilityScheduleRequestsListForScopeSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilityScheduleRequestsListForScopeSample.js new file mode 100644 index 000000000000..b1d782cc825d --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilityScheduleRequestsListForScopeSample.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets role eligibility schedule requests for a scope. + * + * @summary Gets role eligibility schedule requests for a scope. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilityScheduleRequestByScope.json + */ +async function getRoleEligibilityScheduleRequestByScope() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const filter = "assignedTo('A3BB8764-CB92-4276-9D2A-CA1E895E55EA')"; + const options = { + filter, + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleEligibilityScheduleRequests.listForScope(scope, options)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getRoleEligibilityScheduleRequestByScope(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilitySchedulesGetSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilitySchedulesGetSample.js new file mode 100644 index 000000000000..4ce155f87724 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilitySchedulesGetSample.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Get the specified role eligibility schedule for a resource scope + * + * @summary Get the specified role eligibility schedule for a resource scope + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilityScheduleByName.json + */ +async function getRoleEligibilityScheduleByName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleEligibilityScheduleName = "b1477448-2cc6-4ceb-93b4-54a202a89413"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleEligibilitySchedules.get(scope, roleEligibilityScheduleName); + console.log(result); +} + +async function main() { + getRoleEligibilityScheduleByName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilitySchedulesListForScopeSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilitySchedulesListForScopeSample.js new file mode 100644 index 000000000000..b59d8f2e56ee --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleEligibilitySchedulesListForScopeSample.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets role eligibility schedules for a resource scope. + * + * @summary Gets role eligibility schedules for a resource scope. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilitySchedulesByScope.json + */ +async function getRoleEligibilitySchedulesByScope() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const filter = "assignedTo('a3bb8764-cb92-4276-9d2a-ca1e895e55ea')"; + const options = { + filter, + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleEligibilitySchedules.listForScope(scope, options)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getRoleEligibilitySchedulesByScope(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPoliciesDeleteSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPoliciesDeleteSample.js new file mode 100644 index 000000000000..99d30af509f6 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPoliciesDeleteSample.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Delete a role management policy + * + * @summary Delete a role management policy + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/DeleteRoleManagementPolicy.json + */ +async function deleteRoleManagementPolicy() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + const roleManagementPolicyName = "570c3619-7688-4b34-b290-2b8bb3ccab2a"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleManagementPolicies.delete(scope, roleManagementPolicyName); + console.log(result); +} + +async function main() { + deleteRoleManagementPolicy(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPoliciesGetSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPoliciesGetSample.js new file mode 100644 index 000000000000..73968b8985a9 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPoliciesGetSample.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Get the specified role management policy for a resource scope + * + * @summary Get the specified role management policy for a resource scope + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleManagementPolicyByName.json + */ +async function getRoleManagementPolicyByName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + const roleManagementPolicyName = "570c3619-7688-4b34-b290-2b8bb3ccab2a"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleManagementPolicies.get(scope, roleManagementPolicyName); + console.log(result); +} + +async function main() { + getRoleManagementPolicyByName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPoliciesListForScopeSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPoliciesListForScopeSample.js new file mode 100644 index 000000000000..6cd4282ee649 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPoliciesListForScopeSample.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets role management policies for a resource scope. + * + * @summary Gets role management policies for a resource scope. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleManagementPolicyByScope.json + */ +async function getRoleManagementPolicyByRoleDefinitionFilter() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleManagementPolicies.listForScope(scope)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getRoleManagementPolicyByRoleDefinitionFilter(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPoliciesUpdateSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPoliciesUpdateSample.js new file mode 100644 index 000000000000..4ba38e410eb6 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPoliciesUpdateSample.js @@ -0,0 +1,392 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Update a role management policy + * + * @summary Update a role management policy + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/PatchPartialRoleManagementPolicy.json + */ +async function patchPartialRoleManagementPolicy() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + const roleManagementPolicyName = "570c3619-7688-4b34-b290-2b8bb3ccab2a"; + const parameters = { + rules: [ + { + id: "Expiration_Admin_Eligibility", + isExpirationRequired: false, + maximumDuration: "P180D", + ruleType: "RoleManagementPolicyExpirationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Eligibility", + targetObjects: [], + operations: ["All"], + }, + }, + { + id: "Notification_Admin_Admin_Eligibility", + isDefaultRecipientsEnabled: false, + notificationLevel: "Critical", + notificationRecipients: ["admin_admin_eligible@test.com"], + notificationType: "Email", + recipientType: "Admin", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Eligibility", + targetObjects: [], + operations: ["All"], + }, + }, + ], + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleManagementPolicies.update( + scope, + roleManagementPolicyName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Update a role management policy + * + * @summary Update a role management policy + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/PatchRoleManagementPolicy.json + */ +async function patchRoleManagementPolicy() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + const roleManagementPolicyName = "570c3619-7688-4b34-b290-2b8bb3ccab2a"; + const parameters = { + rules: [ + { + id: "Expiration_Admin_Eligibility", + isExpirationRequired: false, + maximumDuration: "P180D", + ruleType: "RoleManagementPolicyExpirationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Eligibility", + targetObjects: [], + operations: ["All"], + }, + }, + { + id: "Notification_Admin_Admin_Eligibility", + isDefaultRecipientsEnabled: false, + notificationLevel: "Critical", + notificationRecipients: ["admin_admin_eligible@test.com"], + notificationType: "Email", + recipientType: "Admin", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Eligibility", + targetObjects: [], + operations: ["All"], + }, + }, + { + id: "Notification_Requestor_Admin_Eligibility", + isDefaultRecipientsEnabled: false, + notificationLevel: "Critical", + notificationRecipients: ["requestor_admin_eligible@test.com"], + notificationType: "Email", + recipientType: "Requestor", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Eligibility", + targetObjects: [], + operations: ["All"], + }, + }, + { + id: "Notification_Approver_Admin_Eligibility", + isDefaultRecipientsEnabled: false, + notificationLevel: "Critical", + notificationRecipients: ["approver_admin_eligible@test.com"], + notificationType: "Email", + recipientType: "Approver", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Eligibility", + targetObjects: [], + operations: ["All"], + }, + }, + { + enabledRules: [], + id: "Enablement_Admin_Eligibility", + ruleType: "RoleManagementPolicyEnablementRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Eligibility", + targetObjects: [], + operations: ["All"], + }, + }, + { + id: "Expiration_Admin_Assignment", + isExpirationRequired: false, + maximumDuration: "P90D", + ruleType: "RoleManagementPolicyExpirationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"], + }, + }, + { + enabledRules: ["Justification", "MultiFactorAuthentication"], + id: "Enablement_Admin_Assignment", + ruleType: "RoleManagementPolicyEnablementRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"], + }, + }, + { + id: "Notification_Admin_Admin_Assignment", + isDefaultRecipientsEnabled: false, + notificationLevel: "Critical", + notificationRecipients: ["admin_admin_member@test.com"], + notificationType: "Email", + recipientType: "Admin", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"], + }, + }, + { + id: "Notification_Requestor_Admin_Assignment", + isDefaultRecipientsEnabled: false, + notificationLevel: "Critical", + notificationRecipients: ["requestor_admin_member@test.com"], + notificationType: "Email", + recipientType: "Requestor", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"], + }, + }, + { + id: "Notification_Approver_Admin_Assignment", + isDefaultRecipientsEnabled: false, + notificationLevel: "Critical", + notificationRecipients: ["approver_admin_member@test.com"], + notificationType: "Email", + recipientType: "Approver", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"], + }, + }, + { + id: "Expiration_EndUser_Assignment", + isExpirationRequired: true, + maximumDuration: "PT7H", + ruleType: "RoleManagementPolicyExpirationRule", + target: { + caller: "EndUser", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"], + }, + }, + { + enabledRules: ["Justification", "MultiFactorAuthentication", "Ticketing"], + id: "Enablement_EndUser_Assignment", + ruleType: "RoleManagementPolicyEnablementRule", + target: { + caller: "EndUser", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"], + }, + }, + { + id: "Approval_EndUser_Assignment", + ruleType: "RoleManagementPolicyApprovalRule", + setting: { + approvalMode: "SingleStage", + approvalStages: [ + { + approvalStageTimeOutInDays: 1, + escalationApprovers: [], + escalationTimeInMinutes: 0, + isApproverJustificationRequired: true, + isEscalationEnabled: false, + primaryApprovers: [ + { + description: "amansw_new_group", + id: "2385b0f3-5fa9-43cf-8ca4-b01dc97298cd", + isBackup: false, + userType: "Group", + }, + { + description: "amansw_group", + id: "2f4913c9-d15b-406a-9946-1d66a28f2690", + isBackup: false, + userType: "Group", + }, + ], + }, + ], + isApprovalRequired: true, + isApprovalRequiredForExtension: false, + isRequestorJustificationRequired: true, + }, + target: { + caller: "EndUser", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"], + }, + }, + { + claimValue: "", + id: "AuthenticationContext_EndUser_Assignment", + isEnabled: false, + ruleType: "RoleManagementPolicyAuthenticationContextRule", + target: { + caller: "EndUser", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"], + }, + }, + { + id: "Notification_Admin_EndUser_Assignment", + isDefaultRecipientsEnabled: false, + notificationLevel: "Critical", + notificationRecipients: ["admin_enduser_member@test.com"], + notificationType: "Email", + recipientType: "Admin", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "EndUser", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"], + }, + }, + { + id: "Notification_Requestor_EndUser_Assignment", + isDefaultRecipientsEnabled: false, + notificationLevel: "Critical", + notificationRecipients: ["requestor_enduser_member@test.com"], + notificationType: "Email", + recipientType: "Requestor", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "EndUser", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"], + }, + }, + { + id: "Notification_Approver_EndUser_Assignment", + isDefaultRecipientsEnabled: true, + notificationLevel: "Critical", + notificationRecipients: [], + notificationType: "Email", + recipientType: "Approver", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "EndUser", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"], + }, + }, + ], + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleManagementPolicies.update( + scope, + roleManagementPolicyName, + parameters + ); + console.log(result); +} + +async function main() { + patchPartialRoleManagementPolicy(); + patchRoleManagementPolicy(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPolicyAssignmentsCreateSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPolicyAssignmentsCreateSample.js new file mode 100644 index 000000000000..f39d8a17312b --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPolicyAssignmentsCreateSample.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Create a role management policy assignment + * + * @summary Create a role management policy assignment + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/PutRoleManagementPolicyAssignment.json + */ +async function getConfigurations() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + const roleManagementPolicyAssignmentName = + "b959d571-f0b5-4042-88a7-01be6cb22db9_a1705bd2-3a8f-45a5-8683-466fcfd5cc24"; + const parameters = { + policyId: + "/providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368/providers/Microsoft.Authorization/roleManagementPolicies/b959d571-f0b5-4042-88a7-01be6cb22db9", + roleDefinitionId: + "/subscriptions/129ff972-28f8-46b8-a726-e497be039368/providers/Microsoft.Authorization/roleDefinitions/a1705bd2-3a8f-45a5-8683-466fcfd5cc24", + scope: "/subscriptions/129ff972-28f8-46b8-a726-e497be039368", + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleManagementPolicyAssignments.create( + scope, + roleManagementPolicyAssignmentName, + parameters + ); + console.log(result); +} + +async function main() { + getConfigurations(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPolicyAssignmentsDeleteSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPolicyAssignmentsDeleteSample.js new file mode 100644 index 000000000000..ce5c0a86e84c --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPolicyAssignmentsDeleteSample.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Delete a role management policy assignment + * + * @summary Delete a role management policy assignment + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/DeleteRoleManagementPolicyAssignment.json + */ +async function getConfigurations() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + const roleManagementPolicyAssignmentName = + "b959d571-f0b5-4042-88a7-01be6cb22db9_a1705bd2-3a8f-45a5-8683-466fcfd5cc24"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleManagementPolicyAssignments.delete( + scope, + roleManagementPolicyAssignmentName + ); + console.log(result); +} + +async function main() { + getConfigurations(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPolicyAssignmentsGetSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPolicyAssignmentsGetSample.js new file mode 100644 index 000000000000..1275fadd30d9 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPolicyAssignmentsGetSample.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Get the specified role management policy assignment for a resource scope + * + * @summary Get the specified role management policy assignment for a resource scope + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleManagementPolicyAssignmentByName.json + */ +async function getConfigurations() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + const roleManagementPolicyAssignmentName = + "b959d571-f0b5-4042-88a7-01be6cb22db9_a1705bd2-3a8f-45a5-8683-466fcfd5cc24"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleManagementPolicyAssignments.get( + scope, + roleManagementPolicyAssignmentName + ); + console.log(result); +} + +async function main() { + getConfigurations(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPolicyAssignmentsListForScopeSample.js b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPolicyAssignmentsListForScopeSample.js new file mode 100644 index 000000000000..7e610404f47e --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/roleManagementPolicyAssignmentsListForScopeSample.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { AuthorizationManagementClient } = require("@azure/arm-authorization"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets role management assignment policies for a resource scope. + * + * @summary Gets role management assignment policies for a resource scope. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleManagementPolicyAssignmentByScope.json + */ +async function getConfigurations() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleManagementPolicyAssignments.listForScope(scope)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getConfigurations(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/javascript/sample.env b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/javascript/sample.env @@ -0,0 +1,4 @@ +# App registration secret for AAD authentication +AZURE_CLIENT_SECRET= +AZURE_CLIENT_ID= +AZURE_TENANT_ID= \ No newline at end of file diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/README.md b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/README.md new file mode 100644 index 000000000000..7c51835995b4 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/README.md @@ -0,0 +1,135 @@ +# client library samples for TypeScript (Beta) + +These sample programs show how to use the TypeScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [eligibleChildResourcesGetSample.ts][eligiblechildresourcesgetsample] | Get the child resources of a resource on which user has eligible access x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetEligibleChildResourcesByScope.json | +| [roleAssignmentScheduleInstancesGetSample.ts][roleassignmentscheduleinstancesgetsample] | Gets the specified role assignment schedule instance. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentScheduleInstanceByName.json | +| [roleAssignmentScheduleInstancesListForScopeSample.ts][roleassignmentscheduleinstanceslistforscopesample] | Gets role assignment schedule instances of a role assignment schedule. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentScheduleInstancesByScope.json | +| [roleAssignmentScheduleRequestsCancelSample.ts][roleassignmentschedulerequestscancelsample] | Cancels a pending role assignment schedule request. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/CancelRoleAssignmentScheduleRequestByName.json | +| [roleAssignmentScheduleRequestsCreateSample.ts][roleassignmentschedulerequestscreatesample] | Creates a role assignment schedule request. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/PutRoleAssignmentScheduleRequest.json | +| [roleAssignmentScheduleRequestsGetSample.ts][roleassignmentschedulerequestsgetsample] | Get the specified role assignment schedule request. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentScheduleRequestByName.json | +| [roleAssignmentScheduleRequestsListForScopeSample.ts][roleassignmentschedulerequestslistforscopesample] | Gets role assignment schedule requests for a scope. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentScheduleRequestByScope.json | +| [roleAssignmentSchedulesGetSample.ts][roleassignmentschedulesgetsample] | Get the specified role assignment schedule for a resource scope x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentScheduleByName.json | +| [roleAssignmentSchedulesListForScopeSample.ts][roleassignmentscheduleslistforscopesample] | Gets role assignment schedules for a resource scope. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentSchedulesByScope.json | +| [roleAssignmentsCreateByIdSample.ts][roleassignmentscreatebyidsample] | Create or update a role assignment by ID. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_CreateById.json | +| [roleAssignmentsCreateSample.ts][roleassignmentscreatesample] | Create or update a role assignment by scope and name. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_CreateForResource.json | +| [roleAssignmentsDeleteByIdSample.ts][roleassignmentsdeletebyidsample] | Delete a role assignment by ID. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_DeleteById.json | +| [roleAssignmentsDeleteSample.ts][roleassignmentsdeletesample] | Delete a role assignment by scope and name. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_Delete.json | +| [roleAssignmentsGetByIdSample.ts][roleassignmentsgetbyidsample] | Get a role assignment by ID. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_GetById.json | +| [roleAssignmentsGetSample.ts][roleassignmentsgetsample] | Get a role assignment by scope and name. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_Get.json | +| [roleAssignmentsListForResourceGroupSample.ts][roleassignmentslistforresourcegroupsample] | List all role assignments that apply to a resource group. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ListForResourceGroup.json | +| [roleAssignmentsListForResourceSample.ts][roleassignmentslistforresourcesample] | List all role assignments that apply to a resource. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ListForResource.json | +| [roleAssignmentsListForScopeSample.ts][roleassignmentslistforscopesample] | List all role assignments that apply to a scope. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ListForScope.json | +| [roleAssignmentsListForSubscriptionSample.ts][roleassignmentslistforsubscriptionsample] | List all role assignments that apply to a subscription. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ListForSubscription.json | +| [roleAssignmentsValidateByIdSample.ts][roleassignmentsvalidatebyidsample] | Validate a role assignment create or update operation by ID. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ValidateByIdInvalid.json | +| [roleAssignmentsValidateSample.ts][roleassignmentsvalidatesample] | Validate a role assignment create or update operation by scope and name. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ValidateInvalid.json | +| [roleEligibilityScheduleInstancesGetSample.ts][roleeligibilityscheduleinstancesgetsample] | Gets the specified role eligibility schedule instance. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilityScheduleInstanceByName.json | +| [roleEligibilityScheduleInstancesListForScopeSample.ts][roleeligibilityscheduleinstanceslistforscopesample] | Gets role eligibility schedule instances of a role eligibility schedule. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilityScheduleInstancesByScope.json | +| [roleEligibilityScheduleRequestsCancelSample.ts][roleeligibilityschedulerequestscancelsample] | Cancels a pending role eligibility schedule request. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/CancelRoleEligibilityScheduleRequestByName.json | +| [roleEligibilityScheduleRequestsCreateSample.ts][roleeligibilityschedulerequestscreatesample] | Creates a role eligibility schedule request. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/PutRoleEligibilityScheduleRequest.json | +| [roleEligibilityScheduleRequestsGetSample.ts][roleeligibilityschedulerequestsgetsample] | Get the specified role eligibility schedule request. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilityScheduleRequestByName.json | +| [roleEligibilityScheduleRequestsListForScopeSample.ts][roleeligibilityschedulerequestslistforscopesample] | Gets role eligibility schedule requests for a scope. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilityScheduleRequestByScope.json | +| [roleEligibilitySchedulesGetSample.ts][roleeligibilityschedulesgetsample] | Get the specified role eligibility schedule for a resource scope x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilityScheduleByName.json | +| [roleEligibilitySchedulesListForScopeSample.ts][roleeligibilityscheduleslistforscopesample] | Gets role eligibility schedules for a resource scope. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilitySchedulesByScope.json | +| [roleManagementPoliciesDeleteSample.ts][rolemanagementpoliciesdeletesample] | Delete a role management policy x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/DeleteRoleManagementPolicy.json | +| [roleManagementPoliciesGetSample.ts][rolemanagementpoliciesgetsample] | Get the specified role management policy for a resource scope x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleManagementPolicyByName.json | +| [roleManagementPoliciesListForScopeSample.ts][rolemanagementpolicieslistforscopesample] | Gets role management policies for a resource scope. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleManagementPolicyByScope.json | +| [roleManagementPoliciesUpdateSample.ts][rolemanagementpoliciesupdatesample] | Update a role management policy x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/PatchPartialRoleManagementPolicy.json | +| [roleManagementPolicyAssignmentsCreateSample.ts][rolemanagementpolicyassignmentscreatesample] | Create a role management policy assignment x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/PutRoleManagementPolicyAssignment.json | +| [roleManagementPolicyAssignmentsDeleteSample.ts][rolemanagementpolicyassignmentsdeletesample] | Delete a role management policy assignment x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/DeleteRoleManagementPolicyAssignment.json | +| [roleManagementPolicyAssignmentsGetSample.ts][rolemanagementpolicyassignmentsgetsample] | Get the specified role management policy assignment for a resource scope x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleManagementPolicyAssignmentByName.json | +| [roleManagementPolicyAssignmentsListForScopeSample.ts][rolemanagementpolicyassignmentslistforscopesample] | Gets role management assignment policies for a resource scope. x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleManagementPolicyAssignmentByScope.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). + +Before running the samples in Node, they must be compiled to JavaScript using the TypeScript compiler. For more information on TypeScript, see the [TypeScript documentation][typescript]. Install the TypeScript compiler using: + +```bash +npm install -g typescript +``` + +You need [an Azure subscription][freesub] to run these sample programs. + +Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. + +Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. + +## Setup + +To run the samples using the published version of the package: + +1. Install the dependencies using `npm`: + +```bash +npm install +``` + +2. Compile the samples: + +```bash +npm run build +``` + +3. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. + +4. Run whichever samples you like (note that some samples may require additional setup, see the table above): + +```bash +node dist/eligibleChildResourcesGetSample.js +``` + +Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): + +```bash +npx cross-env AUTHORIZATION_SUBSCRIPTION_ID="" node dist/eligibleChildResourcesGetSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[eligiblechildresourcesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/eligibleChildResourcesGetSample.ts +[roleassignmentscheduleinstancesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentScheduleInstancesGetSample.ts +[roleassignmentscheduleinstanceslistforscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentScheduleInstancesListForScopeSample.ts +[roleassignmentschedulerequestscancelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentScheduleRequestsCancelSample.ts +[roleassignmentschedulerequestscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentScheduleRequestsCreateSample.ts +[roleassignmentschedulerequestsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentScheduleRequestsGetSample.ts +[roleassignmentschedulerequestslistforscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentScheduleRequestsListForScopeSample.ts +[roleassignmentschedulesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentSchedulesGetSample.ts +[roleassignmentscheduleslistforscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentSchedulesListForScopeSample.ts +[roleassignmentscreatebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsCreateByIdSample.ts +[roleassignmentscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsCreateSample.ts +[roleassignmentsdeletebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsDeleteByIdSample.ts +[roleassignmentsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsDeleteSample.ts +[roleassignmentsgetbyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsGetByIdSample.ts +[roleassignmentsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsGetSample.ts +[roleassignmentslistforresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsListForResourceGroupSample.ts +[roleassignmentslistforresourcesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsListForResourceSample.ts +[roleassignmentslistforscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsListForScopeSample.ts +[roleassignmentslistforsubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsListForSubscriptionSample.ts +[roleassignmentsvalidatebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsValidateByIdSample.ts +[roleassignmentsvalidatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsValidateSample.ts +[roleeligibilityscheduleinstancesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilityScheduleInstancesGetSample.ts +[roleeligibilityscheduleinstanceslistforscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilityScheduleInstancesListForScopeSample.ts +[roleeligibilityschedulerequestscancelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilityScheduleRequestsCancelSample.ts +[roleeligibilityschedulerequestscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilityScheduleRequestsCreateSample.ts +[roleeligibilityschedulerequestsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilityScheduleRequestsGetSample.ts +[roleeligibilityschedulerequestslistforscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilityScheduleRequestsListForScopeSample.ts +[roleeligibilityschedulesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilitySchedulesGetSample.ts +[roleeligibilityscheduleslistforscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilitySchedulesListForScopeSample.ts +[rolemanagementpoliciesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPoliciesDeleteSample.ts +[rolemanagementpoliciesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPoliciesGetSample.ts +[rolemanagementpolicieslistforscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPoliciesListForScopeSample.ts +[rolemanagementpoliciesupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPoliciesUpdateSample.ts +[rolemanagementpolicyassignmentscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPolicyAssignmentsCreateSample.ts +[rolemanagementpolicyassignmentsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPolicyAssignmentsDeleteSample.ts +[rolemanagementpolicyassignmentsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPolicyAssignmentsGetSample.ts +[rolemanagementpolicyassignmentslistforscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPolicyAssignmentsListForScopeSample.ts +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-authorization?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/authorization/arm-authorization/README.md +[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/package.json b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/package.json new file mode 100644 index 000000000000..371fad0af8ac --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/package.json @@ -0,0 +1,41 @@ +{ + "name": "@azure-samples/arm-authorization-ts-beta", + "private": true, + "version": "1.0.0", + "description": " client library samples for TypeScript (Beta)", + "engines": { + "node": ">=14.0.0" + }, + "scripts": { + "build": "tsc", + "prebuild": "rimraf dist/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/authorization/arm-authorization" + }, + "keywords": [ + "node", + "azure", + "typescript", + "browser", + "isomorphic" + ], + "author": "Microsoft Corporation", + "license": "MIT", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/authorization/arm-authorization", + "dependencies": { + "@azure/arm-authorization": "next", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + }, + "devDependencies": { + "@types/node": "^14.0.0", + "typescript": "~4.8.0", + "rimraf": "latest" + } +} diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/sample.env b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/sample.env @@ -0,0 +1,4 @@ +# App registration secret for AAD authentication +AZURE_CLIENT_SECRET= +AZURE_CLIENT_ID= +AZURE_TENANT_ID= \ No newline at end of file diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/eligibleChildResourcesGetSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/eligibleChildResourcesGetSample.ts new file mode 100644 index 000000000000..78433606341b --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/eligibleChildResourcesGetSample.ts @@ -0,0 +1,47 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + EligibleChildResourcesGetOptionalParams, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get the child resources of a resource on which user has eligible access + * + * @summary Get the child resources of a resource on which user has eligible access + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetEligibleChildResourcesByScope.json + */ +async function getEligibleChildResourcesByScope() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const filter = "resourceType+eq+'resourcegroup'"; + const options: EligibleChildResourcesGetOptionalParams = { filter }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.eligibleChildResources.list(scope, options)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getEligibleChildResourcesByScope(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentScheduleInstancesGetSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentScheduleInstancesGetSample.ts new file mode 100644 index 000000000000..5859ad796c11 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentScheduleInstancesGetSample.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified role assignment schedule instance. + * + * @summary Gets the specified role assignment schedule instance. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentScheduleInstanceByName.json + */ +async function getRoleAssignmentScheduleInstanceByName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleAssignmentScheduleInstanceName = + "ed9b8180-cef7-4c77-a63c-b8566ecfc412"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignmentScheduleInstances.get( + scope, + roleAssignmentScheduleInstanceName + ); + console.log(result); +} + +async function main() { + getRoleAssignmentScheduleInstanceByName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentScheduleInstancesListForScopeSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentScheduleInstancesListForScopeSample.ts new file mode 100644 index 000000000000..60c6c596c8cc --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentScheduleInstancesListForScopeSample.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleAssignmentScheduleInstancesListForScopeOptionalParams, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets role assignment schedule instances of a role assignment schedule. + * + * @summary Gets role assignment schedule instances of a role assignment schedule. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentScheduleInstancesByScope.json + */ +async function getRoleAssignmentScheduleInstancesByScope() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const filter = "assignedTo('a3bb8764-cb92-4276-9d2a-ca1e895e55ea')"; + const options: RoleAssignmentScheduleInstancesListForScopeOptionalParams = { + filter + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleAssignmentScheduleInstances.listForScope( + scope, + options + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getRoleAssignmentScheduleInstancesByScope(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentScheduleRequestsCancelSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentScheduleRequestsCancelSample.ts new file mode 100644 index 000000000000..39586a9dfa06 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentScheduleRequestsCancelSample.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Cancels a pending role assignment schedule request. + * + * @summary Cancels a pending role assignment schedule request. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/CancelRoleAssignmentScheduleRequestByName.json + */ +async function cancelRoleAssignmentScheduleRequestByName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleAssignmentScheduleRequestName = + "fea7a502-9a96-4806-a26f-eee560e52045"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignmentScheduleRequests.cancel( + scope, + roleAssignmentScheduleRequestName + ); + console.log(result); +} + +async function main() { + cancelRoleAssignmentScheduleRequestByName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentScheduleRequestsCreateSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentScheduleRequestsCreateSample.ts new file mode 100644 index 000000000000..01d1032dc5cd --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentScheduleRequestsCreateSample.ts @@ -0,0 +1,66 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleAssignmentScheduleRequest, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates a role assignment schedule request. + * + * @summary Creates a role assignment schedule request. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/PutRoleAssignmentScheduleRequest.json + */ +async function putRoleAssignmentScheduleRequest() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleAssignmentScheduleRequestName = + "fea7a502-9a96-4806-a26f-eee560e52045"; + const parameters: RoleAssignmentScheduleRequest = { + condition: + "@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'", + conditionVersion: "1.0", + linkedRoleEligibilityScheduleId: "b1477448-2cc6-4ceb-93b4-54a202a89413", + principalId: "a3bb8764-cb92-4276-9d2a-ca1e895e55ea", + requestType: "SelfActivate", + roleDefinitionId: + "/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/roleDefinitions/c8d4ff99-41c3-41a8-9f60-21dfdad59608", + scheduleInfo: { + expiration: { + type: "AfterDuration", + duration: "PT8H", + endDateTime: undefined + }, + startDateTime: new Date("2020-09-09T21:35:27.91Z") + } + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignmentScheduleRequests.create( + scope, + roleAssignmentScheduleRequestName, + parameters + ); + console.log(result); +} + +async function main() { + putRoleAssignmentScheduleRequest(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentScheduleRequestsGetSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentScheduleRequestsGetSample.ts new file mode 100644 index 000000000000..b3ced6a7d1fc --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentScheduleRequestsGetSample.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get the specified role assignment schedule request. + * + * @summary Get the specified role assignment schedule request. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentScheduleRequestByName.json + */ +async function getRoleAssignmentScheduleRequestByName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleAssignmentScheduleRequestName = + "fea7a502-9a96-4806-a26f-eee560e52045"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignmentScheduleRequests.get( + scope, + roleAssignmentScheduleRequestName + ); + console.log(result); +} + +async function main() { + getRoleAssignmentScheduleRequestByName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentScheduleRequestsListForScopeSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentScheduleRequestsListForScopeSample.ts new file mode 100644 index 000000000000..283b3ef5df9b --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentScheduleRequestsListForScopeSample.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleAssignmentScheduleRequestsListForScopeOptionalParams, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets role assignment schedule requests for a scope. + * + * @summary Gets role assignment schedule requests for a scope. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentScheduleRequestByScope.json + */ +async function getRoleAssignmentScheduleRequestByScope() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const filter = "assignedTo('A3BB8764-CB92-4276-9D2A-CA1E895E55EA')"; + const options: RoleAssignmentScheduleRequestsListForScopeOptionalParams = { + filter + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleAssignmentScheduleRequests.listForScope( + scope, + options + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getRoleAssignmentScheduleRequestByScope(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentSchedulesGetSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentSchedulesGetSample.ts new file mode 100644 index 000000000000..52c5ef87b6d6 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentSchedulesGetSample.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get the specified role assignment schedule for a resource scope + * + * @summary Get the specified role assignment schedule for a resource scope + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentScheduleByName.json + */ +async function getRoleAssignmentScheduleByName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleAssignmentScheduleName = "c9e264ff-3133-4776-a81a-ebc7c33c8ec6"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignmentSchedules.get( + scope, + roleAssignmentScheduleName + ); + console.log(result); +} + +async function main() { + getRoleAssignmentScheduleByName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentSchedulesListForScopeSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentSchedulesListForScopeSample.ts new file mode 100644 index 000000000000..a8a03a0076f9 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentSchedulesListForScopeSample.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleAssignmentSchedulesListForScopeOptionalParams, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets role assignment schedules for a resource scope. + * + * @summary Gets role assignment schedules for a resource scope. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleAssignmentSchedulesByScope.json + */ +async function getRoleAssignmentSchedulesByScope() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const filter = "assignedTo('a3bb8764-cb92-4276-9d2a-ca1e895e55ea')"; + const options: RoleAssignmentSchedulesListForScopeOptionalParams = { filter }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleAssignmentSchedules.listForScope( + scope, + options + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getRoleAssignmentSchedulesByScope(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsCreateByIdSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsCreateByIdSample.ts new file mode 100644 index 000000000000..5660d6d7abc9 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsCreateByIdSample.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleAssignmentCreateParameters, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Create or update a role assignment by ID. + * + * @summary Create or update a role assignment by ID. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_CreateById.json + */ +async function createOrUpdateRoleAssignmentById() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const roleAssignmentId = + "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleAssignments/b0f43c54-e787-4862-89b1-a653fa9cf747"; + const parameters: RoleAssignmentCreateParameters = { + principalId: "ce2ce14e-85d7-4629-bdbc-454d0519d987", + principalType: "User", + roleDefinitionId: + "/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d" + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.createById( + roleAssignmentId, + parameters + ); + console.log(result); +} + +async function main() { + createOrUpdateRoleAssignmentById(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsCreateSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsCreateSample.ts new file mode 100644 index 000000000000..b210e0bc6780 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsCreateSample.ts @@ -0,0 +1,112 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleAssignmentCreateParameters, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Create or update a role assignment by scope and name. + * + * @summary Create or update a role assignment by scope and name. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_CreateForResource.json + */ +async function createRoleAssignmentForResource() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.DocumentDb/databaseAccounts/test-db-account"; + const roleAssignmentName = "05c5a614-a7d6-4502-b150-c2fb455033ff"; + const parameters: RoleAssignmentCreateParameters = { + principalId: "ce2ce14e-85d7-4629-bdbc-454d0519d987", + principalType: "User", + roleDefinitionId: + "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d" + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.create( + scope, + roleAssignmentName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Create or update a role assignment by scope and name. + * + * @summary Create or update a role assignment by scope and name. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_CreateForResourceGroup.json + */ +async function createRoleAssignmentForResourceGroup() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg"; + const roleAssignmentName = "05c5a614-a7d6-4502-b150-c2fb455033ff"; + const parameters: RoleAssignmentCreateParameters = { + principalId: "ce2ce14e-85d7-4629-bdbc-454d0519d987", + principalType: "User", + roleDefinitionId: + "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d" + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.create( + scope, + roleAssignmentName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Create or update a role assignment by scope and name. + * + * @summary Create or update a role assignment by scope and name. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_CreateForSubscription.json + */ +async function createRoleAssignmentForSubscription() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + const roleAssignmentName = "05c5a614-a7d6-4502-b150-c2fb455033ff"; + const parameters: RoleAssignmentCreateParameters = { + principalId: "ce2ce14e-85d7-4629-bdbc-454d0519d987", + principalType: "User", + roleDefinitionId: + "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d" + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.create( + scope, + roleAssignmentName, + parameters + ); + console.log(result); +} + +async function main() { + createRoleAssignmentForResource(); + createRoleAssignmentForResourceGroup(); + createRoleAssignmentForSubscription(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsDeleteByIdSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsDeleteByIdSample.ts new file mode 100644 index 000000000000..3a7837a7b88d --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsDeleteByIdSample.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Delete a role assignment by ID. + * + * @summary Delete a role assignment by ID. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_DeleteById.json + */ +async function deleteRoleAssignmentById() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const roleAssignmentId = + "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleAssignments/b0f43c54-e787-4862-89b1-a653fa9cf747"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.deleteById(roleAssignmentId); + console.log(result); +} + +async function main() { + deleteRoleAssignmentById(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsDeleteSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsDeleteSample.ts new file mode 100644 index 000000000000..9c0c3ccbc7bc --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsDeleteSample.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Delete a role assignment by scope and name. + * + * @summary Delete a role assignment by scope and name. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_Delete.json + */ +async function deleteRoleAssignment() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + const roleAssignmentName = "b0f43c54-e787-4862-89b1-a653fa9cf747"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.delete(scope, roleAssignmentName); + console.log(result); +} + +async function main() { + deleteRoleAssignment(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsGetByIdSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsGetByIdSample.ts new file mode 100644 index 000000000000..9f58610c613b --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsGetByIdSample.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get a role assignment by ID. + * + * @summary Get a role assignment by ID. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_GetById.json + */ +async function getRoleAssignmentById() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const roleAssignmentId = + "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleAssignments/b0f43c54-e787-4862-89b1-a653fa9cf747"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.getById(roleAssignmentId); + console.log(result); +} + +async function main() { + getRoleAssignmentById(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsGetSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsGetSample.ts new file mode 100644 index 000000000000..d1af0d296d08 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsGetSample.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get a role assignment by scope and name. + * + * @summary Get a role assignment by scope and name. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_Get.json + */ +async function getRoleAssignmentByScopeAndName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + const roleAssignmentName = "b0f43c54-e787-4862-89b1-a653fa9cf747"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.get(scope, roleAssignmentName); + console.log(result); +} + +async function main() { + getRoleAssignmentByScopeAndName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsListForResourceGroupSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsListForResourceGroupSample.ts new file mode 100644 index 000000000000..7be2a762c477 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsListForResourceGroupSample.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List all role assignments that apply to a resource group. + * + * @summary List all role assignments that apply to a resource group. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ListForResourceGroup.json + */ +async function listRoleAssignmentsForResourceGroup() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + const resourceGroupName = + process.env["AUTHORIZATION_RESOURCE_GROUP"] || "testrg"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleAssignments.listForResourceGroup( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listRoleAssignmentsForResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsListForResourceSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsListForResourceSample.ts new file mode 100644 index 000000000000..ff2bc90da89c --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsListForResourceSample.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List all role assignments that apply to a resource. + * + * @summary List all role assignments that apply to a resource. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ListForResource.json + */ +async function listRoleAssignmentsForAResource() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + const resourceGroupName = + process.env["AUTHORIZATION_RESOURCE_GROUP"] || "testrg"; + const resourceProviderNamespace = "Microsoft.DocumentDb"; + const resourceType = "databaseAccounts"; + const resourceName = "test-db-account"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleAssignments.listForResource( + resourceGroupName, + resourceProviderNamespace, + resourceType, + resourceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listRoleAssignmentsForAResource(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsListForScopeSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsListForScopeSample.ts new file mode 100644 index 000000000000..3d3731ec0862 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsListForScopeSample.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List all role assignments that apply to a scope. + * + * @summary List all role assignments that apply to a scope. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ListForScope.json + */ +async function listRoleAssignmentsForScope() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleAssignments.listForScope(scope)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listRoleAssignmentsForScope(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsListForSubscriptionSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsListForSubscriptionSample.ts new file mode 100644 index 000000000000..11c76fed583c --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsListForSubscriptionSample.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List all role assignments that apply to a subscription. + * + * @summary List all role assignments that apply to a subscription. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ListForSubscription.json + */ +async function listRoleAssignmentsForSubscription() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleAssignments.listForSubscription()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listRoleAssignmentsForSubscription(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsValidateByIdSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsValidateByIdSample.ts new file mode 100644 index 000000000000..3c76372cd765 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsValidateByIdSample.ts @@ -0,0 +1,79 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleAssignmentCreateParameters, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Validate a role assignment create or update operation by ID. + * + * @summary Validate a role assignment create or update operation by ID. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ValidateByIdInvalid.json + */ +async function validateARoleAssignmentCreateOrUpdateOperationByIdWithFailedValidation() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const roleAssignmentId = + "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleAssignments/b0f43c54-e787-4862-89b1-a653fa9cf747"; + const parameters: RoleAssignmentCreateParameters = { + principalId: "ce2ce14e-85d7-4629-bdbc-454d0519d987", + principalType: "User", + roleDefinitionId: + "/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d" + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.validateById( + roleAssignmentId, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Validate a role assignment create or update operation by ID. + * + * @summary Validate a role assignment create or update operation by ID. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ValidateByIdValid.json + */ +async function validateARoleAssignmentCreateOrUpdateOperationByIdWithSuccessfulValidation() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const roleAssignmentId = + "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleAssignments/b0f43c54-e787-4862-89b1-a653fa9cf747"; + const parameters: RoleAssignmentCreateParameters = { + principalId: "ce2ce14e-85d7-4629-bdbc-454d0519d987", + principalType: "User", + roleDefinitionId: + "/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d" + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.validateById( + roleAssignmentId, + parameters + ); + console.log(result); +} + +async function main() { + validateARoleAssignmentCreateOrUpdateOperationByIdWithFailedValidation(); + validateARoleAssignmentCreateOrUpdateOperationByIdWithSuccessfulValidation(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsValidateSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsValidateSample.ts new file mode 100644 index 000000000000..1966dbf7367c --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleAssignmentsValidateSample.ts @@ -0,0 +1,81 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleAssignmentCreateParameters, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Validate a role assignment create or update operation by scope and name. + * + * @summary Validate a role assignment create or update operation by scope and name. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ValidateInvalid.json + */ +async function validateARoleAssignmentCreateOrUpdateOperationWithFailedValidation() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + const roleAssignmentName = "05c5a614-a7d6-4502-b150-c2fb455033ff"; + const parameters: RoleAssignmentCreateParameters = { + principalId: "ce2ce14e-85d7-4629-bdbc-454d0519d987", + principalType: "User", + roleDefinitionId: + "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d" + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.validate( + scope, + roleAssignmentName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Validate a role assignment create or update operation by scope and name. + * + * @summary Validate a role assignment create or update operation by scope and name. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/RoleAssignments_ValidateValid.json + */ +async function validateARoleAssignmentCreateOrUpdateOperationWithSuccessfulValidation() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + const roleAssignmentName = "05c5a614-a7d6-4502-b150-c2fb455033ff"; + const parameters: RoleAssignmentCreateParameters = { + principalId: "ce2ce14e-85d7-4629-bdbc-454d0519d987", + principalType: "User", + roleDefinitionId: + "/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d" + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleAssignments.validate( + scope, + roleAssignmentName, + parameters + ); + console.log(result); +} + +async function main() { + validateARoleAssignmentCreateOrUpdateOperationWithFailedValidation(); + validateARoleAssignmentCreateOrUpdateOperationWithSuccessfulValidation(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilityScheduleInstancesGetSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilityScheduleInstancesGetSample.ts new file mode 100644 index 000000000000..4f1607896f1b --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilityScheduleInstancesGetSample.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified role eligibility schedule instance. + * + * @summary Gets the specified role eligibility schedule instance. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilityScheduleInstanceByName.json + */ +async function getRoleEligibilityScheduleInstanceByName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleEligibilityScheduleInstanceName = + "21e4b59a-0499-4fe0-a3c3-43a3055b773a"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleEligibilityScheduleInstances.get( + scope, + roleEligibilityScheduleInstanceName + ); + console.log(result); +} + +async function main() { + getRoleEligibilityScheduleInstanceByName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilityScheduleInstancesListForScopeSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilityScheduleInstancesListForScopeSample.ts new file mode 100644 index 000000000000..b8974b01d726 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilityScheduleInstancesListForScopeSample.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleEligibilityScheduleInstancesListForScopeOptionalParams, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets role eligibility schedule instances of a role eligibility schedule. + * + * @summary Gets role eligibility schedule instances of a role eligibility schedule. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilityScheduleInstancesByScope.json + */ +async function getRoleEligibilityScheduleInstancesByScope() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const filter = "assignedTo('a3bb8764-cb92-4276-9d2a-ca1e895e55ea')"; + const options: RoleEligibilityScheduleInstancesListForScopeOptionalParams = { + filter + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleEligibilityScheduleInstances.listForScope( + scope, + options + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getRoleEligibilityScheduleInstancesByScope(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilityScheduleRequestsCancelSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilityScheduleRequestsCancelSample.ts new file mode 100644 index 000000000000..d1564bf1fcd7 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilityScheduleRequestsCancelSample.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Cancels a pending role eligibility schedule request. + * + * @summary Cancels a pending role eligibility schedule request. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/CancelRoleEligibilityScheduleRequestByName.json + */ +async function cancelRoleEligibilityScheduleRequestByName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleEligibilityScheduleRequestName = + "64caffb6-55c0-4deb-a585-68e948ea1ad6"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleEligibilityScheduleRequests.cancel( + scope, + roleEligibilityScheduleRequestName + ); + console.log(result); +} + +async function main() { + cancelRoleEligibilityScheduleRequestByName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilityScheduleRequestsCreateSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilityScheduleRequestsCreateSample.ts new file mode 100644 index 000000000000..2f34bce6c370 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilityScheduleRequestsCreateSample.ts @@ -0,0 +1,65 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleEligibilityScheduleRequest, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates a role eligibility schedule request. + * + * @summary Creates a role eligibility schedule request. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/PutRoleEligibilityScheduleRequest.json + */ +async function putRoleEligibilityScheduleRequest() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleEligibilityScheduleRequestName = + "64caffb6-55c0-4deb-a585-68e948ea1ad6"; + const parameters: RoleEligibilityScheduleRequest = { + condition: + "@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'", + conditionVersion: "1.0", + principalId: "a3bb8764-cb92-4276-9d2a-ca1e895e55ea", + requestType: "AdminAssign", + roleDefinitionId: + "/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/roleDefinitions/c8d4ff99-41c3-41a8-9f60-21dfdad59608", + scheduleInfo: { + expiration: { + type: "AfterDuration", + duration: "P365D", + endDateTime: undefined + }, + startDateTime: new Date("2020-09-09T21:31:27.91Z") + } + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleEligibilityScheduleRequests.create( + scope, + roleEligibilityScheduleRequestName, + parameters + ); + console.log(result); +} + +async function main() { + putRoleEligibilityScheduleRequest(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilityScheduleRequestsGetSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilityScheduleRequestsGetSample.ts new file mode 100644 index 000000000000..1a338db3c6be --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilityScheduleRequestsGetSample.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get the specified role eligibility schedule request. + * + * @summary Get the specified role eligibility schedule request. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilityScheduleRequestByName.json + */ +async function getRoleEligibilityScheduleRequestByName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleEligibilityScheduleRequestName = + "64caffb6-55c0-4deb-a585-68e948ea1ad6"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleEligibilityScheduleRequests.get( + scope, + roleEligibilityScheduleRequestName + ); + console.log(result); +} + +async function main() { + getRoleEligibilityScheduleRequestByName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilityScheduleRequestsListForScopeSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilityScheduleRequestsListForScopeSample.ts new file mode 100644 index 000000000000..74a3159644e0 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilityScheduleRequestsListForScopeSample.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleEligibilityScheduleRequestsListForScopeOptionalParams, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets role eligibility schedule requests for a scope. + * + * @summary Gets role eligibility schedule requests for a scope. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilityScheduleRequestByScope.json + */ +async function getRoleEligibilityScheduleRequestByScope() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const filter = "assignedTo('A3BB8764-CB92-4276-9D2A-CA1E895E55EA')"; + const options: RoleEligibilityScheduleRequestsListForScopeOptionalParams = { + filter + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleEligibilityScheduleRequests.listForScope( + scope, + options + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getRoleEligibilityScheduleRequestByScope(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilitySchedulesGetSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilitySchedulesGetSample.ts new file mode 100644 index 000000000000..dc4feaff5062 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilitySchedulesGetSample.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get the specified role eligibility schedule for a resource scope + * + * @summary Get the specified role eligibility schedule for a resource scope + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilityScheduleByName.json + */ +async function getRoleEligibilityScheduleByName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const roleEligibilityScheduleName = "b1477448-2cc6-4ceb-93b4-54a202a89413"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleEligibilitySchedules.get( + scope, + roleEligibilityScheduleName + ); + console.log(result); +} + +async function main() { + getRoleEligibilityScheduleByName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilitySchedulesListForScopeSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilitySchedulesListForScopeSample.ts new file mode 100644 index 000000000000..ae4098aedf8f --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleEligibilitySchedulesListForScopeSample.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleEligibilitySchedulesListForScopeOptionalParams, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets role eligibility schedules for a resource scope. + * + * @summary Gets role eligibility schedules for a resource scope. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleEligibilitySchedulesByScope.json + */ +async function getRoleEligibilitySchedulesByScope() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + const filter = "assignedTo('a3bb8764-cb92-4276-9d2a-ca1e895e55ea')"; + const options: RoleEligibilitySchedulesListForScopeOptionalParams = { + filter + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleEligibilitySchedules.listForScope( + scope, + options + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getRoleEligibilitySchedulesByScope(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPoliciesDeleteSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPoliciesDeleteSample.ts new file mode 100644 index 000000000000..e681abd9c737 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPoliciesDeleteSample.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Delete a role management policy + * + * @summary Delete a role management policy + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/DeleteRoleManagementPolicy.json + */ +async function deleteRoleManagementPolicy() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + const roleManagementPolicyName = "570c3619-7688-4b34-b290-2b8bb3ccab2a"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleManagementPolicies.delete( + scope, + roleManagementPolicyName + ); + console.log(result); +} + +async function main() { + deleteRoleManagementPolicy(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPoliciesGetSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPoliciesGetSample.ts new file mode 100644 index 000000000000..ec8c129b6652 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPoliciesGetSample.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get the specified role management policy for a resource scope + * + * @summary Get the specified role management policy for a resource scope + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleManagementPolicyByName.json + */ +async function getRoleManagementPolicyByName() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + const roleManagementPolicyName = "570c3619-7688-4b34-b290-2b8bb3ccab2a"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleManagementPolicies.get( + scope, + roleManagementPolicyName + ); + console.log(result); +} + +async function main() { + getRoleManagementPolicyByName(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPoliciesListForScopeSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPoliciesListForScopeSample.ts new file mode 100644 index 000000000000..d9477bd3b940 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPoliciesListForScopeSample.ts @@ -0,0 +1,42 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets role management policies for a resource scope. + * + * @summary Gets role management policies for a resource scope. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleManagementPolicyByScope.json + */ +async function getRoleManagementPolicyByRoleDefinitionFilter() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleManagementPolicies.listForScope(scope)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getRoleManagementPolicyByRoleDefinitionFilter(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPoliciesUpdateSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPoliciesUpdateSample.ts new file mode 100644 index 000000000000..7adab756d255 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPoliciesUpdateSample.ts @@ -0,0 +1,403 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleManagementPolicy, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Update a role management policy + * + * @summary Update a role management policy + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/PatchPartialRoleManagementPolicy.json + */ +async function patchPartialRoleManagementPolicy() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + const roleManagementPolicyName = "570c3619-7688-4b34-b290-2b8bb3ccab2a"; + const parameters: RoleManagementPolicy = { + rules: [ + { + id: "Expiration_Admin_Eligibility", + isExpirationRequired: false, + maximumDuration: "P180D", + ruleType: "RoleManagementPolicyExpirationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Eligibility", + targetObjects: [], + operations: ["All"] + } + }, + { + id: "Notification_Admin_Admin_Eligibility", + isDefaultRecipientsEnabled: false, + notificationLevel: "Critical", + notificationRecipients: ["admin_admin_eligible@test.com"], + notificationType: "Email", + recipientType: "Admin", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Eligibility", + targetObjects: [], + operations: ["All"] + } + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleManagementPolicies.update( + scope, + roleManagementPolicyName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Update a role management policy + * + * @summary Update a role management policy + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/PatchRoleManagementPolicy.json + */ +async function patchRoleManagementPolicy() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + const roleManagementPolicyName = "570c3619-7688-4b34-b290-2b8bb3ccab2a"; + const parameters: RoleManagementPolicy = { + rules: [ + { + id: "Expiration_Admin_Eligibility", + isExpirationRequired: false, + maximumDuration: "P180D", + ruleType: "RoleManagementPolicyExpirationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Eligibility", + targetObjects: [], + operations: ["All"] + } + }, + { + id: "Notification_Admin_Admin_Eligibility", + isDefaultRecipientsEnabled: false, + notificationLevel: "Critical", + notificationRecipients: ["admin_admin_eligible@test.com"], + notificationType: "Email", + recipientType: "Admin", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Eligibility", + targetObjects: [], + operations: ["All"] + } + }, + { + id: "Notification_Requestor_Admin_Eligibility", + isDefaultRecipientsEnabled: false, + notificationLevel: "Critical", + notificationRecipients: ["requestor_admin_eligible@test.com"], + notificationType: "Email", + recipientType: "Requestor", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Eligibility", + targetObjects: [], + operations: ["All"] + } + }, + { + id: "Notification_Approver_Admin_Eligibility", + isDefaultRecipientsEnabled: false, + notificationLevel: "Critical", + notificationRecipients: ["approver_admin_eligible@test.com"], + notificationType: "Email", + recipientType: "Approver", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Eligibility", + targetObjects: [], + operations: ["All"] + } + }, + { + enabledRules: [], + id: "Enablement_Admin_Eligibility", + ruleType: "RoleManagementPolicyEnablementRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Eligibility", + targetObjects: [], + operations: ["All"] + } + }, + { + id: "Expiration_Admin_Assignment", + isExpirationRequired: false, + maximumDuration: "P90D", + ruleType: "RoleManagementPolicyExpirationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"] + } + }, + { + enabledRules: ["Justification", "MultiFactorAuthentication"], + id: "Enablement_Admin_Assignment", + ruleType: "RoleManagementPolicyEnablementRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"] + } + }, + { + id: "Notification_Admin_Admin_Assignment", + isDefaultRecipientsEnabled: false, + notificationLevel: "Critical", + notificationRecipients: ["admin_admin_member@test.com"], + notificationType: "Email", + recipientType: "Admin", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"] + } + }, + { + id: "Notification_Requestor_Admin_Assignment", + isDefaultRecipientsEnabled: false, + notificationLevel: "Critical", + notificationRecipients: ["requestor_admin_member@test.com"], + notificationType: "Email", + recipientType: "Requestor", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"] + } + }, + { + id: "Notification_Approver_Admin_Assignment", + isDefaultRecipientsEnabled: false, + notificationLevel: "Critical", + notificationRecipients: ["approver_admin_member@test.com"], + notificationType: "Email", + recipientType: "Approver", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "Admin", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"] + } + }, + { + id: "Expiration_EndUser_Assignment", + isExpirationRequired: true, + maximumDuration: "PT7H", + ruleType: "RoleManagementPolicyExpirationRule", + target: { + caller: "EndUser", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"] + } + }, + { + enabledRules: [ + "Justification", + "MultiFactorAuthentication", + "Ticketing" + ], + id: "Enablement_EndUser_Assignment", + ruleType: "RoleManagementPolicyEnablementRule", + target: { + caller: "EndUser", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"] + } + }, + { + id: "Approval_EndUser_Assignment", + ruleType: "RoleManagementPolicyApprovalRule", + setting: { + approvalMode: "SingleStage", + approvalStages: [ + { + approvalStageTimeOutInDays: 1, + escalationApprovers: [], + escalationTimeInMinutes: 0, + isApproverJustificationRequired: true, + isEscalationEnabled: false, + primaryApprovers: [ + { + description: "amansw_new_group", + id: "2385b0f3-5fa9-43cf-8ca4-b01dc97298cd", + isBackup: false, + userType: "Group" + }, + { + description: "amansw_group", + id: "2f4913c9-d15b-406a-9946-1d66a28f2690", + isBackup: false, + userType: "Group" + } + ] + } + ], + isApprovalRequired: true, + isApprovalRequiredForExtension: false, + isRequestorJustificationRequired: true + }, + target: { + caller: "EndUser", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"] + } + }, + { + claimValue: "", + id: "AuthenticationContext_EndUser_Assignment", + isEnabled: false, + ruleType: "RoleManagementPolicyAuthenticationContextRule", + target: { + caller: "EndUser", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"] + } + }, + { + id: "Notification_Admin_EndUser_Assignment", + isDefaultRecipientsEnabled: false, + notificationLevel: "Critical", + notificationRecipients: ["admin_enduser_member@test.com"], + notificationType: "Email", + recipientType: "Admin", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "EndUser", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"] + } + }, + { + id: "Notification_Requestor_EndUser_Assignment", + isDefaultRecipientsEnabled: false, + notificationLevel: "Critical", + notificationRecipients: ["requestor_enduser_member@test.com"], + notificationType: "Email", + recipientType: "Requestor", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "EndUser", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"] + } + }, + { + id: "Notification_Approver_EndUser_Assignment", + isDefaultRecipientsEnabled: true, + notificationLevel: "Critical", + notificationRecipients: [], + notificationType: "Email", + recipientType: "Approver", + ruleType: "RoleManagementPolicyNotificationRule", + target: { + caller: "EndUser", + enforcedSettings: [], + inheritableSettings: [], + level: "Assignment", + targetObjects: [], + operations: ["All"] + } + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleManagementPolicies.update( + scope, + roleManagementPolicyName, + parameters + ); + console.log(result); +} + +async function main() { + patchPartialRoleManagementPolicy(); + patchRoleManagementPolicy(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPolicyAssignmentsCreateSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPolicyAssignmentsCreateSample.ts new file mode 100644 index 000000000000..713df394e36e --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPolicyAssignmentsCreateSample.ts @@ -0,0 +1,55 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RoleManagementPolicyAssignment, + AuthorizationManagementClient +} from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Create a role management policy assignment + * + * @summary Create a role management policy assignment + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/PutRoleManagementPolicyAssignment.json + */ +async function getConfigurations() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + const roleManagementPolicyAssignmentName = + "b959d571-f0b5-4042-88a7-01be6cb22db9_a1705bd2-3a8f-45a5-8683-466fcfd5cc24"; + const parameters: RoleManagementPolicyAssignment = { + policyId: + "/providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368/providers/Microsoft.Authorization/roleManagementPolicies/b959d571-f0b5-4042-88a7-01be6cb22db9", + roleDefinitionId: + "/subscriptions/129ff972-28f8-46b8-a726-e497be039368/providers/Microsoft.Authorization/roleDefinitions/a1705bd2-3a8f-45a5-8683-466fcfd5cc24", + scope: "/subscriptions/129ff972-28f8-46b8-a726-e497be039368" + }; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleManagementPolicyAssignments.create( + scope, + roleManagementPolicyAssignmentName, + parameters + ); + console.log(result); +} + +async function main() { + getConfigurations(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPolicyAssignmentsDeleteSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPolicyAssignmentsDeleteSample.ts new file mode 100644 index 000000000000..ef5b410f6b80 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPolicyAssignmentsDeleteSample.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Delete a role management policy assignment + * + * @summary Delete a role management policy assignment + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/DeleteRoleManagementPolicyAssignment.json + */ +async function getConfigurations() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + const roleManagementPolicyAssignmentName = + "b959d571-f0b5-4042-88a7-01be6cb22db9_a1705bd2-3a8f-45a5-8683-466fcfd5cc24"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleManagementPolicyAssignments.delete( + scope, + roleManagementPolicyAssignmentName + ); + console.log(result); +} + +async function main() { + getConfigurations(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPolicyAssignmentsGetSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPolicyAssignmentsGetSample.ts new file mode 100644 index 000000000000..351f27d44fbb --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPolicyAssignmentsGetSample.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get the specified role management policy assignment for a resource scope + * + * @summary Get the specified role management policy assignment for a resource scope + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleManagementPolicyAssignmentByName.json + */ +async function getConfigurations() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + const roleManagementPolicyAssignmentName = + "b959d571-f0b5-4042-88a7-01be6cb22db9_a1705bd2-3a8f-45a5-8683-466fcfd5cc24"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const result = await client.roleManagementPolicyAssignments.get( + scope, + roleManagementPolicyAssignmentName + ); + console.log(result); +} + +async function main() { + getConfigurations(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPolicyAssignmentsListForScopeSample.ts b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPolicyAssignmentsListForScopeSample.ts new file mode 100644 index 000000000000..084aa147d1cd --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/src/roleManagementPolicyAssignmentsListForScopeSample.ts @@ -0,0 +1,44 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { AuthorizationManagementClient } from "@azure/arm-authorization"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets role management assignment policies for a resource scope. + * + * @summary Gets role management assignment policies for a resource scope. + * x-ms-original-file: specification/authorization/resource-manager/Microsoft.Authorization/preview/2020-10-01-preview/examples/GetRoleManagementPolicyAssignmentByScope.json + */ +async function getConfigurations() { + const subscriptionId = + process.env["AUTHORIZATION_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + const credential = new DefaultAzureCredential(); + const client = new AuthorizationManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.roleManagementPolicyAssignments.listForScope( + scope + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getConfigurations(); +} + +main().catch(console.error); diff --git a/sdk/authorization/arm-authorization/samples/v9-beta/typescript/tsconfig.json b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/tsconfig.json new file mode 100644 index 000000000000..e26ce2a6d8f7 --- /dev/null +++ b/sdk/authorization/arm-authorization/samples/v9-beta/typescript/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "commonjs", + "moduleResolution": "node", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "alwaysStrict": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": [ + "src/**.ts" + ] +} diff --git a/sdk/authorization/arm-authorization/src/authorizationManagementClient.ts b/sdk/authorization/arm-authorization/src/authorizationManagementClient.ts index 23ac722e0ca1..7552ee25469f 100644 --- a/sdk/authorization/arm-authorization/src/authorizationManagementClient.ts +++ b/sdk/authorization/arm-authorization/src/authorizationManagementClient.ts @@ -6,6 +6,13 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ +import * as coreClient from "@azure/core-client"; +import * as coreRestPipeline from "@azure/core-rest-pipeline"; +import { + PipelineRequest, + PipelineResponse, + SendRequest +} from "@azure/core-rest-pipeline"; import * as coreAuth from "@azure/core-auth"; import { RoleAssignmentSchedulesImpl, @@ -31,10 +38,13 @@ import { EligibleChildResources, RoleAssignments } from "./operationsInterfaces"; -import { AuthorizationManagementClientContext } from "./authorizationManagementClientContext"; import { AuthorizationManagementClientOptionalParams } from "./models"; -export class AuthorizationManagementClient extends AuthorizationManagementClientContext { +export class AuthorizationManagementClient extends coreClient.ServiceClient { + $host: string; + apiVersion: string; + subscriptionId: string; + /** * Initializes a new instance of the AuthorizationManagementClient class. * @param credentials Subscription credentials which uniquely identify client subscription. @@ -46,7 +56,76 @@ export class AuthorizationManagementClient extends AuthorizationManagementClient subscriptionId: string, options?: AuthorizationManagementClientOptionalParams ) { - super(credentials, subscriptionId, options); + if (credentials === undefined) { + throw new Error("'credentials' cannot be null"); + } + if (subscriptionId === undefined) { + throw new Error("'subscriptionId' cannot be null"); + } + + // Initializing default values for options + if (!options) { + options = {}; + } + const defaults: AuthorizationManagementClientOptionalParams = { + requestContentType: "application/json; charset=utf-8", + credential: credentials + }; + + const packageDetails = `azsdk-js-arm-authorization/9.0.0-beta.4`; + const userAgentPrefix = + options.userAgentOptions && options.userAgentOptions.userAgentPrefix + ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` + : `${packageDetails}`; + + const optionsWithDefaults = { + ...defaults, + ...options, + userAgentOptions: { + userAgentPrefix + }, + endpoint: + options.endpoint ?? options.baseUri ?? "https://management.azure.com" + }; + super(optionsWithDefaults); + + let bearerTokenAuthenticationPolicyFound: boolean = false; + if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { + const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies(); + bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( + (pipelinePolicy) => + pipelinePolicy.name === + coreRestPipeline.bearerTokenAuthenticationPolicyName + ); + } + if ( + !options || + !options.pipeline || + options.pipeline.getOrderedPolicies().length == 0 || + !bearerTokenAuthenticationPolicyFound + ) { + this.pipeline.removePolicy({ + name: coreRestPipeline.bearerTokenAuthenticationPolicyName + }); + this.pipeline.addPolicy( + coreRestPipeline.bearerTokenAuthenticationPolicy({ + credential: credentials, + scopes: + optionsWithDefaults.credentialScopes ?? + `${optionsWithDefaults.endpoint}/.default`, + challengeCallbacks: { + authorizeRequestOnChallenge: + coreClient.authorizeRequestOnClaimChallenge + } + }) + ); + } + // Parameter assignments + this.subscriptionId = subscriptionId; + + // Assigning values to Constant parameters + this.$host = options.$host || "https://management.azure.com"; + this.apiVersion = options.apiVersion || "2020-10-01-preview"; this.roleAssignmentSchedules = new RoleAssignmentSchedulesImpl(this); this.roleAssignmentScheduleInstances = new RoleAssignmentScheduleInstancesImpl( this @@ -67,6 +146,35 @@ export class AuthorizationManagementClient extends AuthorizationManagementClient ); this.eligibleChildResources = new EligibleChildResourcesImpl(this); this.roleAssignments = new RoleAssignmentsImpl(this); + this.addCustomApiVersionPolicy(options.apiVersion); + } + + /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */ + private addCustomApiVersionPolicy(apiVersion?: string) { + if (!apiVersion) { + return; + } + const apiVersionPolicy = { + name: "CustomApiVersionPolicy", + async sendRequest( + request: PipelineRequest, + next: SendRequest + ): Promise { + const param = request.url.split("?"); + if (param.length > 1) { + const newParams = param[1].split("&").map((item) => { + if (item.indexOf("api-version") > -1) { + return "api-version=" + apiVersion; + } else { + return item; + } + }); + request.url = param[0] + "?" + newParams.join("&"); + } + return next(request); + } + }; + this.pipeline.addPolicy(apiVersionPolicy); } roleAssignmentSchedules: RoleAssignmentSchedules; diff --git a/sdk/authorization/arm-authorization/src/authorizationManagementClientContext.ts b/sdk/authorization/arm-authorization/src/authorizationManagementClientContext.ts deleted file mode 100644 index 5cc28f392655..000000000000 --- a/sdk/authorization/arm-authorization/src/authorizationManagementClientContext.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import * as coreClient from "@azure/core-client"; -import * as coreAuth from "@azure/core-auth"; -import { AuthorizationManagementClientOptionalParams } from "./models"; - -export class AuthorizationManagementClientContext extends coreClient.ServiceClient { - $host: string; - apiVersion: string; - subscriptionId: string; - - /** - * Initializes a new instance of the AuthorizationManagementClientContext class. - * @param credentials Subscription credentials which uniquely identify client subscription. - * @param subscriptionId The ID of the target subscription. - * @param options The parameter options - */ - constructor( - credentials: coreAuth.TokenCredential, - subscriptionId: string, - options?: AuthorizationManagementClientOptionalParams - ) { - if (credentials === undefined) { - throw new Error("'credentials' cannot be null"); - } - if (subscriptionId === undefined) { - throw new Error("'subscriptionId' cannot be null"); - } - - // Initializing default values for options - if (!options) { - options = {}; - } - const defaults: AuthorizationManagementClientOptionalParams = { - requestContentType: "application/json; charset=utf-8", - credential: credentials - }; - - const packageDetails = `azsdk-js-arm-authorization/9.0.0-beta.1`; - const userAgentPrefix = - options.userAgentOptions && options.userAgentOptions.userAgentPrefix - ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` - : `${packageDetails}`; - - if (!options.credentialScopes) { - options.credentialScopes = ["https://management.azure.com/.default"]; - } - const optionsWithDefaults = { - ...defaults, - ...options, - userAgentOptions: { - userAgentPrefix - }, - baseUri: options.endpoint || "https://management.azure.com" - }; - super(optionsWithDefaults); - // Parameter assignments - this.subscriptionId = subscriptionId; - - // Assigning values to Constant parameters - this.$host = options.$host || "https://management.azure.com"; - this.apiVersion = options.apiVersion || "2020-10-01-preview"; - } -} diff --git a/sdk/authorization/arm-authorization/src/index.ts b/sdk/authorization/arm-authorization/src/index.ts index 4902352993d2..1a8d45806eaa 100644 --- a/sdk/authorization/arm-authorization/src/index.ts +++ b/sdk/authorization/arm-authorization/src/index.ts @@ -7,7 +7,7 @@ */ /// +export { getContinuationToken } from "./pagingHelper"; export * from "./models"; export { AuthorizationManagementClient } from "./authorizationManagementClient"; -export { AuthorizationManagementClientContext } from "./authorizationManagementClientContext"; export * from "./operationsInterfaces"; diff --git a/sdk/authorization/arm-authorization/src/models/index.ts b/sdk/authorization/arm-authorization/src/models/index.ts index 2e4c005cd3fc..758a5864bf23 100644 --- a/sdk/authorization/arm-authorization/src/models/index.ts +++ b/sdk/authorization/arm-authorization/src/models/index.ts @@ -1045,43 +1045,48 @@ export interface RoleAssignmentFilter { } /** The role management policy rule. */ -export type RoleManagementPolicyApprovalRule = RoleManagementPolicyRule & { +export interface RoleManagementPolicyApprovalRule + extends RoleManagementPolicyRule { /** Polymorphic discriminator, which specifies the different types this object can be */ ruleType: "RoleManagementPolicyApprovalRule"; /** The approval setting */ setting?: ApprovalSettings; -}; +} /** The role management policy rule. */ -export type RoleManagementPolicyAuthenticationContextRule = RoleManagementPolicyRule & { +export interface RoleManagementPolicyAuthenticationContextRule + extends RoleManagementPolicyRule { /** Polymorphic discriminator, which specifies the different types this object can be */ ruleType: "RoleManagementPolicyAuthenticationContextRule"; /** The value indicating if rule is enabled. */ isEnabled?: boolean; /** The claim value. */ claimValue?: string; -}; +} /** The role management policy rule. */ -export type RoleManagementPolicyEnablementRule = RoleManagementPolicyRule & { +export interface RoleManagementPolicyEnablementRule + extends RoleManagementPolicyRule { /** Polymorphic discriminator, which specifies the different types this object can be */ ruleType: "RoleManagementPolicyEnablementRule"; /** The list of enabled rules. */ enabledRules?: EnablementRules[]; -}; +} /** The role management policy rule. */ -export type RoleManagementPolicyExpirationRule = RoleManagementPolicyRule & { +export interface RoleManagementPolicyExpirationRule + extends RoleManagementPolicyRule { /** Polymorphic discriminator, which specifies the different types this object can be */ ruleType: "RoleManagementPolicyExpirationRule"; /** The value indicating whether expiration is required. */ isExpirationRequired?: boolean; /** The maximum duration of expiration in timespan. */ maximumDuration?: string; -}; +} /** The role management policy rule. */ -export type RoleManagementPolicyNotificationRule = RoleManagementPolicyRule & { +export interface RoleManagementPolicyNotificationRule + extends RoleManagementPolicyRule { /** Polymorphic discriminator, which specifies the different types this object can be */ ruleType: "RoleManagementPolicyNotificationRule"; /** The type of notification. */ @@ -1094,20 +1099,31 @@ export type RoleManagementPolicyNotificationRule = RoleManagementPolicyRule & { notificationRecipients?: string[]; /** Its value determine if the notification need to be sent to the recipient type specified in policy rule. */ isDefaultRecipientsEnabled?: boolean; -}; +} /** Known values of {@link PrincipalType} that the service accepts. */ export enum KnownPrincipalType { + /** User */ User = "User", + /** Group */ Group = "Group", + /** ServicePrincipal */ ServicePrincipal = "ServicePrincipal", + /** Unknown */ Unknown = "Unknown", + /** DirectoryRoleTemplate */ DirectoryRoleTemplate = "DirectoryRoleTemplate", + /** ForeignGroup */ ForeignGroup = "ForeignGroup", + /** Application */ Application = "Application", + /** MSI */ MSI = "MSI", + /** DirectoryObjectOrGroup */ DirectoryObjectOrGroup = "DirectoryObjectOrGroup", + /** Everyone */ Everyone = "Everyone", + /** Device */ Device = "Device" } @@ -1132,7 +1148,9 @@ export type PrincipalType = string; /** Known values of {@link AssignmentType} that the service accepts. */ export enum KnownAssignmentType { + /** Activated */ Activated = "Activated", + /** Assigned */ Assigned = "Assigned" } @@ -1148,8 +1166,11 @@ export type AssignmentType = string; /** Known values of {@link MemberType} that the service accepts. */ export enum KnownMemberType { + /** Inherited */ Inherited = "Inherited", + /** Direct */ Direct = "Direct", + /** Group */ Group = "Group" } @@ -1166,27 +1187,49 @@ export type MemberType = string; /** Known values of {@link Status} that the service accepts. */ export enum KnownStatus { + /** Accepted */ Accepted = "Accepted", + /** PendingEvaluation */ PendingEvaluation = "PendingEvaluation", + /** Granted */ Granted = "Granted", + /** Denied */ Denied = "Denied", + /** PendingProvisioning */ PendingProvisioning = "PendingProvisioning", + /** Provisioned */ Provisioned = "Provisioned", + /** PendingRevocation */ PendingRevocation = "PendingRevocation", + /** Revoked */ Revoked = "Revoked", + /** Canceled */ Canceled = "Canceled", + /** Failed */ Failed = "Failed", + /** PendingApprovalProvisioning */ PendingApprovalProvisioning = "PendingApprovalProvisioning", + /** PendingApproval */ PendingApproval = "PendingApproval", + /** FailedAsResourceIsLocked */ FailedAsResourceIsLocked = "FailedAsResourceIsLocked", + /** PendingAdminDecision */ PendingAdminDecision = "PendingAdminDecision", + /** AdminApproved */ AdminApproved = "AdminApproved", + /** AdminDenied */ AdminDenied = "AdminDenied", + /** TimedOut */ TimedOut = "TimedOut", + /** ProvisioningStarted */ ProvisioningStarted = "ProvisioningStarted", + /** Invalid */ Invalid = "Invalid", + /** PendingScheduleCreation */ PendingScheduleCreation = "PendingScheduleCreation", + /** ScheduleCreated */ ScheduleCreated = "ScheduleCreated", + /** PendingExternalProvisioning */ PendingExternalProvisioning = "PendingExternalProvisioning" } @@ -1222,14 +1265,23 @@ export type Status = string; /** Known values of {@link RequestType} that the service accepts. */ export enum KnownRequestType { + /** AdminAssign */ AdminAssign = "AdminAssign", + /** AdminRemove */ AdminRemove = "AdminRemove", + /** AdminUpdate */ AdminUpdate = "AdminUpdate", + /** AdminExtend */ AdminExtend = "AdminExtend", + /** AdminRenew */ AdminRenew = "AdminRenew", + /** SelfActivate */ SelfActivate = "SelfActivate", + /** SelfDeactivate */ SelfDeactivate = "SelfDeactivate", + /** SelfExtend */ SelfExtend = "SelfExtend", + /** SelfRenew */ SelfRenew = "SelfRenew" } @@ -1252,8 +1304,11 @@ export type RequestType = string; /** Known values of {@link Type} that the service accepts. */ export enum KnownType { + /** AfterDuration */ AfterDuration = "AfterDuration", + /** AfterDateTime */ AfterDateTime = "AfterDateTime", + /** NoExpiration */ NoExpiration = "NoExpiration" } @@ -1270,10 +1325,15 @@ export type Type = string; /** Known values of {@link RoleManagementPolicyRuleType} that the service accepts. */ export enum KnownRoleManagementPolicyRuleType { + /** RoleManagementPolicyApprovalRule */ RoleManagementPolicyApprovalRule = "RoleManagementPolicyApprovalRule", + /** RoleManagementPolicyAuthenticationContextRule */ RoleManagementPolicyAuthenticationContextRule = "RoleManagementPolicyAuthenticationContextRule", + /** RoleManagementPolicyEnablementRule */ RoleManagementPolicyEnablementRule = "RoleManagementPolicyEnablementRule", + /** RoleManagementPolicyExpirationRule */ RoleManagementPolicyExpirationRule = "RoleManagementPolicyExpirationRule", + /** RoleManagementPolicyNotificationRule */ RoleManagementPolicyNotificationRule = "RoleManagementPolicyNotificationRule" } @@ -1292,9 +1352,13 @@ export type RoleManagementPolicyRuleType = string; /** Known values of {@link ApprovalMode} that the service accepts. */ export enum KnownApprovalMode { + /** SingleStage */ SingleStage = "SingleStage", + /** Serial */ Serial = "Serial", + /** Parallel */ Parallel = "Parallel", + /** NoApproval */ NoApproval = "NoApproval" } @@ -1312,7 +1376,9 @@ export type ApprovalMode = string; /** Known values of {@link UserType} that the service accepts. */ export enum KnownUserType { + /** User */ User = "User", + /** Group */ Group = "Group" } @@ -1328,8 +1394,11 @@ export type UserType = string; /** Known values of {@link EnablementRules} that the service accepts. */ export enum KnownEnablementRules { + /** MultiFactorAuthentication */ MultiFactorAuthentication = "MultiFactorAuthentication", + /** Justification */ Justification = "Justification", + /** Ticketing */ Ticketing = "Ticketing" } @@ -1346,6 +1415,7 @@ export type EnablementRules = string; /** Known values of {@link NotificationDeliveryMechanism} that the service accepts. */ export enum KnownNotificationDeliveryMechanism { + /** Email */ Email = "Email" } @@ -1360,8 +1430,11 @@ export type NotificationDeliveryMechanism = string; /** Known values of {@link NotificationLevel} that the service accepts. */ export enum KnownNotificationLevel { + /** None */ None = "None", + /** Critical */ Critical = "Critical", + /** All */ All = "All" } @@ -1378,8 +1451,11 @@ export type NotificationLevel = string; /** Known values of {@link RecipientType} that the service accepts. */ export enum KnownRecipientType { + /** Requestor */ Requestor = "Requestor", + /** Approver */ Approver = "Approver", + /** Admin */ Admin = "Admin" } @@ -1413,10 +1489,7 @@ export type RoleAssignmentSchedulesListForScopeResponse = RoleAssignmentSchedule /** Optional parameters. */ export interface RoleAssignmentSchedulesListForScopeNextOptionalParams - extends coreClient.OperationOptions { - /** The filter to apply on the operation. Use $filter=atScope() to return all role assignment schedules at or above the scope. Use $filter=principalId eq {id} to return all role assignment schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role assignment schedules for the current user. Use $filter=asTarget() to return all role assignment schedules created for the current user. */ - filter?: string; -} + extends coreClient.OperationOptions {} /** Contains response data for the listForScopeNext operation. */ export type RoleAssignmentSchedulesListForScopeNextResponse = RoleAssignmentScheduleListResult; @@ -1440,10 +1513,7 @@ export type RoleAssignmentScheduleInstancesGetResponse = RoleAssignmentScheduleI /** Optional parameters. */ export interface RoleAssignmentScheduleInstancesListForScopeNextOptionalParams - extends coreClient.OperationOptions { - /** The filter to apply on the operation. Use $filter=atScope() to return all role assignment schedules at or above the scope. Use $filter=principalId eq {id} to return all role assignment schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role assignment schedule instances for the user. Use $filter=asTarget() to return all role assignment schedule instances created for the current user. */ - filter?: string; -} + extends coreClient.OperationOptions {} /** Contains response data for the listForScopeNext operation. */ export type RoleAssignmentScheduleInstancesListForScopeNextResponse = RoleAssignmentScheduleInstanceListResult; @@ -1478,10 +1548,7 @@ export interface RoleAssignmentScheduleRequestsCancelOptionalParams /** Optional parameters. */ export interface RoleAssignmentScheduleRequestsListForScopeNextOptionalParams - extends coreClient.OperationOptions { - /** The filter to apply on the operation. Use $filter=atScope() to return all role assignment schedule requests at or above the scope. Use $filter=principalId eq {id} to return all role assignment schedule requests at, above or below the scope for the specified principal. Use $filter=asRequestor() to return all role assignment schedule requests requested by the current user. Use $filter=asTarget() to return all role assignment schedule requests created for the current user. Use $filter=asApprover() to return all role assignment schedule requests where the current user is an approver. */ - filter?: string; -} + extends coreClient.OperationOptions {} /** Contains response data for the listForScopeNext operation. */ export type RoleAssignmentScheduleRequestsListForScopeNextResponse = RoleAssignmentScheduleRequestListResult; @@ -1505,10 +1572,7 @@ export type RoleEligibilitySchedulesListForScopeResponse = RoleEligibilitySchedu /** Optional parameters. */ export interface RoleEligibilitySchedulesListForScopeNextOptionalParams - extends coreClient.OperationOptions { - /** The filter to apply on the operation. Use $filter=atScope() to return all role eligibility schedules at or above the scope. Use $filter=principalId eq {id} to return all role eligibility schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role eligibility schedules for the user. Use $filter=asTarget() to return all role eligibility schedules created for the current user. */ - filter?: string; -} + extends coreClient.OperationOptions {} /** Contains response data for the listForScopeNext operation. */ export type RoleEligibilitySchedulesListForScopeNextResponse = RoleEligibilityScheduleListResult; @@ -1532,10 +1596,7 @@ export type RoleEligibilityScheduleInstancesGetResponse = RoleEligibilitySchedul /** Optional parameters. */ export interface RoleEligibilityScheduleInstancesListForScopeNextOptionalParams - extends coreClient.OperationOptions { - /** The filter to apply on the operation. Use $filter=atScope() to return all role assignment schedules at or above the scope. Use $filter=principalId eq {id} to return all role assignment schedules at, above or below the scope for the specified principal. Use $filter=assignedTo('{userId}') to return all role eligibility schedules for the user. Use $filter=asTarget() to return all role eligibility schedules created for the current user. */ - filter?: string; -} + extends coreClient.OperationOptions {} /** Contains response data for the listForScopeNext operation. */ export type RoleEligibilityScheduleInstancesListForScopeNextResponse = RoleEligibilityScheduleInstanceListResult; @@ -1570,10 +1631,7 @@ export interface RoleEligibilityScheduleRequestsCancelOptionalParams /** Optional parameters. */ export interface RoleEligibilityScheduleRequestsListForScopeNextOptionalParams - extends coreClient.OperationOptions { - /** The filter to apply on the operation. Use $filter=atScope() to return all role eligibility schedule requests at or above the scope. Use $filter=principalId eq {id} to return all role eligibility schedule requests at, above or below the scope for the specified principal. Use $filter=asRequestor() to return all role eligibility schedule requests requested by the current user. Use $filter=asTarget() to return all role eligibility schedule requests created for the current user. Use $filter=asApprover() to return all role eligibility schedule requests where the current user is an approver. */ - filter?: string; -} + extends coreClient.OperationOptions {} /** Contains response data for the listForScopeNext operation. */ export type RoleEligibilityScheduleRequestsListForScopeNextResponse = RoleEligibilityScheduleRequestListResult; @@ -1654,10 +1712,7 @@ export type EligibleChildResourcesGetResponse = EligibleChildResourcesListResult /** Optional parameters. */ export interface EligibleChildResourcesGetNextOptionalParams - extends coreClient.OperationOptions { - /** The filter to apply on the operation. Use $filter=resourceType+eq+'Subscription' to filter on only resource of type = 'Subscription'. Use $filter=resourceType+eq+'subscription'+or+resourceType+eq+'resourcegroup' to filter on resource of type = 'Subscription' or 'ResourceGroup' */ - filter?: string; -} + extends coreClient.OperationOptions {} /** Contains response data for the getNext operation. */ export type EligibleChildResourcesGetNextResponse = EligibleChildResourcesListResult; @@ -1780,48 +1835,28 @@ export type RoleAssignmentsValidateByIdResponse = ValidationResponse; /** Optional parameters. */ export interface RoleAssignmentsListForSubscriptionNextOptionalParams - extends coreClient.OperationOptions { - /** The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. */ - filter?: string; - /** Tenant ID for cross-tenant request */ - tenantId?: string; -} + extends coreClient.OperationOptions {} /** Contains response data for the listForSubscriptionNext operation. */ export type RoleAssignmentsListForSubscriptionNextResponse = RoleAssignmentListResult; /** Optional parameters. */ export interface RoleAssignmentsListForResourceGroupNextOptionalParams - extends coreClient.OperationOptions { - /** The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. */ - filter?: string; - /** Tenant ID for cross-tenant request */ - tenantId?: string; -} + extends coreClient.OperationOptions {} /** Contains response data for the listForResourceGroupNext operation. */ export type RoleAssignmentsListForResourceGroupNextResponse = RoleAssignmentListResult; /** Optional parameters. */ export interface RoleAssignmentsListForResourceNextOptionalParams - extends coreClient.OperationOptions { - /** The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. */ - filter?: string; - /** Tenant ID for cross-tenant request */ - tenantId?: string; -} + extends coreClient.OperationOptions {} /** Contains response data for the listForResourceNext operation. */ export type RoleAssignmentsListForResourceNextResponse = RoleAssignmentListResult; /** Optional parameters. */ export interface RoleAssignmentsListForScopeNextOptionalParams - extends coreClient.OperationOptions { - /** The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to return all role assignments at, above or below the scope for the specified principal. */ - filter?: string; - /** Tenant ID for cross-tenant request */ - tenantId?: string; -} + extends coreClient.OperationOptions {} /** Contains response data for the listForScopeNext operation. */ export type RoleAssignmentsListForScopeNextResponse = RoleAssignmentListResult; diff --git a/sdk/authorization/arm-authorization/src/operations/eligibleChildResources.ts b/sdk/authorization/arm-authorization/src/operations/eligibleChildResources.ts index 1e98e4feaa3e..b0ceee1de88e 100644 --- a/sdk/authorization/arm-authorization/src/operations/eligibleChildResources.ts +++ b/sdk/authorization/arm-authorization/src/operations/eligibleChildResources.ts @@ -6,13 +6,13 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import "@azure/core-paging"; -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { EligibleChildResources } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; -import { AuthorizationManagementClientContext } from "../authorizationManagementClientContext"; +import { AuthorizationManagementClient } from "../authorizationManagementClient"; import { EligibleChildResource, EligibleChildResourcesGetNextOptionalParams, @@ -24,13 +24,13 @@ import { /// /** Class containing EligibleChildResources operations. */ export class EligibleChildResourcesImpl implements EligibleChildResources { - private readonly client: AuthorizationManagementClientContext; + private readonly client: AuthorizationManagementClient; /** * Initialize a new instance of the class EligibleChildResources class. * @param client Reference to the service client */ - constructor(client: AuthorizationManagementClientContext) { + constructor(client: AuthorizationManagementClient) { this.client = client; } @@ -51,23 +51,35 @@ export class EligibleChildResourcesImpl implements EligibleChildResources { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.getPagingPage(scope, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.getPagingPage(scope, options, settings); } }; } private async *getPagingPage( scope: string, - options?: EligibleChildResourcesGetOptionalParams + options?: EligibleChildResourcesGetOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._get(scope, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: EligibleChildResourcesGetResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._get(scope, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._getNext(scope, continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -142,7 +154,6 @@ const getNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion, Parameters.filter], urlParameters: [Parameters.$host, Parameters.scope, Parameters.nextLink], headerParameters: [Parameters.accept], serializer diff --git a/sdk/authorization/arm-authorization/src/operations/roleAssignmentScheduleInstances.ts b/sdk/authorization/arm-authorization/src/operations/roleAssignmentScheduleInstances.ts index 68ee23d55f0c..a2ff2c4e377c 100644 --- a/sdk/authorization/arm-authorization/src/operations/roleAssignmentScheduleInstances.ts +++ b/sdk/authorization/arm-authorization/src/operations/roleAssignmentScheduleInstances.ts @@ -6,13 +6,13 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import "@azure/core-paging"; -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { RoleAssignmentScheduleInstances } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; -import { AuthorizationManagementClientContext } from "../authorizationManagementClientContext"; +import { AuthorizationManagementClient } from "../authorizationManagementClient"; import { RoleAssignmentScheduleInstance, RoleAssignmentScheduleInstancesListForScopeNextOptionalParams, @@ -27,13 +27,13 @@ import { /** Class containing RoleAssignmentScheduleInstances operations. */ export class RoleAssignmentScheduleInstancesImpl implements RoleAssignmentScheduleInstances { - private readonly client: AuthorizationManagementClientContext; + private readonly client: AuthorizationManagementClient; /** * Initialize a new instance of the class RoleAssignmentScheduleInstances class. * @param client Reference to the service client */ - constructor(client: AuthorizationManagementClientContext) { + constructor(client: AuthorizationManagementClient) { this.client = client; } @@ -54,23 +54,35 @@ export class RoleAssignmentScheduleInstancesImpl [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listForScopePagingPage(scope, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listForScopePagingPage(scope, options, settings); } }; } private async *listForScopePagingPage( scope: string, - options?: RoleAssignmentScheduleInstancesListForScopeOptionalParams + options?: RoleAssignmentScheduleInstancesListForScopeOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listForScope(scope, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: RoleAssignmentScheduleInstancesListForScopeResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listForScope(scope, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listForScopeNext(scope, continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -185,7 +197,6 @@ const listForScopeNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion, Parameters.filter], urlParameters: [Parameters.$host, Parameters.scope, Parameters.nextLink], headerParameters: [Parameters.accept], serializer diff --git a/sdk/authorization/arm-authorization/src/operations/roleAssignmentScheduleRequests.ts b/sdk/authorization/arm-authorization/src/operations/roleAssignmentScheduleRequests.ts index 6443fee67f96..f14217d1c3cb 100644 --- a/sdk/authorization/arm-authorization/src/operations/roleAssignmentScheduleRequests.ts +++ b/sdk/authorization/arm-authorization/src/operations/roleAssignmentScheduleRequests.ts @@ -6,22 +6,22 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import "@azure/core-paging"; -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { RoleAssignmentScheduleRequests } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; -import { AuthorizationManagementClientContext } from "../authorizationManagementClientContext"; +import { AuthorizationManagementClient } from "../authorizationManagementClient"; import { RoleAssignmentScheduleRequest, RoleAssignmentScheduleRequestsListForScopeNextOptionalParams, RoleAssignmentScheduleRequestsListForScopeOptionalParams, + RoleAssignmentScheduleRequestsListForScopeResponse, RoleAssignmentScheduleRequestsCreateOptionalParams, RoleAssignmentScheduleRequestsCreateResponse, RoleAssignmentScheduleRequestsGetOptionalParams, RoleAssignmentScheduleRequestsGetResponse, - RoleAssignmentScheduleRequestsListForScopeResponse, RoleAssignmentScheduleRequestsCancelOptionalParams, RoleAssignmentScheduleRequestsListForScopeNextResponse } from "../models"; @@ -30,13 +30,13 @@ import { /** Class containing RoleAssignmentScheduleRequests operations. */ export class RoleAssignmentScheduleRequestsImpl implements RoleAssignmentScheduleRequests { - private readonly client: AuthorizationManagementClientContext; + private readonly client: AuthorizationManagementClient; /** * Initialize a new instance of the class RoleAssignmentScheduleRequests class. * @param client Reference to the service client */ - constructor(client: AuthorizationManagementClientContext) { + constructor(client: AuthorizationManagementClient) { this.client = client; } @@ -57,23 +57,35 @@ export class RoleAssignmentScheduleRequestsImpl [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listForScopePagingPage(scope, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listForScopePagingPage(scope, options, settings); } }; } private async *listForScopePagingPage( scope: string, - options?: RoleAssignmentScheduleRequestsListForScopeOptionalParams + options?: RoleAssignmentScheduleRequestsListForScopeOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listForScope(scope, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: RoleAssignmentScheduleRequestsListForScopeResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listForScope(scope, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listForScopeNext(scope, continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -273,7 +285,6 @@ const listForScopeNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion, Parameters.filter], urlParameters: [Parameters.$host, Parameters.scope, Parameters.nextLink], headerParameters: [Parameters.accept], serializer diff --git a/sdk/authorization/arm-authorization/src/operations/roleAssignmentSchedules.ts b/sdk/authorization/arm-authorization/src/operations/roleAssignmentSchedules.ts index f625ac6f3ab2..a4c7ab6fdb76 100644 --- a/sdk/authorization/arm-authorization/src/operations/roleAssignmentSchedules.ts +++ b/sdk/authorization/arm-authorization/src/operations/roleAssignmentSchedules.ts @@ -6,33 +6,33 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import "@azure/core-paging"; -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { RoleAssignmentSchedules } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; -import { AuthorizationManagementClientContext } from "../authorizationManagementClientContext"; +import { AuthorizationManagementClient } from "../authorizationManagementClient"; import { RoleAssignmentSchedule, RoleAssignmentSchedulesListForScopeNextOptionalParams, RoleAssignmentSchedulesListForScopeOptionalParams, + RoleAssignmentSchedulesListForScopeResponse, RoleAssignmentSchedulesGetOptionalParams, RoleAssignmentSchedulesGetResponse, - RoleAssignmentSchedulesListForScopeResponse, RoleAssignmentSchedulesListForScopeNextResponse } from "../models"; /// /** Class containing RoleAssignmentSchedules operations. */ export class RoleAssignmentSchedulesImpl implements RoleAssignmentSchedules { - private readonly client: AuthorizationManagementClientContext; + private readonly client: AuthorizationManagementClient; /** * Initialize a new instance of the class RoleAssignmentSchedules class. * @param client Reference to the service client */ - constructor(client: AuthorizationManagementClientContext) { + constructor(client: AuthorizationManagementClient) { this.client = client; } @@ -53,23 +53,35 @@ export class RoleAssignmentSchedulesImpl implements RoleAssignmentSchedules { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listForScopePagingPage(scope, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listForScopePagingPage(scope, options, settings); } }; } private async *listForScopePagingPage( scope: string, - options?: RoleAssignmentSchedulesListForScopeOptionalParams + options?: RoleAssignmentSchedulesListForScopeOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listForScope(scope, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: RoleAssignmentSchedulesListForScopeResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listForScope(scope, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listForScopeNext(scope, continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -182,7 +194,6 @@ const listForScopeNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion, Parameters.filter], urlParameters: [Parameters.$host, Parameters.scope, Parameters.nextLink], headerParameters: [Parameters.accept], serializer diff --git a/sdk/authorization/arm-authorization/src/operations/roleAssignments.ts b/sdk/authorization/arm-authorization/src/operations/roleAssignments.ts index 5fbb7b8825d2..675302ec0466 100644 --- a/sdk/authorization/arm-authorization/src/operations/roleAssignments.ts +++ b/sdk/authorization/arm-authorization/src/operations/roleAssignments.ts @@ -6,26 +6,27 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import "@azure/core-paging"; -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { RoleAssignments } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; -import { AuthorizationManagementClientContext } from "../authorizationManagementClientContext"; +import { AuthorizationManagementClient } from "../authorizationManagementClient"; import { RoleAssignment, RoleAssignmentsListForSubscriptionNextOptionalParams, RoleAssignmentsListForSubscriptionOptionalParams, + RoleAssignmentsListForSubscriptionResponse, RoleAssignmentsListForResourceGroupNextOptionalParams, RoleAssignmentsListForResourceGroupOptionalParams, + RoleAssignmentsListForResourceGroupResponse, RoleAssignmentsListForResourceNextOptionalParams, RoleAssignmentsListForResourceOptionalParams, + RoleAssignmentsListForResourceResponse, RoleAssignmentsListForScopeNextOptionalParams, RoleAssignmentsListForScopeOptionalParams, - RoleAssignmentsListForSubscriptionResponse, - RoleAssignmentsListForResourceGroupResponse, - RoleAssignmentsListForResourceResponse, + RoleAssignmentsListForScopeResponse, RoleAssignmentsGetOptionalParams, RoleAssignmentsGetResponse, RoleAssignmentCreateParameters, @@ -35,7 +36,6 @@ import { RoleAssignmentsDeleteResponse, RoleAssignmentsValidateOptionalParams, RoleAssignmentsValidateResponse, - RoleAssignmentsListForScopeResponse, RoleAssignmentsGetByIdOptionalParams, RoleAssignmentsGetByIdResponse, RoleAssignmentsCreateByIdOptionalParams, @@ -53,13 +53,13 @@ import { /// /** Class containing RoleAssignments operations. */ export class RoleAssignmentsImpl implements RoleAssignments { - private readonly client: AuthorizationManagementClientContext; + private readonly client: AuthorizationManagementClient; /** * Initialize a new instance of the class RoleAssignments class. * @param client Reference to the service client */ - constructor(client: AuthorizationManagementClientContext) { + constructor(client: AuthorizationManagementClient) { this.client = client; } @@ -78,22 +78,34 @@ export class RoleAssignmentsImpl implements RoleAssignments { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listForSubscriptionPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listForSubscriptionPagingPage(options, settings); } }; } private async *listForSubscriptionPagingPage( - options?: RoleAssignmentsListForSubscriptionOptionalParams + options?: RoleAssignmentsListForSubscriptionOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listForSubscription(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: RoleAssignmentsListForSubscriptionResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listForSubscription(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listForSubscriptionNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -122,19 +134,33 @@ export class RoleAssignmentsImpl implements RoleAssignments { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listForResourceGroupPagingPage(resourceGroupName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listForResourceGroupPagingPage( + resourceGroupName, + options, + settings + ); } }; } private async *listForResourceGroupPagingPage( resourceGroupName: string, - options?: RoleAssignmentsListForResourceGroupOptionalParams + options?: RoleAssignmentsListForResourceGroupOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listForResourceGroup(resourceGroupName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: RoleAssignmentsListForResourceGroupResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listForResourceGroup(resourceGroupName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listForResourceGroupNext( resourceGroupName, @@ -142,7 +168,9 @@ export class RoleAssignmentsImpl implements RoleAssignments { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -188,13 +216,17 @@ export class RoleAssignmentsImpl implements RoleAssignments { [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listForResourcePagingPage( resourceGroupName, resourceProviderNamespace, resourceType, resourceName, - options + options, + settings ); } }; @@ -205,17 +237,24 @@ export class RoleAssignmentsImpl implements RoleAssignments { resourceProviderNamespace: string, resourceType: string, resourceName: string, - options?: RoleAssignmentsListForResourceOptionalParams + options?: RoleAssignmentsListForResourceOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listForResource( - resourceGroupName, - resourceProviderNamespace, - resourceType, - resourceName, - options - ); - yield result.value || []; - let continuationToken = result.nextLink; + let result: RoleAssignmentsListForResourceResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listForResource( + resourceGroupName, + resourceProviderNamespace, + resourceType, + resourceName, + options + ); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listForResourceNext( resourceGroupName, @@ -226,7 +265,9 @@ export class RoleAssignmentsImpl implements RoleAssignments { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -268,23 +309,35 @@ export class RoleAssignmentsImpl implements RoleAssignments { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listForScopePagingPage(scope, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listForScopePagingPage(scope, options, settings); } }; } private async *listForScopePagingPage( scope: string, - options?: RoleAssignmentsListForScopeOptionalParams + options?: RoleAssignmentsListForScopeOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listForScope(scope, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: RoleAssignmentsListForScopeResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listForScope(scope, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listForScopeNext(scope, continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -886,11 +939,6 @@ const listForSubscriptionNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.ErrorResponse } }, - queryParameters: [ - Parameters.apiVersion, - Parameters.filter1, - Parameters.tenantId - ], urlParameters: [ Parameters.$host, Parameters.nextLink, @@ -910,11 +958,6 @@ const listForResourceGroupNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.ErrorResponse } }, - queryParameters: [ - Parameters.apiVersion, - Parameters.filter1, - Parameters.tenantId - ], urlParameters: [ Parameters.$host, Parameters.nextLink, @@ -935,11 +978,6 @@ const listForResourceNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.ErrorResponse } }, - queryParameters: [ - Parameters.apiVersion, - Parameters.filter1, - Parameters.tenantId - ], urlParameters: [ Parameters.$host, Parameters.nextLink, @@ -963,11 +1001,6 @@ const listForScopeNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.ErrorResponse } }, - queryParameters: [ - Parameters.apiVersion, - Parameters.filter1, - Parameters.tenantId - ], urlParameters: [Parameters.$host, Parameters.scope, Parameters.nextLink], headerParameters: [Parameters.accept], serializer diff --git a/sdk/authorization/arm-authorization/src/operations/roleEligibilityScheduleInstances.ts b/sdk/authorization/arm-authorization/src/operations/roleEligibilityScheduleInstances.ts index 29ca5e2f75b4..78b6e80260dd 100644 --- a/sdk/authorization/arm-authorization/src/operations/roleEligibilityScheduleInstances.ts +++ b/sdk/authorization/arm-authorization/src/operations/roleEligibilityScheduleInstances.ts @@ -6,13 +6,13 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import "@azure/core-paging"; -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { RoleEligibilityScheduleInstances } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; -import { AuthorizationManagementClientContext } from "../authorizationManagementClientContext"; +import { AuthorizationManagementClient } from "../authorizationManagementClient"; import { RoleEligibilityScheduleInstance, RoleEligibilityScheduleInstancesListForScopeNextOptionalParams, @@ -27,13 +27,13 @@ import { /** Class containing RoleEligibilityScheduleInstances operations. */ export class RoleEligibilityScheduleInstancesImpl implements RoleEligibilityScheduleInstances { - private readonly client: AuthorizationManagementClientContext; + private readonly client: AuthorizationManagementClient; /** * Initialize a new instance of the class RoleEligibilityScheduleInstances class. * @param client Reference to the service client */ - constructor(client: AuthorizationManagementClientContext) { + constructor(client: AuthorizationManagementClient) { this.client = client; } @@ -54,23 +54,35 @@ export class RoleEligibilityScheduleInstancesImpl [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listForScopePagingPage(scope, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listForScopePagingPage(scope, options, settings); } }; } private async *listForScopePagingPage( scope: string, - options?: RoleEligibilityScheduleInstancesListForScopeOptionalParams + options?: RoleEligibilityScheduleInstancesListForScopeOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listForScope(scope, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: RoleEligibilityScheduleInstancesListForScopeResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listForScope(scope, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listForScopeNext(scope, continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -185,7 +197,6 @@ const listForScopeNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion, Parameters.filter], urlParameters: [Parameters.$host, Parameters.scope, Parameters.nextLink], headerParameters: [Parameters.accept], serializer diff --git a/sdk/authorization/arm-authorization/src/operations/roleEligibilityScheduleRequests.ts b/sdk/authorization/arm-authorization/src/operations/roleEligibilityScheduleRequests.ts index 5c13e3ab412d..63783610bbd4 100644 --- a/sdk/authorization/arm-authorization/src/operations/roleEligibilityScheduleRequests.ts +++ b/sdk/authorization/arm-authorization/src/operations/roleEligibilityScheduleRequests.ts @@ -6,22 +6,22 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import "@azure/core-paging"; -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { RoleEligibilityScheduleRequests } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; -import { AuthorizationManagementClientContext } from "../authorizationManagementClientContext"; +import { AuthorizationManagementClient } from "../authorizationManagementClient"; import { RoleEligibilityScheduleRequest, RoleEligibilityScheduleRequestsListForScopeNextOptionalParams, RoleEligibilityScheduleRequestsListForScopeOptionalParams, + RoleEligibilityScheduleRequestsListForScopeResponse, RoleEligibilityScheduleRequestsCreateOptionalParams, RoleEligibilityScheduleRequestsCreateResponse, RoleEligibilityScheduleRequestsGetOptionalParams, RoleEligibilityScheduleRequestsGetResponse, - RoleEligibilityScheduleRequestsListForScopeResponse, RoleEligibilityScheduleRequestsCancelOptionalParams, RoleEligibilityScheduleRequestsListForScopeNextResponse } from "../models"; @@ -30,13 +30,13 @@ import { /** Class containing RoleEligibilityScheduleRequests operations. */ export class RoleEligibilityScheduleRequestsImpl implements RoleEligibilityScheduleRequests { - private readonly client: AuthorizationManagementClientContext; + private readonly client: AuthorizationManagementClient; /** * Initialize a new instance of the class RoleEligibilityScheduleRequests class. * @param client Reference to the service client */ - constructor(client: AuthorizationManagementClientContext) { + constructor(client: AuthorizationManagementClient) { this.client = client; } @@ -57,23 +57,35 @@ export class RoleEligibilityScheduleRequestsImpl [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listForScopePagingPage(scope, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listForScopePagingPage(scope, options, settings); } }; } private async *listForScopePagingPage( scope: string, - options?: RoleEligibilityScheduleRequestsListForScopeOptionalParams + options?: RoleEligibilityScheduleRequestsListForScopeOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listForScope(scope, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: RoleEligibilityScheduleRequestsListForScopeResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listForScope(scope, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listForScopeNext(scope, continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -273,7 +285,6 @@ const listForScopeNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion, Parameters.filter], urlParameters: [Parameters.$host, Parameters.scope, Parameters.nextLink], headerParameters: [Parameters.accept], serializer diff --git a/sdk/authorization/arm-authorization/src/operations/roleEligibilitySchedules.ts b/sdk/authorization/arm-authorization/src/operations/roleEligibilitySchedules.ts index 3ab81c1dc5ba..6f7712be0749 100644 --- a/sdk/authorization/arm-authorization/src/operations/roleEligibilitySchedules.ts +++ b/sdk/authorization/arm-authorization/src/operations/roleEligibilitySchedules.ts @@ -6,33 +6,33 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import "@azure/core-paging"; -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { RoleEligibilitySchedules } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; -import { AuthorizationManagementClientContext } from "../authorizationManagementClientContext"; +import { AuthorizationManagementClient } from "../authorizationManagementClient"; import { RoleEligibilitySchedule, RoleEligibilitySchedulesListForScopeNextOptionalParams, RoleEligibilitySchedulesListForScopeOptionalParams, + RoleEligibilitySchedulesListForScopeResponse, RoleEligibilitySchedulesGetOptionalParams, RoleEligibilitySchedulesGetResponse, - RoleEligibilitySchedulesListForScopeResponse, RoleEligibilitySchedulesListForScopeNextResponse } from "../models"; /// /** Class containing RoleEligibilitySchedules operations. */ export class RoleEligibilitySchedulesImpl implements RoleEligibilitySchedules { - private readonly client: AuthorizationManagementClientContext; + private readonly client: AuthorizationManagementClient; /** * Initialize a new instance of the class RoleEligibilitySchedules class. * @param client Reference to the service client */ - constructor(client: AuthorizationManagementClientContext) { + constructor(client: AuthorizationManagementClient) { this.client = client; } @@ -53,23 +53,35 @@ export class RoleEligibilitySchedulesImpl implements RoleEligibilitySchedules { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listForScopePagingPage(scope, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listForScopePagingPage(scope, options, settings); } }; } private async *listForScopePagingPage( scope: string, - options?: RoleEligibilitySchedulesListForScopeOptionalParams + options?: RoleEligibilitySchedulesListForScopeOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listForScope(scope, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: RoleEligibilitySchedulesListForScopeResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listForScope(scope, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listForScopeNext(scope, continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -182,7 +194,6 @@ const listForScopeNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion, Parameters.filter], urlParameters: [Parameters.$host, Parameters.scope, Parameters.nextLink], headerParameters: [Parameters.accept], serializer diff --git a/sdk/authorization/arm-authorization/src/operations/roleManagementPolicies.ts b/sdk/authorization/arm-authorization/src/operations/roleManagementPolicies.ts index 69f6ca49cf7f..d2d55eec9d85 100644 --- a/sdk/authorization/arm-authorization/src/operations/roleManagementPolicies.ts +++ b/sdk/authorization/arm-authorization/src/operations/roleManagementPolicies.ts @@ -6,36 +6,36 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import "@azure/core-paging"; -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { RoleManagementPolicies } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; -import { AuthorizationManagementClientContext } from "../authorizationManagementClientContext"; +import { AuthorizationManagementClient } from "../authorizationManagementClient"; import { RoleManagementPolicy, RoleManagementPoliciesListForScopeNextOptionalParams, RoleManagementPoliciesListForScopeOptionalParams, + RoleManagementPoliciesListForScopeResponse, RoleManagementPoliciesGetOptionalParams, RoleManagementPoliciesGetResponse, RoleManagementPoliciesUpdateOptionalParams, RoleManagementPoliciesUpdateResponse, RoleManagementPoliciesDeleteOptionalParams, - RoleManagementPoliciesListForScopeResponse, RoleManagementPoliciesListForScopeNextResponse } from "../models"; /// /** Class containing RoleManagementPolicies operations. */ export class RoleManagementPoliciesImpl implements RoleManagementPolicies { - private readonly client: AuthorizationManagementClientContext; + private readonly client: AuthorizationManagementClient; /** * Initialize a new instance of the class RoleManagementPolicies class. * @param client Reference to the service client */ - constructor(client: AuthorizationManagementClientContext) { + constructor(client: AuthorizationManagementClient) { this.client = client; } @@ -56,23 +56,35 @@ export class RoleManagementPoliciesImpl implements RoleManagementPolicies { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listForScopePagingPage(scope, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listForScopePagingPage(scope, options, settings); } }; } private async *listForScopePagingPage( scope: string, - options?: RoleManagementPoliciesListForScopeOptionalParams + options?: RoleManagementPoliciesListForScopeOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listForScope(scope, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: RoleManagementPoliciesListForScopeResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listForScope(scope, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listForScopeNext(scope, continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -264,7 +276,6 @@ const listForScopeNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.$host, Parameters.scope, Parameters.nextLink], headerParameters: [Parameters.accept], serializer diff --git a/sdk/authorization/arm-authorization/src/operations/roleManagementPolicyAssignments.ts b/sdk/authorization/arm-authorization/src/operations/roleManagementPolicyAssignments.ts index e8a8efe0fa3e..d7e2a56e1f6a 100644 --- a/sdk/authorization/arm-authorization/src/operations/roleManagementPolicyAssignments.ts +++ b/sdk/authorization/arm-authorization/src/operations/roleManagementPolicyAssignments.ts @@ -6,23 +6,23 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import "@azure/core-paging"; -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { RoleManagementPolicyAssignments } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; -import { AuthorizationManagementClientContext } from "../authorizationManagementClientContext"; +import { AuthorizationManagementClient } from "../authorizationManagementClient"; import { RoleManagementPolicyAssignment, RoleManagementPolicyAssignmentsListForScopeNextOptionalParams, RoleManagementPolicyAssignmentsListForScopeOptionalParams, + RoleManagementPolicyAssignmentsListForScopeResponse, RoleManagementPolicyAssignmentsGetOptionalParams, RoleManagementPolicyAssignmentsGetResponse, RoleManagementPolicyAssignmentsCreateOptionalParams, RoleManagementPolicyAssignmentsCreateResponse, RoleManagementPolicyAssignmentsDeleteOptionalParams, - RoleManagementPolicyAssignmentsListForScopeResponse, RoleManagementPolicyAssignmentsListForScopeNextResponse } from "../models"; @@ -30,13 +30,13 @@ import { /** Class containing RoleManagementPolicyAssignments operations. */ export class RoleManagementPolicyAssignmentsImpl implements RoleManagementPolicyAssignments { - private readonly client: AuthorizationManagementClientContext; + private readonly client: AuthorizationManagementClient; /** * Initialize a new instance of the class RoleManagementPolicyAssignments class. * @param client Reference to the service client */ - constructor(client: AuthorizationManagementClientContext) { + constructor(client: AuthorizationManagementClient) { this.client = client; } @@ -57,23 +57,35 @@ export class RoleManagementPolicyAssignmentsImpl [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listForScopePagingPage(scope, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listForScopePagingPage(scope, options, settings); } }; } private async *listForScopePagingPage( scope: string, - options?: RoleManagementPolicyAssignmentsListForScopeOptionalParams + options?: RoleManagementPolicyAssignmentsListForScopeOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listForScope(scope, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: RoleManagementPolicyAssignmentsListForScopeResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listForScope(scope, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listForScopeNext(scope, continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -269,7 +281,6 @@ const listForScopeNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.$host, Parameters.scope, Parameters.nextLink], headerParameters: [Parameters.accept], serializer diff --git a/sdk/authorization/arm-authorization/src/operationsInterfaces/eligibleChildResources.ts b/sdk/authorization/arm-authorization/src/operationsInterfaces/eligibleChildResources.ts index 0138496ee322..e4d88d125602 100644 --- a/sdk/authorization/arm-authorization/src/operationsInterfaces/eligibleChildResources.ts +++ b/sdk/authorization/arm-authorization/src/operationsInterfaces/eligibleChildResources.ts @@ -6,7 +6,6 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import "@azure/core-paging"; import { PagedAsyncIterableIterator } from "@azure/core-paging"; import { EligibleChildResource, diff --git a/sdk/authorization/arm-authorization/src/operationsInterfaces/roleAssignmentScheduleInstances.ts b/sdk/authorization/arm-authorization/src/operationsInterfaces/roleAssignmentScheduleInstances.ts index 7ee590cfbb23..6e839fde6303 100644 --- a/sdk/authorization/arm-authorization/src/operationsInterfaces/roleAssignmentScheduleInstances.ts +++ b/sdk/authorization/arm-authorization/src/operationsInterfaces/roleAssignmentScheduleInstances.ts @@ -6,7 +6,6 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import "@azure/core-paging"; import { PagedAsyncIterableIterator } from "@azure/core-paging"; import { RoleAssignmentScheduleInstance, diff --git a/sdk/authorization/arm-authorization/src/operationsInterfaces/roleAssignmentScheduleRequests.ts b/sdk/authorization/arm-authorization/src/operationsInterfaces/roleAssignmentScheduleRequests.ts index c46f3b993eb6..87a21178f38b 100644 --- a/sdk/authorization/arm-authorization/src/operationsInterfaces/roleAssignmentScheduleRequests.ts +++ b/sdk/authorization/arm-authorization/src/operationsInterfaces/roleAssignmentScheduleRequests.ts @@ -6,7 +6,6 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import "@azure/core-paging"; import { PagedAsyncIterableIterator } from "@azure/core-paging"; import { RoleAssignmentScheduleRequest, diff --git a/sdk/authorization/arm-authorization/src/operationsInterfaces/roleAssignmentSchedules.ts b/sdk/authorization/arm-authorization/src/operationsInterfaces/roleAssignmentSchedules.ts index c0e5a062a1a6..860f62c3bfda 100644 --- a/sdk/authorization/arm-authorization/src/operationsInterfaces/roleAssignmentSchedules.ts +++ b/sdk/authorization/arm-authorization/src/operationsInterfaces/roleAssignmentSchedules.ts @@ -6,7 +6,6 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import "@azure/core-paging"; import { PagedAsyncIterableIterator } from "@azure/core-paging"; import { RoleAssignmentSchedule, diff --git a/sdk/authorization/arm-authorization/src/operationsInterfaces/roleAssignments.ts b/sdk/authorization/arm-authorization/src/operationsInterfaces/roleAssignments.ts index 718ee54a19bd..3745daafbc50 100644 --- a/sdk/authorization/arm-authorization/src/operationsInterfaces/roleAssignments.ts +++ b/sdk/authorization/arm-authorization/src/operationsInterfaces/roleAssignments.ts @@ -6,7 +6,6 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import "@azure/core-paging"; import { PagedAsyncIterableIterator } from "@azure/core-paging"; import { RoleAssignment, diff --git a/sdk/authorization/arm-authorization/src/operationsInterfaces/roleEligibilityScheduleInstances.ts b/sdk/authorization/arm-authorization/src/operationsInterfaces/roleEligibilityScheduleInstances.ts index d59284393a78..a749afd71b39 100644 --- a/sdk/authorization/arm-authorization/src/operationsInterfaces/roleEligibilityScheduleInstances.ts +++ b/sdk/authorization/arm-authorization/src/operationsInterfaces/roleEligibilityScheduleInstances.ts @@ -6,7 +6,6 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import "@azure/core-paging"; import { PagedAsyncIterableIterator } from "@azure/core-paging"; import { RoleEligibilityScheduleInstance, diff --git a/sdk/authorization/arm-authorization/src/operationsInterfaces/roleEligibilityScheduleRequests.ts b/sdk/authorization/arm-authorization/src/operationsInterfaces/roleEligibilityScheduleRequests.ts index 70c01dd4e630..764e81fc080e 100644 --- a/sdk/authorization/arm-authorization/src/operationsInterfaces/roleEligibilityScheduleRequests.ts +++ b/sdk/authorization/arm-authorization/src/operationsInterfaces/roleEligibilityScheduleRequests.ts @@ -6,7 +6,6 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import "@azure/core-paging"; import { PagedAsyncIterableIterator } from "@azure/core-paging"; import { RoleEligibilityScheduleRequest, diff --git a/sdk/authorization/arm-authorization/src/operationsInterfaces/roleEligibilitySchedules.ts b/sdk/authorization/arm-authorization/src/operationsInterfaces/roleEligibilitySchedules.ts index 8722a0e08226..7a8e00368b23 100644 --- a/sdk/authorization/arm-authorization/src/operationsInterfaces/roleEligibilitySchedules.ts +++ b/sdk/authorization/arm-authorization/src/operationsInterfaces/roleEligibilitySchedules.ts @@ -6,7 +6,6 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import "@azure/core-paging"; import { PagedAsyncIterableIterator } from "@azure/core-paging"; import { RoleEligibilitySchedule, diff --git a/sdk/authorization/arm-authorization/src/operationsInterfaces/roleManagementPolicies.ts b/sdk/authorization/arm-authorization/src/operationsInterfaces/roleManagementPolicies.ts index 43edadbd4354..1f9ef62fd721 100644 --- a/sdk/authorization/arm-authorization/src/operationsInterfaces/roleManagementPolicies.ts +++ b/sdk/authorization/arm-authorization/src/operationsInterfaces/roleManagementPolicies.ts @@ -6,7 +6,6 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import "@azure/core-paging"; import { PagedAsyncIterableIterator } from "@azure/core-paging"; import { RoleManagementPolicy, diff --git a/sdk/authorization/arm-authorization/src/operationsInterfaces/roleManagementPolicyAssignments.ts b/sdk/authorization/arm-authorization/src/operationsInterfaces/roleManagementPolicyAssignments.ts index 4c06af309a19..04743a2ae06d 100644 --- a/sdk/authorization/arm-authorization/src/operationsInterfaces/roleManagementPolicyAssignments.ts +++ b/sdk/authorization/arm-authorization/src/operationsInterfaces/roleManagementPolicyAssignments.ts @@ -6,7 +6,6 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import "@azure/core-paging"; import { PagedAsyncIterableIterator } from "@azure/core-paging"; import { RoleManagementPolicyAssignment, diff --git a/sdk/authorization/arm-authorization/src/pagingHelper.ts b/sdk/authorization/arm-authorization/src/pagingHelper.ts new file mode 100644 index 000000000000..269a2b9814b5 --- /dev/null +++ b/sdk/authorization/arm-authorization/src/pagingHelper.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export interface PageInfo { + continuationToken?: string; +} + +const pageMap = new WeakMap(); + +/** + * Given the last `.value` produced by the `byPage` iterator, + * returns a continuation token that can be used to begin paging from + * that point later. + * @param page An object from accessing `value` on the IteratorResult from a `byPage` iterator. + * @returns The continuation token that can be passed into byPage() during future calls. + */ +export function getContinuationToken(page: unknown): string | undefined { + if (typeof page !== "object" || page === null) { + return undefined; + } + return pageMap.get(page)?.continuationToken; +} + +export function setContinuationToken( + page: unknown, + continuationToken: string | undefined +): void { + if (typeof page !== "object" || page === null || !continuationToken) { + return; + } + const pageInfo = pageMap.get(page) ?? {}; + pageInfo.continuationToken = continuationToken; + pageMap.set(page, pageInfo); +} diff --git a/sdk/authorization/arm-authorization/test/sampleTest.ts b/sdk/authorization/arm-authorization/test/sampleTest.ts new file mode 100644 index 000000000000..25aeb3ebcc36 --- /dev/null +++ b/sdk/authorization/arm-authorization/test/sampleTest.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { + Recorder, + RecorderStartOptions, + env +} from "@azure-tools/test-recorder"; +import { assert } from "chai"; +import { Context } from "mocha"; + +const replaceableVariables: Record = { + AZURE_CLIENT_ID: "azure_client_id", + AZURE_CLIENT_SECRET: "azure_client_secret", + AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", + SUBSCRIPTION_ID: "azure_subscription_id" +}; + +const recorderOptions: RecorderStartOptions = { + envSetupForPlayback: replaceableVariables +}; + +describe("My test", () => { + let recorder: Recorder; + + beforeEach(async function(this: Context) { + recorder = new Recorder(this.currentTest); + await recorder.start(recorderOptions); + }); + + afterEach(async function() { + await recorder.stop(); + }); + + it("sample test", async function() { + console.log("Hi, I'm a test!"); + }); +}); diff --git a/sdk/authorization/arm-authorization/tsconfig.json b/sdk/authorization/arm-authorization/tsconfig.json index 603440b3a359..bd142baf706d 100644 --- a/sdk/authorization/arm-authorization/tsconfig.json +++ b/sdk/authorization/arm-authorization/tsconfig.json @@ -9,11 +9,25 @@ "esModuleInterop": true, "allowSyntheticDefaultImports": true, "forceConsistentCasingInFileNames": true, - "lib": ["es6", "dom"], + "lib": [ + "es6", + "dom" + ], "declaration": true, "outDir": "./dist-esm", - "importHelpers": true + "importHelpers": true, + "paths": { + "@azure/arm-authorization": [ + "./src/index" + ] + } }, - "include": ["./src/**/*.ts"], - "exclude": ["node_modules"] -} + "include": [ + "./src/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts" + ], + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/sdk/authorization/ci.mgmt.yml b/sdk/authorization/ci.mgmt.yml index a7561b803ee9..38af77e96cd5 100644 --- a/sdk/authorization/ci.mgmt.yml +++ b/sdk/authorization/ci.mgmt.yml @@ -1,5 +1,5 @@ # NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. - + trigger: branches: include: @@ -9,8 +9,8 @@ trigger: paths: include: - sdk/authorization/ci.mgmt.yml - - sdk/authorization/arm-authorization/ - sdk/authorization/arm-authorization-profile-2020-09-01-hybrid + - sdk/authorization/arm-authorization pr: branches: include: @@ -23,8 +23,8 @@ pr: paths: include: - sdk/authorization/ci.mgmt.yml - - sdk/authorization/arm-authorization/ - sdk/authorization/arm-authorization-profile-2020-09-01-hybrid + - sdk/authorization/arm-authorization extends: template: /eng/pipelines/templates/stages/archetype-sdk-client.yml parameters: