diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index c207df550487..a0f502dbfdb2 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -10647,7 +10647,7 @@ packages: dev: false file:projects/arm-digitaltwins.tgz: - resolution: {integrity: sha512-UoYxvLJ6lsdjg2ko5jVsLEQQLC1nIjSFPc4lkFkwwUJAMFgceRXpPAcTMs+O0aICUIZSgs3Fw+sVW8m6ZbFsxA==, tarball: file:projects/arm-digitaltwins.tgz} + resolution: {integrity: sha512-hW849ZUuBqPjs2hSiWFKM2L38jA29tgjpn1HSxr5gdGqSbkh+xJWb10tjhbByoPAGoC/xiLlmFsEzLWoIME2HQ==, tarball: file:projects/arm-digitaltwins.tgz} name: '@rush-temp/arm-digitaltwins' version: 0.0.0 dependencies: @@ -10703,34 +10703,35 @@ packages: dev: false file:projects/arm-dns.tgz: - resolution: {integrity: sha512-lNH4104hmq8+MemTpwQgpthSZtz07RGeORUIpI1m5s+j0t7U8XMDGNvCdNtEduEW+8EIYlLy+gcvedWRAOoYMQ==, tarball: file:projects/arm-dns.tgz} + resolution: {integrity: sha512-i8TiBoOj9lXLt99eF1caVtFXnXBsgTSYqSOCfIeXuc2gdgERBvRzng89bck00hj+4w1m6yyWvuiBln2rrwwlOg==, tarball: file:projects/arm-dns.tgz} name: '@rush-temp/arm-dns' version: 0.0.0 dependencies: '@azure-tools/test-recorder': 1.0.2 '@azure/identity': 2.0.4 '@microsoft/api-extractor': 7.22.1 - '@rollup/plugin-commonjs': 11.0.2_rollup@1.32.1 - '@rollup/plugin-json': 4.1.0_rollup@1.32.1 - '@rollup/plugin-multi-entry': 3.0.1_rollup@1.32.1 - '@rollup/plugin-node-resolve': 8.4.0_rollup@1.32.1 + '@rollup/plugin-commonjs': 21.0.3_rollup@2.70.1 + '@rollup/plugin-json': 4.1.0_rollup@2.70.1 + '@rollup/plugin-multi-entry': 4.1.0_rollup@2.70.1 + '@rollup/plugin-node-resolve': 13.2.0_rollup@2.70.1 cross-env: 7.0.3 mkdirp: 1.0.4 mocha: 7.2.0 rimraf: 3.0.2 - rollup: 1.32.1 - rollup-plugin-sourcemaps: 0.4.2_rollup@1.32.1 + rollup: 2.70.1 + rollup-plugin-sourcemaps: 0.6.3_rollup@2.70.1 tslib: 2.3.1 typescript: 4.2.4 uglify-js: 3.15.4 transitivePeerDependencies: + - '@types/node' - debug - encoding - supports-color dev: false file:projects/arm-dnsresolver.tgz: - resolution: {integrity: sha512-Mdpxepj5NOCwZ35IxyC3phiZypOZw1GGibXV0PcM8mUgh/0lDb7brPCSdardWT7MuEIEkdz/oSCKMpu245xLmA==, tarball: file:projects/arm-dnsresolver.tgz} + resolution: {integrity: sha512-/2woKciaPYSducDVWATFhO8pzoOR1ek7mXhLE32uNcOK3Uq55pGydQHlrJ5dE/DgMjkqOVY/TsnugUBEGT+Ujg==, tarball: file:projects/arm-dnsresolver.tgz} name: '@rush-temp/arm-dnsresolver' version: 0.0.0 dependencies: @@ -10758,27 +10759,28 @@ packages: dev: false file:projects/arm-domainservices.tgz: - resolution: {integrity: sha512-2fix9U6/4/u9dimkMVzAem51sezUnrpo7HOQCOKk8Z1N7xbGNLzbv25jILXCJCRFo7v4W+NCiByzxZvHS723CA==, tarball: file:projects/arm-domainservices.tgz} + resolution: {integrity: sha512-lRm7SmbgT+t3kLpR7/Nq8ghNVB9Zu/DoTw8OAXwUMUodHlR1sOA8t4lKw8fFcLJbfKaiQ0/OUhkdThWdg8WfNQ==, tarball: file:projects/arm-domainservices.tgz} name: '@rush-temp/arm-domainservices' version: 0.0.0 dependencies: '@azure-tools/test-recorder': 1.0.2 '@azure/identity': 2.0.4 '@microsoft/api-extractor': 7.22.1 - '@rollup/plugin-commonjs': 11.0.2_rollup@1.32.1 - '@rollup/plugin-json': 4.1.0_rollup@1.32.1 - '@rollup/plugin-multi-entry': 3.0.1_rollup@1.32.1 - '@rollup/plugin-node-resolve': 8.4.0_rollup@1.32.1 + '@rollup/plugin-commonjs': 21.0.3_rollup@2.70.1 + '@rollup/plugin-json': 4.1.0_rollup@2.70.1 + '@rollup/plugin-multi-entry': 4.1.0_rollup@2.70.1 + '@rollup/plugin-node-resolve': 13.2.0_rollup@2.70.1 cross-env: 7.0.3 mkdirp: 1.0.4 mocha: 7.2.0 rimraf: 3.0.2 - rollup: 1.32.1 - rollup-plugin-sourcemaps: 0.4.2_rollup@1.32.1 + rollup: 2.70.1 + rollup-plugin-sourcemaps: 0.6.3_rollup@2.70.1 tslib: 2.3.1 typescript: 4.2.4 uglify-js: 3.15.4 transitivePeerDependencies: + - '@types/node' - debug - encoding - supports-color @@ -10841,7 +10843,7 @@ packages: dev: false file:projects/arm-eventhub.tgz: - resolution: {integrity: sha512-PSXQZCbu3khNcog69nSkJIkxY5B/rrJrDzexztWggP8zv739TwQNKg4UU8bQ4D/FguT6lMaqLk/umLu+cQ9/Pg==, tarball: file:projects/arm-eventhub.tgz} + resolution: {integrity: sha512-kR+bKe5j52c6mA6YtR4hc6P9e0HfvwguqHTSSs5ksanC+C2b30ywFUR1yWtDYBZR7INe5W9mdw3YNhg6Sgajhg==, tarball: file:projects/arm-eventhub.tgz} name: '@rush-temp/arm-eventhub' version: 0.0.0 dependencies: @@ -10850,18 +10852,19 @@ packages: '@microsoft/api-extractor': 7.22.1 '@rollup/plugin-commonjs': 21.0.3_rollup@2.70.1 '@rollup/plugin-json': 4.1.0_rollup@2.70.1 - '@rollup/plugin-multi-entry': 3.0.1_rollup@2.70.1 - '@rollup/plugin-node-resolve': 8.4.0_rollup@2.70.1 + '@rollup/plugin-multi-entry': 4.1.0_rollup@2.70.1 + '@rollup/plugin-node-resolve': 13.2.0_rollup@2.70.1 cross-env: 7.0.3 mkdirp: 1.0.4 mocha: 7.2.0 rimraf: 3.0.2 rollup: 2.70.1 - rollup-plugin-sourcemaps: 0.4.2_rollup@2.70.1 + rollup-plugin-sourcemaps: 0.6.3_rollup@2.70.1 tslib: 2.3.1 typescript: 4.2.4 uglify-js: 3.15.4 transitivePeerDependencies: + - '@types/node' - debug - encoding - supports-color @@ -10894,7 +10897,7 @@ packages: dev: false file:projects/arm-features.tgz: - resolution: {integrity: sha512-DViMNjyzmfMGkHCrqCMltWcpM4GVFaK+9KrcI9zjPE4EXEEpIhUL2raKgdvEfIscPJTlojobq5Xl8Z2qLx2w6A==, tarball: file:projects/arm-features.tgz} + resolution: {integrity: sha512-RUfzOPPCnBBRZWam4z2V5DLc4KLILwKDYxblrA6wN4pAhDlphsCHYJnUV4C5dGhvCmO9z+bD2EOTZ53K7UWmww==, tarball: file:projects/arm-features.tgz} name: '@rush-temp/arm-features' version: 0.0.0 dependencies: @@ -10903,18 +10906,19 @@ packages: '@microsoft/api-extractor': 7.22.1 '@rollup/plugin-commonjs': 21.0.3_rollup@2.70.1 '@rollup/plugin-json': 4.1.0_rollup@2.70.1 - '@rollup/plugin-multi-entry': 3.0.1_rollup@2.70.1 - '@rollup/plugin-node-resolve': 8.4.0_rollup@2.70.1 + '@rollup/plugin-multi-entry': 4.1.0_rollup@2.70.1 + '@rollup/plugin-node-resolve': 13.2.0_rollup@2.70.1 cross-env: 7.0.3 mkdirp: 1.0.4 mocha: 7.2.0 rimraf: 3.0.2 rollup: 2.70.1 - rollup-plugin-sourcemaps: 0.4.2_rollup@2.70.1 + rollup-plugin-sourcemaps: 0.6.3_rollup@2.70.1 tslib: 2.3.1 typescript: 4.2.4 uglify-js: 3.15.4 transitivePeerDependencies: + - '@types/node' - debug - encoding - supports-color @@ -11389,7 +11393,7 @@ packages: dev: false file:projects/arm-links.tgz: - resolution: {integrity: sha512-5Jd8Lh92kFnuiPpGs8xqDFdDoXJ6jR7cQIrn3kg3anlCy2jFBCOlHmBtvw3vzYiOvDjnEsyC6DdT4wiwzCfaLQ==, tarball: file:projects/arm-links.tgz} + resolution: {integrity: sha512-6b0saW24zzO4tUTRKUjbNs2SqnBRyHl1YulfkAXgClGdfHR7XPrlKfVSJ+/j8SY5xqS5MKz75e3VKaeAKIixYw==, tarball: file:projects/arm-links.tgz} name: '@rush-temp/arm-links' version: 0.0.0 dependencies: @@ -11398,18 +11402,19 @@ packages: '@microsoft/api-extractor': 7.22.1 '@rollup/plugin-commonjs': 21.0.3_rollup@2.70.1 '@rollup/plugin-json': 4.1.0_rollup@2.70.1 - '@rollup/plugin-multi-entry': 3.0.1_rollup@2.70.1 - '@rollup/plugin-node-resolve': 8.4.0_rollup@2.70.1 + '@rollup/plugin-multi-entry': 4.1.0_rollup@2.70.1 + '@rollup/plugin-node-resolve': 13.2.0_rollup@2.70.1 cross-env: 7.0.3 mkdirp: 1.0.4 mocha: 7.2.0 rimraf: 3.0.2 rollup: 2.70.1 - rollup-plugin-sourcemaps: 0.4.2_rollup@2.70.1 + rollup-plugin-sourcemaps: 0.6.3_rollup@2.70.1 tslib: 2.3.1 typescript: 4.2.4 uglify-js: 3.15.4 transitivePeerDependencies: + - '@types/node' - debug - encoding - supports-color @@ -11471,7 +11476,7 @@ packages: dev: false file:projects/arm-locks.tgz: - resolution: {integrity: sha512-IMmYQddkd+gIWuG+Pqk8kqtc8WGvvI/Rl8QIOCHdRvA6UDumqNIX0pczGEyALzbFfxREbSLOvwel8t5mMbTXTQ==, tarball: file:projects/arm-locks.tgz} + resolution: {integrity: sha512-K1/Sb4eDySnq4tEFQIORBTnLOPe1NtdFrRXM+54drdqeKzgwnOpK58fxipfXQZLIv2X4sNkIdweIvaJUzT+PHg==, tarball: file:projects/arm-locks.tgz} name: '@rush-temp/arm-locks' version: 0.0.0 dependencies: @@ -11480,18 +11485,19 @@ packages: '@microsoft/api-extractor': 7.22.1 '@rollup/plugin-commonjs': 21.0.3_rollup@2.70.1 '@rollup/plugin-json': 4.1.0_rollup@2.70.1 - '@rollup/plugin-multi-entry': 3.0.1_rollup@2.70.1 - '@rollup/plugin-node-resolve': 8.4.0_rollup@2.70.1 + '@rollup/plugin-multi-entry': 4.1.0_rollup@2.70.1 + '@rollup/plugin-node-resolve': 13.2.0_rollup@2.70.1 cross-env: 7.0.3 mkdirp: 1.0.4 mocha: 7.2.0 rimraf: 3.0.2 rollup: 2.70.1 - rollup-plugin-sourcemaps: 0.4.2_rollup@2.70.1 + rollup-plugin-sourcemaps: 0.6.3_rollup@2.70.1 tslib: 2.3.1 typescript: 4.2.4 uglify-js: 3.15.4 transitivePeerDependencies: + - '@types/node' - debug - encoding - supports-color @@ -11606,7 +11612,7 @@ packages: dev: false file:projects/arm-managedapplications.tgz: - resolution: {integrity: sha512-mMzLzle8gAbHD2L40yoMw0R880/Ivgr8RNHtjGWetwzt0oGgrK/cnRd01WTAkYaL6u5mzW41Q1DO8ZATjet+Yw==, tarball: file:projects/arm-managedapplications.tgz} + resolution: {integrity: sha512-5NkhwKrpUFE8CCIOg2BP8wrV8nR4HqAbsVjdX78ZaItpSRbHxhUleAmBk3i1E15xkxGgbj5LVmN91rh2LJkITA==, tarball: file:projects/arm-managedapplications.tgz} name: '@rush-temp/arm-managedapplications' version: 0.0.0 dependencies: @@ -11615,18 +11621,19 @@ packages: '@microsoft/api-extractor': 7.22.1 '@rollup/plugin-commonjs': 21.0.3_rollup@2.70.1 '@rollup/plugin-json': 4.1.0_rollup@2.70.1 - '@rollup/plugin-multi-entry': 3.0.1_rollup@2.70.1 - '@rollup/plugin-node-resolve': 8.4.0_rollup@2.70.1 + '@rollup/plugin-multi-entry': 4.1.0_rollup@2.70.1 + '@rollup/plugin-node-resolve': 13.2.0_rollup@2.70.1 cross-env: 7.0.3 mkdirp: 1.0.4 mocha: 7.2.0 rimraf: 3.0.2 rollup: 2.70.1 - rollup-plugin-sourcemaps: 0.4.2_rollup@2.70.1 + rollup-plugin-sourcemaps: 0.6.3_rollup@2.70.1 tslib: 2.3.1 typescript: 4.2.4 uglify-js: 3.15.4 transitivePeerDependencies: + - '@types/node' - debug - encoding - supports-color @@ -12289,7 +12296,7 @@ packages: dev: false file:projects/arm-policy.tgz: - resolution: {integrity: sha512-S8YG3gEBFiuJtwOTqFXRaiJ5J7LrDGd5Li68322L4lCwC2sTDtutjFpUFsgugYtMcf9aF+HlHt5XWLXzSEhDCA==, tarball: file:projects/arm-policy.tgz} + resolution: {integrity: sha512-zD1xdPnloTYWj0aPhDUZF5PS8cOhTBrSrqkjT3ZQC8glip2qinzA9SlhvpYuSGkvMXHKpyYxDmgY6fTsFkaXdA==, tarball: file:projects/arm-policy.tgz} name: '@rush-temp/arm-policy' version: 0.0.0 dependencies: @@ -12298,18 +12305,19 @@ packages: '@microsoft/api-extractor': 7.22.1 '@rollup/plugin-commonjs': 21.0.3_rollup@2.70.1 '@rollup/plugin-json': 4.1.0_rollup@2.70.1 - '@rollup/plugin-multi-entry': 3.0.1_rollup@2.70.1 - '@rollup/plugin-node-resolve': 8.4.0_rollup@2.70.1 + '@rollup/plugin-multi-entry': 4.1.0_rollup@2.70.1 + '@rollup/plugin-node-resolve': 13.2.0_rollup@2.70.1 cross-env: 7.0.3 mkdirp: 1.0.4 mocha: 7.2.0 rimraf: 3.0.2 rollup: 2.70.1 - rollup-plugin-sourcemaps: 0.4.2_rollup@2.70.1 + rollup-plugin-sourcemaps: 0.6.3_rollup@2.70.1 tslib: 2.3.1 typescript: 4.2.4 uglify-js: 3.15.4 transitivePeerDependencies: + - '@types/node' - debug - encoding - supports-color @@ -12860,7 +12868,7 @@ packages: dev: false file:projects/arm-resources-subscriptions.tgz: - resolution: {integrity: sha512-0h4G+pEZRKtMpHvVKX1DESX7mhYYKHf++qaANFa2T6/nDKwr8hqOr8ZKL2moWOqLYm8k+hxvkL75HLDm+ATyUQ==, tarball: file:projects/arm-resources-subscriptions.tgz} + resolution: {integrity: sha512-MeonSZa7jE2DoCM/Yl+DtKhcFQxSvyqbhjOjycW09J97mp5wI+LlzXivvsD6b2OmJKOmxTrAfXdzM1ZKL+x8fA==, tarball: file:projects/arm-resources-subscriptions.tgz} name: '@rush-temp/arm-resources-subscriptions' version: 0.0.0 dependencies: @@ -12869,25 +12877,26 @@ packages: '@microsoft/api-extractor': 7.22.1 '@rollup/plugin-commonjs': 21.0.3_rollup@2.70.1 '@rollup/plugin-json': 4.1.0_rollup@2.70.1 - '@rollup/plugin-multi-entry': 3.0.1_rollup@2.70.1 - '@rollup/plugin-node-resolve': 8.4.0_rollup@2.70.1 + '@rollup/plugin-multi-entry': 4.1.0_rollup@2.70.1 + '@rollup/plugin-node-resolve': 13.2.0_rollup@2.70.1 cross-env: 7.0.3 mkdirp: 1.0.4 mocha: 7.2.0 rimraf: 3.0.2 rollup: 2.70.1 - rollup-plugin-sourcemaps: 0.4.2_rollup@2.70.1 + rollup-plugin-sourcemaps: 0.6.3_rollup@2.70.1 tslib: 2.3.1 typescript: 4.2.4 uglify-js: 3.15.4 transitivePeerDependencies: + - '@types/node' - debug - encoding - supports-color dev: false file:projects/arm-resources.tgz: - resolution: {integrity: sha512-y2FiCFtpnmiMB0OacO611Sqlsr0/UQ6oKTv/q6JonPxes4Lz3sRwCqn+lFWrEjF7Vn1xgm/WugoCXL7tp3eyEQ==, tarball: file:projects/arm-resources.tgz} + resolution: {integrity: sha512-E0EJhA4/klMvBHqEWH7PCAPcWOJOLMIVx8TLdcH+wQduj2vdDfv8Ti9AcIw9oGHSfZ884WcT20ou3toGApXyLw==, tarball: file:projects/arm-resources.tgz} name: '@rush-temp/arm-resources' version: 0.0.0 dependencies: @@ -12896,18 +12905,19 @@ packages: '@microsoft/api-extractor': 7.22.1 '@rollup/plugin-commonjs': 21.0.3_rollup@2.70.1 '@rollup/plugin-json': 4.1.0_rollup@2.70.1 - '@rollup/plugin-multi-entry': 3.0.1_rollup@2.70.1 - '@rollup/plugin-node-resolve': 8.4.0_rollup@2.70.1 + '@rollup/plugin-multi-entry': 4.1.0_rollup@2.70.1 + '@rollup/plugin-node-resolve': 13.2.0_rollup@2.70.1 cross-env: 7.0.3 mkdirp: 1.0.4 mocha: 7.2.0 rimraf: 3.0.2 rollup: 2.70.1 - rollup-plugin-sourcemaps: 0.4.2_rollup@2.70.1 + rollup-plugin-sourcemaps: 0.6.3_rollup@2.70.1 tslib: 2.3.1 typescript: 4.2.4 uglify-js: 3.15.4 transitivePeerDependencies: + - '@types/node' - debug - encoding - supports-color @@ -13543,7 +13553,7 @@ packages: dev: false file:projects/arm-templatespecs.tgz: - resolution: {integrity: sha512-o0Qh5cZPGQDqFCFWt/CtLRecoYltLMkUY/VjMiVax5VpGJyOAHo8EWNlfh1p/QTqKhSGDiS+f9H4xASA7bExQQ==, tarball: file:projects/arm-templatespecs.tgz} + resolution: {integrity: sha512-j9Oa28D2fvG7CgudfPFux9wFA28Oftvk3jVSKAj0qkMVSMk57Ah9kwp4pQ2r56pZ8/XSWTj1M9wBOswxDrCrGg==, tarball: file:projects/arm-templatespecs.tgz} name: '@rush-temp/arm-templatespecs' version: 0.0.0 dependencies: @@ -13552,18 +13562,19 @@ packages: '@microsoft/api-extractor': 7.22.1 '@rollup/plugin-commonjs': 21.0.3_rollup@2.70.1 '@rollup/plugin-json': 4.1.0_rollup@2.70.1 - '@rollup/plugin-multi-entry': 3.0.1_rollup@2.70.1 - '@rollup/plugin-node-resolve': 8.4.0_rollup@2.70.1 + '@rollup/plugin-multi-entry': 4.1.0_rollup@2.70.1 + '@rollup/plugin-node-resolve': 13.2.0_rollup@2.70.1 cross-env: 7.0.3 mkdirp: 1.0.4 mocha: 7.2.0 rimraf: 3.0.2 rollup: 2.70.1 - rollup-plugin-sourcemaps: 0.4.2_rollup@2.70.1 + rollup-plugin-sourcemaps: 0.6.3_rollup@2.70.1 tslib: 2.3.1 typescript: 4.2.4 uglify-js: 3.15.4 transitivePeerDependencies: + - '@types/node' - debug - encoding - supports-color diff --git a/sdk/dns/arm-dns/CHANGELOG.md b/sdk/dns/arm-dns/CHANGELOG.md index 6f8290f6c643..81a5339fc8af 100644 --- a/sdk/dns/arm-dns/CHANGELOG.md +++ b/sdk/dns/arm-dns/CHANGELOG.md @@ -1,14 +1,10 @@ # Release History -## 5.0.1 (Unreleased) +## 5.0.1 (2022-04-18) -### Features Added +**features** -### Breaking Changes - -### Bugs Fixed - -### Other Changes + - Bug fix ## 5.0.0 (2022-01-13) diff --git a/sdk/dns/arm-dns/LICENSE.txt b/sdk/dns/arm-dns/LICENSE.txt deleted file mode 100644 index ea8fb1516028..000000000000 --- a/sdk/dns/arm-dns/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2020 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 -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/sdk/dns/arm-dns/README.md b/sdk/dns/arm-dns/README.md index ea8bc7174650..76af276e438c 100644 --- a/sdk/dns/arm-dns/README.md +++ b/sdk/dns/arm-dns/README.md @@ -16,6 +16,8 @@ The DNS Management Client. - [LTS versions of Node.js](https://nodejs.org/about/releases/) - 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]. @@ -49,8 +51,17 @@ For more information about how to create an Azure AD Application check out [this ```javascript const { DnsManagementClient } = require("@azure/arm-dns"); 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 DnsManagementClient(new DefaultAzureCredential(), subscriptionId); + +// For client-side applications running in the browser, use this code instead: +// const credential = new InteractiveBrowserCredential({ +// tenantId: "", +// clientId: "" +// }); +// const client = new DnsManagementClient(credential, subscriptionId); ``` diff --git a/sdk/dns/arm-dns/_meta.json b/sdk/dns/arm-dns/_meta.json index 21c2c69629af..4143a486531d 100644 --- a/sdk/dns/arm-dns/_meta.json +++ b/sdk/dns/arm-dns/_meta.json @@ -1,7 +1,8 @@ { "commit": "1f1d5b0b9ce6cc94605b2fd619dce374fb6e033a", - "readme": "specification/dns/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 --generate-test --typescript-sdks-folder=D:\\mydev\\azure-sdk-for-js ../azure-rest-api-specs/specification/devspaces/resource-manager/readme.md --use=@autorest/typescript@6.0.0-alpha.16.20211217.1", + "readme": "specification\\dns\\resource-manager\\readme.md", + "autorest_command": "autorest --version=3.7.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\work\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\dns\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-alpha.19.20220408.1 --generate-sample=true", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "use": "@autorest/typescript@6.0.0-alpha.16.20211217.1" -} + "release_tool": "@azure-tools/js-sdk-release-tools@2.2.6", + "use": "@autorest/typescript@6.0.0-alpha.19.20220408.1" +} \ No newline at end of file diff --git a/sdk/dns/arm-dns/api-extractor.json b/sdk/dns/arm-dns/api-extractor.json index c583a0195bd7..b5e3f19279e0 100644 --- a/sdk/dns/arm-dns/api-extractor.json +++ b/sdk/dns/arm-dns/api-extractor.json @@ -1,18 +1,31 @@ { "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", "mainEntryPointFilePath": "./dist-esm/src/index.d.ts", - "docModel": { "enabled": true }, - "apiReport": { "enabled": true, "reportFolder": "./review" }, + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, "dtsRollup": { "enabled": true, "untrimmedFilePath": "", "publicTrimmedFilePath": "./types/arm-dns.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/dns/arm-dns/package.json b/sdk/dns/arm-dns/package.json index 2a2c7765ec2e..877ea5ec3dcb 100644 --- a/sdk/dns/arm-dns/package.json +++ b/sdk/dns/arm-dns/package.json @@ -11,9 +11,9 @@ "@azure/core-lro": "^2.2.0", "@azure/abort-controller": "^1.0.0", "@azure/core-paging": "^1.2.0", - "@azure/core-client": "^1.0.0", + "@azure/core-client": "^1.5.0", "@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": [ @@ -29,13 +29,13 @@ "types": "./types/arm-dns.d.ts", "devDependencies": { "@microsoft/api-extractor": "^7.18.11", - "@rollup/plugin-commonjs": "11.0.2", - "@rollup/plugin-json": "^4.0.0", - "@rollup/plugin-multi-entry": "^3.0.0", - "@rollup/plugin-node-resolve": "^8.0.0", + "@rollup/plugin-commonjs": "^21.0.1", + "@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": "^1.16.3", - "rollup-plugin-sourcemaps": "^0.4.2", + "rollup": "^2.66.1", + "rollup-plugin-sourcemaps": "^0.6.3", "typescript": "~4.2.0", "uglify-js": "^3.4.9", "rimraf": "^3.0.0", @@ -98,5 +98,21 @@ "docs": "echo skipped" }, "sideEffects": false, - "autoPublish": true + "//metadata": { + "constantPaths": [ + { + "path": "src/dnsManagementClient.ts", + "prefix": "packageDetails" + } + ] + }, + "autoPublish": true, + "//sampleConfiguration": { + "productName": "", + "productSlugs": [ + "azure" + ], + "disableDocsMs": true, + "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-dns?view=azure-node-preview" + } } diff --git a/sdk/dns/arm-dns/rollup.config.js b/sdk/dns/arm-dns/rollup.config.js index 9be1955eb7f1..3f89d7309da5 100644 --- a/sdk/dns/arm-dns/rollup.config.js +++ b/sdk/dns/arm-dns/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/dns/arm-dns/sample.env b/sdk/dns/arm-dns/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/dns/arm-dns/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/dns/arm-dns/samples-dev/dnsResourceReferenceGetByTargetResourcesSample.ts b/sdk/dns/arm-dns/samples-dev/dnsResourceReferenceGetByTargetResourcesSample.ts new file mode 100644 index 000000000000..d821484661a3 --- /dev/null +++ b/sdk/dns/arm-dns/samples-dev/dnsResourceReferenceGetByTargetResourcesSample.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 { + DnsResourceReferenceRequest, + DnsManagementClient +} from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Returns the DNS records specified by the referencing targetResourceIds. + * + * @summary Returns the DNS records specified by the referencing targetResourceIds. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetDnsResourceReference.json + */ +async function listZonesByResourceGroup() { + const subscriptionId = "subid"; + const parameters: DnsResourceReferenceRequest = { + targetResources: [ + { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/trafficManagerProfiles/testpp2" + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.dnsResourceReferenceOperations.getByTargetResources( + parameters + ); + console.log(result); +} + +listZonesByResourceGroup().catch(console.error); diff --git a/sdk/dns/arm-dns/samples-dev/recordSetsCreateOrUpdateSample.ts b/sdk/dns/arm-dns/samples-dev/recordSetsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..503aab50d6f9 --- /dev/null +++ b/sdk/dns/arm-dns/samples-dev/recordSetsCreateOrUpdateSample.ts @@ -0,0 +1,364 @@ +/* + * 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 { RecordSet, DnsManagementClient } from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateARecordset.json + */ +async function createARecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "A"; + const parameters: RecordSet = { + aRecords: [{ ipv4Address: "127.0.0.1" }], + ttl: 3600, + metadata: { key1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createARecordset().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateARecordsetAlias.json + */ +async function createARecordsetWithAliasTargetResource() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "A"; + const parameters: RecordSet = { + ttl: 3600, + metadata: { key1: "value1" }, + targetResource: { + id: + "/subscriptions/726f8cd6-6459-4db4-8e6d-2cd2716904e2/resourceGroups/test/providers/Microsoft.Network/trafficManagerProfiles/testpp2" + } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createARecordsetWithAliasTargetResource().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateAAAARecordset.json + */ +async function createAaaaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "AAAA"; + const parameters: RecordSet = { + aaaaRecords: [{ ipv6Address: "::1" }], + ttl: 3600, + metadata: { key1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createAaaaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateCaaRecordset.json + */ +async function createCaaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "CAA"; + const parameters: RecordSet = { + ttl: 3600, + caaRecords: [{ flags: 0, tag: "issue", value: "ca.contoso.com" }], + metadata: { key1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createCaaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateCNAMERecordset.json + */ +async function createCnameRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "CNAME"; + const parameters: RecordSet = { + cnameRecord: { cname: "contoso.com" }, + ttl: 3600, + metadata: { key1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createCnameRecordset().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateMXRecordset.json + */ +async function createMxRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "MX"; + const parameters: RecordSet = { + mxRecords: [{ exchange: "mail.contoso.com", preference: 0 }], + ttl: 3600, + metadata: { key1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createMxRecordset().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateNSRecordset.json + */ +async function createNsRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "NS"; + const parameters: RecordSet = { + nsRecords: [{ nsdname: "ns1.contoso.com" }], + ttl: 3600, + metadata: { key1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createNsRecordset().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdatePTRRecordset.json + */ +async function createPtrRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "0.0.127.in-addr.arpa"; + const relativeRecordSetName = "1"; + const recordType = "PTR"; + const parameters: RecordSet = { + ptrRecords: [{ ptrdname: "localhost" }], + ttl: 3600, + metadata: { key1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createPtrRecordset().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateSOARecordset.json + */ +async function createSoaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "@"; + const recordType = "SOA"; + const parameters: RecordSet = { + soaRecord: { + email: "hostmaster.contoso.com", + expireTime: 2419200, + host: "ns1.contoso.com", + minimumTtl: 300, + refreshTime: 3600, + retryTime: 300, + serialNumber: 1 + }, + ttl: 3600, + metadata: { key1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createSoaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateSRVRecordset.json + */ +async function createSrvRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "SRV"; + const parameters: RecordSet = { + srvRecords: [{ port: 80, priority: 0, target: "contoso.com", weight: 10 }], + ttl: 3600, + metadata: { key1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createSrvRecordset().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateTXTRecordset.json + */ +async function createTxtRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "TXT"; + const parameters: RecordSet = { + ttl: 3600, + txtRecords: [{ value: ["string1", "string2"] }], + metadata: { key1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createTxtRecordset().catch(console.error); diff --git a/sdk/dns/arm-dns/samples-dev/recordSetsDeleteSample.ts b/sdk/dns/arm-dns/samples-dev/recordSetsDeleteSample.ts new file mode 100644 index 000000000000..dfd43a5b485e --- /dev/null +++ b/sdk/dns/arm-dns/samples-dev/recordSetsDeleteSample.ts @@ -0,0 +1,237 @@ +/* + * 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 { DnsManagementClient } from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes a record set from a DNS zone. This operation cannot be undone. + * + * @summary Deletes a record set from a DNS zone. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteARecordset.json + */ +async function deleteARecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "A"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.delete( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +deleteARecordset().catch(console.error); + +/** + * This sample demonstrates how to Deletes a record set from a DNS zone. This operation cannot be undone. + * + * @summary Deletes a record set from a DNS zone. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteAAAARecordset.json + */ +async function deleteAaaaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "AAAA"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.delete( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +deleteAaaaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Deletes a record set from a DNS zone. This operation cannot be undone. + * + * @summary Deletes a record set from a DNS zone. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteCaaRecordset.json + */ +async function deleteCaaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "CAA"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.delete( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +deleteCaaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Deletes a record set from a DNS zone. This operation cannot be undone. + * + * @summary Deletes a record set from a DNS zone. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteARecordset.json + */ +async function deleteCnameRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "A"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.delete( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +deleteCnameRecordset().catch(console.error); + +/** + * This sample demonstrates how to Deletes a record set from a DNS zone. This operation cannot be undone. + * + * @summary Deletes a record set from a DNS zone. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteARecordset.json + */ +async function deleteMxRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "A"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.delete( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +deleteMxRecordset().catch(console.error); + +/** + * This sample demonstrates how to Deletes a record set from a DNS zone. This operation cannot be undone. + * + * @summary Deletes a record set from a DNS zone. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteARecordset.json + */ +async function deleteNsRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "A"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.delete( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +deleteNsRecordset().catch(console.error); + +/** + * This sample demonstrates how to Deletes a record set from a DNS zone. This operation cannot be undone. + * + * @summary Deletes a record set from a DNS zone. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeletePTRRecordset.json + */ +async function deletePtrRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "0.0.127.in-addr.arpa"; + const relativeRecordSetName = "1"; + const recordType = "PTR"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.delete( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +deletePtrRecordset().catch(console.error); + +/** + * This sample demonstrates how to Deletes a record set from a DNS zone. This operation cannot be undone. + * + * @summary Deletes a record set from a DNS zone. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteSRVRecordset.json + */ +async function deleteSrvRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "SRV"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.delete( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +deleteSrvRecordset().catch(console.error); + +/** + * This sample demonstrates how to Deletes a record set from a DNS zone. This operation cannot be undone. + * + * @summary Deletes a record set from a DNS zone. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteTXTRecordset.json + */ +async function deleteTxtRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "TXT"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.delete( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +deleteTxtRecordset().catch(console.error); diff --git a/sdk/dns/arm-dns/samples-dev/recordSetsGetSample.ts b/sdk/dns/arm-dns/samples-dev/recordSetsGetSample.ts new file mode 100644 index 000000000000..6dc689b1631a --- /dev/null +++ b/sdk/dns/arm-dns/samples-dev/recordSetsGetSample.ts @@ -0,0 +1,262 @@ +/* + * 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 { DnsManagementClient } from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetARecordset.json + */ +async function getARecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "A"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getARecordset().catch(console.error); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetAAAARecordset.json + */ +async function getAaaaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "AAAA"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getAaaaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetCaaRecordset.json + */ +async function getCaaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "CAA"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getCaaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetCNAMERecordset.json + */ +async function getCnameRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "CNAME"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getCnameRecordset().catch(console.error); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetMXRecordset.json + */ +async function getMxRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "MX"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getMxRecordset().catch(console.error); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetNSRecordset.json + */ +async function getNsRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "NS"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getNsRecordset().catch(console.error); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetPTRRecordset.json + */ +async function getPtrRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "0.0.127.in-addr.arpa"; + const relativeRecordSetName = "1"; + const recordType = "PTR"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getPtrRecordset().catch(console.error); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetSOARecordset.json + */ +async function getSoaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "@"; + const recordType = "SOA"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getSoaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetSRVRecordset.json + */ +async function getSrvRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "SRV"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getSrvRecordset().catch(console.error); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetTXTRecordset.json + */ +async function getTxtRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "TXT"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getTxtRecordset().catch(console.error); diff --git a/sdk/dns/arm-dns/samples-dev/recordSetsListAllByDnsZoneSample.ts b/sdk/dns/arm-dns/samples-dev/recordSetsListAllByDnsZoneSample.ts new file mode 100644 index 000000000000..7e598a43bd6a --- /dev/null +++ b/sdk/dns/arm-dns/samples-dev/recordSetsListAllByDnsZoneSample.ts @@ -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. +import { DnsManagementClient } from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists all record sets in a DNS zone. + * + * @summary Lists all record sets in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListRecordSetsByZone.json + */ +async function listRecordsetsByZone() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listAllByDnsZone( + resourceGroupName, + zoneName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listRecordsetsByZone().catch(console.error); diff --git a/sdk/dns/arm-dns/samples-dev/recordSetsListByDnsZoneSample.ts b/sdk/dns/arm-dns/samples-dev/recordSetsListByDnsZoneSample.ts new file mode 100644 index 000000000000..ecfdc6d50729 --- /dev/null +++ b/sdk/dns/arm-dns/samples-dev/recordSetsListByDnsZoneSample.ts @@ -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. +import { DnsManagementClient } from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists all record sets in a DNS zone. + * + * @summary Lists all record sets in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListRecordSetsByZone.json + */ +async function listRecordsetsByZone() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByDnsZone( + resourceGroupName, + zoneName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listRecordsetsByZone().catch(console.error); diff --git a/sdk/dns/arm-dns/samples-dev/recordSetsListByTypeSample.ts b/sdk/dns/arm-dns/samples-dev/recordSetsListByTypeSample.ts new file mode 100644 index 000000000000..13bf55297832 --- /dev/null +++ b/sdk/dns/arm-dns/samples-dev/recordSetsListByTypeSample.ts @@ -0,0 +1,272 @@ +/* + * 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 { DnsManagementClient } from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListARecordset.json + */ +async function listARecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const recordType = "A"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType( + resourceGroupName, + zoneName, + recordType + )) { + resArray.push(item); + } + console.log(resArray); +} + +listARecordsets().catch(console.error); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListAAAARecordset.json + */ +async function listAaaaRecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const recordType = "AAAA"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType( + resourceGroupName, + zoneName, + recordType + )) { + resArray.push(item); + } + console.log(resArray); +} + +listAaaaRecordsets().catch(console.error); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListCaaRecordset.json + */ +async function listCaaRecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const recordType = "CAA"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType( + resourceGroupName, + zoneName, + recordType + )) { + resArray.push(item); + } + console.log(resArray); +} + +listCaaRecordsets().catch(console.error); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListCNAMERecordset.json + */ +async function listCnameRecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const recordType = "CNAME"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType( + resourceGroupName, + zoneName, + recordType + )) { + resArray.push(item); + } + console.log(resArray); +} + +listCnameRecordsets().catch(console.error); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListMXRecordset.json + */ +async function listMxRecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const recordType = "MX"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType( + resourceGroupName, + zoneName, + recordType + )) { + resArray.push(item); + } + console.log(resArray); +} + +listMxRecordsets().catch(console.error); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListNSRecordset.json + */ +async function listNsRecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const recordType = "NS"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType( + resourceGroupName, + zoneName, + recordType + )) { + resArray.push(item); + } + console.log(resArray); +} + +listNsRecordsets().catch(console.error); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListPTRRecordset.json + */ +async function listPtrRecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "0.0.127.in-addr.arpa"; + const recordType = "PTR"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType( + resourceGroupName, + zoneName, + recordType + )) { + resArray.push(item); + } + console.log(resArray); +} + +listPtrRecordsets().catch(console.error); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListSOARecordset.json + */ +async function listSoaRecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const recordType = "SOA"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType( + resourceGroupName, + zoneName, + recordType + )) { + resArray.push(item); + } + console.log(resArray); +} + +listSoaRecordsets().catch(console.error); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListSRVRecordset.json + */ +async function listSrvRecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const recordType = "SRV"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType( + resourceGroupName, + zoneName, + recordType + )) { + resArray.push(item); + } + console.log(resArray); +} + +listSrvRecordsets().catch(console.error); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListTXTRecordset.json + */ +async function listTxtRecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const recordType = "TXT"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType( + resourceGroupName, + zoneName, + recordType + )) { + resArray.push(item); + } + console.log(resArray); +} + +listTxtRecordsets().catch(console.error); diff --git a/sdk/dns/arm-dns/samples-dev/recordSetsUpdateSample.ts b/sdk/dns/arm-dns/samples-dev/recordSetsUpdateSample.ts new file mode 100644 index 000000000000..08daa3eb25d4 --- /dev/null +++ b/sdk/dns/arm-dns/samples-dev/recordSetsUpdateSample.ts @@ -0,0 +1,282 @@ +/* + * 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 { RecordSet, DnsManagementClient } from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchARecordset.json + */ +async function patchARecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "A"; + const parameters: RecordSet = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchARecordset().catch(console.error); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchAAAARecordset.json + */ +async function patchAaaaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "AAAA"; + const parameters: RecordSet = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchAaaaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchCaaRecordset.json + */ +async function patchCaaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "CAA"; + const parameters: RecordSet = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchCaaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchCNAMERecordset.json + */ +async function patchCnameRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "CNAME"; + const parameters: RecordSet = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchCnameRecordset().catch(console.error); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchMXRecordset.json + */ +async function patchMxRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "MX"; + const parameters: RecordSet = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchMxRecordset().catch(console.error); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchNSRecordset.json + */ +async function patchNsRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "NS"; + const parameters: RecordSet = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchNsRecordset().catch(console.error); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchPTRRecordset.json + */ +async function patchPtrRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "0.0.127.in-addr.arpa"; + const relativeRecordSetName = "1"; + const recordType = "PTR"; + const parameters: RecordSet = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchPtrRecordset().catch(console.error); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchSOARecordset.json + */ +async function patchSoaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "@"; + const recordType = "SOA"; + const parameters: RecordSet = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchSoaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchSRVRecordset.json + */ +async function patchSrvRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "SRV"; + const parameters: RecordSet = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchSrvRecordset().catch(console.error); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchTXTRecordset.json + */ +async function patchTxtRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "TXT"; + const parameters: RecordSet = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchTxtRecordset().catch(console.error); diff --git a/sdk/dns/arm-dns/samples-dev/zonesCreateOrUpdateSample.ts b/sdk/dns/arm-dns/samples-dev/zonesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..8528dff6389f --- /dev/null +++ b/sdk/dns/arm-dns/samples-dev/zonesCreateOrUpdateSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { Zone, DnsManagementClient } from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates a DNS zone. Does not modify DNS records within the zone. + * + * @summary Creates or updates a DNS zone. Does not modify DNS records within the zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateZone.json + */ +async function createZone() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const parameters: Zone = { location: "Global", tags: { key1: "value1" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.zones.createOrUpdate( + resourceGroupName, + zoneName, + parameters + ); + console.log(result); +} + +createZone().catch(console.error); diff --git a/sdk/dns/arm-dns/samples-dev/zonesDeleteSample.ts b/sdk/dns/arm-dns/samples-dev/zonesDeleteSample.ts new file mode 100644 index 000000000000..b4e525a5dfc0 --- /dev/null +++ b/sdk/dns/arm-dns/samples-dev/zonesDeleteSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { DnsManagementClient } from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation cannot be undone. + * + * @summary Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteZone.json + */ +async function deleteZone() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.zones.beginDeleteAndWait( + resourceGroupName, + zoneName + ); + console.log(result); +} + +deleteZone().catch(console.error); diff --git a/sdk/dns/arm-dns/samples-dev/zonesGetSample.ts b/sdk/dns/arm-dns/samples-dev/zonesGetSample.ts new file mode 100644 index 000000000000..9612b92ecf16 --- /dev/null +++ b/sdk/dns/arm-dns/samples-dev/zonesGetSample.ts @@ -0,0 +1,30 @@ +/* + * 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 { DnsManagementClient } from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets a DNS zone. Retrieves the zone properties, but not the record sets within the zone. + * + * @summary Gets a DNS zone. Retrieves the zone properties, but not the record sets within the zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetZone.json + */ +async function getZone() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.zones.get(resourceGroupName, zoneName); + console.log(result); +} + +getZone().catch(console.error); diff --git a/sdk/dns/arm-dns/samples-dev/zonesListByResourceGroupSample.ts b/sdk/dns/arm-dns/samples-dev/zonesListByResourceGroupSample.ts new file mode 100644 index 000000000000..f533a0ad64c9 --- /dev/null +++ b/sdk/dns/arm-dns/samples-dev/zonesListByResourceGroupSample.ts @@ -0,0 +1,32 @@ +/* + * 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 { DnsManagementClient } from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists the DNS zones within a resource group. + * + * @summary Lists the DNS zones within a resource group. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListZonesByResourceGroup.json + */ +async function listZonesByResourceGroup() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.zones.listByResourceGroup(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +listZonesByResourceGroup().catch(console.error); diff --git a/sdk/dns/arm-dns/samples-dev/zonesListSample.ts b/sdk/dns/arm-dns/samples-dev/zonesListSample.ts new file mode 100644 index 000000000000..fa9cc20c8383 --- /dev/null +++ b/sdk/dns/arm-dns/samples-dev/zonesListSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { DnsManagementClient } from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists the DNS zones in all resource groups in a subscription. + * + * @summary Lists the DNS zones in all resource groups in a subscription. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListZonesBySubscription.json + */ +async function listZonesBySubscription() { + const subscriptionId = "subid"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.zones.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listZonesBySubscription().catch(console.error); diff --git a/sdk/dns/arm-dns/samples-dev/zonesUpdateSample.ts b/sdk/dns/arm-dns/samples-dev/zonesUpdateSample.ts new file mode 100644 index 000000000000..eca304e5ece3 --- /dev/null +++ b/sdk/dns/arm-dns/samples-dev/zonesUpdateSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { ZoneUpdate, DnsManagementClient } from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Updates a DNS zone. Does not modify DNS records within the zone. + * + * @summary Updates a DNS zone. Does not modify DNS records within the zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchZone.json + */ +async function patchZone() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const parameters: ZoneUpdate = { tags: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.zones.update( + resourceGroupName, + zoneName, + parameters + ); + console.log(result); +} + +patchZone().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/javascript/README.md b/sdk/dns/arm-dns/samples/v5/javascript/README.md new file mode 100644 index 000000000000..36e769d35531 --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/javascript/README.md @@ -0,0 +1,76 @@ +# client library samples for JavaScript + +These sample programs show how to use the JavaScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| --------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [dnsResourceReferenceGetByTargetResourcesSample.js][dnsresourcereferencegetbytargetresourcessample] | Returns the DNS records specified by the referencing targetResourceIds. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetDnsResourceReference.json | +| [recordSetsCreateOrUpdateSample.js][recordsetscreateorupdatesample] | Creates or updates a record set within a DNS zone. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateARecordset.json | +| [recordSetsDeleteSample.js][recordsetsdeletesample] | Deletes a record set from a DNS zone. This operation cannot be undone. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteARecordset.json | +| [recordSetsGetSample.js][recordsetsgetsample] | Gets a record set. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetARecordset.json | +| [recordSetsListAllByDnsZoneSample.js][recordsetslistallbydnszonesample] | Lists all record sets in a DNS zone. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListRecordSetsByZone.json | +| [recordSetsListByDnsZoneSample.js][recordsetslistbydnszonesample] | Lists all record sets in a DNS zone. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListRecordSetsByZone.json | +| [recordSetsListByTypeSample.js][recordsetslistbytypesample] | Lists the record sets of a specified type in a DNS zone. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListARecordset.json | +| [recordSetsUpdateSample.js][recordsetsupdatesample] | Updates a record set within a DNS zone. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchARecordset.json | +| [zonesCreateOrUpdateSample.js][zonescreateorupdatesample] | Creates or updates a DNS zone. Does not modify DNS records within the zone. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateZone.json | +| [zonesDeleteSample.js][zonesdeletesample] | Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation cannot be undone. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteZone.json | +| [zonesGetSample.js][zonesgetsample] | Gets a DNS zone. Retrieves the zone properties, but not the record sets within the zone. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetZone.json | +| [zonesListByResourceGroupSample.js][zoneslistbyresourcegroupsample] | Lists the DNS zones within a resource group. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListZonesByResourceGroup.json | +| [zonesListSample.js][zoneslistsample] | Lists the DNS zones in all resource groups in a subscription. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListZonesBySubscription.json | +| [zonesUpdateSample.js][zonesupdatesample] | Updates a DNS zone. Does not modify DNS records within the zone. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchZone.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +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 dnsResourceReferenceGetByTargetResourcesSample.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 node dnsResourceReferenceGetByTargetResourcesSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[dnsresourcereferencegetbytargetresourcessample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/javascript/dnsResourceReferenceGetByTargetResourcesSample.js +[recordsetscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/javascript/recordSetsCreateOrUpdateSample.js +[recordsetsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/javascript/recordSetsDeleteSample.js +[recordsetsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/javascript/recordSetsGetSample.js +[recordsetslistallbydnszonesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/javascript/recordSetsListAllByDnsZoneSample.js +[recordsetslistbydnszonesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/javascript/recordSetsListByDnsZoneSample.js +[recordsetslistbytypesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/javascript/recordSetsListByTypeSample.js +[recordsetsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/javascript/recordSetsUpdateSample.js +[zonescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/javascript/zonesCreateOrUpdateSample.js +[zonesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/javascript/zonesDeleteSample.js +[zonesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/javascript/zonesGetSample.js +[zoneslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/javascript/zonesListByResourceGroupSample.js +[zoneslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/javascript/zonesListSample.js +[zonesupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/javascript/zonesUpdateSample.js +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-dns?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/dns/arm-dns/README.md diff --git a/sdk/dns/arm-dns/samples/v5/javascript/dnsResourceReferenceGetByTargetResourcesSample.js b/sdk/dns/arm-dns/samples/v5/javascript/dnsResourceReferenceGetByTargetResourcesSample.js new file mode 100644 index 000000000000..6dca26df3c7c --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/javascript/dnsResourceReferenceGetByTargetResourcesSample.js @@ -0,0 +1,35 @@ +/* + * 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 { DnsManagementClient } = require("@azure/arm-dns"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Returns the DNS records specified by the referencing targetResourceIds. + * + * @summary Returns the DNS records specified by the referencing targetResourceIds. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetDnsResourceReference.json + */ +async function listZonesByResourceGroup() { + const subscriptionId = "subid"; + const parameters = { + targetResources: [ + { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/trafficManagerProfiles/testpp2", + }, + ], + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.dnsResourceReferenceOperations.getByTargetResources(parameters); + console.log(result); +} + +listZonesByResourceGroup().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/javascript/package.json b/sdk/dns/arm-dns/samples/v5/javascript/package.json new file mode 100644 index 000000000000..e1ef875245fd --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/javascript/package.json @@ -0,0 +1,32 @@ +{ + "name": "@azure-samples/arm-dns-js", + "private": true, + "version": "1.0.0", + "description": " client library samples for JavaScript", + "engines": { + "node": ">=12.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/dns/arm-dns" + }, + "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/dns/arm-dns", + "dependencies": { + "@azure/arm-dns": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + } +} diff --git a/sdk/dns/arm-dns/samples/v5/javascript/recordSetsCreateOrUpdateSample.js b/sdk/dns/arm-dns/samples/v5/javascript/recordSetsCreateOrUpdateSample.js new file mode 100644 index 000000000000..9650fc73748f --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/javascript/recordSetsCreateOrUpdateSample.js @@ -0,0 +1,363 @@ +/* + * 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 { DnsManagementClient } = require("@azure/arm-dns"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateARecordset.json + */ +async function createARecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "A"; + const parameters = { + aRecords: [{ ipv4Address: "127.0.0.1" }], + ttl: 3600, + metadata: { key1: "value1" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createARecordset().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateARecordsetAlias.json + */ +async function createARecordsetWithAliasTargetResource() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "A"; + const parameters = { + ttl: 3600, + metadata: { key1: "value1" }, + targetResource: { + id: "/subscriptions/726f8cd6-6459-4db4-8e6d-2cd2716904e2/resourceGroups/test/providers/Microsoft.Network/trafficManagerProfiles/testpp2", + }, + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createARecordsetWithAliasTargetResource().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateAAAARecordset.json + */ +async function createAaaaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "AAAA"; + const parameters = { + aaaaRecords: [{ ipv6Address: "::1" }], + ttl: 3600, + metadata: { key1: "value1" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createAaaaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateCaaRecordset.json + */ +async function createCaaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "CAA"; + const parameters = { + ttl: 3600, + caaRecords: [{ flags: 0, tag: "issue", value: "ca.contoso.com" }], + metadata: { key1: "value1" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createCaaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateCNAMERecordset.json + */ +async function createCnameRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "CNAME"; + const parameters = { + cnameRecord: { cname: "contoso.com" }, + ttl: 3600, + metadata: { key1: "value1" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createCnameRecordset().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateMXRecordset.json + */ +async function createMxRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "MX"; + const parameters = { + mxRecords: [{ exchange: "mail.contoso.com", preference: 0 }], + ttl: 3600, + metadata: { key1: "value1" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createMxRecordset().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateNSRecordset.json + */ +async function createNsRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "NS"; + const parameters = { + nsRecords: [{ nsdname: "ns1.contoso.com" }], + ttl: 3600, + metadata: { key1: "value1" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createNsRecordset().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdatePTRRecordset.json + */ +async function createPtrRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "0.0.127.in-addr.arpa"; + const relativeRecordSetName = "1"; + const recordType = "PTR"; + const parameters = { + ptrRecords: [{ ptrdname: "localhost" }], + ttl: 3600, + metadata: { key1: "value1" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createPtrRecordset().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateSOARecordset.json + */ +async function createSoaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "@"; + const recordType = "SOA"; + const parameters = { + soaRecord: { + email: "hostmaster.contoso.com", + expireTime: 2419200, + host: "ns1.contoso.com", + minimumTtl: 300, + refreshTime: 3600, + retryTime: 300, + serialNumber: 1, + }, + ttl: 3600, + metadata: { key1: "value1" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createSoaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateSRVRecordset.json + */ +async function createSrvRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "SRV"; + const parameters = { + srvRecords: [{ port: 80, priority: 0, target: "contoso.com", weight: 10 }], + ttl: 3600, + metadata: { key1: "value1" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createSrvRecordset().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateTXTRecordset.json + */ +async function createTxtRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "TXT"; + const parameters = { + ttl: 3600, + txtRecords: [{ value: ["string1", "string2"] }], + metadata: { key1: "value1" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createTxtRecordset().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/javascript/recordSetsDeleteSample.js b/sdk/dns/arm-dns/samples/v5/javascript/recordSetsDeleteSample.js new file mode 100644 index 000000000000..aee7f62ed614 --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/javascript/recordSetsDeleteSample.js @@ -0,0 +1,237 @@ +/* + * 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 { DnsManagementClient } = require("@azure/arm-dns"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes a record set from a DNS zone. This operation cannot be undone. + * + * @summary Deletes a record set from a DNS zone. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteARecordset.json + */ +async function deleteARecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "A"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.delete( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +deleteARecordset().catch(console.error); + +/** + * This sample demonstrates how to Deletes a record set from a DNS zone. This operation cannot be undone. + * + * @summary Deletes a record set from a DNS zone. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteAAAARecordset.json + */ +async function deleteAaaaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "AAAA"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.delete( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +deleteAaaaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Deletes a record set from a DNS zone. This operation cannot be undone. + * + * @summary Deletes a record set from a DNS zone. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteCaaRecordset.json + */ +async function deleteCaaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "CAA"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.delete( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +deleteCaaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Deletes a record set from a DNS zone. This operation cannot be undone. + * + * @summary Deletes a record set from a DNS zone. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteARecordset.json + */ +async function deleteCnameRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "A"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.delete( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +deleteCnameRecordset().catch(console.error); + +/** + * This sample demonstrates how to Deletes a record set from a DNS zone. This operation cannot be undone. + * + * @summary Deletes a record set from a DNS zone. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteARecordset.json + */ +async function deleteMxRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "A"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.delete( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +deleteMxRecordset().catch(console.error); + +/** + * This sample demonstrates how to Deletes a record set from a DNS zone. This operation cannot be undone. + * + * @summary Deletes a record set from a DNS zone. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteARecordset.json + */ +async function deleteNsRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "A"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.delete( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +deleteNsRecordset().catch(console.error); + +/** + * This sample demonstrates how to Deletes a record set from a DNS zone. This operation cannot be undone. + * + * @summary Deletes a record set from a DNS zone. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeletePTRRecordset.json + */ +async function deletePtrRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "0.0.127.in-addr.arpa"; + const relativeRecordSetName = "1"; + const recordType = "PTR"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.delete( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +deletePtrRecordset().catch(console.error); + +/** + * This sample demonstrates how to Deletes a record set from a DNS zone. This operation cannot be undone. + * + * @summary Deletes a record set from a DNS zone. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteSRVRecordset.json + */ +async function deleteSrvRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "SRV"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.delete( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +deleteSrvRecordset().catch(console.error); + +/** + * This sample demonstrates how to Deletes a record set from a DNS zone. This operation cannot be undone. + * + * @summary Deletes a record set from a DNS zone. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteTXTRecordset.json + */ +async function deleteTxtRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "TXT"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.delete( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +deleteTxtRecordset().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/javascript/recordSetsGetSample.js b/sdk/dns/arm-dns/samples/v5/javascript/recordSetsGetSample.js new file mode 100644 index 000000000000..b0df8cb09045 --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/javascript/recordSetsGetSample.js @@ -0,0 +1,262 @@ +/* + * 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 { DnsManagementClient } = require("@azure/arm-dns"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetARecordset.json + */ +async function getARecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "A"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getARecordset().catch(console.error); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetAAAARecordset.json + */ +async function getAaaaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "AAAA"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getAaaaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetCaaRecordset.json + */ +async function getCaaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "CAA"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getCaaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetCNAMERecordset.json + */ +async function getCnameRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "CNAME"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getCnameRecordset().catch(console.error); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetMXRecordset.json + */ +async function getMxRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "MX"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getMxRecordset().catch(console.error); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetNSRecordset.json + */ +async function getNsRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "NS"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getNsRecordset().catch(console.error); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetPTRRecordset.json + */ +async function getPtrRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "0.0.127.in-addr.arpa"; + const relativeRecordSetName = "1"; + const recordType = "PTR"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getPtrRecordset().catch(console.error); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetSOARecordset.json + */ +async function getSoaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "@"; + const recordType = "SOA"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getSoaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetSRVRecordset.json + */ +async function getSrvRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "SRV"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getSrvRecordset().catch(console.error); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetTXTRecordset.json + */ +async function getTxtRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "TXT"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getTxtRecordset().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/javascript/recordSetsListAllByDnsZoneSample.js b/sdk/dns/arm-dns/samples/v5/javascript/recordSetsListAllByDnsZoneSample.js new file mode 100644 index 000000000000..729a5bc43e7e --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/javascript/recordSetsListAllByDnsZoneSample.js @@ -0,0 +1,33 @@ +/* + * 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 { DnsManagementClient } = require("@azure/arm-dns"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists all record sets in a DNS zone. + * + * @summary Lists all record sets in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListRecordSetsByZone.json + */ +async function listRecordsetsByZone() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listAllByDnsZone(resourceGroupName, zoneName)) { + resArray.push(item); + } + console.log(resArray); +} + +listRecordsetsByZone().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/javascript/recordSetsListByDnsZoneSample.js b/sdk/dns/arm-dns/samples/v5/javascript/recordSetsListByDnsZoneSample.js new file mode 100644 index 000000000000..51aba98c902d --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/javascript/recordSetsListByDnsZoneSample.js @@ -0,0 +1,33 @@ +/* + * 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 { DnsManagementClient } = require("@azure/arm-dns"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists all record sets in a DNS zone. + * + * @summary Lists all record sets in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListRecordSetsByZone.json + */ +async function listRecordsetsByZone() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByDnsZone(resourceGroupName, zoneName)) { + resArray.push(item); + } + console.log(resArray); +} + +listRecordsetsByZone().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/javascript/recordSetsListByTypeSample.js b/sdk/dns/arm-dns/samples/v5/javascript/recordSetsListByTypeSample.js new file mode 100644 index 000000000000..2f8a43a67ef4 --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/javascript/recordSetsListByTypeSample.js @@ -0,0 +1,232 @@ +/* + * 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 { DnsManagementClient } = require("@azure/arm-dns"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListARecordset.json + */ +async function listARecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const recordType = "A"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType(resourceGroupName, zoneName, recordType)) { + resArray.push(item); + } + console.log(resArray); +} + +listARecordsets().catch(console.error); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListAAAARecordset.json + */ +async function listAaaaRecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const recordType = "AAAA"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType(resourceGroupName, zoneName, recordType)) { + resArray.push(item); + } + console.log(resArray); +} + +listAaaaRecordsets().catch(console.error); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListCaaRecordset.json + */ +async function listCaaRecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const recordType = "CAA"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType(resourceGroupName, zoneName, recordType)) { + resArray.push(item); + } + console.log(resArray); +} + +listCaaRecordsets().catch(console.error); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListCNAMERecordset.json + */ +async function listCnameRecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const recordType = "CNAME"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType(resourceGroupName, zoneName, recordType)) { + resArray.push(item); + } + console.log(resArray); +} + +listCnameRecordsets().catch(console.error); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListMXRecordset.json + */ +async function listMxRecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const recordType = "MX"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType(resourceGroupName, zoneName, recordType)) { + resArray.push(item); + } + console.log(resArray); +} + +listMxRecordsets().catch(console.error); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListNSRecordset.json + */ +async function listNsRecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const recordType = "NS"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType(resourceGroupName, zoneName, recordType)) { + resArray.push(item); + } + console.log(resArray); +} + +listNsRecordsets().catch(console.error); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListPTRRecordset.json + */ +async function listPtrRecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "0.0.127.in-addr.arpa"; + const recordType = "PTR"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType(resourceGroupName, zoneName, recordType)) { + resArray.push(item); + } + console.log(resArray); +} + +listPtrRecordsets().catch(console.error); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListSOARecordset.json + */ +async function listSoaRecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const recordType = "SOA"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType(resourceGroupName, zoneName, recordType)) { + resArray.push(item); + } + console.log(resArray); +} + +listSoaRecordsets().catch(console.error); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListSRVRecordset.json + */ +async function listSrvRecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const recordType = "SRV"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType(resourceGroupName, zoneName, recordType)) { + resArray.push(item); + } + console.log(resArray); +} + +listSrvRecordsets().catch(console.error); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListTXTRecordset.json + */ +async function listTxtRecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const recordType = "TXT"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType(resourceGroupName, zoneName, recordType)) { + resArray.push(item); + } + console.log(resArray); +} + +listTxtRecordsets().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/javascript/recordSetsUpdateSample.js b/sdk/dns/arm-dns/samples/v5/javascript/recordSetsUpdateSample.js new file mode 100644 index 000000000000..ecaf1f4e156c --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/javascript/recordSetsUpdateSample.js @@ -0,0 +1,282 @@ +/* + * 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 { DnsManagementClient } = require("@azure/arm-dns"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchARecordset.json + */ +async function patchARecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "A"; + const parameters = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchARecordset().catch(console.error); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchAAAARecordset.json + */ +async function patchAaaaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "AAAA"; + const parameters = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchAaaaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchCaaRecordset.json + */ +async function patchCaaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "CAA"; + const parameters = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchCaaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchCNAMERecordset.json + */ +async function patchCnameRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "CNAME"; + const parameters = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchCnameRecordset().catch(console.error); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchMXRecordset.json + */ +async function patchMxRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "MX"; + const parameters = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchMxRecordset().catch(console.error); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchNSRecordset.json + */ +async function patchNsRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "NS"; + const parameters = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchNsRecordset().catch(console.error); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchPTRRecordset.json + */ +async function patchPtrRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "0.0.127.in-addr.arpa"; + const relativeRecordSetName = "1"; + const recordType = "PTR"; + const parameters = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchPtrRecordset().catch(console.error); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchSOARecordset.json + */ +async function patchSoaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "@"; + const recordType = "SOA"; + const parameters = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchSoaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchSRVRecordset.json + */ +async function patchSrvRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "SRV"; + const parameters = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchSrvRecordset().catch(console.error); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchTXTRecordset.json + */ +async function patchTxtRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "TXT"; + const parameters = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchTxtRecordset().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/javascript/sample.env b/sdk/dns/arm-dns/samples/v5/javascript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/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/dns/arm-dns/samples/v5/javascript/zonesCreateOrUpdateSample.js b/sdk/dns/arm-dns/samples/v5/javascript/zonesCreateOrUpdateSample.js new file mode 100644 index 000000000000..5d3a13d7bca7 --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/javascript/zonesCreateOrUpdateSample.js @@ -0,0 +1,31 @@ +/* + * 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 { DnsManagementClient } = require("@azure/arm-dns"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Creates or updates a DNS zone. Does not modify DNS records within the zone. + * + * @summary Creates or updates a DNS zone. Does not modify DNS records within the zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateZone.json + */ +async function createZone() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const parameters = { location: "Global", tags: { key1: "value1" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.zones.createOrUpdate(resourceGroupName, zoneName, parameters); + console.log(result); +} + +createZone().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/javascript/zonesDeleteSample.js b/sdk/dns/arm-dns/samples/v5/javascript/zonesDeleteSample.js new file mode 100644 index 000000000000..e5ae5890ad32 --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/javascript/zonesDeleteSample.js @@ -0,0 +1,30 @@ +/* + * 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 { DnsManagementClient } = require("@azure/arm-dns"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation cannot be undone. + * + * @summary Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteZone.json + */ +async function deleteZone() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.zones.beginDeleteAndWait(resourceGroupName, zoneName); + console.log(result); +} + +deleteZone().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/javascript/zonesGetSample.js b/sdk/dns/arm-dns/samples/v5/javascript/zonesGetSample.js new file mode 100644 index 000000000000..344a093a550a --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/javascript/zonesGetSample.js @@ -0,0 +1,30 @@ +/* + * 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 { DnsManagementClient } = require("@azure/arm-dns"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets a DNS zone. Retrieves the zone properties, but not the record sets within the zone. + * + * @summary Gets a DNS zone. Retrieves the zone properties, but not the record sets within the zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetZone.json + */ +async function getZone() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.zones.get(resourceGroupName, zoneName); + console.log(result); +} + +getZone().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/javascript/zonesListByResourceGroupSample.js b/sdk/dns/arm-dns/samples/v5/javascript/zonesListByResourceGroupSample.js new file mode 100644 index 000000000000..d53403ed6d73 --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/javascript/zonesListByResourceGroupSample.js @@ -0,0 +1,32 @@ +/* + * 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 { DnsManagementClient } = require("@azure/arm-dns"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists the DNS zones within a resource group. + * + * @summary Lists the DNS zones within a resource group. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListZonesByResourceGroup.json + */ +async function listZonesByResourceGroup() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.zones.listByResourceGroup(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +listZonesByResourceGroup().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/javascript/zonesListSample.js b/sdk/dns/arm-dns/samples/v5/javascript/zonesListSample.js new file mode 100644 index 000000000000..67cbb27f8b39 --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/javascript/zonesListSample.js @@ -0,0 +1,31 @@ +/* + * 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 { DnsManagementClient } = require("@azure/arm-dns"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists the DNS zones in all resource groups in a subscription. + * + * @summary Lists the DNS zones in all resource groups in a subscription. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListZonesBySubscription.json + */ +async function listZonesBySubscription() { + const subscriptionId = "subid"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.zones.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listZonesBySubscription().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/javascript/zonesUpdateSample.js b/sdk/dns/arm-dns/samples/v5/javascript/zonesUpdateSample.js new file mode 100644 index 000000000000..a11cdc5582e7 --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/javascript/zonesUpdateSample.js @@ -0,0 +1,31 @@ +/* + * 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 { DnsManagementClient } = require("@azure/arm-dns"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Updates a DNS zone. Does not modify DNS records within the zone. + * + * @summary Updates a DNS zone. Does not modify DNS records within the zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchZone.json + */ +async function patchZone() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const parameters = { tags: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.zones.update(resourceGroupName, zoneName, parameters); + console.log(result); +} + +patchZone().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/typescript/README.md b/sdk/dns/arm-dns/samples/v5/typescript/README.md new file mode 100644 index 000000000000..77da9e3e63d9 --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/typescript/README.md @@ -0,0 +1,89 @@ +# client library samples for TypeScript + +These sample programs show how to use the TypeScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| --------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [dnsResourceReferenceGetByTargetResourcesSample.ts][dnsresourcereferencegetbytargetresourcessample] | Returns the DNS records specified by the referencing targetResourceIds. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetDnsResourceReference.json | +| [recordSetsCreateOrUpdateSample.ts][recordsetscreateorupdatesample] | Creates or updates a record set within a DNS zone. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateARecordset.json | +| [recordSetsDeleteSample.ts][recordsetsdeletesample] | Deletes a record set from a DNS zone. This operation cannot be undone. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteARecordset.json | +| [recordSetsGetSample.ts][recordsetsgetsample] | Gets a record set. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetARecordset.json | +| [recordSetsListAllByDnsZoneSample.ts][recordsetslistallbydnszonesample] | Lists all record sets in a DNS zone. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListRecordSetsByZone.json | +| [recordSetsListByDnsZoneSample.ts][recordsetslistbydnszonesample] | Lists all record sets in a DNS zone. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListRecordSetsByZone.json | +| [recordSetsListByTypeSample.ts][recordsetslistbytypesample] | Lists the record sets of a specified type in a DNS zone. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListARecordset.json | +| [recordSetsUpdateSample.ts][recordsetsupdatesample] | Updates a record set within a DNS zone. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchARecordset.json | +| [zonesCreateOrUpdateSample.ts][zonescreateorupdatesample] | Creates or updates a DNS zone. Does not modify DNS records within the zone. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateZone.json | +| [zonesDeleteSample.ts][zonesdeletesample] | Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation cannot be undone. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteZone.json | +| [zonesGetSample.ts][zonesgetsample] | Gets a DNS zone. Retrieves the zone properties, but not the record sets within the zone. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetZone.json | +| [zonesListByResourceGroupSample.ts][zoneslistbyresourcegroupsample] | Lists the DNS zones within a resource group. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListZonesByResourceGroup.json | +| [zonesListSample.ts][zoneslistsample] | Lists the DNS zones in all resource groups in a subscription. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListZonesBySubscription.json | +| [zonesUpdateSample.ts][zonesupdatesample] | Updates a DNS zone. Does not modify DNS records within the zone. x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchZone.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +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/dnsResourceReferenceGetByTargetResourcesSample.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 node dist/dnsResourceReferenceGetByTargetResourcesSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[dnsresourcereferencegetbytargetresourcessample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/typescript/src/dnsResourceReferenceGetByTargetResourcesSample.ts +[recordsetscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsCreateOrUpdateSample.ts +[recordsetsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsDeleteSample.ts +[recordsetsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsGetSample.ts +[recordsetslistallbydnszonesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsListAllByDnsZoneSample.ts +[recordsetslistbydnszonesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsListByDnsZoneSample.ts +[recordsetslistbytypesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsListByTypeSample.ts +[recordsetsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsUpdateSample.ts +[zonescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/typescript/src/zonesCreateOrUpdateSample.ts +[zonesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/typescript/src/zonesDeleteSample.ts +[zonesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/typescript/src/zonesGetSample.ts +[zoneslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/typescript/src/zonesListByResourceGroupSample.ts +[zoneslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/typescript/src/zonesListSample.ts +[zonesupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dns/arm-dns/samples/v5/typescript/src/zonesUpdateSample.ts +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-dns?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/dns/arm-dns/README.md +[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/dns/arm-dns/samples/v5/typescript/package.json b/sdk/dns/arm-dns/samples/v5/typescript/package.json new file mode 100644 index 000000000000..022280aa2278 --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/typescript/package.json @@ -0,0 +1,41 @@ +{ + "name": "@azure-samples/arm-dns-ts", + "private": true, + "version": "1.0.0", + "description": " client library samples for TypeScript", + "engines": { + "node": ">=12.0.0" + }, + "scripts": { + "build": "tsc", + "prebuild": "rimraf dist/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/dns/arm-dns" + }, + "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/dns/arm-dns", + "dependencies": { + "@azure/arm-dns": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + }, + "devDependencies": { + "@types/node": "^12.0.0", + "typescript": "~4.4.0", + "rimraf": "latest" + } +} diff --git a/sdk/dns/arm-dns/samples/v5/typescript/sample.env b/sdk/dns/arm-dns/samples/v5/typescript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/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/dns/arm-dns/samples/v5/typescript/src/dnsResourceReferenceGetByTargetResourcesSample.ts b/sdk/dns/arm-dns/samples/v5/typescript/src/dnsResourceReferenceGetByTargetResourcesSample.ts new file mode 100644 index 000000000000..d821484661a3 --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/typescript/src/dnsResourceReferenceGetByTargetResourcesSample.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 { + DnsResourceReferenceRequest, + DnsManagementClient +} from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Returns the DNS records specified by the referencing targetResourceIds. + * + * @summary Returns the DNS records specified by the referencing targetResourceIds. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetDnsResourceReference.json + */ +async function listZonesByResourceGroup() { + const subscriptionId = "subid"; + const parameters: DnsResourceReferenceRequest = { + targetResources: [ + { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/trafficManagerProfiles/testpp2" + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.dnsResourceReferenceOperations.getByTargetResources( + parameters + ); + console.log(result); +} + +listZonesByResourceGroup().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsCreateOrUpdateSample.ts b/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..503aab50d6f9 --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsCreateOrUpdateSample.ts @@ -0,0 +1,364 @@ +/* + * 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 { RecordSet, DnsManagementClient } from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateARecordset.json + */ +async function createARecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "A"; + const parameters: RecordSet = { + aRecords: [{ ipv4Address: "127.0.0.1" }], + ttl: 3600, + metadata: { key1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createARecordset().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateARecordsetAlias.json + */ +async function createARecordsetWithAliasTargetResource() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "A"; + const parameters: RecordSet = { + ttl: 3600, + metadata: { key1: "value1" }, + targetResource: { + id: + "/subscriptions/726f8cd6-6459-4db4-8e6d-2cd2716904e2/resourceGroups/test/providers/Microsoft.Network/trafficManagerProfiles/testpp2" + } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createARecordsetWithAliasTargetResource().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateAAAARecordset.json + */ +async function createAaaaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "AAAA"; + const parameters: RecordSet = { + aaaaRecords: [{ ipv6Address: "::1" }], + ttl: 3600, + metadata: { key1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createAaaaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateCaaRecordset.json + */ +async function createCaaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "CAA"; + const parameters: RecordSet = { + ttl: 3600, + caaRecords: [{ flags: 0, tag: "issue", value: "ca.contoso.com" }], + metadata: { key1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createCaaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateCNAMERecordset.json + */ +async function createCnameRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "CNAME"; + const parameters: RecordSet = { + cnameRecord: { cname: "contoso.com" }, + ttl: 3600, + metadata: { key1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createCnameRecordset().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateMXRecordset.json + */ +async function createMxRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "MX"; + const parameters: RecordSet = { + mxRecords: [{ exchange: "mail.contoso.com", preference: 0 }], + ttl: 3600, + metadata: { key1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createMxRecordset().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateNSRecordset.json + */ +async function createNsRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "NS"; + const parameters: RecordSet = { + nsRecords: [{ nsdname: "ns1.contoso.com" }], + ttl: 3600, + metadata: { key1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createNsRecordset().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdatePTRRecordset.json + */ +async function createPtrRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "0.0.127.in-addr.arpa"; + const relativeRecordSetName = "1"; + const recordType = "PTR"; + const parameters: RecordSet = { + ptrRecords: [{ ptrdname: "localhost" }], + ttl: 3600, + metadata: { key1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createPtrRecordset().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateSOARecordset.json + */ +async function createSoaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "@"; + const recordType = "SOA"; + const parameters: RecordSet = { + soaRecord: { + email: "hostmaster.contoso.com", + expireTime: 2419200, + host: "ns1.contoso.com", + minimumTtl: 300, + refreshTime: 3600, + retryTime: 300, + serialNumber: 1 + }, + ttl: 3600, + metadata: { key1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createSoaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateSRVRecordset.json + */ +async function createSrvRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "SRV"; + const parameters: RecordSet = { + srvRecords: [{ port: 80, priority: 0, target: "contoso.com", weight: 10 }], + ttl: 3600, + metadata: { key1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createSrvRecordset().catch(console.error); + +/** + * This sample demonstrates how to Creates or updates a record set within a DNS zone. + * + * @summary Creates or updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateTXTRecordset.json + */ +async function createTxtRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "TXT"; + const parameters: RecordSet = { + ttl: 3600, + txtRecords: [{ value: ["string1", "string2"] }], + metadata: { key1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.createOrUpdate( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +createTxtRecordset().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsDeleteSample.ts b/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsDeleteSample.ts new file mode 100644 index 000000000000..dfd43a5b485e --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsDeleteSample.ts @@ -0,0 +1,237 @@ +/* + * 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 { DnsManagementClient } from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes a record set from a DNS zone. This operation cannot be undone. + * + * @summary Deletes a record set from a DNS zone. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteARecordset.json + */ +async function deleteARecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "A"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.delete( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +deleteARecordset().catch(console.error); + +/** + * This sample demonstrates how to Deletes a record set from a DNS zone. This operation cannot be undone. + * + * @summary Deletes a record set from a DNS zone. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteAAAARecordset.json + */ +async function deleteAaaaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "AAAA"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.delete( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +deleteAaaaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Deletes a record set from a DNS zone. This operation cannot be undone. + * + * @summary Deletes a record set from a DNS zone. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteCaaRecordset.json + */ +async function deleteCaaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "CAA"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.delete( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +deleteCaaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Deletes a record set from a DNS zone. This operation cannot be undone. + * + * @summary Deletes a record set from a DNS zone. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteARecordset.json + */ +async function deleteCnameRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "A"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.delete( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +deleteCnameRecordset().catch(console.error); + +/** + * This sample demonstrates how to Deletes a record set from a DNS zone. This operation cannot be undone. + * + * @summary Deletes a record set from a DNS zone. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteARecordset.json + */ +async function deleteMxRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "A"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.delete( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +deleteMxRecordset().catch(console.error); + +/** + * This sample demonstrates how to Deletes a record set from a DNS zone. This operation cannot be undone. + * + * @summary Deletes a record set from a DNS zone. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteARecordset.json + */ +async function deleteNsRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "A"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.delete( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +deleteNsRecordset().catch(console.error); + +/** + * This sample demonstrates how to Deletes a record set from a DNS zone. This operation cannot be undone. + * + * @summary Deletes a record set from a DNS zone. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeletePTRRecordset.json + */ +async function deletePtrRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "0.0.127.in-addr.arpa"; + const relativeRecordSetName = "1"; + const recordType = "PTR"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.delete( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +deletePtrRecordset().catch(console.error); + +/** + * This sample demonstrates how to Deletes a record set from a DNS zone. This operation cannot be undone. + * + * @summary Deletes a record set from a DNS zone. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteSRVRecordset.json + */ +async function deleteSrvRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "SRV"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.delete( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +deleteSrvRecordset().catch(console.error); + +/** + * This sample demonstrates how to Deletes a record set from a DNS zone. This operation cannot be undone. + * + * @summary Deletes a record set from a DNS zone. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteTXTRecordset.json + */ +async function deleteTxtRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "TXT"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.delete( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +deleteTxtRecordset().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsGetSample.ts b/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsGetSample.ts new file mode 100644 index 000000000000..6dc689b1631a --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsGetSample.ts @@ -0,0 +1,262 @@ +/* + * 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 { DnsManagementClient } from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetARecordset.json + */ +async function getARecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "A"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getARecordset().catch(console.error); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetAAAARecordset.json + */ +async function getAaaaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "AAAA"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getAaaaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetCaaRecordset.json + */ +async function getCaaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "CAA"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getCaaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetCNAMERecordset.json + */ +async function getCnameRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "CNAME"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getCnameRecordset().catch(console.error); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetMXRecordset.json + */ +async function getMxRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "MX"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getMxRecordset().catch(console.error); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetNSRecordset.json + */ +async function getNsRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "NS"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getNsRecordset().catch(console.error); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetPTRRecordset.json + */ +async function getPtrRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "0.0.127.in-addr.arpa"; + const relativeRecordSetName = "1"; + const recordType = "PTR"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getPtrRecordset().catch(console.error); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetSOARecordset.json + */ +async function getSoaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "@"; + const recordType = "SOA"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getSoaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetSRVRecordset.json + */ +async function getSrvRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "SRV"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getSrvRecordset().catch(console.error); + +/** + * This sample demonstrates how to Gets a record set. + * + * @summary Gets a record set. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetTXTRecordset.json + */ +async function getTxtRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "TXT"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.get( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType + ); + console.log(result); +} + +getTxtRecordset().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsListAllByDnsZoneSample.ts b/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsListAllByDnsZoneSample.ts new file mode 100644 index 000000000000..7e598a43bd6a --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsListAllByDnsZoneSample.ts @@ -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. +import { DnsManagementClient } from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists all record sets in a DNS zone. + * + * @summary Lists all record sets in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListRecordSetsByZone.json + */ +async function listRecordsetsByZone() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listAllByDnsZone( + resourceGroupName, + zoneName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listRecordsetsByZone().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsListByDnsZoneSample.ts b/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsListByDnsZoneSample.ts new file mode 100644 index 000000000000..ecfdc6d50729 --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsListByDnsZoneSample.ts @@ -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. +import { DnsManagementClient } from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists all record sets in a DNS zone. + * + * @summary Lists all record sets in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListRecordSetsByZone.json + */ +async function listRecordsetsByZone() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByDnsZone( + resourceGroupName, + zoneName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listRecordsetsByZone().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsListByTypeSample.ts b/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsListByTypeSample.ts new file mode 100644 index 000000000000..13bf55297832 --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsListByTypeSample.ts @@ -0,0 +1,272 @@ +/* + * 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 { DnsManagementClient } from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListARecordset.json + */ +async function listARecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const recordType = "A"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType( + resourceGroupName, + zoneName, + recordType + )) { + resArray.push(item); + } + console.log(resArray); +} + +listARecordsets().catch(console.error); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListAAAARecordset.json + */ +async function listAaaaRecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const recordType = "AAAA"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType( + resourceGroupName, + zoneName, + recordType + )) { + resArray.push(item); + } + console.log(resArray); +} + +listAaaaRecordsets().catch(console.error); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListCaaRecordset.json + */ +async function listCaaRecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const recordType = "CAA"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType( + resourceGroupName, + zoneName, + recordType + )) { + resArray.push(item); + } + console.log(resArray); +} + +listCaaRecordsets().catch(console.error); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListCNAMERecordset.json + */ +async function listCnameRecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const recordType = "CNAME"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType( + resourceGroupName, + zoneName, + recordType + )) { + resArray.push(item); + } + console.log(resArray); +} + +listCnameRecordsets().catch(console.error); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListMXRecordset.json + */ +async function listMxRecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const recordType = "MX"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType( + resourceGroupName, + zoneName, + recordType + )) { + resArray.push(item); + } + console.log(resArray); +} + +listMxRecordsets().catch(console.error); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListNSRecordset.json + */ +async function listNsRecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const recordType = "NS"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType( + resourceGroupName, + zoneName, + recordType + )) { + resArray.push(item); + } + console.log(resArray); +} + +listNsRecordsets().catch(console.error); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListPTRRecordset.json + */ +async function listPtrRecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "0.0.127.in-addr.arpa"; + const recordType = "PTR"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType( + resourceGroupName, + zoneName, + recordType + )) { + resArray.push(item); + } + console.log(resArray); +} + +listPtrRecordsets().catch(console.error); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListSOARecordset.json + */ +async function listSoaRecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const recordType = "SOA"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType( + resourceGroupName, + zoneName, + recordType + )) { + resArray.push(item); + } + console.log(resArray); +} + +listSoaRecordsets().catch(console.error); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListSRVRecordset.json + */ +async function listSrvRecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const recordType = "SRV"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType( + resourceGroupName, + zoneName, + recordType + )) { + resArray.push(item); + } + console.log(resArray); +} + +listSrvRecordsets().catch(console.error); + +/** + * This sample demonstrates how to Lists the record sets of a specified type in a DNS zone. + * + * @summary Lists the record sets of a specified type in a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListTXTRecordset.json + */ +async function listTxtRecordsets() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const recordType = "TXT"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.recordSets.listByType( + resourceGroupName, + zoneName, + recordType + )) { + resArray.push(item); + } + console.log(resArray); +} + +listTxtRecordsets().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsUpdateSample.ts b/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsUpdateSample.ts new file mode 100644 index 000000000000..08daa3eb25d4 --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/typescript/src/recordSetsUpdateSample.ts @@ -0,0 +1,282 @@ +/* + * 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 { RecordSet, DnsManagementClient } from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchARecordset.json + */ +async function patchARecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "A"; + const parameters: RecordSet = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchARecordset().catch(console.error); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchAAAARecordset.json + */ +async function patchAaaaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "AAAA"; + const parameters: RecordSet = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchAaaaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchCaaRecordset.json + */ +async function patchCaaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "CAA"; + const parameters: RecordSet = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchCaaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchCNAMERecordset.json + */ +async function patchCnameRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "CNAME"; + const parameters: RecordSet = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchCnameRecordset().catch(console.error); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchMXRecordset.json + */ +async function patchMxRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "MX"; + const parameters: RecordSet = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchMxRecordset().catch(console.error); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchNSRecordset.json + */ +async function patchNsRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "NS"; + const parameters: RecordSet = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchNsRecordset().catch(console.error); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchPTRRecordset.json + */ +async function patchPtrRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "0.0.127.in-addr.arpa"; + const relativeRecordSetName = "1"; + const recordType = "PTR"; + const parameters: RecordSet = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchPtrRecordset().catch(console.error); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchSOARecordset.json + */ +async function patchSoaRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "@"; + const recordType = "SOA"; + const parameters: RecordSet = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchSoaRecordset().catch(console.error); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchSRVRecordset.json + */ +async function patchSrvRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "SRV"; + const parameters: RecordSet = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchSrvRecordset().catch(console.error); + +/** + * This sample demonstrates how to Updates a record set within a DNS zone. + * + * @summary Updates a record set within a DNS zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchTXTRecordset.json + */ +async function patchTxtRecordset() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const relativeRecordSetName = "record1"; + const recordType = "TXT"; + const parameters: RecordSet = { metadata: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.recordSets.update( + resourceGroupName, + zoneName, + relativeRecordSetName, + recordType, + parameters + ); + console.log(result); +} + +patchTxtRecordset().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/typescript/src/zonesCreateOrUpdateSample.ts b/sdk/dns/arm-dns/samples/v5/typescript/src/zonesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..8528dff6389f --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/typescript/src/zonesCreateOrUpdateSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { Zone, DnsManagementClient } from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates a DNS zone. Does not modify DNS records within the zone. + * + * @summary Creates or updates a DNS zone. Does not modify DNS records within the zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/CreateOrUpdateZone.json + */ +async function createZone() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const parameters: Zone = { location: "Global", tags: { key1: "value1" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.zones.createOrUpdate( + resourceGroupName, + zoneName, + parameters + ); + console.log(result); +} + +createZone().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/typescript/src/zonesDeleteSample.ts b/sdk/dns/arm-dns/samples/v5/typescript/src/zonesDeleteSample.ts new file mode 100644 index 000000000000..b4e525a5dfc0 --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/typescript/src/zonesDeleteSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { DnsManagementClient } from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation cannot be undone. + * + * @summary Deletes a DNS zone. WARNING: All DNS records in the zone will also be deleted. This operation cannot be undone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/DeleteZone.json + */ +async function deleteZone() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.zones.beginDeleteAndWait( + resourceGroupName, + zoneName + ); + console.log(result); +} + +deleteZone().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/typescript/src/zonesGetSample.ts b/sdk/dns/arm-dns/samples/v5/typescript/src/zonesGetSample.ts new file mode 100644 index 000000000000..9612b92ecf16 --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/typescript/src/zonesGetSample.ts @@ -0,0 +1,30 @@ +/* + * 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 { DnsManagementClient } from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets a DNS zone. Retrieves the zone properties, but not the record sets within the zone. + * + * @summary Gets a DNS zone. Retrieves the zone properties, but not the record sets within the zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/GetZone.json + */ +async function getZone() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.zones.get(resourceGroupName, zoneName); + console.log(result); +} + +getZone().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/typescript/src/zonesListByResourceGroupSample.ts b/sdk/dns/arm-dns/samples/v5/typescript/src/zonesListByResourceGroupSample.ts new file mode 100644 index 000000000000..f533a0ad64c9 --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/typescript/src/zonesListByResourceGroupSample.ts @@ -0,0 +1,32 @@ +/* + * 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 { DnsManagementClient } from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists the DNS zones within a resource group. + * + * @summary Lists the DNS zones within a resource group. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListZonesByResourceGroup.json + */ +async function listZonesByResourceGroup() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.zones.listByResourceGroup(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +listZonesByResourceGroup().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/typescript/src/zonesListSample.ts b/sdk/dns/arm-dns/samples/v5/typescript/src/zonesListSample.ts new file mode 100644 index 000000000000..fa9cc20c8383 --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/typescript/src/zonesListSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { DnsManagementClient } from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists the DNS zones in all resource groups in a subscription. + * + * @summary Lists the DNS zones in all resource groups in a subscription. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/ListZonesBySubscription.json + */ +async function listZonesBySubscription() { + const subscriptionId = "subid"; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.zones.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listZonesBySubscription().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/typescript/src/zonesUpdateSample.ts b/sdk/dns/arm-dns/samples/v5/typescript/src/zonesUpdateSample.ts new file mode 100644 index 000000000000..eca304e5ece3 --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/typescript/src/zonesUpdateSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { ZoneUpdate, DnsManagementClient } from "@azure/arm-dns"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Updates a DNS zone. Does not modify DNS records within the zone. + * + * @summary Updates a DNS zone. Does not modify DNS records within the zone. + * x-ms-original-file: specification/dns/resource-manager/Microsoft.Network/stable/2018-05-01/examples/PatchZone.json + */ +async function patchZone() { + const subscriptionId = "subid"; + const resourceGroupName = "rg1"; + const zoneName = "zone1"; + const parameters: ZoneUpdate = { tags: { key2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsManagementClient(credential, subscriptionId); + const result = await client.zones.update( + resourceGroupName, + zoneName, + parameters + ); + console.log(result); +} + +patchZone().catch(console.error); diff --git a/sdk/dns/arm-dns/samples/v5/typescript/tsconfig.json b/sdk/dns/arm-dns/samples/v5/typescript/tsconfig.json new file mode 100644 index 000000000000..416c2dd82e00 --- /dev/null +++ b/sdk/dns/arm-dns/samples/v5/typescript/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2018", + "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/dns/arm-dns/src/dnsManagementClient.ts b/sdk/dns/arm-dns/src/dnsManagementClient.ts index df63a2c1266b..9a8c496263ec 100644 --- a/sdk/dns/arm-dns/src/dnsManagementClient.ts +++ b/sdk/dns/arm-dns/src/dnsManagementClient.ts @@ -7,6 +7,7 @@ */ import * as coreClient from "@azure/core-client"; +import * as coreRestPipeline from "@azure/core-rest-pipeline"; import * as coreAuth from "@azure/core-auth"; import { RecordSetsImpl, @@ -53,7 +54,7 @@ export class DnsManagementClient extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-dns/5.0.0`; + const packageDetails = `azsdk-js-arm-dns/5.0.1`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` @@ -68,9 +69,33 @@ export class DnsManagementClient extends coreClient.ServiceClient { userAgentOptions: { userAgentPrefix }, - baseUri: options.endpoint || "https://management.azure.com" + baseUri: + options.endpoint ?? options.baseUri ?? "https://management.azure.com" }; super(optionsWithDefaults); + + if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { + const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies(); + const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( + (pipelinePolicy) => + pipelinePolicy.name === + coreRestPipeline.bearerTokenAuthenticationPolicyName + ); + if (!bearerTokenAuthenticationPolicyFound) { + this.pipeline.removePolicy({ + name: coreRestPipeline.bearerTokenAuthenticationPolicyName + }); + this.pipeline.addPolicy( + coreRestPipeline.bearerTokenAuthenticationPolicy({ + scopes: `${optionsWithDefaults.baseUri}/.default`, + challengeCallbacks: { + authorizeRequestOnChallenge: + coreClient.authorizeRequestOnClaimChallenge + } + }) + ); + } + } // Parameter assignments this.subscriptionId = subscriptionId; diff --git a/sdk/dns/arm-dns/src/operations/zones.ts b/sdk/dns/arm-dns/src/operations/zones.ts index 0097cb60b7cf..71138f3de961 100644 --- a/sdk/dns/arm-dns/src/operations/zones.ts +++ b/sdk/dns/arm-dns/src/operations/zones.ts @@ -217,10 +217,12 @@ export class ZonesImpl implements Zones { { resourceGroupName, zoneName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** diff --git a/sdk/dns/arm-dns/tsconfig.json b/sdk/dns/arm-dns/tsconfig.json index 6e3251194117..5741b264d59d 100644 --- a/sdk/dns/arm-dns/tsconfig.json +++ b/sdk/dns/arm-dns/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-dns": [ + "./src/index" + ] + } }, - "include": ["./src/**/*.ts", "./test/**/*.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/dns/ci.mgmt.yml b/sdk/dns/ci.mgmt.yml index 7a3fa10e7724..2995e6a6efac 100644 --- a/sdk/dns/ci.mgmt.yml +++ b/sdk/dns/ci.mgmt.yml @@ -9,8 +9,8 @@ trigger: paths: include: - sdk/dns/ci.mgmt.yml - - sdk/dns/arm-dns/ - sdk/dns/arm-dns-profile-2020-09-01-hybrid + - sdk/dns/arm-dns pr: branches: include: @@ -23,8 +23,8 @@ pr: paths: include: - sdk/dns/ci.mgmt.yml - - sdk/dns/arm-dns/ - sdk/dns/arm-dns-profile-2020-09-01-hybrid + - sdk/dns/arm-dns extends: template: /eng/pipelines/templates/stages/archetype-sdk-client.yml parameters: diff --git a/sdk/dnsresolver/arm-dnsresolver/CHANGELOG.md b/sdk/dnsresolver/arm-dnsresolver/CHANGELOG.md index 56ff0bcd2e9e..b5a1c15601fb 100644 --- a/sdk/dnsresolver/arm-dnsresolver/CHANGELOG.md +++ b/sdk/dnsresolver/arm-dnsresolver/CHANGELOG.md @@ -1,14 +1,10 @@ # Release History -## 1.0.0-beta.2 (Unreleased) +## 1.0.0-beta.3 (2022-04-18) -### Features Added +**features** -### Breaking Changes - -### Bugs Fixed - -### Other Changes + - Bug fix ## 1.0.0-beta.1 (2022-02-16) diff --git a/sdk/dnsresolver/arm-dnsresolver/README.md b/sdk/dnsresolver/arm-dnsresolver/README.md index 7e75ad2a606c..fc0d9d0dd598 100644 --- a/sdk/dnsresolver/arm-dnsresolver/README.md +++ b/sdk/dnsresolver/arm-dnsresolver/README.md @@ -16,6 +16,8 @@ The DNS Resolver Management Client. - [LTS versions of Node.js](https://nodejs.org/about/releases/) - 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]. @@ -49,8 +51,17 @@ For more information about how to create an Azure AD Application check out [this ```javascript const { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); 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 DnsResolverManagementClient(new DefaultAzureCredential(), subscriptionId); + +// For client-side applications running in the browser, use this code instead: +// const credential = new InteractiveBrowserCredential({ +// tenantId: "", +// clientId: "" +// }); +// const client = new DnsResolverManagementClient(credential, subscriptionId); ``` diff --git a/sdk/dnsresolver/arm-dnsresolver/_meta.json b/sdk/dnsresolver/arm-dnsresolver/_meta.json index 736296f0320c..bb4edf2fba0c 100644 --- a/sdk/dnsresolver/arm-dnsresolver/_meta.json +++ b/sdk/dnsresolver/arm-dnsresolver/_meta.json @@ -1,7 +1,8 @@ { "commit": "ff4dffa3aa168c2ec0b58b9dbe9e9b13613208a2", - "readme": "specification/dnsresolver/resource-manager/readme.md", - "autorest_command": "autorest --version=3.7.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\mydev\\azure-sdk-for-js ../azure-rest-api-specs/specification/dnsresolver/resource-manager/readme.md --use=@autorest/typescript@6.0.0-alpha.16.20220214.1 --generate-sample=true", + "readme": "specification\\dnsresolver\\resource-manager\\readme.md", + "autorest_command": "autorest --version=3.7.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\work\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\dnsresolver\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-alpha.19.20220408.1 --generate-sample=true", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "use": "@autorest/typescript@6.0.0-alpha.16.20220214.1" + "release_tool": "@azure-tools/js-sdk-release-tools@2.2.6", + "use": "@autorest/typescript@6.0.0-alpha.19.20220408.1" } \ No newline at end of file diff --git a/sdk/dnsresolver/arm-dnsresolver/package.json b/sdk/dnsresolver/arm-dnsresolver/package.json index fc6db70c1eba..a65b3ee001b4 100644 --- a/sdk/dnsresolver/arm-dnsresolver/package.json +++ b/sdk/dnsresolver/arm-dnsresolver/package.json @@ -3,7 +3,7 @@ "sdk-type": "mgmt", "author": "Microsoft Corporation", "description": "A generated SDK for DnsResolverManagementClient.", - "version": "1.0.0-beta.2", + "version": "1.0.0-beta.3", "engines": { "node": ">=12.0.0" }, @@ -11,9 +11,9 @@ "@azure/core-lro": "^2.2.0", "@azure/abort-controller": "^1.0.0", "@azure/core-paging": "^1.2.0", - "@azure/core-client": "^1.0.0", + "@azure/core-client": "^1.5.0", "@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": [ @@ -115,4 +115,4 @@ "disableDocsMs": true, "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-dnsresolver?view=azure-node-preview" } -} +} \ No newline at end of file diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsForwardingRulesetsCreateOrUpdateSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsForwardingRulesetsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..8e1f8901f7f0 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsForwardingRulesetsCreateOrUpdateSample.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 { + DnsForwardingRuleset, + DnsResolverManagementClient +} from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates a DNS forwarding ruleset. + * + * @summary Creates or updates a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_Put.json + */ +async function upsertDnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "samplednsForwardingRuleset"; + const parameters: DnsForwardingRuleset = { + dnsResolverOutboundEndpoints: [ + { + id: + "/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver/outboundEndpoints/sampleOutboundEndpoint0" + }, + { + id: + "/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver/outboundEndpoints/sampleOutboundEndpoint1" + } + ], + location: "westus2", + tags: { key1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.dnsForwardingRulesets.beginCreateOrUpdateAndWait( + resourceGroupName, + dnsForwardingRulesetName, + parameters + ); + console.log(result); +} + +upsertDnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsForwardingRulesetsDeleteSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsForwardingRulesetsDeleteSample.ts new file mode 100644 index 000000000000..bdee153ba72a --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsForwardingRulesetsDeleteSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes a DNS forwarding ruleset. WARNING: This operation cannot be undone. All forwarding rules within the ruleset will be deleted. + * + * @summary Deletes a DNS forwarding ruleset. WARNING: This operation cannot be undone. All forwarding rules within the ruleset will be deleted. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_Delete.json + */ +async function deleteDnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "samplednsForwardingRulesetName"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.dnsForwardingRulesets.beginDeleteAndWait( + resourceGroupName, + dnsForwardingRulesetName + ); + console.log(result); +} + +deleteDnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsForwardingRulesetsGetSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsForwardingRulesetsGetSample.ts new file mode 100644 index 000000000000..006980c0d73c --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsForwardingRulesetsGetSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets a DNS forwarding ruleset properties. + * + * @summary Gets a DNS forwarding ruleset properties. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_Get.json + */ +async function retrieveDnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.dnsForwardingRulesets.get( + resourceGroupName, + dnsForwardingRulesetName + ); + console.log(result); +} + +retrieveDnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsForwardingRulesetsListByResourceGroupSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsForwardingRulesetsListByResourceGroupSample.ts new file mode 100644 index 000000000000..9f17ed4f86ea --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsForwardingRulesetsListByResourceGroupSample.ts @@ -0,0 +1,34 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists DNS forwarding rulesets within a resource group. + * + * @summary Lists DNS forwarding rulesets within a resource group. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_ListByResourceGroup.json + */ +async function listDnsForwardingRulesetsByResourceGroup() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.dnsForwardingRulesets.listByResourceGroup( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listDnsForwardingRulesetsByResourceGroup().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsForwardingRulesetsListByVirtualNetworkSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsForwardingRulesetsListByVirtualNetworkSample.ts new file mode 100644 index 000000000000..76421954e9a5 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsForwardingRulesetsListByVirtualNetworkSample.ts @@ -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. +import { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists DNS forwarding ruleset resource IDs attached to a virtual network. + * + * @summary Lists DNS forwarding ruleset resource IDs attached to a virtual network. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_ListByVirtualNetwork.json + */ +async function listDnsForwardingRulesetsByVirtualNetwork() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const virtualNetworkName = "sampleVirtualNetwork"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.dnsForwardingRulesets.listByVirtualNetwork( + resourceGroupName, + virtualNetworkName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listDnsForwardingRulesetsByVirtualNetwork().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsForwardingRulesetsListSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsForwardingRulesetsListSample.ts new file mode 100644 index 000000000000..53f964a0d89e --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsForwardingRulesetsListSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists DNS forwarding rulesets in all resource groups of a subscription. + * + * @summary Lists DNS forwarding rulesets in all resource groups of a subscription. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_ListBySubscription.json + */ +async function listDnsForwardingRulesetsBySubscription() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.dnsForwardingRulesets.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listDnsForwardingRulesetsBySubscription().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsForwardingRulesetsUpdateSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsForwardingRulesetsUpdateSample.ts new file mode 100644 index 000000000000..6a2a0a29294c --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsForwardingRulesetsUpdateSample.ts @@ -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. +import { + DnsForwardingRulesetPatch, + DnsResolverManagementClient +} from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Updates a DNS forwarding ruleset. + * + * @summary Updates a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_Patch.json + */ +async function updateDnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const parameters: DnsForwardingRulesetPatch = { tags: { key1: "value1" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.dnsForwardingRulesets.beginUpdateAndWait( + resourceGroupName, + dnsForwardingRulesetName, + parameters + ); + console.log(result); +} + +updateDnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsResolversCreateOrUpdateSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsResolversCreateOrUpdateSample.ts new file mode 100644 index 000000000000..8a75adc9e500 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsResolversCreateOrUpdateSample.ts @@ -0,0 +1,45 @@ +/* + * 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 { + DnsResolver, + DnsResolverManagementClient +} from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates a DNS resolver. + * + * @summary Creates or updates a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_Put.json + */ +async function upsertDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const parameters: DnsResolver = { + location: "westus2", + tags: { key1: "value1" }, + virtualNetwork: { + id: + "/subscriptions/cbb1387e-4b03-44f2-ad41-58d4677b9873/resourceGroups/virtualNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork" + } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.dnsResolvers.beginCreateOrUpdateAndWait( + resourceGroupName, + dnsResolverName, + parameters + ); + console.log(result); +} + +upsertDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsResolversDeleteSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsResolversDeleteSample.ts new file mode 100644 index 000000000000..59e5e9e2a773 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsResolversDeleteSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes a DNS resolver. WARNING: This operation cannot be undone. + * + * @summary Deletes a DNS resolver. WARNING: This operation cannot be undone. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_Delete.json + */ +async function deleteDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.dnsResolvers.beginDeleteAndWait( + resourceGroupName, + dnsResolverName + ); + console.log(result); +} + +deleteDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsResolversGetSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsResolversGetSample.ts new file mode 100644 index 000000000000..01b514b58f90 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsResolversGetSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets properties of a DNS resolver. + * + * @summary Gets properties of a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_Get.json + */ +async function retrieveDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.dnsResolvers.get( + resourceGroupName, + dnsResolverName + ); + console.log(result); +} + +retrieveDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsResolversListByResourceGroupSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsResolversListByResourceGroupSample.ts new file mode 100644 index 000000000000..f29f4489facd --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsResolversListByResourceGroupSample.ts @@ -0,0 +1,34 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists DNS resolvers within a resource group. + * + * @summary Lists DNS resolvers within a resource group. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_ListByResourceGroup.json + */ +async function listDnsResolversByResourceGroup() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.dnsResolvers.listByResourceGroup( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listDnsResolversByResourceGroup().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsResolversListByVirtualNetworkSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsResolversListByVirtualNetworkSample.ts new file mode 100644 index 000000000000..cc1347621c3a --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsResolversListByVirtualNetworkSample.ts @@ -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. +import { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists DNS resolver resource IDs linked to a virtual network. + * + * @summary Lists DNS resolver resource IDs linked to a virtual network. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_ListByVirtualNetwork.json + */ +async function listDnsResolversByVirtualNetwork() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const virtualNetworkName = "sampleVirtualNetwork"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.dnsResolvers.listByVirtualNetwork( + resourceGroupName, + virtualNetworkName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listDnsResolversByVirtualNetwork().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsResolversListSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsResolversListSample.ts new file mode 100644 index 000000000000..2f6d4cadaba0 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsResolversListSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists DNS resolvers in all resource groups of a subscription. + * + * @summary Lists DNS resolvers in all resource groups of a subscription. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_ListBySubscription.json + */ +async function listDnsResolversBySubscription() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.dnsResolvers.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listDnsResolversBySubscription().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsResolversUpdateSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsResolversUpdateSample.ts new file mode 100644 index 000000000000..4b16f7579042 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/dnsResolversUpdateSample.ts @@ -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. +import { + DnsResolverPatch, + DnsResolverManagementClient +} from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Updates a DNS resolver. + * + * @summary Updates a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_Patch.json + */ +async function updateDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const parameters: DnsResolverPatch = { tags: { key1: "value1" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.dnsResolvers.beginUpdateAndWait( + resourceGroupName, + dnsResolverName, + parameters + ); + console.log(result); +} + +updateDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/forwardingRulesCreateOrUpdateSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/forwardingRulesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..d9d2762d4ff8 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/forwardingRulesCreateOrUpdateSample.ts @@ -0,0 +1,48 @@ +/* + * 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 { + ForwardingRule, + DnsResolverManagementClient +} from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates a forwarding rule in a DNS forwarding ruleset. + * + * @summary Creates or updates a forwarding rule in a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/ForwardingRule_Put.json + */ +async function upsertForwardingRuleInADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const forwardingRuleName = "sampleForwardingRule"; + const parameters: ForwardingRule = { + domainName: "contoso.com.", + forwardingRuleState: "Enabled", + metadata: { additionalProp1: "value1" }, + targetDnsServers: [ + { ipAddress: "10.0.0.1", port: 53 }, + { ipAddress: "10.0.0.2", port: 53 } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.forwardingRules.createOrUpdate( + resourceGroupName, + dnsForwardingRulesetName, + forwardingRuleName, + parameters + ); + console.log(result); +} + +upsertForwardingRuleInADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/forwardingRulesDeleteSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/forwardingRulesDeleteSample.ts new file mode 100644 index 000000000000..97173aefa7e4 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/forwardingRulesDeleteSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes a forwarding rule in a DNS forwarding ruleset. WARNING: This operation cannot be undone. + * + * @summary Deletes a forwarding rule in a DNS forwarding ruleset. WARNING: This operation cannot be undone. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/ForwardingRule_Delete.json + */ +async function deleteForwardingRuleInADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const forwardingRuleName = "sampleForwardingRule"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.forwardingRules.delete( + resourceGroupName, + dnsForwardingRulesetName, + forwardingRuleName + ); + console.log(result); +} + +deleteForwardingRuleInADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/forwardingRulesGetSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/forwardingRulesGetSample.ts new file mode 100644 index 000000000000..ee90282d9af1 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/forwardingRulesGetSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets properties of a forwarding rule in a DNS forwarding ruleset. + * + * @summary Gets properties of a forwarding rule in a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/ForwardingRule_Get.json + */ +async function retrieveForwardingRuleInADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const forwardingRuleName = "sampleForwardingRule"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.forwardingRules.get( + resourceGroupName, + dnsForwardingRulesetName, + forwardingRuleName + ); + console.log(result); +} + +retrieveForwardingRuleInADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/forwardingRulesListSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/forwardingRulesListSample.ts new file mode 100644 index 000000000000..a4b0d321b153 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/forwardingRulesListSample.ts @@ -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. +import { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists forwarding rules in a DNS forwarding ruleset. + * + * @summary Lists forwarding rules in a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/ForwardingRule_List.json + */ +async function listForwardingRulesInADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.forwardingRules.list( + resourceGroupName, + dnsForwardingRulesetName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listForwardingRulesInADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/forwardingRulesUpdateSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/forwardingRulesUpdateSample.ts new file mode 100644 index 000000000000..ecabe311f7b5 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/forwardingRulesUpdateSample.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 { + ForwardingRulePatch, + DnsResolverManagementClient +} from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Updates a forwarding rule in a DNS forwarding ruleset. + * + * @summary Updates a forwarding rule in a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/ForwardingRule_Patch.json + */ +async function updateForwardingRuleInADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const forwardingRuleName = "sampleForwardingRule"; + const parameters: ForwardingRulePatch = { + forwardingRuleState: "Disabled", + metadata: { additionalProp2: "value2" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.forwardingRules.update( + resourceGroupName, + dnsForwardingRulesetName, + forwardingRuleName, + parameters + ); + console.log(result); +} + +updateForwardingRuleInADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/inboundEndpointsCreateOrUpdateSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/inboundEndpointsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..facbb6ec9988 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/inboundEndpointsCreateOrUpdateSample.ts @@ -0,0 +1,53 @@ +/* + * 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 { + InboundEndpoint, + DnsResolverManagementClient +} from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates an inbound endpoint for a DNS resolver. + * + * @summary Creates or updates an inbound endpoint for a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_Put.json + */ +async function upsertInboundEndpointForDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const inboundEndpointName = "sampleInboundEndpoint"; + const parameters: InboundEndpoint = { + ipConfigurations: [ + { + privateIpAddress: "255.255.255.255", + privateIpAllocationMethod: "Static", + subnet: { + id: + "/subscriptions/0403cfa9-9659-4f33-9f30-1f191c51d111/resourceGroups/sampleVnetResourceGroupName/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork/subnets/sampleSubnet" + } + } + ], + location: "westus2", + tags: { key1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.inboundEndpoints.beginCreateOrUpdateAndWait( + resourceGroupName, + dnsResolverName, + inboundEndpointName, + parameters + ); + console.log(result); +} + +upsertInboundEndpointForDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/inboundEndpointsDeleteSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/inboundEndpointsDeleteSample.ts new file mode 100644 index 000000000000..b6e1243c1052 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/inboundEndpointsDeleteSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes an inbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. + * + * @summary Deletes an inbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_Delete.json + */ +async function deleteInboundEndpointForDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const inboundEndpointName = "sampleInboundEndpoint"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.inboundEndpoints.beginDeleteAndWait( + resourceGroupName, + dnsResolverName, + inboundEndpointName + ); + console.log(result); +} + +deleteInboundEndpointForDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/inboundEndpointsGetSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/inboundEndpointsGetSample.ts new file mode 100644 index 000000000000..1de6d4ab4fa3 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/inboundEndpointsGetSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets properties of an inbound endpoint for a DNS resolver. + * + * @summary Gets properties of an inbound endpoint for a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_Get.json + */ +async function retrieveInboundEndpointForDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const inboundEndpointName = "sampleInboundEndpoint"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.inboundEndpoints.get( + resourceGroupName, + dnsResolverName, + inboundEndpointName + ); + console.log(result); +} + +retrieveInboundEndpointForDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/inboundEndpointsListSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/inboundEndpointsListSample.ts new file mode 100644 index 000000000000..9a013d83ad10 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/inboundEndpointsListSample.ts @@ -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. +import { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists inbound endpoints for a DNS resolver. + * + * @summary Lists inbound endpoints for a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_List.json + */ +async function listInboundEndpointsByDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.inboundEndpoints.list( + resourceGroupName, + dnsResolverName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listInboundEndpointsByDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/inboundEndpointsUpdateSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/inboundEndpointsUpdateSample.ts new file mode 100644 index 000000000000..96b46d679ed7 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/inboundEndpointsUpdateSample.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 { + InboundEndpointPatch, + DnsResolverManagementClient +} from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Updates an inbound endpoint for a DNS resolver. + * + * @summary Updates an inbound endpoint for a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_Patch.json + */ +async function updateInboundEndpointForDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const inboundEndpointName = "sampleInboundEndpoint"; + const parameters: InboundEndpointPatch = { tags: { key1: "value1" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.inboundEndpoints.beginUpdateAndWait( + resourceGroupName, + dnsResolverName, + inboundEndpointName, + parameters + ); + console.log(result); +} + +updateInboundEndpointForDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/outboundEndpointsCreateOrUpdateSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/outboundEndpointsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..0f27b8648182 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/outboundEndpointsCreateOrUpdateSample.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 { + OutboundEndpoint, + DnsResolverManagementClient +} from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates an outbound endpoint for a DNS resolver. + * + * @summary Creates or updates an outbound endpoint for a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_Put.json + */ +async function upsertOutboundEndpointForDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const outboundEndpointName = "sampleOutboundEndpoint"; + const parameters: OutboundEndpoint = { + location: "westus2", + subnet: { + id: + "/subscriptions/0403cfa9-9659-4f33-9f30-1f191c51d111/resourceGroups/sampleVnetResourceGroupName/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork/subnets/sampleSubnet" + }, + tags: { key1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.outboundEndpoints.beginCreateOrUpdateAndWait( + resourceGroupName, + dnsResolverName, + outboundEndpointName, + parameters + ); + console.log(result); +} + +upsertOutboundEndpointForDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/outboundEndpointsDeleteSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/outboundEndpointsDeleteSample.ts new file mode 100644 index 000000000000..272fe587158a --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/outboundEndpointsDeleteSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes an outbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. + * + * @summary Deletes an outbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_Delete.json + */ +async function deleteOutboundEndpointForDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const outboundEndpointName = "sampleOutboundEndpoint"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.outboundEndpoints.beginDeleteAndWait( + resourceGroupName, + dnsResolverName, + outboundEndpointName + ); + console.log(result); +} + +deleteOutboundEndpointForDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/outboundEndpointsGetSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/outboundEndpointsGetSample.ts new file mode 100644 index 000000000000..b74024086257 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/outboundEndpointsGetSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets properties of an outbound endpoint for a DNS resolver. + * + * @summary Gets properties of an outbound endpoint for a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_Get.json + */ +async function retrieveOutboundEndpointForDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const outboundEndpointName = "sampleOutboundEndpoint"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.outboundEndpoints.get( + resourceGroupName, + dnsResolverName, + outboundEndpointName + ); + console.log(result); +} + +retrieveOutboundEndpointForDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/outboundEndpointsListSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/outboundEndpointsListSample.ts new file mode 100644 index 000000000000..3d81046a8ed2 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/outboundEndpointsListSample.ts @@ -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. +import { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists outbound endpoints for a DNS resolver. + * + * @summary Lists outbound endpoints for a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_List.json + */ +async function listOutboundEndpointsByDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.outboundEndpoints.list( + resourceGroupName, + dnsResolverName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listOutboundEndpointsByDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/outboundEndpointsUpdateSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/outboundEndpointsUpdateSample.ts new file mode 100644 index 000000000000..1ec556db755b --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/outboundEndpointsUpdateSample.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 { + OutboundEndpointPatch, + DnsResolverManagementClient +} from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Updates an outbound endpoint for a DNS resolver. + * + * @summary Updates an outbound endpoint for a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_Patch.json + */ +async function updateOutboundEndpointForDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const outboundEndpointName = "sampleOutboundEndpoint"; + const parameters: OutboundEndpointPatch = { tags: { key1: "value1" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.outboundEndpoints.beginUpdateAndWait( + resourceGroupName, + dnsResolverName, + outboundEndpointName, + parameters + ); + console.log(result); +} + +updateOutboundEndpointForDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/virtualNetworkLinksCreateOrUpdateSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/virtualNetworkLinksCreateOrUpdateSample.ts new file mode 100644 index 000000000000..37aaae5ba471 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/virtualNetworkLinksCreateOrUpdateSample.ts @@ -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. +import { + VirtualNetworkLink, + DnsResolverManagementClient +} from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates a virtual network link to a DNS forwarding ruleset. + * + * @summary Creates or updates a virtual network link to a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_Put.json + */ +async function upsertVirtualNetworkLinkToADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const virtualNetworkLinkName = "sampleVirtualNetworkLink"; + const parameters: VirtualNetworkLink = { + metadata: { additionalProp1: "value1" }, + virtualNetwork: { + id: + "/subscriptions/0403cfa9-9659-4f33-9f30-1f191c51d111/resourceGroups/sampleVnetResourceGroupName/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork" + } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkLinks.beginCreateOrUpdateAndWait( + resourceGroupName, + dnsForwardingRulesetName, + virtualNetworkLinkName, + parameters + ); + console.log(result); +} + +upsertVirtualNetworkLinkToADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/virtualNetworkLinksDeleteSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/virtualNetworkLinksDeleteSample.ts new file mode 100644 index 000000000000..e9d3b1df660e --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/virtualNetworkLinksDeleteSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes a virtual network link to a DNS forwarding ruleset. WARNING: This operation cannot be undone. + * + * @summary Deletes a virtual network link to a DNS forwarding ruleset. WARNING: This operation cannot be undone. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_Delete.json + */ +async function deleteVirtualNetworkLinkToADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const virtualNetworkLinkName = "sampleVirtualNetworkLink"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkLinks.beginDeleteAndWait( + resourceGroupName, + dnsForwardingRulesetName, + virtualNetworkLinkName + ); + console.log(result); +} + +deleteVirtualNetworkLinkToADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/virtualNetworkLinksGetSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/virtualNetworkLinksGetSample.ts new file mode 100644 index 000000000000..fd89dae1cbee --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/virtualNetworkLinksGetSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets properties of a virtual network link to a DNS forwarding ruleset. + * + * @summary Gets properties of a virtual network link to a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_Get.json + */ +async function retrieveVirtualNetworkLinkToADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const virtualNetworkLinkName = "sampleVirtualNetworkLink"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkLinks.get( + resourceGroupName, + dnsForwardingRulesetName, + virtualNetworkLinkName + ); + console.log(result); +} + +retrieveVirtualNetworkLinkToADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/virtualNetworkLinksListSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/virtualNetworkLinksListSample.ts new file mode 100644 index 000000000000..dcd323a49e5a --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/virtualNetworkLinksListSample.ts @@ -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. +import { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists virtual network links to a DNS forwarding ruleset. + * + * @summary Lists virtual network links to a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_List.json + */ +async function listVirtualNetworkLinksToADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.virtualNetworkLinks.list( + resourceGroupName, + dnsForwardingRulesetName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listVirtualNetworkLinksToADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples-dev/virtualNetworkLinksUpdateSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples-dev/virtualNetworkLinksUpdateSample.ts new file mode 100644 index 000000000000..bb5d9cbbf11e --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples-dev/virtualNetworkLinksUpdateSample.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 { + VirtualNetworkLinkPatch, + DnsResolverManagementClient +} from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Updates a virtual network link to a DNS forwarding ruleset. + * + * @summary Updates a virtual network link to a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_Patch.json + */ +async function updateVirtualNetworkLinkToADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const virtualNetworkLinkName = "sampleVirtualNetworkLink"; + const parameters: VirtualNetworkLinkPatch = { + metadata: { additionalProp1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkLinks.beginUpdateAndWait( + resourceGroupName, + dnsForwardingRulesetName, + virtualNetworkLinkName, + parameters + ); + console.log(result); +} + +updateVirtualNetworkLinkToADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/README.md b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/README.md index adadcf177e92..e481d87eceae 100644 --- a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/README.md +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/README.md @@ -10,6 +10,30 @@ These sample programs show how to use the JavaScript client libraries for in som | [deleteInboundEndpointForDnsResolver.js][deleteinboundendpointfordnsresolver] | Deletes an inbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_Delete.json | | [deleteOutboundEndpointForDnsResolver.js][deleteoutboundendpointfordnsresolver] | Deletes an outbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_Delete.json | | [deleteVirtualNetworkLinkToADnsForwardingRuleset.js][deletevirtualnetworklinktoadnsforwardingruleset] | Deletes a virtual network link to a DNS forwarding ruleset. WARNING: This operation cannot be undone. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_Delete.json | +| [dnsForwardingRulesetsCreateOrUpdateSample.js][dnsforwardingrulesetscreateorupdatesample] | Creates or updates a DNS forwarding ruleset. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_Put.json | +| [dnsForwardingRulesetsDeleteSample.js][dnsforwardingrulesetsdeletesample] | Deletes a DNS forwarding ruleset. WARNING: This operation cannot be undone. All forwarding rules within the ruleset will be deleted. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_Delete.json | +| [dnsForwardingRulesetsGetSample.js][dnsforwardingrulesetsgetsample] | Gets a DNS forwarding ruleset properties. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_Get.json | +| [dnsForwardingRulesetsListByResourceGroupSample.js][dnsforwardingrulesetslistbyresourcegroupsample] | Lists DNS forwarding rulesets within a resource group. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_ListByResourceGroup.json | +| [dnsForwardingRulesetsListByVirtualNetworkSample.js][dnsforwardingrulesetslistbyvirtualnetworksample] | Lists DNS forwarding ruleset resource IDs attached to a virtual network. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_ListByVirtualNetwork.json | +| [dnsForwardingRulesetsListSample.js][dnsforwardingrulesetslistsample] | Lists DNS forwarding rulesets in all resource groups of a subscription. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_ListBySubscription.json | +| [dnsForwardingRulesetsUpdateSample.js][dnsforwardingrulesetsupdatesample] | Updates a DNS forwarding ruleset. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_Patch.json | +| [dnsResolversCreateOrUpdateSample.js][dnsresolverscreateorupdatesample] | Creates or updates a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_Put.json | +| [dnsResolversDeleteSample.js][dnsresolversdeletesample] | Deletes a DNS resolver. WARNING: This operation cannot be undone. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_Delete.json | +| [dnsResolversGetSample.js][dnsresolversgetsample] | Gets properties of a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_Get.json | +| [dnsResolversListByResourceGroupSample.js][dnsresolverslistbyresourcegroupsample] | Lists DNS resolvers within a resource group. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_ListByResourceGroup.json | +| [dnsResolversListByVirtualNetworkSample.js][dnsresolverslistbyvirtualnetworksample] | Lists DNS resolver resource IDs linked to a virtual network. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_ListByVirtualNetwork.json | +| [dnsResolversListSample.js][dnsresolverslistsample] | Lists DNS resolvers in all resource groups of a subscription. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_ListBySubscription.json | +| [dnsResolversUpdateSample.js][dnsresolversupdatesample] | Updates a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_Patch.json | +| [forwardingRulesCreateOrUpdateSample.js][forwardingrulescreateorupdatesample] | Creates or updates a forwarding rule in a DNS forwarding ruleset. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/ForwardingRule_Put.json | +| [forwardingRulesDeleteSample.js][forwardingrulesdeletesample] | Deletes a forwarding rule in a DNS forwarding ruleset. WARNING: This operation cannot be undone. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/ForwardingRule_Delete.json | +| [forwardingRulesGetSample.js][forwardingrulesgetsample] | Gets properties of a forwarding rule in a DNS forwarding ruleset. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/ForwardingRule_Get.json | +| [forwardingRulesListSample.js][forwardingruleslistsample] | Lists forwarding rules in a DNS forwarding ruleset. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/ForwardingRule_List.json | +| [forwardingRulesUpdateSample.js][forwardingrulesupdatesample] | Updates a forwarding rule in a DNS forwarding ruleset. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/ForwardingRule_Patch.json | +| [inboundEndpointsCreateOrUpdateSample.js][inboundendpointscreateorupdatesample] | Creates or updates an inbound endpoint for a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_Put.json | +| [inboundEndpointsDeleteSample.js][inboundendpointsdeletesample] | Deletes an inbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_Delete.json | +| [inboundEndpointsGetSample.js][inboundendpointsgetsample] | Gets properties of an inbound endpoint for a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_Get.json | +| [inboundEndpointsListSample.js][inboundendpointslistsample] | Lists inbound endpoints for a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_List.json | +| [inboundEndpointsUpdateSample.js][inboundendpointsupdatesample] | Updates an inbound endpoint for a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_Patch.json | | [listDnsForwardingRulesetsByResourceGroup.js][listdnsforwardingrulesetsbyresourcegroup] | Lists DNS forwarding rulesets within a resource group. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_ListByResourceGroup.json | | [listDnsForwardingRulesetsBySubscription.js][listdnsforwardingrulesetsbysubscription] | Lists DNS forwarding rulesets in all resource groups of a subscription. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_ListBySubscription.json | | [listDnsForwardingRulesetsByVirtualNetwork.js][listdnsforwardingrulesetsbyvirtualnetwork] | Lists DNS forwarding ruleset resource IDs attached to a virtual network. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_ListByVirtualNetwork.json | @@ -20,6 +44,11 @@ These sample programs show how to use the JavaScript client libraries for in som | [listInboundEndpointsByDnsResolver.js][listinboundendpointsbydnsresolver] | Lists inbound endpoints for a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_List.json | | [listOutboundEndpointsByDnsResolver.js][listoutboundendpointsbydnsresolver] | Lists outbound endpoints for a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_List.json | | [listVirtualNetworkLinksToADnsForwardingRuleset.js][listvirtualnetworklinkstoadnsforwardingruleset] | Lists virtual network links to a DNS forwarding ruleset. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_List.json | +| [outboundEndpointsCreateOrUpdateSample.js][outboundendpointscreateorupdatesample] | Creates or updates an outbound endpoint for a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_Put.json | +| [outboundEndpointsDeleteSample.js][outboundendpointsdeletesample] | Deletes an outbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_Delete.json | +| [outboundEndpointsGetSample.js][outboundendpointsgetsample] | Gets properties of an outbound endpoint for a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_Get.json | +| [outboundEndpointsListSample.js][outboundendpointslistsample] | Lists outbound endpoints for a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_List.json | +| [outboundEndpointsUpdateSample.js][outboundendpointsupdatesample] | Updates an outbound endpoint for a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_Patch.json | | [retrieveDnsForwardingRuleset.js][retrievednsforwardingruleset] | Gets a DNS forwarding ruleset properties. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_Get.json | | [retrieveDnsResolver.js][retrievednsresolver] | Gets properties of a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_Get.json | | [retrieveForwardingRuleInADnsForwardingRuleset.js][retrieveforwardingruleinadnsforwardingruleset] | Gets properties of a forwarding rule in a DNS forwarding ruleset. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/ForwardingRule_Get.json | @@ -38,6 +67,11 @@ These sample programs show how to use the JavaScript client libraries for in som | [upsertInboundEndpointForDnsResolver.js][upsertinboundendpointfordnsresolver] | Creates or updates an inbound endpoint for a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_Put.json | | [upsertOutboundEndpointForDnsResolver.js][upsertoutboundendpointfordnsresolver] | Creates or updates an outbound endpoint for a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_Put.json | | [upsertVirtualNetworkLinkToADnsForwardingRuleset.js][upsertvirtualnetworklinktoadnsforwardingruleset] | Creates or updates a virtual network link to a DNS forwarding ruleset. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_Put.json | +| [virtualNetworkLinksCreateOrUpdateSample.js][virtualnetworklinkscreateorupdatesample] | Creates or updates a virtual network link to a DNS forwarding ruleset. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_Put.json | +| [virtualNetworkLinksDeleteSample.js][virtualnetworklinksdeletesample] | Deletes a virtual network link to a DNS forwarding ruleset. WARNING: This operation cannot be undone. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_Delete.json | +| [virtualNetworkLinksGetSample.js][virtualnetworklinksgetsample] | Gets properties of a virtual network link to a DNS forwarding ruleset. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_Get.json | +| [virtualNetworkLinksListSample.js][virtualnetworklinkslistsample] | Lists virtual network links to a DNS forwarding ruleset. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_List.json | +| [virtualNetworkLinksUpdateSample.js][virtualnetworklinksupdatesample] | Updates a virtual network link to a DNS forwarding ruleset. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_Patch.json | ## Prerequisites @@ -83,6 +117,30 @@ Take a look at our [API Documentation][apiref] for more information about the AP [deleteinboundendpointfordnsresolver]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/deleteInboundEndpointForDnsResolver.js [deleteoutboundendpointfordnsresolver]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/deleteOutboundEndpointForDnsResolver.js [deletevirtualnetworklinktoadnsforwardingruleset]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/deleteVirtualNetworkLinkToADnsForwardingRuleset.js +[dnsforwardingrulesetscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsCreateOrUpdateSample.js +[dnsforwardingrulesetsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsDeleteSample.js +[dnsforwardingrulesetsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsGetSample.js +[dnsforwardingrulesetslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsListByResourceGroupSample.js +[dnsforwardingrulesetslistbyvirtualnetworksample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsListByVirtualNetworkSample.js +[dnsforwardingrulesetslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsListSample.js +[dnsforwardingrulesetsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsUpdateSample.js +[dnsresolverscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversCreateOrUpdateSample.js +[dnsresolversdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversDeleteSample.js +[dnsresolversgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversGetSample.js +[dnsresolverslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversListByResourceGroupSample.js +[dnsresolverslistbyvirtualnetworksample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversListByVirtualNetworkSample.js +[dnsresolverslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversListSample.js +[dnsresolversupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversUpdateSample.js +[forwardingrulescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/forwardingRulesCreateOrUpdateSample.js +[forwardingrulesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/forwardingRulesDeleteSample.js +[forwardingrulesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/forwardingRulesGetSample.js +[forwardingruleslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/forwardingRulesListSample.js +[forwardingrulesupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/forwardingRulesUpdateSample.js +[inboundendpointscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/inboundEndpointsCreateOrUpdateSample.js +[inboundendpointsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/inboundEndpointsDeleteSample.js +[inboundendpointsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/inboundEndpointsGetSample.js +[inboundendpointslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/inboundEndpointsListSample.js +[inboundendpointsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/inboundEndpointsUpdateSample.js [listdnsforwardingrulesetsbyresourcegroup]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/listDnsForwardingRulesetsByResourceGroup.js [listdnsforwardingrulesetsbysubscription]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/listDnsForwardingRulesetsBySubscription.js [listdnsforwardingrulesetsbyvirtualnetwork]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/listDnsForwardingRulesetsByVirtualNetwork.js @@ -93,6 +151,11 @@ Take a look at our [API Documentation][apiref] for more information about the AP [listinboundendpointsbydnsresolver]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/listInboundEndpointsByDnsResolver.js [listoutboundendpointsbydnsresolver]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/listOutboundEndpointsByDnsResolver.js [listvirtualnetworklinkstoadnsforwardingruleset]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/listVirtualNetworkLinksToADnsForwardingRuleset.js +[outboundendpointscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/outboundEndpointsCreateOrUpdateSample.js +[outboundendpointsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/outboundEndpointsDeleteSample.js +[outboundendpointsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/outboundEndpointsGetSample.js +[outboundendpointslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/outboundEndpointsListSample.js +[outboundendpointsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/outboundEndpointsUpdateSample.js [retrievednsforwardingruleset]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/retrieveDnsForwardingRuleset.js [retrievednsresolver]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/retrieveDnsResolver.js [retrieveforwardingruleinadnsforwardingruleset]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/retrieveForwardingRuleInADnsForwardingRuleset.js @@ -111,6 +174,11 @@ Take a look at our [API Documentation][apiref] for more information about the AP [upsertinboundendpointfordnsresolver]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/upsertInboundEndpointForDnsResolver.js [upsertoutboundendpointfordnsresolver]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/upsertOutboundEndpointForDnsResolver.js [upsertvirtualnetworklinktoadnsforwardingruleset]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/upsertVirtualNetworkLinkToADnsForwardingRuleset.js +[virtualnetworklinkscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/virtualNetworkLinksCreateOrUpdateSample.js +[virtualnetworklinksdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/virtualNetworkLinksDeleteSample.js +[virtualnetworklinksgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/virtualNetworkLinksGetSample.js +[virtualnetworklinkslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/virtualNetworkLinksListSample.js +[virtualnetworklinksupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/virtualNetworkLinksUpdateSample.js [apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-dnsresolver?view=azure-node-preview [freesub]: https://azure.microsoft.com/free/ [package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/dnsresolver/arm-dnsresolver/README.md diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsCreateOrUpdateSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsCreateOrUpdateSample.js new file mode 100644 index 000000000000..625cdabfc264 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsCreateOrUpdateSample.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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Creates or updates a DNS forwarding ruleset. + * + * @summary Creates or updates a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_Put.json + */ +async function upsertDnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "samplednsForwardingRuleset"; + const parameters = { + dnsResolverOutboundEndpoints: [ + { + id: "/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver/outboundEndpoints/sampleOutboundEndpoint0", + }, + { + id: "/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver/outboundEndpoints/sampleOutboundEndpoint1", + }, + ], + location: "westus2", + tags: { key1: "value1" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.dnsForwardingRulesets.beginCreateOrUpdateAndWait( + resourceGroupName, + dnsForwardingRulesetName, + parameters + ); + console.log(result); +} + +upsertDnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsDeleteSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsDeleteSample.js new file mode 100644 index 000000000000..2313dcd0296c --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsDeleteSample.js @@ -0,0 +1,33 @@ +/* + * 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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes a DNS forwarding ruleset. WARNING: This operation cannot be undone. All forwarding rules within the ruleset will be deleted. + * + * @summary Deletes a DNS forwarding ruleset. WARNING: This operation cannot be undone. All forwarding rules within the ruleset will be deleted. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_Delete.json + */ +async function deleteDnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "samplednsForwardingRulesetName"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.dnsForwardingRulesets.beginDeleteAndWait( + resourceGroupName, + dnsForwardingRulesetName + ); + console.log(result); +} + +deleteDnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsGetSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsGetSample.js new file mode 100644 index 000000000000..c442484a13df --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsGetSample.js @@ -0,0 +1,33 @@ +/* + * 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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets a DNS forwarding ruleset properties. + * + * @summary Gets a DNS forwarding ruleset properties. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_Get.json + */ +async function retrieveDnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.dnsForwardingRulesets.get( + resourceGroupName, + dnsForwardingRulesetName + ); + console.log(result); +} + +retrieveDnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsListByResourceGroupSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsListByResourceGroupSample.js new file mode 100644 index 000000000000..3131ab60b21a --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsListByResourceGroupSample.js @@ -0,0 +1,32 @@ +/* + * 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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists DNS forwarding rulesets within a resource group. + * + * @summary Lists DNS forwarding rulesets within a resource group. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_ListByResourceGroup.json + */ +async function listDnsForwardingRulesetsByResourceGroup() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.dnsForwardingRulesets.listByResourceGroup(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +listDnsForwardingRulesetsByResourceGroup().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsListByVirtualNetworkSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsListByVirtualNetworkSample.js new file mode 100644 index 000000000000..3572017ca2ec --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsListByVirtualNetworkSample.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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists DNS forwarding ruleset resource IDs attached to a virtual network. + * + * @summary Lists DNS forwarding ruleset resource IDs attached to a virtual network. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_ListByVirtualNetwork.json + */ +async function listDnsForwardingRulesetsByVirtualNetwork() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const virtualNetworkName = "sampleVirtualNetwork"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.dnsForwardingRulesets.listByVirtualNetwork( + resourceGroupName, + virtualNetworkName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listDnsForwardingRulesetsByVirtualNetwork().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsListSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsListSample.js new file mode 100644 index 000000000000..042102962c22 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsListSample.js @@ -0,0 +1,31 @@ +/* + * 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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists DNS forwarding rulesets in all resource groups of a subscription. + * + * @summary Lists DNS forwarding rulesets in all resource groups of a subscription. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_ListBySubscription.json + */ +async function listDnsForwardingRulesetsBySubscription() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.dnsForwardingRulesets.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listDnsForwardingRulesetsBySubscription().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsUpdateSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsUpdateSample.js new file mode 100644 index 000000000000..55d1bc9e0740 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsForwardingRulesetsUpdateSample.js @@ -0,0 +1,35 @@ +/* + * 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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Updates a DNS forwarding ruleset. + * + * @summary Updates a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_Patch.json + */ +async function updateDnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const parameters = { tags: { key1: "value1" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.dnsForwardingRulesets.beginUpdateAndWait( + resourceGroupName, + dnsForwardingRulesetName, + parameters + ); + console.log(result); +} + +updateDnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversCreateOrUpdateSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversCreateOrUpdateSample.js new file mode 100644 index 000000000000..4af786bb76a6 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversCreateOrUpdateSample.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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Creates or updates a DNS resolver. + * + * @summary Creates or updates a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_Put.json + */ +async function upsertDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const parameters = { + location: "westus2", + tags: { key1: "value1" }, + virtualNetwork: { + id: "/subscriptions/cbb1387e-4b03-44f2-ad41-58d4677b9873/resourceGroups/virtualNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork", + }, + }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.dnsResolvers.beginCreateOrUpdateAndWait( + resourceGroupName, + dnsResolverName, + parameters + ); + console.log(result); +} + +upsertDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversDeleteSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversDeleteSample.js new file mode 100644 index 000000000000..447cb6106fe0 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversDeleteSample.js @@ -0,0 +1,30 @@ +/* + * 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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes a DNS resolver. WARNING: This operation cannot be undone. + * + * @summary Deletes a DNS resolver. WARNING: This operation cannot be undone. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_Delete.json + */ +async function deleteDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.dnsResolvers.beginDeleteAndWait(resourceGroupName, dnsResolverName); + console.log(result); +} + +deleteDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversGetSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversGetSample.js new file mode 100644 index 000000000000..5160ffcdc552 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversGetSample.js @@ -0,0 +1,30 @@ +/* + * 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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets properties of a DNS resolver. + * + * @summary Gets properties of a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_Get.json + */ +async function retrieveDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.dnsResolvers.get(resourceGroupName, dnsResolverName); + console.log(result); +} + +retrieveDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversListByResourceGroupSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversListByResourceGroupSample.js new file mode 100644 index 000000000000..f00a8f1edb4a --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversListByResourceGroupSample.js @@ -0,0 +1,32 @@ +/* + * 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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists DNS resolvers within a resource group. + * + * @summary Lists DNS resolvers within a resource group. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_ListByResourceGroup.json + */ +async function listDnsResolversByResourceGroup() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.dnsResolvers.listByResourceGroup(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +listDnsResolversByResourceGroup().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversListByVirtualNetworkSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversListByVirtualNetworkSample.js new file mode 100644 index 000000000000..f6f6f3dd983e --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversListByVirtualNetworkSample.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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists DNS resolver resource IDs linked to a virtual network. + * + * @summary Lists DNS resolver resource IDs linked to a virtual network. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_ListByVirtualNetwork.json + */ +async function listDnsResolversByVirtualNetwork() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const virtualNetworkName = "sampleVirtualNetwork"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.dnsResolvers.listByVirtualNetwork( + resourceGroupName, + virtualNetworkName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listDnsResolversByVirtualNetwork().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversListSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversListSample.js new file mode 100644 index 000000000000..5a3d1a50a84f --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversListSample.js @@ -0,0 +1,31 @@ +/* + * 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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists DNS resolvers in all resource groups of a subscription. + * + * @summary Lists DNS resolvers in all resource groups of a subscription. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_ListBySubscription.json + */ +async function listDnsResolversBySubscription() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.dnsResolvers.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listDnsResolversBySubscription().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversUpdateSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversUpdateSample.js new file mode 100644 index 000000000000..fef5b425ac8b --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/dnsResolversUpdateSample.js @@ -0,0 +1,35 @@ +/* + * 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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Updates a DNS resolver. + * + * @summary Updates a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_Patch.json + */ +async function updateDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const parameters = { tags: { key1: "value1" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.dnsResolvers.beginUpdateAndWait( + resourceGroupName, + dnsResolverName, + parameters + ); + console.log(result); +} + +updateDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/forwardingRulesCreateOrUpdateSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/forwardingRulesCreateOrUpdateSample.js new file mode 100644 index 000000000000..1919b53619b9 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/forwardingRulesCreateOrUpdateSample.js @@ -0,0 +1,45 @@ +/* + * 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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Creates or updates a forwarding rule in a DNS forwarding ruleset. + * + * @summary Creates or updates a forwarding rule in a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/ForwardingRule_Put.json + */ +async function upsertForwardingRuleInADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const forwardingRuleName = "sampleForwardingRule"; + const parameters = { + domainName: "contoso.com.", + forwardingRuleState: "Enabled", + metadata: { additionalProp1: "value1" }, + targetDnsServers: [ + { ipAddress: "10.0.0.1", port: 53 }, + { ipAddress: "10.0.0.2", port: 53 }, + ], + }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.forwardingRules.createOrUpdate( + resourceGroupName, + dnsForwardingRulesetName, + forwardingRuleName, + parameters + ); + console.log(result); +} + +upsertForwardingRuleInADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/forwardingRulesDeleteSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/forwardingRulesDeleteSample.js new file mode 100644 index 000000000000..c010925b4866 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/forwardingRulesDeleteSample.js @@ -0,0 +1,35 @@ +/* + * 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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes a forwarding rule in a DNS forwarding ruleset. WARNING: This operation cannot be undone. + * + * @summary Deletes a forwarding rule in a DNS forwarding ruleset. WARNING: This operation cannot be undone. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/ForwardingRule_Delete.json + */ +async function deleteForwardingRuleInADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const forwardingRuleName = "sampleForwardingRule"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.forwardingRules.delete( + resourceGroupName, + dnsForwardingRulesetName, + forwardingRuleName + ); + console.log(result); +} + +deleteForwardingRuleInADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/forwardingRulesGetSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/forwardingRulesGetSample.js new file mode 100644 index 000000000000..5dc53566ab0e --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/forwardingRulesGetSample.js @@ -0,0 +1,35 @@ +/* + * 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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets properties of a forwarding rule in a DNS forwarding ruleset. + * + * @summary Gets properties of a forwarding rule in a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/ForwardingRule_Get.json + */ +async function retrieveForwardingRuleInADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const forwardingRuleName = "sampleForwardingRule"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.forwardingRules.get( + resourceGroupName, + dnsForwardingRulesetName, + forwardingRuleName + ); + console.log(result); +} + +retrieveForwardingRuleInADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/forwardingRulesListSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/forwardingRulesListSample.js new file mode 100644 index 000000000000..7f4756b02537 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/forwardingRulesListSample.js @@ -0,0 +1,33 @@ +/* + * 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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists forwarding rules in a DNS forwarding ruleset. + * + * @summary Lists forwarding rules in a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/ForwardingRule_List.json + */ +async function listForwardingRulesInADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.forwardingRules.list(resourceGroupName, dnsForwardingRulesetName)) { + resArray.push(item); + } + console.log(resArray); +} + +listForwardingRulesInADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/forwardingRulesUpdateSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/forwardingRulesUpdateSample.js new file mode 100644 index 000000000000..1d4586de57c3 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/forwardingRulesUpdateSample.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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Updates a forwarding rule in a DNS forwarding ruleset. + * + * @summary Updates a forwarding rule in a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/ForwardingRule_Patch.json + */ +async function updateForwardingRuleInADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const forwardingRuleName = "sampleForwardingRule"; + const parameters = { + forwardingRuleState: "Disabled", + metadata: { additionalProp2: "value2" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.forwardingRules.update( + resourceGroupName, + dnsForwardingRulesetName, + forwardingRuleName, + parameters + ); + console.log(result); +} + +updateForwardingRuleInADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/inboundEndpointsCreateOrUpdateSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/inboundEndpointsCreateOrUpdateSample.js new file mode 100644 index 000000000000..8c725b98decc --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/inboundEndpointsCreateOrUpdateSample.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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Creates or updates an inbound endpoint for a DNS resolver. + * + * @summary Creates or updates an inbound endpoint for a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_Put.json + */ +async function upsertInboundEndpointForDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const inboundEndpointName = "sampleInboundEndpoint"; + const parameters = { + ipConfigurations: [ + { + privateIpAddress: "255.255.255.255", + privateIpAllocationMethod: "Static", + subnet: { + id: "/subscriptions/0403cfa9-9659-4f33-9f30-1f191c51d111/resourceGroups/sampleVnetResourceGroupName/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork/subnets/sampleSubnet", + }, + }, + ], + location: "westus2", + tags: { key1: "value1" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.inboundEndpoints.beginCreateOrUpdateAndWait( + resourceGroupName, + dnsResolverName, + inboundEndpointName, + parameters + ); + console.log(result); +} + +upsertInboundEndpointForDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/inboundEndpointsDeleteSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/inboundEndpointsDeleteSample.js new file mode 100644 index 000000000000..65698cda57a0 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/inboundEndpointsDeleteSample.js @@ -0,0 +1,35 @@ +/* + * 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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes an inbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. + * + * @summary Deletes an inbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_Delete.json + */ +async function deleteInboundEndpointForDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const inboundEndpointName = "sampleInboundEndpoint"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.inboundEndpoints.beginDeleteAndWait( + resourceGroupName, + dnsResolverName, + inboundEndpointName + ); + console.log(result); +} + +deleteInboundEndpointForDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/inboundEndpointsGetSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/inboundEndpointsGetSample.js new file mode 100644 index 000000000000..28a5da3ebedd --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/inboundEndpointsGetSample.js @@ -0,0 +1,35 @@ +/* + * 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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets properties of an inbound endpoint for a DNS resolver. + * + * @summary Gets properties of an inbound endpoint for a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_Get.json + */ +async function retrieveInboundEndpointForDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const inboundEndpointName = "sampleInboundEndpoint"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.inboundEndpoints.get( + resourceGroupName, + dnsResolverName, + inboundEndpointName + ); + console.log(result); +} + +retrieveInboundEndpointForDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/inboundEndpointsListSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/inboundEndpointsListSample.js new file mode 100644 index 000000000000..5af7a0b6a7bc --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/inboundEndpointsListSample.js @@ -0,0 +1,33 @@ +/* + * 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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists inbound endpoints for a DNS resolver. + * + * @summary Lists inbound endpoints for a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_List.json + */ +async function listInboundEndpointsByDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.inboundEndpoints.list(resourceGroupName, dnsResolverName)) { + resArray.push(item); + } + console.log(resArray); +} + +listInboundEndpointsByDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/inboundEndpointsUpdateSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/inboundEndpointsUpdateSample.js new file mode 100644 index 000000000000..61b60298f844 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/inboundEndpointsUpdateSample.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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Updates an inbound endpoint for a DNS resolver. + * + * @summary Updates an inbound endpoint for a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_Patch.json + */ +async function updateInboundEndpointForDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const inboundEndpointName = "sampleInboundEndpoint"; + const parameters = { tags: { key1: "value1" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.inboundEndpoints.beginUpdateAndWait( + resourceGroupName, + dnsResolverName, + inboundEndpointName, + parameters + ); + console.log(result); +} + +updateInboundEndpointForDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/outboundEndpointsCreateOrUpdateSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/outboundEndpointsCreateOrUpdateSample.js new file mode 100644 index 000000000000..5d8648f30162 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/outboundEndpointsCreateOrUpdateSample.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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Creates or updates an outbound endpoint for a DNS resolver. + * + * @summary Creates or updates an outbound endpoint for a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_Put.json + */ +async function upsertOutboundEndpointForDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const outboundEndpointName = "sampleOutboundEndpoint"; + const parameters = { + location: "westus2", + subnet: { + id: "/subscriptions/0403cfa9-9659-4f33-9f30-1f191c51d111/resourceGroups/sampleVnetResourceGroupName/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork/subnets/sampleSubnet", + }, + tags: { key1: "value1" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.outboundEndpoints.beginCreateOrUpdateAndWait( + resourceGroupName, + dnsResolverName, + outboundEndpointName, + parameters + ); + console.log(result); +} + +upsertOutboundEndpointForDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/outboundEndpointsDeleteSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/outboundEndpointsDeleteSample.js new file mode 100644 index 000000000000..3e04fc922423 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/outboundEndpointsDeleteSample.js @@ -0,0 +1,35 @@ +/* + * 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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes an outbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. + * + * @summary Deletes an outbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_Delete.json + */ +async function deleteOutboundEndpointForDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const outboundEndpointName = "sampleOutboundEndpoint"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.outboundEndpoints.beginDeleteAndWait( + resourceGroupName, + dnsResolverName, + outboundEndpointName + ); + console.log(result); +} + +deleteOutboundEndpointForDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/outboundEndpointsGetSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/outboundEndpointsGetSample.js new file mode 100644 index 000000000000..ce0e0bc9ac10 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/outboundEndpointsGetSample.js @@ -0,0 +1,35 @@ +/* + * 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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets properties of an outbound endpoint for a DNS resolver. + * + * @summary Gets properties of an outbound endpoint for a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_Get.json + */ +async function retrieveOutboundEndpointForDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const outboundEndpointName = "sampleOutboundEndpoint"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.outboundEndpoints.get( + resourceGroupName, + dnsResolverName, + outboundEndpointName + ); + console.log(result); +} + +retrieveOutboundEndpointForDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/outboundEndpointsListSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/outboundEndpointsListSample.js new file mode 100644 index 000000000000..40c298718341 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/outboundEndpointsListSample.js @@ -0,0 +1,33 @@ +/* + * 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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists outbound endpoints for a DNS resolver. + * + * @summary Lists outbound endpoints for a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_List.json + */ +async function listOutboundEndpointsByDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.outboundEndpoints.list(resourceGroupName, dnsResolverName)) { + resArray.push(item); + } + console.log(resArray); +} + +listOutboundEndpointsByDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/outboundEndpointsUpdateSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/outboundEndpointsUpdateSample.js new file mode 100644 index 000000000000..ed02818d2b1d --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/outboundEndpointsUpdateSample.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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Updates an outbound endpoint for a DNS resolver. + * + * @summary Updates an outbound endpoint for a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_Patch.json + */ +async function updateOutboundEndpointForDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const outboundEndpointName = "sampleOutboundEndpoint"; + const parameters = { tags: { key1: "value1" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.outboundEndpoints.beginUpdateAndWait( + resourceGroupName, + dnsResolverName, + outboundEndpointName, + parameters + ); + console.log(result); +} + +updateOutboundEndpointForDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/virtualNetworkLinksCreateOrUpdateSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/virtualNetworkLinksCreateOrUpdateSample.js new file mode 100644 index 000000000000..42d568ab838a --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/virtualNetworkLinksCreateOrUpdateSample.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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Creates or updates a virtual network link to a DNS forwarding ruleset. + * + * @summary Creates or updates a virtual network link to a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_Put.json + */ +async function upsertVirtualNetworkLinkToADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const virtualNetworkLinkName = "sampleVirtualNetworkLink"; + const parameters = { + metadata: { additionalProp1: "value1" }, + virtualNetwork: { + id: "/subscriptions/0403cfa9-9659-4f33-9f30-1f191c51d111/resourceGroups/sampleVnetResourceGroupName/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork", + }, + }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkLinks.beginCreateOrUpdateAndWait( + resourceGroupName, + dnsForwardingRulesetName, + virtualNetworkLinkName, + parameters + ); + console.log(result); +} + +upsertVirtualNetworkLinkToADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/virtualNetworkLinksDeleteSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/virtualNetworkLinksDeleteSample.js new file mode 100644 index 000000000000..47f6509b6d99 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/virtualNetworkLinksDeleteSample.js @@ -0,0 +1,35 @@ +/* + * 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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes a virtual network link to a DNS forwarding ruleset. WARNING: This operation cannot be undone. + * + * @summary Deletes a virtual network link to a DNS forwarding ruleset. WARNING: This operation cannot be undone. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_Delete.json + */ +async function deleteVirtualNetworkLinkToADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const virtualNetworkLinkName = "sampleVirtualNetworkLink"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkLinks.beginDeleteAndWait( + resourceGroupName, + dnsForwardingRulesetName, + virtualNetworkLinkName + ); + console.log(result); +} + +deleteVirtualNetworkLinkToADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/virtualNetworkLinksGetSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/virtualNetworkLinksGetSample.js new file mode 100644 index 000000000000..2976dd589e8f --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/virtualNetworkLinksGetSample.js @@ -0,0 +1,35 @@ +/* + * 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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets properties of a virtual network link to a DNS forwarding ruleset. + * + * @summary Gets properties of a virtual network link to a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_Get.json + */ +async function retrieveVirtualNetworkLinkToADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const virtualNetworkLinkName = "sampleVirtualNetworkLink"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkLinks.get( + resourceGroupName, + dnsForwardingRulesetName, + virtualNetworkLinkName + ); + console.log(result); +} + +retrieveVirtualNetworkLinkToADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/virtualNetworkLinksListSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/virtualNetworkLinksListSample.js new file mode 100644 index 000000000000..e3406f9ad8e9 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/virtualNetworkLinksListSample.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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists virtual network links to a DNS forwarding ruleset. + * + * @summary Lists virtual network links to a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_List.json + */ +async function listVirtualNetworkLinksToADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.virtualNetworkLinks.list( + resourceGroupName, + dnsForwardingRulesetName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listVirtualNetworkLinksToADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/virtualNetworkLinksUpdateSample.js b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/virtualNetworkLinksUpdateSample.js new file mode 100644 index 000000000000..26c1246231ee --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/javascript/virtualNetworkLinksUpdateSample.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 { DnsResolverManagementClient } = require("@azure/arm-dnsresolver"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Updates a virtual network link to a DNS forwarding ruleset. + * + * @summary Updates a virtual network link to a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_Patch.json + */ +async function updateVirtualNetworkLinkToADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const virtualNetworkLinkName = "sampleVirtualNetworkLink"; + const parameters = { + metadata: { additionalProp1: "value1" }, + }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkLinks.beginUpdateAndWait( + resourceGroupName, + dnsForwardingRulesetName, + virtualNetworkLinkName, + parameters + ); + console.log(result); +} + +updateVirtualNetworkLinkToADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/README.md b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/README.md index 26528ee6ed1b..c7fbc3f092b9 100644 --- a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/README.md +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/README.md @@ -10,6 +10,30 @@ These sample programs show how to use the TypeScript client libraries for in som | [deleteInboundEndpointForDnsResolver.ts][deleteinboundendpointfordnsresolver] | Deletes an inbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_Delete.json | | [deleteOutboundEndpointForDnsResolver.ts][deleteoutboundendpointfordnsresolver] | Deletes an outbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_Delete.json | | [deleteVirtualNetworkLinkToADnsForwardingRuleset.ts][deletevirtualnetworklinktoadnsforwardingruleset] | Deletes a virtual network link to a DNS forwarding ruleset. WARNING: This operation cannot be undone. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_Delete.json | +| [dnsForwardingRulesetsCreateOrUpdateSample.ts][dnsforwardingrulesetscreateorupdatesample] | Creates or updates a DNS forwarding ruleset. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_Put.json | +| [dnsForwardingRulesetsDeleteSample.ts][dnsforwardingrulesetsdeletesample] | Deletes a DNS forwarding ruleset. WARNING: This operation cannot be undone. All forwarding rules within the ruleset will be deleted. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_Delete.json | +| [dnsForwardingRulesetsGetSample.ts][dnsforwardingrulesetsgetsample] | Gets a DNS forwarding ruleset properties. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_Get.json | +| [dnsForwardingRulesetsListByResourceGroupSample.ts][dnsforwardingrulesetslistbyresourcegroupsample] | Lists DNS forwarding rulesets within a resource group. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_ListByResourceGroup.json | +| [dnsForwardingRulesetsListByVirtualNetworkSample.ts][dnsforwardingrulesetslistbyvirtualnetworksample] | Lists DNS forwarding ruleset resource IDs attached to a virtual network. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_ListByVirtualNetwork.json | +| [dnsForwardingRulesetsListSample.ts][dnsforwardingrulesetslistsample] | Lists DNS forwarding rulesets in all resource groups of a subscription. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_ListBySubscription.json | +| [dnsForwardingRulesetsUpdateSample.ts][dnsforwardingrulesetsupdatesample] | Updates a DNS forwarding ruleset. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_Patch.json | +| [dnsResolversCreateOrUpdateSample.ts][dnsresolverscreateorupdatesample] | Creates or updates a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_Put.json | +| [dnsResolversDeleteSample.ts][dnsresolversdeletesample] | Deletes a DNS resolver. WARNING: This operation cannot be undone. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_Delete.json | +| [dnsResolversGetSample.ts][dnsresolversgetsample] | Gets properties of a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_Get.json | +| [dnsResolversListByResourceGroupSample.ts][dnsresolverslistbyresourcegroupsample] | Lists DNS resolvers within a resource group. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_ListByResourceGroup.json | +| [dnsResolversListByVirtualNetworkSample.ts][dnsresolverslistbyvirtualnetworksample] | Lists DNS resolver resource IDs linked to a virtual network. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_ListByVirtualNetwork.json | +| [dnsResolversListSample.ts][dnsresolverslistsample] | Lists DNS resolvers in all resource groups of a subscription. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_ListBySubscription.json | +| [dnsResolversUpdateSample.ts][dnsresolversupdatesample] | Updates a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_Patch.json | +| [forwardingRulesCreateOrUpdateSample.ts][forwardingrulescreateorupdatesample] | Creates or updates a forwarding rule in a DNS forwarding ruleset. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/ForwardingRule_Put.json | +| [forwardingRulesDeleteSample.ts][forwardingrulesdeletesample] | Deletes a forwarding rule in a DNS forwarding ruleset. WARNING: This operation cannot be undone. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/ForwardingRule_Delete.json | +| [forwardingRulesGetSample.ts][forwardingrulesgetsample] | Gets properties of a forwarding rule in a DNS forwarding ruleset. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/ForwardingRule_Get.json | +| [forwardingRulesListSample.ts][forwardingruleslistsample] | Lists forwarding rules in a DNS forwarding ruleset. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/ForwardingRule_List.json | +| [forwardingRulesUpdateSample.ts][forwardingrulesupdatesample] | Updates a forwarding rule in a DNS forwarding ruleset. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/ForwardingRule_Patch.json | +| [inboundEndpointsCreateOrUpdateSample.ts][inboundendpointscreateorupdatesample] | Creates or updates an inbound endpoint for a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_Put.json | +| [inboundEndpointsDeleteSample.ts][inboundendpointsdeletesample] | Deletes an inbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_Delete.json | +| [inboundEndpointsGetSample.ts][inboundendpointsgetsample] | Gets properties of an inbound endpoint for a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_Get.json | +| [inboundEndpointsListSample.ts][inboundendpointslistsample] | Lists inbound endpoints for a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_List.json | +| [inboundEndpointsUpdateSample.ts][inboundendpointsupdatesample] | Updates an inbound endpoint for a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_Patch.json | | [listDnsForwardingRulesetsByResourceGroup.ts][listdnsforwardingrulesetsbyresourcegroup] | Lists DNS forwarding rulesets within a resource group. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_ListByResourceGroup.json | | [listDnsForwardingRulesetsBySubscription.ts][listdnsforwardingrulesetsbysubscription] | Lists DNS forwarding rulesets in all resource groups of a subscription. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_ListBySubscription.json | | [listDnsForwardingRulesetsByVirtualNetwork.ts][listdnsforwardingrulesetsbyvirtualnetwork] | Lists DNS forwarding ruleset resource IDs attached to a virtual network. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_ListByVirtualNetwork.json | @@ -20,6 +44,11 @@ These sample programs show how to use the TypeScript client libraries for in som | [listInboundEndpointsByDnsResolver.ts][listinboundendpointsbydnsresolver] | Lists inbound endpoints for a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_List.json | | [listOutboundEndpointsByDnsResolver.ts][listoutboundendpointsbydnsresolver] | Lists outbound endpoints for a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_List.json | | [listVirtualNetworkLinksToADnsForwardingRuleset.ts][listvirtualnetworklinkstoadnsforwardingruleset] | Lists virtual network links to a DNS forwarding ruleset. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_List.json | +| [outboundEndpointsCreateOrUpdateSample.ts][outboundendpointscreateorupdatesample] | Creates or updates an outbound endpoint for a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_Put.json | +| [outboundEndpointsDeleteSample.ts][outboundendpointsdeletesample] | Deletes an outbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_Delete.json | +| [outboundEndpointsGetSample.ts][outboundendpointsgetsample] | Gets properties of an outbound endpoint for a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_Get.json | +| [outboundEndpointsListSample.ts][outboundendpointslistsample] | Lists outbound endpoints for a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_List.json | +| [outboundEndpointsUpdateSample.ts][outboundendpointsupdatesample] | Updates an outbound endpoint for a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_Patch.json | | [retrieveDnsForwardingRuleset.ts][retrievednsforwardingruleset] | Gets a DNS forwarding ruleset properties. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_Get.json | | [retrieveDnsResolver.ts][retrievednsresolver] | Gets properties of a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_Get.json | | [retrieveForwardingRuleInADnsForwardingRuleset.ts][retrieveforwardingruleinadnsforwardingruleset] | Gets properties of a forwarding rule in a DNS forwarding ruleset. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/ForwardingRule_Get.json | @@ -38,6 +67,11 @@ These sample programs show how to use the TypeScript client libraries for in som | [upsertInboundEndpointForDnsResolver.ts][upsertinboundendpointfordnsresolver] | Creates or updates an inbound endpoint for a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_Put.json | | [upsertOutboundEndpointForDnsResolver.ts][upsertoutboundendpointfordnsresolver] | Creates or updates an outbound endpoint for a DNS resolver. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_Put.json | | [upsertVirtualNetworkLinkToADnsForwardingRuleset.ts][upsertvirtualnetworklinktoadnsforwardingruleset] | Creates or updates a virtual network link to a DNS forwarding ruleset. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_Put.json | +| [virtualNetworkLinksCreateOrUpdateSample.ts][virtualnetworklinkscreateorupdatesample] | Creates or updates a virtual network link to a DNS forwarding ruleset. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_Put.json | +| [virtualNetworkLinksDeleteSample.ts][virtualnetworklinksdeletesample] | Deletes a virtual network link to a DNS forwarding ruleset. WARNING: This operation cannot be undone. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_Delete.json | +| [virtualNetworkLinksGetSample.ts][virtualnetworklinksgetsample] | Gets properties of a virtual network link to a DNS forwarding ruleset. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_Get.json | +| [virtualNetworkLinksListSample.ts][virtualnetworklinkslistsample] | Lists virtual network links to a DNS forwarding ruleset. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_List.json | +| [virtualNetworkLinksUpdateSample.ts][virtualnetworklinksupdatesample] | Updates a virtual network link to a DNS forwarding ruleset. x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_Patch.json | ## Prerequisites @@ -95,6 +129,30 @@ Take a look at our [API Documentation][apiref] for more information about the AP [deleteinboundendpointfordnsresolver]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/deleteInboundEndpointForDnsResolver.ts [deleteoutboundendpointfordnsresolver]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/deleteOutboundEndpointForDnsResolver.ts [deletevirtualnetworklinktoadnsforwardingruleset]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/deleteVirtualNetworkLinkToADnsForwardingRuleset.ts +[dnsforwardingrulesetscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsCreateOrUpdateSample.ts +[dnsforwardingrulesetsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsDeleteSample.ts +[dnsforwardingrulesetsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsGetSample.ts +[dnsforwardingrulesetslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsListByResourceGroupSample.ts +[dnsforwardingrulesetslistbyvirtualnetworksample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsListByVirtualNetworkSample.ts +[dnsforwardingrulesetslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsListSample.ts +[dnsforwardingrulesetsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsUpdateSample.ts +[dnsresolverscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversCreateOrUpdateSample.ts +[dnsresolversdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversDeleteSample.ts +[dnsresolversgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversGetSample.ts +[dnsresolverslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversListByResourceGroupSample.ts +[dnsresolverslistbyvirtualnetworksample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversListByVirtualNetworkSample.ts +[dnsresolverslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversListSample.ts +[dnsresolversupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversUpdateSample.ts +[forwardingrulescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/forwardingRulesCreateOrUpdateSample.ts +[forwardingrulesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/forwardingRulesDeleteSample.ts +[forwardingrulesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/forwardingRulesGetSample.ts +[forwardingruleslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/forwardingRulesListSample.ts +[forwardingrulesupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/forwardingRulesUpdateSample.ts +[inboundendpointscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/inboundEndpointsCreateOrUpdateSample.ts +[inboundendpointsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/inboundEndpointsDeleteSample.ts +[inboundendpointsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/inboundEndpointsGetSample.ts +[inboundendpointslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/inboundEndpointsListSample.ts +[inboundendpointsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/inboundEndpointsUpdateSample.ts [listdnsforwardingrulesetsbyresourcegroup]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/listDnsForwardingRulesetsByResourceGroup.ts [listdnsforwardingrulesetsbysubscription]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/listDnsForwardingRulesetsBySubscription.ts [listdnsforwardingrulesetsbyvirtualnetwork]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/listDnsForwardingRulesetsByVirtualNetwork.ts @@ -105,6 +163,11 @@ Take a look at our [API Documentation][apiref] for more information about the AP [listinboundendpointsbydnsresolver]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/listInboundEndpointsByDnsResolver.ts [listoutboundendpointsbydnsresolver]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/listOutboundEndpointsByDnsResolver.ts [listvirtualnetworklinkstoadnsforwardingruleset]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/listVirtualNetworkLinksToADnsForwardingRuleset.ts +[outboundendpointscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/outboundEndpointsCreateOrUpdateSample.ts +[outboundendpointsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/outboundEndpointsDeleteSample.ts +[outboundendpointsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/outboundEndpointsGetSample.ts +[outboundendpointslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/outboundEndpointsListSample.ts +[outboundendpointsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/outboundEndpointsUpdateSample.ts [retrievednsforwardingruleset]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/retrieveDnsForwardingRuleset.ts [retrievednsresolver]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/retrieveDnsResolver.ts [retrieveforwardingruleinadnsforwardingruleset]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/retrieveForwardingRuleInADnsForwardingRuleset.ts @@ -123,6 +186,11 @@ Take a look at our [API Documentation][apiref] for more information about the AP [upsertinboundendpointfordnsresolver]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/upsertInboundEndpointForDnsResolver.ts [upsertoutboundendpointfordnsresolver]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/upsertOutboundEndpointForDnsResolver.ts [upsertvirtualnetworklinktoadnsforwardingruleset]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/upsertVirtualNetworkLinkToADnsForwardingRuleset.ts +[virtualnetworklinkscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/virtualNetworkLinksCreateOrUpdateSample.ts +[virtualnetworklinksdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/virtualNetworkLinksDeleteSample.ts +[virtualnetworklinksgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/virtualNetworkLinksGetSample.ts +[virtualnetworklinkslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/virtualNetworkLinksListSample.ts +[virtualnetworklinksupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/virtualNetworkLinksUpdateSample.ts [apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-dnsresolver?view=azure-node-preview [freesub]: https://azure.microsoft.com/free/ [package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/dnsresolver/arm-dnsresolver/README.md diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsCreateOrUpdateSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..8e1f8901f7f0 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsCreateOrUpdateSample.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 { + DnsForwardingRuleset, + DnsResolverManagementClient +} from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates a DNS forwarding ruleset. + * + * @summary Creates or updates a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_Put.json + */ +async function upsertDnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "samplednsForwardingRuleset"; + const parameters: DnsForwardingRuleset = { + dnsResolverOutboundEndpoints: [ + { + id: + "/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver/outboundEndpoints/sampleOutboundEndpoint0" + }, + { + id: + "/subscriptions/abdd4249-9f34-4cc6-8e42-c2e32110603e/resourceGroups/sampleResourceGroup/providers/Microsoft.Network/dnsResolvers/sampleDnsResolver/outboundEndpoints/sampleOutboundEndpoint1" + } + ], + location: "westus2", + tags: { key1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.dnsForwardingRulesets.beginCreateOrUpdateAndWait( + resourceGroupName, + dnsForwardingRulesetName, + parameters + ); + console.log(result); +} + +upsertDnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsDeleteSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsDeleteSample.ts new file mode 100644 index 000000000000..bdee153ba72a --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsDeleteSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes a DNS forwarding ruleset. WARNING: This operation cannot be undone. All forwarding rules within the ruleset will be deleted. + * + * @summary Deletes a DNS forwarding ruleset. WARNING: This operation cannot be undone. All forwarding rules within the ruleset will be deleted. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_Delete.json + */ +async function deleteDnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "samplednsForwardingRulesetName"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.dnsForwardingRulesets.beginDeleteAndWait( + resourceGroupName, + dnsForwardingRulesetName + ); + console.log(result); +} + +deleteDnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsGetSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsGetSample.ts new file mode 100644 index 000000000000..006980c0d73c --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsGetSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets a DNS forwarding ruleset properties. + * + * @summary Gets a DNS forwarding ruleset properties. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_Get.json + */ +async function retrieveDnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.dnsForwardingRulesets.get( + resourceGroupName, + dnsForwardingRulesetName + ); + console.log(result); +} + +retrieveDnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsListByResourceGroupSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsListByResourceGroupSample.ts new file mode 100644 index 000000000000..9f17ed4f86ea --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsListByResourceGroupSample.ts @@ -0,0 +1,34 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists DNS forwarding rulesets within a resource group. + * + * @summary Lists DNS forwarding rulesets within a resource group. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_ListByResourceGroup.json + */ +async function listDnsForwardingRulesetsByResourceGroup() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.dnsForwardingRulesets.listByResourceGroup( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listDnsForwardingRulesetsByResourceGroup().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsListByVirtualNetworkSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsListByVirtualNetworkSample.ts new file mode 100644 index 000000000000..76421954e9a5 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsListByVirtualNetworkSample.ts @@ -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. +import { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists DNS forwarding ruleset resource IDs attached to a virtual network. + * + * @summary Lists DNS forwarding ruleset resource IDs attached to a virtual network. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_ListByVirtualNetwork.json + */ +async function listDnsForwardingRulesetsByVirtualNetwork() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const virtualNetworkName = "sampleVirtualNetwork"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.dnsForwardingRulesets.listByVirtualNetwork( + resourceGroupName, + virtualNetworkName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listDnsForwardingRulesetsByVirtualNetwork().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsListSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsListSample.ts new file mode 100644 index 000000000000..53f964a0d89e --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsListSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists DNS forwarding rulesets in all resource groups of a subscription. + * + * @summary Lists DNS forwarding rulesets in all resource groups of a subscription. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_ListBySubscription.json + */ +async function listDnsForwardingRulesetsBySubscription() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.dnsForwardingRulesets.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listDnsForwardingRulesetsBySubscription().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsUpdateSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsUpdateSample.ts new file mode 100644 index 000000000000..6a2a0a29294c --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsForwardingRulesetsUpdateSample.ts @@ -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. +import { + DnsForwardingRulesetPatch, + DnsResolverManagementClient +} from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Updates a DNS forwarding ruleset. + * + * @summary Updates a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsForwardingRuleset_Patch.json + */ +async function updateDnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const parameters: DnsForwardingRulesetPatch = { tags: { key1: "value1" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.dnsForwardingRulesets.beginUpdateAndWait( + resourceGroupName, + dnsForwardingRulesetName, + parameters + ); + console.log(result); +} + +updateDnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversCreateOrUpdateSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversCreateOrUpdateSample.ts new file mode 100644 index 000000000000..8a75adc9e500 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversCreateOrUpdateSample.ts @@ -0,0 +1,45 @@ +/* + * 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 { + DnsResolver, + DnsResolverManagementClient +} from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates a DNS resolver. + * + * @summary Creates or updates a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_Put.json + */ +async function upsertDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const parameters: DnsResolver = { + location: "westus2", + tags: { key1: "value1" }, + virtualNetwork: { + id: + "/subscriptions/cbb1387e-4b03-44f2-ad41-58d4677b9873/resourceGroups/virtualNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork" + } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.dnsResolvers.beginCreateOrUpdateAndWait( + resourceGroupName, + dnsResolverName, + parameters + ); + console.log(result); +} + +upsertDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversDeleteSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversDeleteSample.ts new file mode 100644 index 000000000000..59e5e9e2a773 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversDeleteSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes a DNS resolver. WARNING: This operation cannot be undone. + * + * @summary Deletes a DNS resolver. WARNING: This operation cannot be undone. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_Delete.json + */ +async function deleteDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.dnsResolvers.beginDeleteAndWait( + resourceGroupName, + dnsResolverName + ); + console.log(result); +} + +deleteDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversGetSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversGetSample.ts new file mode 100644 index 000000000000..01b514b58f90 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversGetSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets properties of a DNS resolver. + * + * @summary Gets properties of a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_Get.json + */ +async function retrieveDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.dnsResolvers.get( + resourceGroupName, + dnsResolverName + ); + console.log(result); +} + +retrieveDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversListByResourceGroupSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversListByResourceGroupSample.ts new file mode 100644 index 000000000000..f29f4489facd --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversListByResourceGroupSample.ts @@ -0,0 +1,34 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists DNS resolvers within a resource group. + * + * @summary Lists DNS resolvers within a resource group. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_ListByResourceGroup.json + */ +async function listDnsResolversByResourceGroup() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.dnsResolvers.listByResourceGroup( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listDnsResolversByResourceGroup().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversListByVirtualNetworkSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversListByVirtualNetworkSample.ts new file mode 100644 index 000000000000..cc1347621c3a --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversListByVirtualNetworkSample.ts @@ -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. +import { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists DNS resolver resource IDs linked to a virtual network. + * + * @summary Lists DNS resolver resource IDs linked to a virtual network. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_ListByVirtualNetwork.json + */ +async function listDnsResolversByVirtualNetwork() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const virtualNetworkName = "sampleVirtualNetwork"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.dnsResolvers.listByVirtualNetwork( + resourceGroupName, + virtualNetworkName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listDnsResolversByVirtualNetwork().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversListSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversListSample.ts new file mode 100644 index 000000000000..2f6d4cadaba0 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversListSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists DNS resolvers in all resource groups of a subscription. + * + * @summary Lists DNS resolvers in all resource groups of a subscription. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_ListBySubscription.json + */ +async function listDnsResolversBySubscription() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.dnsResolvers.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listDnsResolversBySubscription().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversUpdateSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversUpdateSample.ts new file mode 100644 index 000000000000..4b16f7579042 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/dnsResolversUpdateSample.ts @@ -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. +import { + DnsResolverPatch, + DnsResolverManagementClient +} from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Updates a DNS resolver. + * + * @summary Updates a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/DnsResolver_Patch.json + */ +async function updateDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const parameters: DnsResolverPatch = { tags: { key1: "value1" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.dnsResolvers.beginUpdateAndWait( + resourceGroupName, + dnsResolverName, + parameters + ); + console.log(result); +} + +updateDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/forwardingRulesCreateOrUpdateSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/forwardingRulesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..d9d2762d4ff8 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/forwardingRulesCreateOrUpdateSample.ts @@ -0,0 +1,48 @@ +/* + * 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 { + ForwardingRule, + DnsResolverManagementClient +} from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates a forwarding rule in a DNS forwarding ruleset. + * + * @summary Creates or updates a forwarding rule in a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/ForwardingRule_Put.json + */ +async function upsertForwardingRuleInADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const forwardingRuleName = "sampleForwardingRule"; + const parameters: ForwardingRule = { + domainName: "contoso.com.", + forwardingRuleState: "Enabled", + metadata: { additionalProp1: "value1" }, + targetDnsServers: [ + { ipAddress: "10.0.0.1", port: 53 }, + { ipAddress: "10.0.0.2", port: 53 } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.forwardingRules.createOrUpdate( + resourceGroupName, + dnsForwardingRulesetName, + forwardingRuleName, + parameters + ); + console.log(result); +} + +upsertForwardingRuleInADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/forwardingRulesDeleteSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/forwardingRulesDeleteSample.ts new file mode 100644 index 000000000000..97173aefa7e4 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/forwardingRulesDeleteSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes a forwarding rule in a DNS forwarding ruleset. WARNING: This operation cannot be undone. + * + * @summary Deletes a forwarding rule in a DNS forwarding ruleset. WARNING: This operation cannot be undone. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/ForwardingRule_Delete.json + */ +async function deleteForwardingRuleInADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const forwardingRuleName = "sampleForwardingRule"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.forwardingRules.delete( + resourceGroupName, + dnsForwardingRulesetName, + forwardingRuleName + ); + console.log(result); +} + +deleteForwardingRuleInADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/forwardingRulesGetSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/forwardingRulesGetSample.ts new file mode 100644 index 000000000000..ee90282d9af1 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/forwardingRulesGetSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets properties of a forwarding rule in a DNS forwarding ruleset. + * + * @summary Gets properties of a forwarding rule in a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/ForwardingRule_Get.json + */ +async function retrieveForwardingRuleInADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const forwardingRuleName = "sampleForwardingRule"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.forwardingRules.get( + resourceGroupName, + dnsForwardingRulesetName, + forwardingRuleName + ); + console.log(result); +} + +retrieveForwardingRuleInADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/forwardingRulesListSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/forwardingRulesListSample.ts new file mode 100644 index 000000000000..a4b0d321b153 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/forwardingRulesListSample.ts @@ -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. +import { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists forwarding rules in a DNS forwarding ruleset. + * + * @summary Lists forwarding rules in a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/ForwardingRule_List.json + */ +async function listForwardingRulesInADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.forwardingRules.list( + resourceGroupName, + dnsForwardingRulesetName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listForwardingRulesInADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/forwardingRulesUpdateSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/forwardingRulesUpdateSample.ts new file mode 100644 index 000000000000..ecabe311f7b5 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/forwardingRulesUpdateSample.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 { + ForwardingRulePatch, + DnsResolverManagementClient +} from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Updates a forwarding rule in a DNS forwarding ruleset. + * + * @summary Updates a forwarding rule in a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/ForwardingRule_Patch.json + */ +async function updateForwardingRuleInADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const forwardingRuleName = "sampleForwardingRule"; + const parameters: ForwardingRulePatch = { + forwardingRuleState: "Disabled", + metadata: { additionalProp2: "value2" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.forwardingRules.update( + resourceGroupName, + dnsForwardingRulesetName, + forwardingRuleName, + parameters + ); + console.log(result); +} + +updateForwardingRuleInADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/inboundEndpointsCreateOrUpdateSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/inboundEndpointsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..facbb6ec9988 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/inboundEndpointsCreateOrUpdateSample.ts @@ -0,0 +1,53 @@ +/* + * 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 { + InboundEndpoint, + DnsResolverManagementClient +} from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates an inbound endpoint for a DNS resolver. + * + * @summary Creates or updates an inbound endpoint for a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_Put.json + */ +async function upsertInboundEndpointForDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const inboundEndpointName = "sampleInboundEndpoint"; + const parameters: InboundEndpoint = { + ipConfigurations: [ + { + privateIpAddress: "255.255.255.255", + privateIpAllocationMethod: "Static", + subnet: { + id: + "/subscriptions/0403cfa9-9659-4f33-9f30-1f191c51d111/resourceGroups/sampleVnetResourceGroupName/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork/subnets/sampleSubnet" + } + } + ], + location: "westus2", + tags: { key1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.inboundEndpoints.beginCreateOrUpdateAndWait( + resourceGroupName, + dnsResolverName, + inboundEndpointName, + parameters + ); + console.log(result); +} + +upsertInboundEndpointForDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/inboundEndpointsDeleteSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/inboundEndpointsDeleteSample.ts new file mode 100644 index 000000000000..b6e1243c1052 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/inboundEndpointsDeleteSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes an inbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. + * + * @summary Deletes an inbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_Delete.json + */ +async function deleteInboundEndpointForDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const inboundEndpointName = "sampleInboundEndpoint"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.inboundEndpoints.beginDeleteAndWait( + resourceGroupName, + dnsResolverName, + inboundEndpointName + ); + console.log(result); +} + +deleteInboundEndpointForDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/inboundEndpointsGetSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/inboundEndpointsGetSample.ts new file mode 100644 index 000000000000..1de6d4ab4fa3 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/inboundEndpointsGetSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets properties of an inbound endpoint for a DNS resolver. + * + * @summary Gets properties of an inbound endpoint for a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_Get.json + */ +async function retrieveInboundEndpointForDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const inboundEndpointName = "sampleInboundEndpoint"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.inboundEndpoints.get( + resourceGroupName, + dnsResolverName, + inboundEndpointName + ); + console.log(result); +} + +retrieveInboundEndpointForDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/inboundEndpointsListSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/inboundEndpointsListSample.ts new file mode 100644 index 000000000000..9a013d83ad10 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/inboundEndpointsListSample.ts @@ -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. +import { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists inbound endpoints for a DNS resolver. + * + * @summary Lists inbound endpoints for a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_List.json + */ +async function listInboundEndpointsByDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.inboundEndpoints.list( + resourceGroupName, + dnsResolverName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listInboundEndpointsByDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/inboundEndpointsUpdateSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/inboundEndpointsUpdateSample.ts new file mode 100644 index 000000000000..96b46d679ed7 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/inboundEndpointsUpdateSample.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 { + InboundEndpointPatch, + DnsResolverManagementClient +} from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Updates an inbound endpoint for a DNS resolver. + * + * @summary Updates an inbound endpoint for a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/InboundEndpoint_Patch.json + */ +async function updateInboundEndpointForDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const inboundEndpointName = "sampleInboundEndpoint"; + const parameters: InboundEndpointPatch = { tags: { key1: "value1" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.inboundEndpoints.beginUpdateAndWait( + resourceGroupName, + dnsResolverName, + inboundEndpointName, + parameters + ); + console.log(result); +} + +updateInboundEndpointForDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/outboundEndpointsCreateOrUpdateSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/outboundEndpointsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..0f27b8648182 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/outboundEndpointsCreateOrUpdateSample.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 { + OutboundEndpoint, + DnsResolverManagementClient +} from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates an outbound endpoint for a DNS resolver. + * + * @summary Creates or updates an outbound endpoint for a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_Put.json + */ +async function upsertOutboundEndpointForDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const outboundEndpointName = "sampleOutboundEndpoint"; + const parameters: OutboundEndpoint = { + location: "westus2", + subnet: { + id: + "/subscriptions/0403cfa9-9659-4f33-9f30-1f191c51d111/resourceGroups/sampleVnetResourceGroupName/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork/subnets/sampleSubnet" + }, + tags: { key1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.outboundEndpoints.beginCreateOrUpdateAndWait( + resourceGroupName, + dnsResolverName, + outboundEndpointName, + parameters + ); + console.log(result); +} + +upsertOutboundEndpointForDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/outboundEndpointsDeleteSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/outboundEndpointsDeleteSample.ts new file mode 100644 index 000000000000..272fe587158a --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/outboundEndpointsDeleteSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes an outbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. + * + * @summary Deletes an outbound endpoint for a DNS resolver. WARNING: This operation cannot be undone. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_Delete.json + */ +async function deleteOutboundEndpointForDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const outboundEndpointName = "sampleOutboundEndpoint"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.outboundEndpoints.beginDeleteAndWait( + resourceGroupName, + dnsResolverName, + outboundEndpointName + ); + console.log(result); +} + +deleteOutboundEndpointForDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/outboundEndpointsGetSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/outboundEndpointsGetSample.ts new file mode 100644 index 000000000000..b74024086257 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/outboundEndpointsGetSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets properties of an outbound endpoint for a DNS resolver. + * + * @summary Gets properties of an outbound endpoint for a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_Get.json + */ +async function retrieveOutboundEndpointForDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const outboundEndpointName = "sampleOutboundEndpoint"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.outboundEndpoints.get( + resourceGroupName, + dnsResolverName, + outboundEndpointName + ); + console.log(result); +} + +retrieveOutboundEndpointForDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/outboundEndpointsListSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/outboundEndpointsListSample.ts new file mode 100644 index 000000000000..3d81046a8ed2 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/outboundEndpointsListSample.ts @@ -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. +import { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists outbound endpoints for a DNS resolver. + * + * @summary Lists outbound endpoints for a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_List.json + */ +async function listOutboundEndpointsByDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.outboundEndpoints.list( + resourceGroupName, + dnsResolverName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listOutboundEndpointsByDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/outboundEndpointsUpdateSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/outboundEndpointsUpdateSample.ts new file mode 100644 index 000000000000..1ec556db755b --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/outboundEndpointsUpdateSample.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 { + OutboundEndpointPatch, + DnsResolverManagementClient +} from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Updates an outbound endpoint for a DNS resolver. + * + * @summary Updates an outbound endpoint for a DNS resolver. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/OutboundEndpoint_Patch.json + */ +async function updateOutboundEndpointForDnsResolver() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsResolverName = "sampleDnsResolver"; + const outboundEndpointName = "sampleOutboundEndpoint"; + const parameters: OutboundEndpointPatch = { tags: { key1: "value1" } }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.outboundEndpoints.beginUpdateAndWait( + resourceGroupName, + dnsResolverName, + outboundEndpointName, + parameters + ); + console.log(result); +} + +updateOutboundEndpointForDnsResolver().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/virtualNetworkLinksCreateOrUpdateSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/virtualNetworkLinksCreateOrUpdateSample.ts new file mode 100644 index 000000000000..37aaae5ba471 --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/virtualNetworkLinksCreateOrUpdateSample.ts @@ -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. +import { + VirtualNetworkLink, + DnsResolverManagementClient +} from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates a virtual network link to a DNS forwarding ruleset. + * + * @summary Creates or updates a virtual network link to a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_Put.json + */ +async function upsertVirtualNetworkLinkToADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const virtualNetworkLinkName = "sampleVirtualNetworkLink"; + const parameters: VirtualNetworkLink = { + metadata: { additionalProp1: "value1" }, + virtualNetwork: { + id: + "/subscriptions/0403cfa9-9659-4f33-9f30-1f191c51d111/resourceGroups/sampleVnetResourceGroupName/providers/Microsoft.Network/virtualNetworks/sampleVirtualNetwork" + } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkLinks.beginCreateOrUpdateAndWait( + resourceGroupName, + dnsForwardingRulesetName, + virtualNetworkLinkName, + parameters + ); + console.log(result); +} + +upsertVirtualNetworkLinkToADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/virtualNetworkLinksDeleteSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/virtualNetworkLinksDeleteSample.ts new file mode 100644 index 000000000000..e9d3b1df660e --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/virtualNetworkLinksDeleteSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes a virtual network link to a DNS forwarding ruleset. WARNING: This operation cannot be undone. + * + * @summary Deletes a virtual network link to a DNS forwarding ruleset. WARNING: This operation cannot be undone. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_Delete.json + */ +async function deleteVirtualNetworkLinkToADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const virtualNetworkLinkName = "sampleVirtualNetworkLink"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkLinks.beginDeleteAndWait( + resourceGroupName, + dnsForwardingRulesetName, + virtualNetworkLinkName + ); + console.log(result); +} + +deleteVirtualNetworkLinkToADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/virtualNetworkLinksGetSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/virtualNetworkLinksGetSample.ts new file mode 100644 index 000000000000..fd89dae1cbee --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/virtualNetworkLinksGetSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets properties of a virtual network link to a DNS forwarding ruleset. + * + * @summary Gets properties of a virtual network link to a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_Get.json + */ +async function retrieveVirtualNetworkLinkToADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const virtualNetworkLinkName = "sampleVirtualNetworkLink"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkLinks.get( + resourceGroupName, + dnsForwardingRulesetName, + virtualNetworkLinkName + ); + console.log(result); +} + +retrieveVirtualNetworkLinkToADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/virtualNetworkLinksListSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/virtualNetworkLinksListSample.ts new file mode 100644 index 000000000000..dcd323a49e5a --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/virtualNetworkLinksListSample.ts @@ -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. +import { DnsResolverManagementClient } from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists virtual network links to a DNS forwarding ruleset. + * + * @summary Lists virtual network links to a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_List.json + */ +async function listVirtualNetworkLinksToADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.virtualNetworkLinks.list( + resourceGroupName, + dnsForwardingRulesetName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listVirtualNetworkLinksToADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/virtualNetworkLinksUpdateSample.ts b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/virtualNetworkLinksUpdateSample.ts new file mode 100644 index 000000000000..bb5d9cbbf11e --- /dev/null +++ b/sdk/dnsresolver/arm-dnsresolver/samples/v1-beta/typescript/src/virtualNetworkLinksUpdateSample.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 { + VirtualNetworkLinkPatch, + DnsResolverManagementClient +} from "@azure/arm-dnsresolver"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Updates a virtual network link to a DNS forwarding ruleset. + * + * @summary Updates a virtual network link to a DNS forwarding ruleset. + * x-ms-original-file: specification/dnsresolver/resource-manager/Microsoft.Network/preview/2020-04-01-preview/examples/VirtualNetworkLink_Patch.json + */ +async function updateVirtualNetworkLinkToADnsForwardingRuleset() { + const subscriptionId = "abdd4249-9f34-4cc6-8e42-c2e32110603e"; + const resourceGroupName = "sampleResourceGroup"; + const dnsForwardingRulesetName = "sampleDnsForwardingRuleset"; + const virtualNetworkLinkName = "sampleVirtualNetworkLink"; + const parameters: VirtualNetworkLinkPatch = { + metadata: { additionalProp1: "value1" } + }; + const credential = new DefaultAzureCredential(); + const client = new DnsResolverManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkLinks.beginUpdateAndWait( + resourceGroupName, + dnsForwardingRulesetName, + virtualNetworkLinkName, + parameters + ); + console.log(result); +} + +updateVirtualNetworkLinkToADnsForwardingRuleset().catch(console.error); diff --git a/sdk/dnsresolver/arm-dnsresolver/src/dnsResolverManagementClient.ts b/sdk/dnsresolver/arm-dnsresolver/src/dnsResolverManagementClient.ts index ce51db9529b2..addb9edad4d0 100644 --- a/sdk/dnsresolver/arm-dnsresolver/src/dnsResolverManagementClient.ts +++ b/sdk/dnsresolver/arm-dnsresolver/src/dnsResolverManagementClient.ts @@ -7,6 +7,7 @@ */ import * as coreClient from "@azure/core-client"; +import * as coreRestPipeline from "@azure/core-rest-pipeline"; import * as coreAuth from "@azure/core-auth"; import { DnsResolversImpl, @@ -58,7 +59,7 @@ export class DnsResolverManagementClient extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-dnsresolver/1.0.0-beta.2`; + const packageDetails = `azsdk-js-arm-dnsresolver/1.0.0-beta.3`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` @@ -73,9 +74,33 @@ export class DnsResolverManagementClient extends coreClient.ServiceClient { userAgentOptions: { userAgentPrefix }, - baseUri: options.endpoint || "https://management.azure.com" + baseUri: + options.endpoint ?? options.baseUri ?? "https://management.azure.com" }; super(optionsWithDefaults); + + if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { + const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies(); + const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( + (pipelinePolicy) => + pipelinePolicy.name === + coreRestPipeline.bearerTokenAuthenticationPolicyName + ); + if (!bearerTokenAuthenticationPolicyFound) { + this.pipeline.removePolicy({ + name: coreRestPipeline.bearerTokenAuthenticationPolicyName + }); + this.pipeline.addPolicy( + coreRestPipeline.bearerTokenAuthenticationPolicy({ + scopes: `${optionsWithDefaults.baseUri}/.default`, + challengeCallbacks: { + authorizeRequestOnChallenge: + coreClient.authorizeRequestOnClaimChallenge + } + }) + ); + } + } // Parameter assignments this.subscriptionId = subscriptionId; diff --git a/sdk/dnsresolver/arm-dnsresolver/src/operations/dnsForwardingRulesets.ts b/sdk/dnsresolver/arm-dnsresolver/src/operations/dnsForwardingRulesets.ts index 06a1cc88b8d6..290e7b16c38f 100644 --- a/sdk/dnsresolver/arm-dnsresolver/src/operations/dnsForwardingRulesets.ts +++ b/sdk/dnsresolver/arm-dnsresolver/src/operations/dnsForwardingRulesets.ts @@ -280,10 +280,12 @@ export class DnsForwardingRulesetsImpl implements DnsForwardingRulesets { { resourceGroupName, dnsForwardingRulesetName, parameters, options }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -370,10 +372,12 @@ export class DnsForwardingRulesetsImpl implements DnsForwardingRulesets { { resourceGroupName, dnsForwardingRulesetName, parameters, options }, updateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -454,10 +458,12 @@ export class DnsForwardingRulesetsImpl implements DnsForwardingRulesets { { resourceGroupName, dnsForwardingRulesetName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** diff --git a/sdk/dnsresolver/arm-dnsresolver/src/operations/dnsResolvers.ts b/sdk/dnsresolver/arm-dnsresolver/src/operations/dnsResolvers.ts index 29cbc13fcf77..73dcc97991b3 100644 --- a/sdk/dnsresolver/arm-dnsresolver/src/operations/dnsResolvers.ts +++ b/sdk/dnsresolver/arm-dnsresolver/src/operations/dnsResolvers.ts @@ -280,10 +280,12 @@ export class DnsResolversImpl implements DnsResolvers { { resourceGroupName, dnsResolverName, parameters, options }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -370,10 +372,12 @@ export class DnsResolversImpl implements DnsResolvers { { resourceGroupName, dnsResolverName, parameters, options }, updateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -453,10 +457,12 @@ export class DnsResolversImpl implements DnsResolvers { { resourceGroupName, dnsResolverName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** diff --git a/sdk/dnsresolver/arm-dnsresolver/src/operations/inboundEndpoints.ts b/sdk/dnsresolver/arm-dnsresolver/src/operations/inboundEndpoints.ts index 693a5b2ddd8e..597e3ac115ec 100644 --- a/sdk/dnsresolver/arm-dnsresolver/src/operations/inboundEndpoints.ts +++ b/sdk/dnsresolver/arm-dnsresolver/src/operations/inboundEndpoints.ts @@ -176,10 +176,12 @@ export class InboundEndpointsImpl implements InboundEndpoints { }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -277,10 +279,12 @@ export class InboundEndpointsImpl implements InboundEndpoints { }, updateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -365,10 +369,12 @@ export class InboundEndpointsImpl implements InboundEndpoints { { resourceGroupName, dnsResolverName, inboundEndpointName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** diff --git a/sdk/dnsresolver/arm-dnsresolver/src/operations/outboundEndpoints.ts b/sdk/dnsresolver/arm-dnsresolver/src/operations/outboundEndpoints.ts index ba434afe053a..26b5e1cc90fe 100644 --- a/sdk/dnsresolver/arm-dnsresolver/src/operations/outboundEndpoints.ts +++ b/sdk/dnsresolver/arm-dnsresolver/src/operations/outboundEndpoints.ts @@ -176,10 +176,12 @@ export class OutboundEndpointsImpl implements OutboundEndpoints { }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -277,10 +279,12 @@ export class OutboundEndpointsImpl implements OutboundEndpoints { }, updateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -365,10 +369,12 @@ export class OutboundEndpointsImpl implements OutboundEndpoints { { resourceGroupName, dnsResolverName, outboundEndpointName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** diff --git a/sdk/dnsresolver/arm-dnsresolver/src/operations/virtualNetworkLinks.ts b/sdk/dnsresolver/arm-dnsresolver/src/operations/virtualNetworkLinks.ts index ae1aaf240ff8..437e16913966 100644 --- a/sdk/dnsresolver/arm-dnsresolver/src/operations/virtualNetworkLinks.ts +++ b/sdk/dnsresolver/arm-dnsresolver/src/operations/virtualNetworkLinks.ts @@ -184,10 +184,12 @@ export class VirtualNetworkLinksImpl implements VirtualNetworkLinks { }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -285,10 +287,12 @@ export class VirtualNetworkLinksImpl implements VirtualNetworkLinks { }, updateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -379,10 +383,12 @@ export class VirtualNetworkLinksImpl implements VirtualNetworkLinks { }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** diff --git a/sdk/dnsresolver/arm-dnsresolver/tsconfig.json b/sdk/dnsresolver/arm-dnsresolver/tsconfig.json index 5f99a93d7690..f630847f3a63 100644 --- a/sdk/dnsresolver/arm-dnsresolver/tsconfig.json +++ b/sdk/dnsresolver/arm-dnsresolver/tsconfig.json @@ -24,7 +24,8 @@ }, "include": [ "./src/**/*.ts", - "./test/**/*.ts" + "./test/**/*.ts", + "samples-dev/**/*.ts" ], "exclude": [ "node_modules" diff --git a/sdk/dnsresolver/ci.mgmt.yml b/sdk/dnsresolver/ci.mgmt.yml index 729fefbfd601..c24153e1f3fd 100644 --- a/sdk/dnsresolver/ci.mgmt.yml +++ b/sdk/dnsresolver/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,7 +9,7 @@ trigger: paths: include: - sdk/dnsresolver/ci.mgmt.yml - - sdk/dnsresolver/arm-dnsresolver/ + - sdk/dnsresolver/arm-dnsresolver pr: branches: include: @@ -22,12 +22,11 @@ pr: paths: include: - sdk/dnsresolver/ci.mgmt.yml - - sdk/dnsresolver/arm-dnsresolver/ - + - sdk/dnsresolver/arm-dnsresolver extends: template: /eng/pipelines/templates/stages/archetype-sdk-client.yml parameters: ServiceDirectory: dnsresolver Artifacts: - name: azure-arm-dnsresolver - safeName: azurearmdnsresolver + safeName: azurearmdnsresolver diff --git a/sdk/domainservices/arm-domainservices/CHANGELOG.md b/sdk/domainservices/arm-domainservices/CHANGELOG.md index fe589089a710..7ade5ee771f8 100644 --- a/sdk/domainservices/arm-domainservices/CHANGELOG.md +++ b/sdk/domainservices/arm-domainservices/CHANGELOG.md @@ -1,14 +1,10 @@ # Release History -## 4.0.1 (Unreleased) +## 4.0.1 (2022-04-18) -### Features Added +**features** -### Breaking Changes - -### Bugs Fixed - -### Other Changes + - Bug fix ## 4.0.0 (2022-01-13) diff --git a/sdk/domainservices/arm-domainservices/LICENSE.txt b/sdk/domainservices/arm-domainservices/LICENSE.txt deleted file mode 100644 index a70e8cf66038..000000000000 --- a/sdk/domainservices/arm-domainservices/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2018 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 -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/sdk/domainservices/arm-domainservices/README.md b/sdk/domainservices/arm-domainservices/README.md index 44cdad585226..a1e2db6d2ae5 100644 --- a/sdk/domainservices/arm-domainservices/README.md +++ b/sdk/domainservices/arm-domainservices/README.md @@ -16,6 +16,8 @@ The AAD Domain Services API. - [LTS versions of Node.js](https://nodejs.org/about/releases/) - 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]. @@ -49,8 +51,17 @@ For more information about how to create an Azure AD Application check out [this ```javascript const { DomainServicesResourceProvider } = require("@azure/arm-domainservices"); 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 DomainServicesResourceProvider(new DefaultAzureCredential(), subscriptionId); + +// For client-side applications running in the browser, use this code instead: +// const credential = new InteractiveBrowserCredential({ +// tenantId: "", +// clientId: "" +// }); +// const client = new DomainServicesResourceProvider(credential, subscriptionId); ``` diff --git a/sdk/domainservices/arm-domainservices/_meta.json b/sdk/domainservices/arm-domainservices/_meta.json index 00e694d5c26c..200b460b7905 100644 --- a/sdk/domainservices/arm-domainservices/_meta.json +++ b/sdk/domainservices/arm-domainservices/_meta.json @@ -1,7 +1,8 @@ { "commit": "1f1d5b0b9ce6cc94605b2fd619dce374fb6e033a", - "readme": "specification/domainservices/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 --generate-test --typescript-sdks-folder=D:\\mydev\\azure-sdk-for-js ../azure-rest-api-specs/specification/healthbot/resource-manager/readme.md --use=@autorest/typescript@6.0.0-alpha.16.20211217.1", + "readme": "specification\\domainservices\\resource-manager\\readme.md", + "autorest_command": "autorest --version=3.7.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\work\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\domainservices\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-alpha.19.20220408.1 --generate-sample=true", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "use": "@autorest/typescript@6.0.0-alpha.16.20211217.1" -} + "release_tool": "@azure-tools/js-sdk-release-tools@2.2.6", + "use": "@autorest/typescript@6.0.0-alpha.19.20220408.1" +} \ No newline at end of file diff --git a/sdk/domainservices/arm-domainservices/api-extractor.json b/sdk/domainservices/arm-domainservices/api-extractor.json index 497aeae182d3..8033796565e1 100644 --- a/sdk/domainservices/arm-domainservices/api-extractor.json +++ b/sdk/domainservices/arm-domainservices/api-extractor.json @@ -1,18 +1,31 @@ { "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", "mainEntryPointFilePath": "./dist-esm/src/index.d.ts", - "docModel": { "enabled": true }, - "apiReport": { "enabled": true, "reportFolder": "./review" }, + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, "dtsRollup": { "enabled": true, "untrimmedFilePath": "", "publicTrimmedFilePath": "./types/arm-domainservices.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/domainservices/arm-domainservices/package.json b/sdk/domainservices/arm-domainservices/package.json index 8568fea8647e..6e0fa4423b85 100644 --- a/sdk/domainservices/arm-domainservices/package.json +++ b/sdk/domainservices/arm-domainservices/package.json @@ -11,9 +11,9 @@ "@azure/core-lro": "^2.2.0", "@azure/abort-controller": "^1.0.0", "@azure/core-paging": "^1.2.0", - "@azure/core-client": "^1.0.0", + "@azure/core-client": "^1.5.0", "@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": [ @@ -29,13 +29,13 @@ "types": "./types/arm-domainservices.d.ts", "devDependencies": { "@microsoft/api-extractor": "^7.18.11", - "@rollup/plugin-commonjs": "11.0.2", - "@rollup/plugin-json": "^4.0.0", - "@rollup/plugin-multi-entry": "^3.0.0", - "@rollup/plugin-node-resolve": "^8.0.0", + "@rollup/plugin-commonjs": "^21.0.1", + "@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": "^1.16.3", - "rollup-plugin-sourcemaps": "^0.4.2", + "rollup": "^2.66.1", + "rollup-plugin-sourcemaps": "^0.6.3", "typescript": "~4.2.0", "uglify-js": "^3.4.9", "rimraf": "^3.0.0", @@ -98,5 +98,21 @@ "docs": "echo skipped" }, "sideEffects": false, - "autoPublish": true + "//metadata": { + "constantPaths": [ + { + "path": "src/domainServicesResourceProvider.ts", + "prefix": "packageDetails" + } + ] + }, + "autoPublish": true, + "//sampleConfiguration": { + "productName": "", + "productSlugs": [ + "azure" + ], + "disableDocsMs": true, + "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-domainservices?view=azure-node-preview" + } } diff --git a/sdk/domainservices/arm-domainservices/rollup.config.js b/sdk/domainservices/arm-domainservices/rollup.config.js index 9be1955eb7f1..3f89d7309da5 100644 --- a/sdk/domainservices/arm-domainservices/rollup.config.js +++ b/sdk/domainservices/arm-domainservices/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/domainservices/arm-domainservices/sample.env b/sdk/domainservices/arm-domainservices/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/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/domainservices/arm-domainservices/samples-dev/domainServiceOperationsListSample.ts b/sdk/domainservices/arm-domainservices/samples-dev/domainServiceOperationsListSample.ts new file mode 100644 index 000000000000..46397d070ad6 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples-dev/domainServiceOperationsListSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { DomainServicesResourceProvider } from "@azure/arm-domainservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists all the available Domain Services operations. + * + * @summary Lists all the available Domain Services operations. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetOperations.json + */ +async function getOperations() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.domainServiceOperations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +getOperations().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples-dev/domainServicesCreateOrUpdateSample.ts b/sdk/domainservices/arm-domainservices/samples-dev/domainServicesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..596bb29727f3 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples-dev/domainServicesCreateOrUpdateSample.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 { + DomainService, + DomainServicesResourceProvider +} from "@azure/arm-domainservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to The Create Domain Service operation creates a new domain service with the specified parameters. If the specific service already exists, then any patchable properties will be updated and any immutable properties will remain unchanged. + * + * @summary The Create Domain Service operation creates a new domain service with the specified parameters. If the specific service already exists, then any patchable properties will be updated and any immutable properties will remain unchanged. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/CreateDomainService.json + */ +async function createDomainService() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "TestResourceGroup"; + const domainServiceName = "TestDomainService.com"; + const domainService: DomainService = { + domainName: "TestDomainService.com", + domainSecuritySettings: { + ntlmV1: "Enabled", + syncNtlmPasswords: "Enabled", + tlsV1: "Disabled" + }, + filteredSync: "Enabled", + ldapsSettings: { + externalAccess: "Enabled", + ldaps: "Enabled", + pfxCertificate: + "MIIDPDCCAiSgAwIBAgIQQUI9P6tq2p9OFIJa7DLNvTANBgkqhkiG9w0BAQsFADAgMR4w...", + pfxCertificatePassword: "" + }, + notificationSettings: { + additionalRecipients: ["jicha@microsoft.com", "caalmont@microsoft.com"], + notifyDcAdmins: "Enabled", + notifyGlobalAdmins: "Enabled" + }, + replicaSets: [ + { + location: "West US", + subnetId: + "/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/TestNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/TestVnetWUS/subnets/TestSubnetWUS" + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const result = await client.domainServices.beginCreateOrUpdateAndWait( + resourceGroupName, + domainServiceName, + domainService + ); + console.log(result); +} + +createDomainService().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples-dev/domainServicesDeleteSample.ts b/sdk/domainservices/arm-domainservices/samples-dev/domainServicesDeleteSample.ts new file mode 100644 index 000000000000..43cd6f53e8c0 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples-dev/domainServicesDeleteSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { DomainServicesResourceProvider } from "@azure/arm-domainservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to The Delete Domain Service operation deletes an existing Domain Service. + * + * @summary The Delete Domain Service operation deletes an existing Domain Service. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/DeleteDomainService.json + */ +async function deleteDomainService() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "TestResourceGroup"; + const domainServiceName = "TestDomainService.com"; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const result = await client.domainServices.beginDeleteAndWait( + resourceGroupName, + domainServiceName + ); + console.log(result); +} + +deleteDomainService().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples-dev/domainServicesGetSample.ts b/sdk/domainservices/arm-domainservices/samples-dev/domainServicesGetSample.ts new file mode 100644 index 000000000000..a7b370a594ef --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples-dev/domainServicesGetSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { DomainServicesResourceProvider } from "@azure/arm-domainservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to The Get Domain Service operation retrieves a json representation of the Domain Service. + * + * @summary The Get Domain Service operation retrieves a json representation of the Domain Service. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetDomainService.json + */ +async function getDomainService() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "TestResourceGroup"; + const domainServiceName = "TestDomainService.com"; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const result = await client.domainServices.get( + resourceGroupName, + domainServiceName + ); + console.log(result); +} + +getDomainService().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples-dev/domainServicesListByResourceGroupSample.ts b/sdk/domainservices/arm-domainservices/samples-dev/domainServicesListByResourceGroupSample.ts new file mode 100644 index 000000000000..0e9ac5566571 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples-dev/domainServicesListByResourceGroupSample.ts @@ -0,0 +1,34 @@ +/* + * 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 { DomainServicesResourceProvider } from "@azure/arm-domainservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to The List Domain Services in Resource Group operation lists all the domain services available under the given resource group. + * + * @summary The List Domain Services in Resource Group operation lists all the domain services available under the given resource group. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/ListDomainServicesByResourceGroup.json + */ +async function listDomainService() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "TestResourceGroup"; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.domainServices.listByResourceGroup( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listDomainService().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples-dev/domainServicesListSample.ts b/sdk/domainservices/arm-domainservices/samples-dev/domainServicesListSample.ts new file mode 100644 index 000000000000..b8a0abc0acc3 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples-dev/domainServicesListSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { DomainServicesResourceProvider } from "@azure/arm-domainservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to The List Domain Services in Subscription operation lists all the domain services available under the given subscription (and across all resource groups within that subscription). + * + * @summary The List Domain Services in Subscription operation lists all the domain services available under the given subscription (and across all resource groups within that subscription). + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/ListDomainServicesBySubscription.json + */ +async function listDomainService() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.domainServices.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listDomainService().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples-dev/domainServicesUpdateSample.ts b/sdk/domainservices/arm-domainservices/samples-dev/domainServicesUpdateSample.ts new file mode 100644 index 000000000000..6d7cce3d8de2 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples-dev/domainServicesUpdateSample.ts @@ -0,0 +1,80 @@ +/* + * 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 { + DomainService, + DomainServicesResourceProvider +} from "@azure/arm-domainservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to The Update Domain Service operation can be used to update the existing deployment. The update call only supports the properties listed in the PATCH body. + * + * @summary The Update Domain Service operation can be used to update the existing deployment. The update call only supports the properties listed in the PATCH body. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/UpdateDomainService.json + */ +async function updateDomainService() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "TestResourceGroup"; + const domainServiceName = "TestDomainService.com"; + const domainService: DomainService = { + configDiagnostics: { + lastExecuted: new Date("2021-05-05T12:00:23Z;"), + validatorResults: [ + { + issues: [{ descriptionParams: [], id: "AADDS-CFG-DIAG-I20" }], + replicaSetSubnetDisplayName: "West US/aadds-subnet", + status: "Warning", + validatorId: "AADDS-CFG-DIAG-V06" + } + ] + }, + domainSecuritySettings: { + ntlmV1: "Enabled", + syncNtlmPasswords: "Enabled", + tlsV1: "Disabled" + }, + filteredSync: "Enabled", + ldapsSettings: { + externalAccess: "Enabled", + ldaps: "Enabled", + pfxCertificate: + "MIIDPDCCAiSgAwIBAgIQQUI9P6tq2p9OFIJa7DLNvTANBgkqhkiG9w0BAQsFADAgMR4w...", + pfxCertificatePassword: "" + }, + notificationSettings: { + additionalRecipients: ["jicha@microsoft.com", "caalmont@microsoft.com"], + notifyDcAdmins: "Enabled", + notifyGlobalAdmins: "Enabled" + }, + replicaSets: [ + { + location: "West US", + subnetId: + "/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/TestNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/TestVnetWUS/subnets/TestSubnetWUS" + }, + { + location: "East US", + subnetId: + "/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/TestNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/TestVnetEUS/subnets/TestSubnetEUS" + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const result = await client.domainServices.beginUpdateAndWait( + resourceGroupName, + domainServiceName, + domainService + ); + console.log(result); +} + +updateDomainService().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples-dev/ouContainerCreateSample.ts b/sdk/domainservices/arm-domainservices/samples-dev/ouContainerCreateSample.ts new file mode 100644 index 000000000000..0bf93b5a6b35 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples-dev/ouContainerCreateSample.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 { + ContainerAccount, + DomainServicesResourceProvider +} from "@azure/arm-domainservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to The Create OuContainer operation creates a new OuContainer under the specified Domain Service instance. + * + * @summary The Create OuContainer operation creates a new OuContainer under the specified Domain Service instance. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/CreateOuContainer.json + */ +async function createDomainService() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "OuContainerResourceGroup"; + const domainServiceName = "OuContainer.com"; + const ouContainerName = "OuContainer1"; + const containerAccount: ContainerAccount = { + accountName: "AccountName1", + password: "", + spn: "Spn1" + }; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const result = await client.ouContainerOperationGrp.beginCreateAndWait( + resourceGroupName, + domainServiceName, + ouContainerName, + containerAccount + ); + console.log(result); +} + +createDomainService().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples-dev/ouContainerDeleteSample.ts b/sdk/domainservices/arm-domainservices/samples-dev/ouContainerDeleteSample.ts new file mode 100644 index 000000000000..2dd0ed856f77 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples-dev/ouContainerDeleteSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { DomainServicesResourceProvider } from "@azure/arm-domainservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to The Delete OuContainer operation deletes specified OuContainer. + * + * @summary The Delete OuContainer operation deletes specified OuContainer. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/DeleteOuContainer.json + */ +async function deleteOuContainer() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "OuContainerResourceGroup"; + const domainServiceName = "OuContainer.com"; + const ouContainerName = "OuContainer1"; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const result = await client.ouContainerOperationGrp.beginDeleteAndWait( + resourceGroupName, + domainServiceName, + ouContainerName + ); + console.log(result); +} + +deleteOuContainer().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples-dev/ouContainerGetSample.ts b/sdk/domainservices/arm-domainservices/samples-dev/ouContainerGetSample.ts new file mode 100644 index 000000000000..9543df2c2a5d --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples-dev/ouContainerGetSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { DomainServicesResourceProvider } from "@azure/arm-domainservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Get OuContainer in DomainService instance. + * + * @summary Get OuContainer in DomainService instance. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetOuContainer.json + */ +async function listOfOuContainers() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "OuContainerResourceGroup"; + const domainServiceName = "OuContainer.com"; + const ouContainerName = "OuContainer1"; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const result = await client.ouContainerOperationGrp.get( + resourceGroupName, + domainServiceName, + ouContainerName + ); + console.log(result); +} + +listOfOuContainers().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples-dev/ouContainerListSample.ts b/sdk/domainservices/arm-domainservices/samples-dev/ouContainerListSample.ts new file mode 100644 index 000000000000..dfb1031be7fe --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples-dev/ouContainerListSample.ts @@ -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. +import { DomainServicesResourceProvider } from "@azure/arm-domainservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to The List of OuContainers in DomainService instance. + * + * @summary The List of OuContainers in DomainService instance. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/ListOuContainers.json + */ +async function listOfOuContainers() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "OuContainerResourceGroup"; + const domainServiceName = "OuContainer.com"; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.ouContainerOperationGrp.list( + resourceGroupName, + domainServiceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listOfOuContainers().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples-dev/ouContainerOperationsListSample.ts b/sdk/domainservices/arm-domainservices/samples-dev/ouContainerOperationsListSample.ts new file mode 100644 index 000000000000..f5860e2ea24f --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples-dev/ouContainerOperationsListSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { DomainServicesResourceProvider } from "@azure/arm-domainservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists all the available OuContainer operations. + * + * @summary Lists all the available OuContainer operations. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetOperations.json + */ +async function getOperations() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.ouContainerOperations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +getOperations().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples-dev/ouContainerUpdateSample.ts b/sdk/domainservices/arm-domainservices/samples-dev/ouContainerUpdateSample.ts new file mode 100644 index 000000000000..840b8fa01f58 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples-dev/ouContainerUpdateSample.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 { + ContainerAccount, + DomainServicesResourceProvider +} from "@azure/arm-domainservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to The Update OuContainer operation can be used to update the existing OuContainers. + * + * @summary The Update OuContainer operation can be used to update the existing OuContainers. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/UpdateOuContainer.json + */ +async function updateDomainService() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "OuContainerResourceGroup"; + const domainServiceName = "OuContainer.com"; + const ouContainerName = "OuContainer1"; + const containerAccount: ContainerAccount = { + accountName: "AccountName1", + password: "", + spn: "Spn1" + }; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const result = await client.ouContainerOperationGrp.beginUpdateAndWait( + resourceGroupName, + domainServiceName, + ouContainerName, + containerAccount + ); + console.log(result); +} + +updateDomainService().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples/v4/javascript/README.md b/sdk/domainservices/arm-domainservices/samples/v4/javascript/README.md new file mode 100644 index 000000000000..9da5f3cea127 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/javascript/README.md @@ -0,0 +1,74 @@ +# client library samples for JavaScript + +These sample programs show how to use the JavaScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| ------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [domainServiceOperationsListSample.js][domainserviceoperationslistsample] | Lists all the available Domain Services operations. x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetOperations.json | +| [domainServicesCreateOrUpdateSample.js][domainservicescreateorupdatesample] | The Create Domain Service operation creates a new domain service with the specified parameters. If the specific service already exists, then any patchable properties will be updated and any immutable properties will remain unchanged. x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/CreateDomainService.json | +| [domainServicesDeleteSample.js][domainservicesdeletesample] | The Delete Domain Service operation deletes an existing Domain Service. x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/DeleteDomainService.json | +| [domainServicesGetSample.js][domainservicesgetsample] | The Get Domain Service operation retrieves a json representation of the Domain Service. x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetDomainService.json | +| [domainServicesListByResourceGroupSample.js][domainserviceslistbyresourcegroupsample] | The List Domain Services in Resource Group operation lists all the domain services available under the given resource group. x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/ListDomainServicesByResourceGroup.json | +| [domainServicesListSample.js][domainserviceslistsample] | The List Domain Services in Subscription operation lists all the domain services available under the given subscription (and across all resource groups within that subscription). x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/ListDomainServicesBySubscription.json | +| [domainServicesUpdateSample.js][domainservicesupdatesample] | The Update Domain Service operation can be used to update the existing deployment. The update call only supports the properties listed in the PATCH body. x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/UpdateDomainService.json | +| [ouContainerCreateSample.js][oucontainercreatesample] | The Create OuContainer operation creates a new OuContainer under the specified Domain Service instance. x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/CreateOuContainer.json | +| [ouContainerDeleteSample.js][oucontainerdeletesample] | The Delete OuContainer operation deletes specified OuContainer. x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/DeleteOuContainer.json | +| [ouContainerGetSample.js][oucontainergetsample] | Get OuContainer in DomainService instance. x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetOuContainer.json | +| [ouContainerListSample.js][oucontainerlistsample] | The List of OuContainers in DomainService instance. x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/ListOuContainers.json | +| [ouContainerOperationsListSample.js][oucontaineroperationslistsample] | Lists all the available OuContainer operations. x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetOperations.json | +| [ouContainerUpdateSample.js][oucontainerupdatesample] | The Update OuContainer operation can be used to update the existing OuContainers. x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/UpdateOuContainer.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +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 domainServiceOperationsListSample.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 node domainServiceOperationsListSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[domainserviceoperationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServiceOperationsListSample.js +[domainservicescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServicesCreateOrUpdateSample.js +[domainservicesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServicesDeleteSample.js +[domainservicesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServicesGetSample.js +[domainserviceslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServicesListByResourceGroupSample.js +[domainserviceslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServicesListSample.js +[domainservicesupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServicesUpdateSample.js +[oucontainercreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/domainservices/arm-domainservices/samples/v4/javascript/ouContainerCreateSample.js +[oucontainerdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/domainservices/arm-domainservices/samples/v4/javascript/ouContainerDeleteSample.js +[oucontainergetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/domainservices/arm-domainservices/samples/v4/javascript/ouContainerGetSample.js +[oucontainerlistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/domainservices/arm-domainservices/samples/v4/javascript/ouContainerListSample.js +[oucontaineroperationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/domainservices/arm-domainservices/samples/v4/javascript/ouContainerOperationsListSample.js +[oucontainerupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/domainservices/arm-domainservices/samples/v4/javascript/ouContainerUpdateSample.js +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-domainservices?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/domainservices/arm-domainservices/README.md diff --git a/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServiceOperationsListSample.js b/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServiceOperationsListSample.js new file mode 100644 index 000000000000..7547ec9c470d --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServiceOperationsListSample.js @@ -0,0 +1,31 @@ +/* + * 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 { DomainServicesResourceProvider } = require("@azure/arm-domainservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists all the available Domain Services operations. + * + * @summary Lists all the available Domain Services operations. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetOperations.json + */ +async function getOperations() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.domainServiceOperations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +getOperations().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServicesCreateOrUpdateSample.js b/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServicesCreateOrUpdateSample.js new file mode 100644 index 000000000000..0cecf78de314 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServicesCreateOrUpdateSample.js @@ -0,0 +1,61 @@ +/* + * 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 { DomainServicesResourceProvider } = require("@azure/arm-domainservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to The Create Domain Service operation creates a new domain service with the specified parameters. If the specific service already exists, then any patchable properties will be updated and any immutable properties will remain unchanged. + * + * @summary The Create Domain Service operation creates a new domain service with the specified parameters. If the specific service already exists, then any patchable properties will be updated and any immutable properties will remain unchanged. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/CreateDomainService.json + */ +async function createDomainService() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "TestResourceGroup"; + const domainServiceName = "TestDomainService.com"; + const domainService = { + domainName: "TestDomainService.com", + domainSecuritySettings: { + ntlmV1: "Enabled", + syncNtlmPasswords: "Enabled", + tlsV1: "Disabled", + }, + filteredSync: "Enabled", + ldapsSettings: { + externalAccess: "Enabled", + ldaps: "Enabled", + pfxCertificate: "MIIDPDCCAiSgAwIBAgIQQUI9P6tq2p9OFIJa7DLNvTANBgkqhkiG9w0BAQsFADAgMR4w...", + pfxCertificatePassword: "", + }, + notificationSettings: { + additionalRecipients: ["jicha@microsoft.com", "caalmont@microsoft.com"], + notifyDcAdmins: "Enabled", + notifyGlobalAdmins: "Enabled", + }, + replicaSets: [ + { + location: "West US", + subnetId: + "/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/TestNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/TestVnetWUS/subnets/TestSubnetWUS", + }, + ], + }; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const result = await client.domainServices.beginCreateOrUpdateAndWait( + resourceGroupName, + domainServiceName, + domainService + ); + console.log(result); +} + +createDomainService().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServicesDeleteSample.js b/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServicesDeleteSample.js new file mode 100644 index 000000000000..4e7278dd367e --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServicesDeleteSample.js @@ -0,0 +1,33 @@ +/* + * 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 { DomainServicesResourceProvider } = require("@azure/arm-domainservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to The Delete Domain Service operation deletes an existing Domain Service. + * + * @summary The Delete Domain Service operation deletes an existing Domain Service. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/DeleteDomainService.json + */ +async function deleteDomainService() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "TestResourceGroup"; + const domainServiceName = "TestDomainService.com"; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const result = await client.domainServices.beginDeleteAndWait( + resourceGroupName, + domainServiceName + ); + console.log(result); +} + +deleteDomainService().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServicesGetSample.js b/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServicesGetSample.js new file mode 100644 index 000000000000..a2b63a7424c6 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServicesGetSample.js @@ -0,0 +1,30 @@ +/* + * 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 { DomainServicesResourceProvider } = require("@azure/arm-domainservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to The Get Domain Service operation retrieves a json representation of the Domain Service. + * + * @summary The Get Domain Service operation retrieves a json representation of the Domain Service. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetDomainService.json + */ +async function getDomainService() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "TestResourceGroup"; + const domainServiceName = "TestDomainService.com"; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const result = await client.domainServices.get(resourceGroupName, domainServiceName); + console.log(result); +} + +getDomainService().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServicesListByResourceGroupSample.js b/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServicesListByResourceGroupSample.js new file mode 100644 index 000000000000..656e06bff1e4 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServicesListByResourceGroupSample.js @@ -0,0 +1,32 @@ +/* + * 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 { DomainServicesResourceProvider } = require("@azure/arm-domainservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to The List Domain Services in Resource Group operation lists all the domain services available under the given resource group. + * + * @summary The List Domain Services in Resource Group operation lists all the domain services available under the given resource group. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/ListDomainServicesByResourceGroup.json + */ +async function listDomainService() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "TestResourceGroup"; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.domainServices.listByResourceGroup(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +listDomainService().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServicesListSample.js b/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServicesListSample.js new file mode 100644 index 000000000000..8fe9441cdd05 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServicesListSample.js @@ -0,0 +1,31 @@ +/* + * 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 { DomainServicesResourceProvider } = require("@azure/arm-domainservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to The List Domain Services in Subscription operation lists all the domain services available under the given subscription (and across all resource groups within that subscription). + * + * @summary The List Domain Services in Subscription operation lists all the domain services available under the given subscription (and across all resource groups within that subscription). + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/ListDomainServicesBySubscription.json + */ +async function listDomainService() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.domainServices.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listDomainService().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServicesUpdateSample.js b/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServicesUpdateSample.js new file mode 100644 index 000000000000..1c16c69af144 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/javascript/domainServicesUpdateSample.js @@ -0,0 +1,76 @@ +/* + * 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 { DomainServicesResourceProvider } = require("@azure/arm-domainservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to The Update Domain Service operation can be used to update the existing deployment. The update call only supports the properties listed in the PATCH body. + * + * @summary The Update Domain Service operation can be used to update the existing deployment. The update call only supports the properties listed in the PATCH body. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/UpdateDomainService.json + */ +async function updateDomainService() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "TestResourceGroup"; + const domainServiceName = "TestDomainService.com"; + const domainService = { + configDiagnostics: { + lastExecuted: new Date("2021-05-05T12:00:23Z;"), + validatorResults: [ + { + issues: [{ descriptionParams: [], id: "AADDS-CFG-DIAG-I20" }], + replicaSetSubnetDisplayName: "West US/aadds-subnet", + status: "Warning", + validatorId: "AADDS-CFG-DIAG-V06", + }, + ], + }, + domainSecuritySettings: { + ntlmV1: "Enabled", + syncNtlmPasswords: "Enabled", + tlsV1: "Disabled", + }, + filteredSync: "Enabled", + ldapsSettings: { + externalAccess: "Enabled", + ldaps: "Enabled", + pfxCertificate: "MIIDPDCCAiSgAwIBAgIQQUI9P6tq2p9OFIJa7DLNvTANBgkqhkiG9w0BAQsFADAgMR4w...", + pfxCertificatePassword: "", + }, + notificationSettings: { + additionalRecipients: ["jicha@microsoft.com", "caalmont@microsoft.com"], + notifyDcAdmins: "Enabled", + notifyGlobalAdmins: "Enabled", + }, + replicaSets: [ + { + location: "West US", + subnetId: + "/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/TestNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/TestVnetWUS/subnets/TestSubnetWUS", + }, + { + location: "East US", + subnetId: + "/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/TestNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/TestVnetEUS/subnets/TestSubnetEUS", + }, + ], + }; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const result = await client.domainServices.beginUpdateAndWait( + resourceGroupName, + domainServiceName, + domainService + ); + console.log(result); +} + +updateDomainService().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples/v4/javascript/ouContainerCreateSample.js b/sdk/domainservices/arm-domainservices/samples/v4/javascript/ouContainerCreateSample.js new file mode 100644 index 000000000000..4679bbcfca22 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/javascript/ouContainerCreateSample.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 { DomainServicesResourceProvider } = require("@azure/arm-domainservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to The Create OuContainer operation creates a new OuContainer under the specified Domain Service instance. + * + * @summary The Create OuContainer operation creates a new OuContainer under the specified Domain Service instance. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/CreateOuContainer.json + */ +async function createDomainService() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "OuContainerResourceGroup"; + const domainServiceName = "OuContainer.com"; + const ouContainerName = "OuContainer1"; + const containerAccount = { + accountName: "AccountName1", + password: "", + spn: "Spn1", + }; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const result = await client.ouContainerOperationGrp.beginCreateAndWait( + resourceGroupName, + domainServiceName, + ouContainerName, + containerAccount + ); + console.log(result); +} + +createDomainService().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples/v4/javascript/ouContainerDeleteSample.js b/sdk/domainservices/arm-domainservices/samples/v4/javascript/ouContainerDeleteSample.js new file mode 100644 index 000000000000..360a926d775e --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/javascript/ouContainerDeleteSample.js @@ -0,0 +1,35 @@ +/* + * 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 { DomainServicesResourceProvider } = require("@azure/arm-domainservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to The Delete OuContainer operation deletes specified OuContainer. + * + * @summary The Delete OuContainer operation deletes specified OuContainer. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/DeleteOuContainer.json + */ +async function deleteOuContainer() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "OuContainerResourceGroup"; + const domainServiceName = "OuContainer.com"; + const ouContainerName = "OuContainer1"; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const result = await client.ouContainerOperationGrp.beginDeleteAndWait( + resourceGroupName, + domainServiceName, + ouContainerName + ); + console.log(result); +} + +deleteOuContainer().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples/v4/javascript/ouContainerGetSample.js b/sdk/domainservices/arm-domainservices/samples/v4/javascript/ouContainerGetSample.js new file mode 100644 index 000000000000..10108b715731 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/javascript/ouContainerGetSample.js @@ -0,0 +1,35 @@ +/* + * 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 { DomainServicesResourceProvider } = require("@azure/arm-domainservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Get OuContainer in DomainService instance. + * + * @summary Get OuContainer in DomainService instance. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetOuContainer.json + */ +async function listOfOuContainers() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "OuContainerResourceGroup"; + const domainServiceName = "OuContainer.com"; + const ouContainerName = "OuContainer1"; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const result = await client.ouContainerOperationGrp.get( + resourceGroupName, + domainServiceName, + ouContainerName + ); + console.log(result); +} + +listOfOuContainers().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples/v4/javascript/ouContainerListSample.js b/sdk/domainservices/arm-domainservices/samples/v4/javascript/ouContainerListSample.js new file mode 100644 index 000000000000..2375f4f544c4 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/javascript/ouContainerListSample.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 { DomainServicesResourceProvider } = require("@azure/arm-domainservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to The List of OuContainers in DomainService instance. + * + * @summary The List of OuContainers in DomainService instance. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/ListOuContainers.json + */ +async function listOfOuContainers() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "OuContainerResourceGroup"; + const domainServiceName = "OuContainer.com"; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.ouContainerOperationGrp.list( + resourceGroupName, + domainServiceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listOfOuContainers().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples/v4/javascript/ouContainerOperationsListSample.js b/sdk/domainservices/arm-domainservices/samples/v4/javascript/ouContainerOperationsListSample.js new file mode 100644 index 000000000000..77a724a94273 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/javascript/ouContainerOperationsListSample.js @@ -0,0 +1,31 @@ +/* + * 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 { DomainServicesResourceProvider } = require("@azure/arm-domainservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists all the available OuContainer operations. + * + * @summary Lists all the available OuContainer operations. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetOperations.json + */ +async function getOperations() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.ouContainerOperations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +getOperations().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples/v4/javascript/ouContainerUpdateSample.js b/sdk/domainservices/arm-domainservices/samples/v4/javascript/ouContainerUpdateSample.js new file mode 100644 index 000000000000..6b8445cc95b1 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/javascript/ouContainerUpdateSample.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 { DomainServicesResourceProvider } = require("@azure/arm-domainservices"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to The Update OuContainer operation can be used to update the existing OuContainers. + * + * @summary The Update OuContainer operation can be used to update the existing OuContainers. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/UpdateOuContainer.json + */ +async function updateDomainService() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "OuContainerResourceGroup"; + const domainServiceName = "OuContainer.com"; + const ouContainerName = "OuContainer1"; + const containerAccount = { + accountName: "AccountName1", + password: "", + spn: "Spn1", + }; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const result = await client.ouContainerOperationGrp.beginUpdateAndWait( + resourceGroupName, + domainServiceName, + ouContainerName, + containerAccount + ); + console.log(result); +} + +updateDomainService().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples/v4/javascript/package.json b/sdk/domainservices/arm-domainservices/samples/v4/javascript/package.json new file mode 100644 index 000000000000..d69c2ddb39d6 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/javascript/package.json @@ -0,0 +1,32 @@ +{ + "name": "@azure-samples/arm-domainservices-js", + "private": true, + "version": "1.0.0", + "description": " client library samples for JavaScript", + "engines": { + "node": ">=12.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/domainservices/arm-domainservices" + }, + "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/domainservices/arm-domainservices", + "dependencies": { + "@azure/arm-domainservices": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + } +} diff --git a/sdk/domainservices/arm-domainservices/samples/v4/javascript/sample.env b/sdk/domainservices/arm-domainservices/samples/v4/javascript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/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/domainservices/arm-domainservices/samples/v4/typescript/README.md b/sdk/domainservices/arm-domainservices/samples/v4/typescript/README.md new file mode 100644 index 000000000000..6889e055a12e --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/typescript/README.md @@ -0,0 +1,87 @@ +# client library samples for TypeScript + +These sample programs show how to use the TypeScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| ------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [domainServiceOperationsListSample.ts][domainserviceoperationslistsample] | Lists all the available Domain Services operations. x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetOperations.json | +| [domainServicesCreateOrUpdateSample.ts][domainservicescreateorupdatesample] | The Create Domain Service operation creates a new domain service with the specified parameters. If the specific service already exists, then any patchable properties will be updated and any immutable properties will remain unchanged. x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/CreateDomainService.json | +| [domainServicesDeleteSample.ts][domainservicesdeletesample] | The Delete Domain Service operation deletes an existing Domain Service. x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/DeleteDomainService.json | +| [domainServicesGetSample.ts][domainservicesgetsample] | The Get Domain Service operation retrieves a json representation of the Domain Service. x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetDomainService.json | +| [domainServicesListByResourceGroupSample.ts][domainserviceslistbyresourcegroupsample] | The List Domain Services in Resource Group operation lists all the domain services available under the given resource group. x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/ListDomainServicesByResourceGroup.json | +| [domainServicesListSample.ts][domainserviceslistsample] | The List Domain Services in Subscription operation lists all the domain services available under the given subscription (and across all resource groups within that subscription). x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/ListDomainServicesBySubscription.json | +| [domainServicesUpdateSample.ts][domainservicesupdatesample] | The Update Domain Service operation can be used to update the existing deployment. The update call only supports the properties listed in the PATCH body. x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/UpdateDomainService.json | +| [ouContainerCreateSample.ts][oucontainercreatesample] | The Create OuContainer operation creates a new OuContainer under the specified Domain Service instance. x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/CreateOuContainer.json | +| [ouContainerDeleteSample.ts][oucontainerdeletesample] | The Delete OuContainer operation deletes specified OuContainer. x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/DeleteOuContainer.json | +| [ouContainerGetSample.ts][oucontainergetsample] | Get OuContainer in DomainService instance. x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetOuContainer.json | +| [ouContainerListSample.ts][oucontainerlistsample] | The List of OuContainers in DomainService instance. x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/ListOuContainers.json | +| [ouContainerOperationsListSample.ts][oucontaineroperationslistsample] | Lists all the available OuContainer operations. x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetOperations.json | +| [ouContainerUpdateSample.ts][oucontainerupdatesample] | The Update OuContainer operation can be used to update the existing OuContainers. x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/UpdateOuContainer.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +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/domainServiceOperationsListSample.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 node dist/domainServiceOperationsListSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[domainserviceoperationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/domainServiceOperationsListSample.ts +[domainservicescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/domainServicesCreateOrUpdateSample.ts +[domainservicesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/domainServicesDeleteSample.ts +[domainservicesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/domainServicesGetSample.ts +[domainserviceslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/domainServicesListByResourceGroupSample.ts +[domainserviceslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/domainServicesListSample.ts +[domainservicesupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/domainServicesUpdateSample.ts +[oucontainercreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/ouContainerCreateSample.ts +[oucontainerdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/ouContainerDeleteSample.ts +[oucontainergetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/ouContainerGetSample.ts +[oucontainerlistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/ouContainerListSample.ts +[oucontaineroperationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/ouContainerOperationsListSample.ts +[oucontainerupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/ouContainerUpdateSample.ts +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-domainservices?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/domainservices/arm-domainservices/README.md +[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/domainservices/arm-domainservices/samples/v4/typescript/package.json b/sdk/domainservices/arm-domainservices/samples/v4/typescript/package.json new file mode 100644 index 000000000000..83dd80c289bd --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/typescript/package.json @@ -0,0 +1,41 @@ +{ + "name": "@azure-samples/arm-domainservices-ts", + "private": true, + "version": "1.0.0", + "description": " client library samples for TypeScript", + "engines": { + "node": ">=12.0.0" + }, + "scripts": { + "build": "tsc", + "prebuild": "rimraf dist/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/domainservices/arm-domainservices" + }, + "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/domainservices/arm-domainservices", + "dependencies": { + "@azure/arm-domainservices": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + }, + "devDependencies": { + "@types/node": "^12.0.0", + "typescript": "~4.4.0", + "rimraf": "latest" + } +} diff --git a/sdk/domainservices/arm-domainservices/samples/v4/typescript/sample.env b/sdk/domainservices/arm-domainservices/samples/v4/typescript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/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/domainservices/arm-domainservices/samples/v4/typescript/src/domainServiceOperationsListSample.ts b/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/domainServiceOperationsListSample.ts new file mode 100644 index 000000000000..46397d070ad6 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/domainServiceOperationsListSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { DomainServicesResourceProvider } from "@azure/arm-domainservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists all the available Domain Services operations. + * + * @summary Lists all the available Domain Services operations. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetOperations.json + */ +async function getOperations() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.domainServiceOperations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +getOperations().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/domainServicesCreateOrUpdateSample.ts b/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/domainServicesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..596bb29727f3 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/domainServicesCreateOrUpdateSample.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 { + DomainService, + DomainServicesResourceProvider +} from "@azure/arm-domainservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to The Create Domain Service operation creates a new domain service with the specified parameters. If the specific service already exists, then any patchable properties will be updated and any immutable properties will remain unchanged. + * + * @summary The Create Domain Service operation creates a new domain service with the specified parameters. If the specific service already exists, then any patchable properties will be updated and any immutable properties will remain unchanged. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/CreateDomainService.json + */ +async function createDomainService() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "TestResourceGroup"; + const domainServiceName = "TestDomainService.com"; + const domainService: DomainService = { + domainName: "TestDomainService.com", + domainSecuritySettings: { + ntlmV1: "Enabled", + syncNtlmPasswords: "Enabled", + tlsV1: "Disabled" + }, + filteredSync: "Enabled", + ldapsSettings: { + externalAccess: "Enabled", + ldaps: "Enabled", + pfxCertificate: + "MIIDPDCCAiSgAwIBAgIQQUI9P6tq2p9OFIJa7DLNvTANBgkqhkiG9w0BAQsFADAgMR4w...", + pfxCertificatePassword: "" + }, + notificationSettings: { + additionalRecipients: ["jicha@microsoft.com", "caalmont@microsoft.com"], + notifyDcAdmins: "Enabled", + notifyGlobalAdmins: "Enabled" + }, + replicaSets: [ + { + location: "West US", + subnetId: + "/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/TestNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/TestVnetWUS/subnets/TestSubnetWUS" + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const result = await client.domainServices.beginCreateOrUpdateAndWait( + resourceGroupName, + domainServiceName, + domainService + ); + console.log(result); +} + +createDomainService().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/domainServicesDeleteSample.ts b/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/domainServicesDeleteSample.ts new file mode 100644 index 000000000000..43cd6f53e8c0 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/domainServicesDeleteSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { DomainServicesResourceProvider } from "@azure/arm-domainservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to The Delete Domain Service operation deletes an existing Domain Service. + * + * @summary The Delete Domain Service operation deletes an existing Domain Service. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/DeleteDomainService.json + */ +async function deleteDomainService() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "TestResourceGroup"; + const domainServiceName = "TestDomainService.com"; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const result = await client.domainServices.beginDeleteAndWait( + resourceGroupName, + domainServiceName + ); + console.log(result); +} + +deleteDomainService().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/domainServicesGetSample.ts b/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/domainServicesGetSample.ts new file mode 100644 index 000000000000..a7b370a594ef --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/domainServicesGetSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { DomainServicesResourceProvider } from "@azure/arm-domainservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to The Get Domain Service operation retrieves a json representation of the Domain Service. + * + * @summary The Get Domain Service operation retrieves a json representation of the Domain Service. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetDomainService.json + */ +async function getDomainService() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "TestResourceGroup"; + const domainServiceName = "TestDomainService.com"; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const result = await client.domainServices.get( + resourceGroupName, + domainServiceName + ); + console.log(result); +} + +getDomainService().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/domainServicesListByResourceGroupSample.ts b/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/domainServicesListByResourceGroupSample.ts new file mode 100644 index 000000000000..0e9ac5566571 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/domainServicesListByResourceGroupSample.ts @@ -0,0 +1,34 @@ +/* + * 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 { DomainServicesResourceProvider } from "@azure/arm-domainservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to The List Domain Services in Resource Group operation lists all the domain services available under the given resource group. + * + * @summary The List Domain Services in Resource Group operation lists all the domain services available under the given resource group. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/ListDomainServicesByResourceGroup.json + */ +async function listDomainService() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "TestResourceGroup"; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.domainServices.listByResourceGroup( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listDomainService().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/domainServicesListSample.ts b/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/domainServicesListSample.ts new file mode 100644 index 000000000000..b8a0abc0acc3 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/domainServicesListSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { DomainServicesResourceProvider } from "@azure/arm-domainservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to The List Domain Services in Subscription operation lists all the domain services available under the given subscription (and across all resource groups within that subscription). + * + * @summary The List Domain Services in Subscription operation lists all the domain services available under the given subscription (and across all resource groups within that subscription). + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/ListDomainServicesBySubscription.json + */ +async function listDomainService() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.domainServices.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listDomainService().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/domainServicesUpdateSample.ts b/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/domainServicesUpdateSample.ts new file mode 100644 index 000000000000..6d7cce3d8de2 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/domainServicesUpdateSample.ts @@ -0,0 +1,80 @@ +/* + * 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 { + DomainService, + DomainServicesResourceProvider +} from "@azure/arm-domainservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to The Update Domain Service operation can be used to update the existing deployment. The update call only supports the properties listed in the PATCH body. + * + * @summary The Update Domain Service operation can be used to update the existing deployment. The update call only supports the properties listed in the PATCH body. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/UpdateDomainService.json + */ +async function updateDomainService() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "TestResourceGroup"; + const domainServiceName = "TestDomainService.com"; + const domainService: DomainService = { + configDiagnostics: { + lastExecuted: new Date("2021-05-05T12:00:23Z;"), + validatorResults: [ + { + issues: [{ descriptionParams: [], id: "AADDS-CFG-DIAG-I20" }], + replicaSetSubnetDisplayName: "West US/aadds-subnet", + status: "Warning", + validatorId: "AADDS-CFG-DIAG-V06" + } + ] + }, + domainSecuritySettings: { + ntlmV1: "Enabled", + syncNtlmPasswords: "Enabled", + tlsV1: "Disabled" + }, + filteredSync: "Enabled", + ldapsSettings: { + externalAccess: "Enabled", + ldaps: "Enabled", + pfxCertificate: + "MIIDPDCCAiSgAwIBAgIQQUI9P6tq2p9OFIJa7DLNvTANBgkqhkiG9w0BAQsFADAgMR4w...", + pfxCertificatePassword: "" + }, + notificationSettings: { + additionalRecipients: ["jicha@microsoft.com", "caalmont@microsoft.com"], + notifyDcAdmins: "Enabled", + notifyGlobalAdmins: "Enabled" + }, + replicaSets: [ + { + location: "West US", + subnetId: + "/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/TestNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/TestVnetWUS/subnets/TestSubnetWUS" + }, + { + location: "East US", + subnetId: + "/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/TestNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/TestVnetEUS/subnets/TestSubnetEUS" + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const result = await client.domainServices.beginUpdateAndWait( + resourceGroupName, + domainServiceName, + domainService + ); + console.log(result); +} + +updateDomainService().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/ouContainerCreateSample.ts b/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/ouContainerCreateSample.ts new file mode 100644 index 000000000000..0bf93b5a6b35 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/ouContainerCreateSample.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 { + ContainerAccount, + DomainServicesResourceProvider +} from "@azure/arm-domainservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to The Create OuContainer operation creates a new OuContainer under the specified Domain Service instance. + * + * @summary The Create OuContainer operation creates a new OuContainer under the specified Domain Service instance. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/CreateOuContainer.json + */ +async function createDomainService() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "OuContainerResourceGroup"; + const domainServiceName = "OuContainer.com"; + const ouContainerName = "OuContainer1"; + const containerAccount: ContainerAccount = { + accountName: "AccountName1", + password: "", + spn: "Spn1" + }; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const result = await client.ouContainerOperationGrp.beginCreateAndWait( + resourceGroupName, + domainServiceName, + ouContainerName, + containerAccount + ); + console.log(result); +} + +createDomainService().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/ouContainerDeleteSample.ts b/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/ouContainerDeleteSample.ts new file mode 100644 index 000000000000..2dd0ed856f77 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/ouContainerDeleteSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { DomainServicesResourceProvider } from "@azure/arm-domainservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to The Delete OuContainer operation deletes specified OuContainer. + * + * @summary The Delete OuContainer operation deletes specified OuContainer. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/DeleteOuContainer.json + */ +async function deleteOuContainer() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "OuContainerResourceGroup"; + const domainServiceName = "OuContainer.com"; + const ouContainerName = "OuContainer1"; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const result = await client.ouContainerOperationGrp.beginDeleteAndWait( + resourceGroupName, + domainServiceName, + ouContainerName + ); + console.log(result); +} + +deleteOuContainer().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/ouContainerGetSample.ts b/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/ouContainerGetSample.ts new file mode 100644 index 000000000000..9543df2c2a5d --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/ouContainerGetSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { DomainServicesResourceProvider } from "@azure/arm-domainservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Get OuContainer in DomainService instance. + * + * @summary Get OuContainer in DomainService instance. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetOuContainer.json + */ +async function listOfOuContainers() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "OuContainerResourceGroup"; + const domainServiceName = "OuContainer.com"; + const ouContainerName = "OuContainer1"; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const result = await client.ouContainerOperationGrp.get( + resourceGroupName, + domainServiceName, + ouContainerName + ); + console.log(result); +} + +listOfOuContainers().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/ouContainerListSample.ts b/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/ouContainerListSample.ts new file mode 100644 index 000000000000..dfb1031be7fe --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/ouContainerListSample.ts @@ -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. +import { DomainServicesResourceProvider } from "@azure/arm-domainservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to The List of OuContainers in DomainService instance. + * + * @summary The List of OuContainers in DomainService instance. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/ListOuContainers.json + */ +async function listOfOuContainers() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "OuContainerResourceGroup"; + const domainServiceName = "OuContainer.com"; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.ouContainerOperationGrp.list( + resourceGroupName, + domainServiceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listOfOuContainers().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/ouContainerOperationsListSample.ts b/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/ouContainerOperationsListSample.ts new file mode 100644 index 000000000000..f5860e2ea24f --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/ouContainerOperationsListSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { DomainServicesResourceProvider } from "@azure/arm-domainservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists all the available OuContainer operations. + * + * @summary Lists all the available OuContainer operations. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/GetOperations.json + */ +async function getOperations() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.ouContainerOperations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +getOperations().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/ouContainerUpdateSample.ts b/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/ouContainerUpdateSample.ts new file mode 100644 index 000000000000..840b8fa01f58 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/typescript/src/ouContainerUpdateSample.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 { + ContainerAccount, + DomainServicesResourceProvider +} from "@azure/arm-domainservices"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to The Update OuContainer operation can be used to update the existing OuContainers. + * + * @summary The Update OuContainer operation can be used to update the existing OuContainers. + * x-ms-original-file: specification/domainservices/resource-manager/Microsoft.AAD/stable/2021-05-01/examples/UpdateOuContainer.json + */ +async function updateDomainService() { + const subscriptionId = "1639790a-76a2-4ac4-98d9-8562f5dfcb4d"; + const resourceGroupName = "OuContainerResourceGroup"; + const domainServiceName = "OuContainer.com"; + const ouContainerName = "OuContainer1"; + const containerAccount: ContainerAccount = { + accountName: "AccountName1", + password: "", + spn: "Spn1" + }; + const credential = new DefaultAzureCredential(); + const client = new DomainServicesResourceProvider(credential, subscriptionId); + const result = await client.ouContainerOperationGrp.beginUpdateAndWait( + resourceGroupName, + domainServiceName, + ouContainerName, + containerAccount + ); + console.log(result); +} + +updateDomainService().catch(console.error); diff --git a/sdk/domainservices/arm-domainservices/samples/v4/typescript/tsconfig.json b/sdk/domainservices/arm-domainservices/samples/v4/typescript/tsconfig.json new file mode 100644 index 000000000000..416c2dd82e00 --- /dev/null +++ b/sdk/domainservices/arm-domainservices/samples/v4/typescript/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2018", + "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/domainservices/arm-domainservices/src/domainServicesResourceProvider.ts b/sdk/domainservices/arm-domainservices/src/domainServicesResourceProvider.ts index 8aa2517dc4c9..4dd1c67c21e2 100644 --- a/sdk/domainservices/arm-domainservices/src/domainServicesResourceProvider.ts +++ b/sdk/domainservices/arm-domainservices/src/domainServicesResourceProvider.ts @@ -7,6 +7,7 @@ */ import * as coreClient from "@azure/core-client"; +import * as coreRestPipeline from "@azure/core-rest-pipeline"; import * as coreAuth from "@azure/core-auth"; import { DomainServiceOperationsImpl, @@ -55,7 +56,7 @@ export class DomainServicesResourceProvider extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-domainservices/4.0.0`; + const packageDetails = `azsdk-js-arm-domainservices/4.0.1`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` @@ -70,9 +71,33 @@ export class DomainServicesResourceProvider extends coreClient.ServiceClient { userAgentOptions: { userAgentPrefix }, - baseUri: options.endpoint || "https://management.azure.com" + baseUri: + options.endpoint ?? options.baseUri ?? "https://management.azure.com" }; super(optionsWithDefaults); + + if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { + const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies(); + const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( + (pipelinePolicy) => + pipelinePolicy.name === + coreRestPipeline.bearerTokenAuthenticationPolicyName + ); + if (!bearerTokenAuthenticationPolicyFound) { + this.pipeline.removePolicy({ + name: coreRestPipeline.bearerTokenAuthenticationPolicyName + }); + this.pipeline.addPolicy( + coreRestPipeline.bearerTokenAuthenticationPolicy({ + scopes: `${optionsWithDefaults.baseUri}/.default`, + challengeCallbacks: { + authorizeRequestOnChallenge: + coreClient.authorizeRequestOnClaimChallenge + } + }) + ); + } + } // Parameter assignments this.subscriptionId = subscriptionId; diff --git a/sdk/domainservices/arm-domainservices/src/operations/domainServices.ts b/sdk/domainservices/arm-domainservices/src/operations/domainServices.ts index 697404c11f89..2bf4081b5d1b 100644 --- a/sdk/domainservices/arm-domainservices/src/operations/domainServices.ts +++ b/sdk/domainservices/arm-domainservices/src/operations/domainServices.ts @@ -237,10 +237,12 @@ export class DomainServicesImpl implements DomainServices { { resourceGroupName, domainServiceName, domainService, options }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -342,10 +344,12 @@ export class DomainServicesImpl implements DomainServices { { resourceGroupName, domainServiceName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -432,10 +436,12 @@ export class DomainServicesImpl implements DomainServices { { resourceGroupName, domainServiceName, domainService, options }, updateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** diff --git a/sdk/domainservices/arm-domainservices/src/operations/ouContainerOperationGrp.ts b/sdk/domainservices/arm-domainservices/src/operations/ouContainerOperationGrp.ts index 023796db593e..21c38148988c 100644 --- a/sdk/domainservices/arm-domainservices/src/operations/ouContainerOperationGrp.ts +++ b/sdk/domainservices/arm-domainservices/src/operations/ouContainerOperationGrp.ts @@ -225,10 +225,12 @@ export class OuContainerOperationGrpImpl implements OuContainerOperationGrp { }, createOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -316,10 +318,12 @@ export class OuContainerOperationGrpImpl implements OuContainerOperationGrp { { resourceGroupName, domainServiceName, ouContainerName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -416,10 +420,12 @@ export class OuContainerOperationGrpImpl implements OuContainerOperationGrp { }, updateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** diff --git a/sdk/domainservices/arm-domainservices/tsconfig.json b/sdk/domainservices/arm-domainservices/tsconfig.json index 6e3251194117..b5a74cbfe488 100644 --- a/sdk/domainservices/arm-domainservices/tsconfig.json +++ b/sdk/domainservices/arm-domainservices/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-domainservices": [ + "./src/index" + ] + } }, - "include": ["./src/**/*.ts", "./test/**/*.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/domainservices/ci.mgmt.yml b/sdk/domainservices/ci.mgmt.yml index 30d67a10fc96..04a2ccfcf574 100644 --- a/sdk/domainservices/ci.mgmt.yml +++ b/sdk/domainservices/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,7 +9,7 @@ trigger: paths: include: - sdk/domainservices/ci.mgmt.yml - - sdk/domainservices/arm-domainservices/ + - sdk/domainservices/arm-domainservices pr: branches: include: @@ -22,12 +22,11 @@ pr: paths: include: - sdk/domainservices/ci.mgmt.yml - - sdk/domainservices/arm-domainservices/ - + - sdk/domainservices/arm-domainservices extends: template: /eng/pipelines/templates/stages/archetype-sdk-client.yml parameters: ServiceDirectory: domainservices Artifacts: - name: azure-arm-domainservices - safeName: azurearmdomainservices \ No newline at end of file + safeName: azurearmdomainservices diff --git a/sdk/eventhub/arm-eventhub/CHANGELOG.md b/sdk/eventhub/arm-eventhub/CHANGELOG.md index 9d88be8e3b7f..be5934e1f8b7 100644 --- a/sdk/eventhub/arm-eventhub/CHANGELOG.md +++ b/sdk/eventhub/arm-eventhub/CHANGELOG.md @@ -1,14 +1,10 @@ # Release History -## 5.0.1 (Unreleased) +## 5.0.1 (2022-04-18) -### Features Added +**features** -### Breaking Changes - -### Bugs Fixed - -### Other Changes + - Bug fix ## 5.0.0 (2021-12-09) diff --git a/sdk/eventhub/arm-eventhub/LICENSE b/sdk/eventhub/arm-eventhub/LICENSE index ccb63b166732..5d1d36e0af80 100644 --- a/sdk/eventhub/arm-eventhub/LICENSE +++ b/sdk/eventhub/arm-eventhub/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2021 Microsoft +Copyright (c) 2022 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/eventhub/arm-eventhub/README.md b/sdk/eventhub/arm-eventhub/README.md index 515409c1e257..30e17ffe6fc2 100644 --- a/sdk/eventhub/arm-eventhub/README.md +++ b/sdk/eventhub/arm-eventhub/README.md @@ -16,6 +16,8 @@ Azure Event Hubs client for managing Event Hubs Cluster, IPFilter Rules and Virt - [LTS versions of Node.js](https://nodejs.org/about/releases/) - 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]. @@ -49,8 +51,17 @@ For more information about how to create an Azure AD Application check out [this ```javascript const { EventHubManagementClient } = require("@azure/arm-eventhub"); 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 EventHubManagementClient(new DefaultAzureCredential(), subscriptionId); + +// For client-side applications running in the browser, use this code instead: +// const credential = new InteractiveBrowserCredential({ +// tenantId: "", +// clientId: "" +// }); +// const client = new EventHubManagementClient(credential, subscriptionId); ``` diff --git a/sdk/eventhub/arm-eventhub/_meta.json b/sdk/eventhub/arm-eventhub/_meta.json index f5aebbfc9fa4..987811d91e9c 100644 --- a/sdk/eventhub/arm-eventhub/_meta.json +++ b/sdk/eventhub/arm-eventhub/_meta.json @@ -1,7 +1,8 @@ { "commit": "d710fb7f40338ca6ef00e0a9680be0a3d4cf5059", - "readme": "specification/eventhub/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 --generate-test --typescript-sdks-folder=D:\\mydev\\azure-sdk-for-js ../azure-rest-api-specs/specification/eventhub/resource-manager/readme.md --use=@autorest/typescript@6.0.0-alpha.16.20211130.1", + "readme": "specification\\eventhub\\resource-manager\\readme.md", + "autorest_command": "autorest --version=3.7.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\work\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\eventhub\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-alpha.19.20220408.1 --generate-sample=true", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "use": "@autorest/typescript@6.0.0-alpha.16.20211130.1" + "release_tool": "@azure-tools/js-sdk-release-tools@2.2.6", + "use": "@autorest/typescript@6.0.0-alpha.19.20220408.1" } \ No newline at end of file diff --git a/sdk/eventhub/arm-eventhub/api-extractor.json b/sdk/eventhub/arm-eventhub/api-extractor.json index 32aeb099b712..76a8dc49b5c7 100644 --- a/sdk/eventhub/arm-eventhub/api-extractor.json +++ b/sdk/eventhub/arm-eventhub/api-extractor.json @@ -1,18 +1,31 @@ { "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", "mainEntryPointFilePath": "./dist-esm/src/index.d.ts", - "docModel": { "enabled": true }, - "apiReport": { "enabled": true, "reportFolder": "./review" }, + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, "dtsRollup": { "enabled": true, "untrimmedFilePath": "", "publicTrimmedFilePath": "./types/arm-eventhub.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/eventhub/arm-eventhub/package.json b/sdk/eventhub/arm-eventhub/package.json index 311d216cb656..b115637813a2 100644 --- a/sdk/eventhub/arm-eventhub/package.json +++ b/sdk/eventhub/arm-eventhub/package.json @@ -11,9 +11,9 @@ "@azure/core-lro": "^2.2.0", "@azure/abort-controller": "^1.0.0", "@azure/core-paging": "^1.2.0", - "@azure/core-client": "^1.0.0", + "@azure/core-client": "^1.5.0", "@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": [ @@ -30,12 +30,12 @@ "devDependencies": { "@microsoft/api-extractor": "^7.18.11", "@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-plugin-sourcemaps": "^0.4.2", + "rollup": "^2.66.1", + "rollup-plugin-sourcemaps": "^0.6.3", "typescript": "~4.2.0", "uglify-js": "^3.4.9", "rimraf": "^3.0.0", @@ -100,5 +100,21 @@ "docs": "echo skipped" }, "sideEffects": false, - "autoPublish": true + "//metadata": { + "constantPaths": [ + { + "path": "src/eventHubManagementClient.ts", + "prefix": "packageDetails" + } + ] + }, + "autoPublish": true, + "//sampleConfiguration": { + "productName": "", + "productSlugs": [ + "azure" + ], + "disableDocsMs": true, + "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-eventhub?view=azure-node-preview" + } } diff --git a/sdk/eventhub/arm-eventhub/rollup.config.js b/sdk/eventhub/arm-eventhub/rollup.config.js index 9be1955eb7f1..3f89d7309da5 100644 --- a/sdk/eventhub/arm-eventhub/rollup.config.js +++ b/sdk/eventhub/arm-eventhub/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/eventhub/arm-eventhub/sample.env b/sdk/eventhub/arm-eventhub/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/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/eventhub/arm-eventhub/samples-dev/clustersCreateOrUpdateSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/clustersCreateOrUpdateSample.ts new file mode 100644 index 000000000000..00703d2367b4 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/clustersCreateOrUpdateSample.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 { Cluster, EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates an instance of an Event Hubs Cluster. + * + * @summary Creates or updates an instance of an Event Hubs Cluster. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterPut.json + */ +async function clusterPut() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "myResourceGroup"; + const clusterName = "testCluster"; + const parameters: Cluster = { + location: "South Central US", + sku: { name: "Dedicated", capacity: 1 }, + tags: { tag1: "value1", tag2: "value2" } + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.clusters.beginCreateOrUpdateAndWait( + resourceGroupName, + clusterName, + parameters + ); + console.log(result); +} + +clusterPut().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/clustersDeleteSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/clustersDeleteSample.ts new file mode 100644 index 000000000000..348046fd171f --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/clustersDeleteSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes an existing Event Hubs Cluster. This operation is idempotent. + * + * @summary Deletes an existing Event Hubs Cluster. This operation is idempotent. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterDelete.json + */ +async function clusterDelete() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "myResourceGroup"; + const clusterName = "testCluster"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.clusters.beginDeleteAndWait( + resourceGroupName, + clusterName + ); + console.log(result); +} + +clusterDelete().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/clustersGetSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/clustersGetSample.ts new file mode 100644 index 000000000000..fb0784a5c4df --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/clustersGetSample.ts @@ -0,0 +1,30 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the resource description of the specified Event Hubs Cluster. + * + * @summary Gets the resource description of the specified Event Hubs Cluster. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterGet.json + */ +async function clusterGet() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "myResourceGroup"; + const clusterName = "testCluster"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.clusters.get(resourceGroupName, clusterName); + console.log(result); +} + +clusterGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/clustersListAvailableClusterRegionSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/clustersListAvailableClusterRegionSample.ts new file mode 100644 index 000000000000..a87fe8f4c05a --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/clustersListAvailableClusterRegionSample.ts @@ -0,0 +1,28 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to List the quantity of available pre-provisioned Event Hubs Clusters, indexed by Azure region. + * + * @summary List the quantity of available pre-provisioned Event Hubs Clusters, indexed by Azure region. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ListAvailableClustersGet.json + */ +async function listAvailableClusters() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.clusters.listAvailableClusterRegion(); + console.log(result); +} + +listAvailableClusters().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/clustersListByResourceGroupSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/clustersListByResourceGroupSample.ts new file mode 100644 index 000000000000..094f317cbb3a --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/clustersListByResourceGroupSample.ts @@ -0,0 +1,34 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists the available Event Hubs Clusters within an ARM resource group + * + * @summary Lists the available Event Hubs Clusters within an ARM resource group + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClustersListByResourceGroup.json + */ +async function clustersListByResourceGroup() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "myResourceGroup"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.clusters.listByResourceGroup( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +clustersListByResourceGroup().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/clustersListBySubscriptionSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/clustersListBySubscriptionSample.ts new file mode 100644 index 000000000000..068a6294677f --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/clustersListBySubscriptionSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists the available Event Hubs Clusters within an ARM resource group + * + * @summary Lists the available Event Hubs Clusters within an ARM resource group + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClustersListBySubscription.json + */ +async function clustersListBySubscription() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.clusters.listBySubscription()) { + resArray.push(item); + } + console.log(resArray); +} + +clustersListBySubscription().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/clustersListNamespacesSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/clustersListNamespacesSample.ts new file mode 100644 index 000000000000..a06bfcc4a74d --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/clustersListNamespacesSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to List all Event Hubs Namespace IDs in an Event Hubs Dedicated Cluster. + * + * @summary List all Event Hubs Namespace IDs in an Event Hubs Dedicated Cluster. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ListNamespacesInClusterGet.json + */ +async function listNamespacesInCluster() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "myResourceGroup"; + const clusterName = "testCluster"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.clusters.listNamespaces( + resourceGroupName, + clusterName + ); + console.log(result); +} + +listNamespacesInCluster().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/clustersUpdateSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/clustersUpdateSample.ts new file mode 100644 index 000000000000..b3aaa6aeed5a --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/clustersUpdateSample.ts @@ -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. +import { Cluster, EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Modifies mutable properties on the Event Hubs Cluster. This operation is idempotent. + * + * @summary Modifies mutable properties on the Event Hubs Cluster. This operation is idempotent. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterPatch.json + */ +async function clusterPatch() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "myResourceGroup"; + const clusterName = "testCluster"; + const parameters: Cluster = { + location: "South Central US", + tags: { tag3: "value3", tag4: "value4" } + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.clusters.beginUpdateAndWait( + resourceGroupName, + clusterName, + parameters + ); + console.log(result); +} + +clusterPatch().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/configurationGetSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/configurationGetSample.ts new file mode 100644 index 000000000000..89079236c5ba --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/configurationGetSample.ts @@ -0,0 +1,30 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Get all Event Hubs Cluster settings - a collection of key/value pairs which represent the quotas and settings imposed on the cluster. + * + * @summary Get all Event Hubs Cluster settings - a collection of key/value pairs which represent the quotas and settings imposed on the cluster. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterQuotaConfigurationGet.json + */ +async function clustersQuotasConfigurationGet() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "myResourceGroup"; + const clusterName = "testCluster"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.configuration.get(resourceGroupName, clusterName); + console.log(result); +} + +clustersQuotasConfigurationGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/configurationPatchSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/configurationPatchSample.ts new file mode 100644 index 000000000000..3d6f063e615c --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/configurationPatchSample.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 { + ClusterQuotaConfigurationProperties, + EventHubManagementClient +} from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Replace all specified Event Hubs Cluster settings with those contained in the request body. Leaves the settings not specified in the request body unmodified. + * + * @summary Replace all specified Event Hubs Cluster settings with those contained in the request body. Leaves the settings not specified in the request body unmodified. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterQuotaConfigurationPatch.json + */ +async function clustersQuotasConfigurationPatch() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const clusterName = "testCluster"; + const parameters: ClusterQuotaConfigurationProperties = { + settings: { + eventhubPerNamespaceQuota: "20", + namespacesPerClusterQuota: "200" + } + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.configuration.patch( + resourceGroupName, + clusterName, + parameters + ); + console.log(result); +} + +clustersQuotasConfigurationPatch().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/consumerGroupsCreateOrUpdateSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/consumerGroupsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..9f5018c65a02 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/consumerGroupsCreateOrUpdateSample.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 { ConsumerGroup, EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates an Event Hubs consumer group as a nested resource within a Namespace. + * + * @summary Creates or updates an Event Hubs consumer group as a nested resource within a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/ConsumerGroup/EHConsumerGroupCreate.json + */ +async function consumerGroupCreate() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2661"; + const eventHubName = "sdk-EventHub-6681"; + const consumerGroupName = "sdk-ConsumerGroup-5563"; + const parameters: ConsumerGroup = { userMetadata: "New consumergroup" }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.consumerGroups.createOrUpdate( + resourceGroupName, + namespaceName, + eventHubName, + consumerGroupName, + parameters + ); + console.log(result); +} + +consumerGroupCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/consumerGroupsDeleteSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/consumerGroupsDeleteSample.ts new file mode 100644 index 000000000000..620491fd42a8 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/consumerGroupsDeleteSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes a consumer group from the specified Event Hub and resource group. + * + * @summary Deletes a consumer group from the specified Event Hub and resource group. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/ConsumerGroup/EHConsumerGroupDelete.json + */ +async function consumerGroupDelete() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2661"; + const eventHubName = "sdk-EventHub-6681"; + const consumerGroupName = "sdk-ConsumerGroup-5563"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.consumerGroups.delete( + resourceGroupName, + namespaceName, + eventHubName, + consumerGroupName + ); + console.log(result); +} + +consumerGroupDelete().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/consumerGroupsGetSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/consumerGroupsGetSample.ts new file mode 100644 index 000000000000..8d3e16e089ac --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/consumerGroupsGetSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets a description for the specified consumer group. + * + * @summary Gets a description for the specified consumer group. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/ConsumerGroup/EHConsumerGroupGet.json + */ +async function consumerGroupGet() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2661"; + const eventHubName = "sdk-EventHub-6681"; + const consumerGroupName = "sdk-ConsumerGroup-5563"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.consumerGroups.get( + resourceGroupName, + namespaceName, + eventHubName, + consumerGroupName + ); + console.log(result); +} + +consumerGroupGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/consumerGroupsListByEventHubSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/consumerGroupsListByEventHubSample.ts new file mode 100644 index 000000000000..193369fb30bd --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/consumerGroupsListByEventHubSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all the consumer groups in a Namespace. An empty feed is returned if no consumer group exists in the Namespace. + * + * @summary Gets all the consumer groups in a Namespace. An empty feed is returned if no consumer group exists in the Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/ConsumerGroup/EHConsumerGroupListByEventHub.json + */ +async function consumerGroupsListAll() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2661"; + const eventHubName = "sdk-EventHub-6681"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.consumerGroups.listByEventHub( + resourceGroupName, + namespaceName, + eventHubName + )) { + resArray.push(item); + } + console.log(resArray); +} + +consumerGroupsListAll().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsBreakPairingSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsBreakPairingSample.ts new file mode 100644 index 000000000000..c67ce5388161 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsBreakPairingSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation disables the Disaster Recovery and stops replicating changes from primary to secondary namespaces + * + * @summary This operation disables the Disaster Recovery and stops replicating changes from primary to secondary namespaces + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasBreakPairing.json + */ +async function ehAliasBreakPairing() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-8859"; + const alias = "sdk-DisasterRecovery-3814"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.disasterRecoveryConfigs.breakPairing( + resourceGroupName, + namespaceName, + alias + ); + console.log(result); +} + +ehAliasBreakPairing().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsCheckNameAvailabilitySample.ts b/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsCheckNameAvailabilitySample.ts new file mode 100644 index 000000000000..3b617da055ac --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsCheckNameAvailabilitySample.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 { + CheckNameAvailabilityParameter, + EventHubManagementClient +} from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Check the give Namespace name availability. + * + * @summary Check the give Namespace name availability. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasCheckNameAvailability.json + */ +async function namespacesCheckNameAvailability() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-9080"; + const parameters: CheckNameAvailabilityParameter = { + name: "sdk-DisasterRecovery-9474" + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.disasterRecoveryConfigs.checkNameAvailability( + resourceGroupName, + namespaceName, + parameters + ); + console.log(result); +} + +namespacesCheckNameAvailability().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsCreateOrUpdateSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..d050b27dceb3 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsCreateOrUpdateSample.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 { + ArmDisasterRecovery, + EventHubManagementClient +} from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates a new Alias(Disaster Recovery configuration) + * + * @summary Creates or updates a new Alias(Disaster Recovery configuration) + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasCreate.json + */ +async function ehAliasCreate() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-8859"; + const alias = "sdk-DisasterRecovery-3814"; + const parameters: ArmDisasterRecovery = { + partnerNamespace: "sdk-Namespace-37" + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.disasterRecoveryConfigs.createOrUpdate( + resourceGroupName, + namespaceName, + alias, + parameters + ); + console.log(result); +} + +ehAliasCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsDeleteSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsDeleteSample.ts new file mode 100644 index 000000000000..858dd48ea0eb --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsDeleteSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes an Alias(Disaster Recovery configuration) + * + * @summary Deletes an Alias(Disaster Recovery configuration) + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasDelete.json + */ +async function ehAliasDelete() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-5849"; + const alias = "sdk-DisasterRecovery-3814"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.disasterRecoveryConfigs.delete( + resourceGroupName, + namespaceName, + alias + ); + console.log(result); +} + +ehAliasDelete().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsFailOverSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsFailOverSample.ts new file mode 100644 index 000000000000..c3e9a5cfe1cd --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsFailOverSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace + * + * @summary Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasFailOver.json + */ +async function ehAliasFailOver() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-8859"; + const alias = "sdk-DisasterRecovery-3814"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.disasterRecoveryConfigs.failOver( + resourceGroupName, + namespaceName, + alias + ); + console.log(result); +} + +ehAliasFailOver().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsGetAuthorizationRuleSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsGetAuthorizationRuleSample.ts new file mode 100644 index 000000000000..33a02e180ef0 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsGetAuthorizationRuleSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets an AuthorizationRule for a Namespace by rule name. + * + * @summary Gets an AuthorizationRule for a Namespace by rule name. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasAuthorizationRuleGet.json + */ +async function nameSpaceAuthorizationRuleGet() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-9080"; + const alias = "sdk-DisasterRecovery-4879"; + const authorizationRuleName = "sdk-Authrules-4879"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.disasterRecoveryConfigs.getAuthorizationRule( + resourceGroupName, + namespaceName, + alias, + authorizationRuleName + ); + console.log(result); +} + +nameSpaceAuthorizationRuleGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsGetSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsGetSample.ts new file mode 100644 index 000000000000..f2d3a0d9cb18 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsGetSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace + * + * @summary Retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasGet.json + */ +async function ehAliasGet() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-8859"; + const alias = "sdk-DisasterRecovery-3814"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.disasterRecoveryConfigs.get( + resourceGroupName, + namespaceName, + alias + ); + console.log(result); +} + +ehAliasGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsListAuthorizationRulesSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsListAuthorizationRulesSample.ts new file mode 100644 index 000000000000..05eb6f67c974 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsListAuthorizationRulesSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets a list of authorization rules for a Namespace. + * + * @summary Gets a list of authorization rules for a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasAuthorizationRuleListAll.json + */ +async function listAuthorizationRules() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-9080"; + const alias = "sdk-DisasterRecovery-4047"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.disasterRecoveryConfigs.listAuthorizationRules( + resourceGroupName, + namespaceName, + alias + )) { + resArray.push(item); + } + console.log(resArray); +} + +listAuthorizationRules().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsListKeysSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsListKeysSample.ts new file mode 100644 index 000000000000..db0ef16fe24e --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsListKeysSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the primary and secondary connection strings for the Namespace. + * + * @summary Gets the primary and secondary connection strings for the Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasAuthorizationRuleListKey.json + */ +async function nameSpaceAuthorizationRuleListKey() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-2702"; + const alias = "sdk-DisasterRecovery-4047"; + const authorizationRuleName = "sdk-Authrules-1746"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.disasterRecoveryConfigs.listKeys( + resourceGroupName, + namespaceName, + alias, + authorizationRuleName + ); + console.log(result); +} + +nameSpaceAuthorizationRuleListKey().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsListSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsListSample.ts new file mode 100644 index 000000000000..c9d9eaeb64ac --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/disasterRecoveryConfigsListSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all Alias(Disaster Recovery configurations) + * + * @summary Gets all Alias(Disaster Recovery configurations) + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasList.json + */ +async function ehAliasList() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-8859"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.disasterRecoveryConfigs.list( + resourceGroupName, + namespaceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +ehAliasList().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/eventHubsCreateOrUpdateAuthorizationRuleSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/eventHubsCreateOrUpdateAuthorizationRuleSample.ts new file mode 100644 index 000000000000..04cab867c1e1 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/eventHubsCreateOrUpdateAuthorizationRuleSample.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 { + AuthorizationRule, + EventHubManagementClient +} from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates an AuthorizationRule for the specified Event Hub. Creation/update of the AuthorizationRule will take a few seconds to take effect. + * + * @summary Creates or updates an AuthorizationRule for the specified Event Hub. Creation/update of the AuthorizationRule will take a few seconds to take effect. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleCreate.json + */ +async function eventHubAuthorizationRuleCreate() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-960"; + const eventHubName = "sdk-EventHub-532"; + const authorizationRuleName = "sdk-Authrules-2513"; + const parameters: AuthorizationRule = { rights: ["Listen", "Send"] }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.eventHubs.createOrUpdateAuthorizationRule( + resourceGroupName, + namespaceName, + eventHubName, + authorizationRuleName, + parameters + ); + console.log(result); +} + +eventHubAuthorizationRuleCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/eventHubsCreateOrUpdateSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/eventHubsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..03aae26de590 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/eventHubsCreateOrUpdateSample.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 { Eventhub, EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates a new Event Hub as a nested resource within a Namespace. + * + * @summary Creates or updates a new Event Hub as a nested resource within a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubCreate.json + */ +async function eventHubCreate() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "Default-NotificationHubs-AustraliaEast"; + const namespaceName = "sdk-Namespace-5357"; + const eventHubName = "sdk-EventHub-6547"; + const parameters: Eventhub = { + captureDescription: { + destination: { + name: "EventHubArchive.AzureBlockBlob", + archiveNameFormat: + "{Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}", + blobContainer: "container", + storageAccountResourceId: + "/subscriptions/e2f361f0-3b27-4503-a9cc-21cfba380093/resourceGroups/Default-Storage-SouthCentralUS/providers/Microsoft.ClassicStorage/storageAccounts/arjunteststorage" + }, + enabled: true, + encoding: "Avro", + intervalInSeconds: 120, + sizeLimitInBytes: 10485763 + }, + messageRetentionInDays: 4, + partitionCount: 4, + status: "Active" + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.eventHubs.createOrUpdate( + resourceGroupName, + namespaceName, + eventHubName, + parameters + ); + console.log(result); +} + +eventHubCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/eventHubsDeleteAuthorizationRuleSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/eventHubsDeleteAuthorizationRuleSample.ts new file mode 100644 index 000000000000..531a5446e2d4 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/eventHubsDeleteAuthorizationRuleSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes an Event Hub AuthorizationRule. + * + * @summary Deletes an Event Hub AuthorizationRule. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleDelete.json + */ +async function eventHubAuthorizationRuleDelete() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-960"; + const eventHubName = "sdk-EventHub-532"; + const authorizationRuleName = "sdk-Authrules-2513"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.eventHubs.deleteAuthorizationRule( + resourceGroupName, + namespaceName, + eventHubName, + authorizationRuleName + ); + console.log(result); +} + +eventHubAuthorizationRuleDelete().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/eventHubsDeleteSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/eventHubsDeleteSample.ts new file mode 100644 index 000000000000..523593903fb2 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/eventHubsDeleteSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes an Event Hub from the specified Namespace and resource group. + * + * @summary Deletes an Event Hub from the specified Namespace and resource group. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubDelete.json + */ +async function eventHubDelete() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-5357"; + const eventHubName = "sdk-EventHub-6547"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.eventHubs.delete( + resourceGroupName, + namespaceName, + eventHubName + ); + console.log(result); +} + +eventHubDelete().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/eventHubsGetAuthorizationRuleSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/eventHubsGetAuthorizationRuleSample.ts new file mode 100644 index 000000000000..e52c34b3fada --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/eventHubsGetAuthorizationRuleSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets an AuthorizationRule for an Event Hub by rule name. + * + * @summary Gets an AuthorizationRule for an Event Hub by rule name. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleGet.json + */ +async function eventHubAuthorizationRuleGet() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-960"; + const eventHubName = "sdk-EventHub-532"; + const authorizationRuleName = "sdk-Authrules-2513"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.eventHubs.getAuthorizationRule( + resourceGroupName, + namespaceName, + eventHubName, + authorizationRuleName + ); + console.log(result); +} + +eventHubAuthorizationRuleGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/eventHubsGetSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/eventHubsGetSample.ts new file mode 100644 index 000000000000..ba1a96c779ce --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/eventHubsGetSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets an Event Hubs description for the specified Event Hub. + * + * @summary Gets an Event Hubs description for the specified Event Hub. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubGet.json + */ +async function eventHubGet() { + const subscriptionId = "e2f361f0-3b27-4503-a9cc-21cfba380093"; + const resourceGroupName = "Default-NotificationHubs-AustraliaEast"; + const namespaceName = "sdk-Namespace-716"; + const eventHubName = "sdk-EventHub-10"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.eventHubs.get( + resourceGroupName, + namespaceName, + eventHubName + ); + console.log(result); +} + +eventHubGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/eventHubsListAuthorizationRulesSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/eventHubsListAuthorizationRulesSample.ts new file mode 100644 index 000000000000..bac573436734 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/eventHubsListAuthorizationRulesSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the authorization rules for an Event Hub. + * + * @summary Gets the authorization rules for an Event Hub. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleListAll.json + */ +async function eventHubAuthorizationRuleListAll() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-960"; + const eventHubName = "sdk-EventHub-532"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.eventHubs.listAuthorizationRules( + resourceGroupName, + namespaceName, + eventHubName + )) { + resArray.push(item); + } + console.log(resArray); +} + +eventHubAuthorizationRuleListAll().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/eventHubsListByNamespaceSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/eventHubsListByNamespaceSample.ts new file mode 100644 index 000000000000..ace9f8d546e8 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/eventHubsListByNamespaceSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all the Event Hubs in a Namespace. + * + * @summary Gets all the Event Hubs in a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubListByNameSpace.json + */ +async function eventHubsListAll() { + const subscriptionId = "e2f361f0-3b27-4503-a9cc-21cfba380093"; + const resourceGroupName = "Default-NotificationHubs-AustraliaEast"; + const namespaceName = "sdk-Namespace-5357"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.eventHubs.listByNamespace( + resourceGroupName, + namespaceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +eventHubsListAll().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/eventHubsListKeysSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/eventHubsListKeysSample.ts new file mode 100644 index 000000000000..59fb74b9a3ab --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/eventHubsListKeysSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the ACS and SAS connection strings for the Event Hub. + * + * @summary Gets the ACS and SAS connection strings for the Event Hub. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleListKey.json + */ +async function eventHubAuthorizationRuleListKey() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-namespace-960"; + const eventHubName = "sdk-EventHub-532"; + const authorizationRuleName = "sdk-Authrules-2513"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.eventHubs.listKeys( + resourceGroupName, + namespaceName, + eventHubName, + authorizationRuleName + ); + console.log(result); +} + +eventHubAuthorizationRuleListKey().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/eventHubsRegenerateKeysSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/eventHubsRegenerateKeysSample.ts new file mode 100644 index 000000000000..27ac68b3d5ee --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/eventHubsRegenerateKeysSample.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 { + RegenerateAccessKeyParameters, + EventHubManagementClient +} from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Regenerates the ACS and SAS connection strings for the Event Hub. + * + * @summary Regenerates the ACS and SAS connection strings for the Event Hub. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleRegenerateKey.json + */ +async function eventHubAuthorizationRuleRegenerateKey() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-namespace-960"; + const eventHubName = "sdk-EventHub-532"; + const authorizationRuleName = "sdk-Authrules-1534"; + const parameters: RegenerateAccessKeyParameters = { keyType: "PrimaryKey" }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.eventHubs.regenerateKeys( + resourceGroupName, + namespaceName, + eventHubName, + authorizationRuleName, + parameters + ); + console.log(result); +} + +eventHubAuthorizationRuleRegenerateKey().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/namespacesCheckNameAvailabilitySample.ts b/sdk/eventhub/arm-eventhub/samples-dev/namespacesCheckNameAvailabilitySample.ts new file mode 100644 index 000000000000..6532fa37870e --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/namespacesCheckNameAvailabilitySample.ts @@ -0,0 +1,34 @@ +/* + * 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 { + CheckNameAvailabilityParameter, + EventHubManagementClient +} from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Check the give Namespace name availability. + * + * @summary Check the give Namespace name availability. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceCheckNameAvailability.json + */ +async function namespacesCheckNameAvailability() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const parameters: CheckNameAvailabilityParameter = { + name: "sdk-Namespace-8458" + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.checkNameAvailability(parameters); + console.log(result); +} + +namespacesCheckNameAvailability().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/namespacesCreateOrUpdateAuthorizationRuleSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/namespacesCreateOrUpdateAuthorizationRuleSample.ts new file mode 100644 index 000000000000..38aaf91201b8 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/namespacesCreateOrUpdateAuthorizationRuleSample.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 { + AuthorizationRule, + EventHubManagementClient +} from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates an AuthorizationRule for a Namespace. + * + * @summary Creates or updates an AuthorizationRule for a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleCreate.json + */ +async function nameSpaceAuthorizationRuleCreate() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2702"; + const authorizationRuleName = "sdk-Authrules-1746"; + const parameters: AuthorizationRule = { rights: ["Listen", "Send"] }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.createOrUpdateAuthorizationRule( + resourceGroupName, + namespaceName, + authorizationRuleName, + parameters + ); + console.log(result); +} + +nameSpaceAuthorizationRuleCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/namespacesCreateOrUpdateNetworkRuleSetSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/namespacesCreateOrUpdateNetworkRuleSetSample.ts new file mode 100644 index 000000000000..c29b4e7f3e1f --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/namespacesCreateOrUpdateNetworkRuleSetSample.ts @@ -0,0 +1,67 @@ +/* + * 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 { NetworkRuleSet, EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Create or update NetworkRuleSet for a Namespace. + * + * @summary Create or update NetworkRuleSet for a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/VirtualNetworkRule/EHNetworkRuleSetCreate.json + */ +async function nameSpaceNetworkRuleSetCreate() { + const subscriptionId = "Subscription"; + const resourceGroupName = "ResourceGroup"; + const namespaceName = "sdk-Namespace-6019"; + const parameters: NetworkRuleSet = { + defaultAction: "Deny", + ipRules: [ + { action: "Allow", ipMask: "1.1.1.1" }, + { action: "Allow", ipMask: "1.1.1.2" }, + { action: "Allow", ipMask: "1.1.1.3" }, + { action: "Allow", ipMask: "1.1.1.4" }, + { action: "Allow", ipMask: "1.1.1.5" } + ], + virtualNetworkRules: [ + { + ignoreMissingVnetServiceEndpoint: true, + subnet: { + id: + "/subscriptions/subscriptionid/resourcegroups/resourcegroupid/providers/Microsoft.Network/virtualNetworks/myvn/subnets/subnet2" + } + }, + { + ignoreMissingVnetServiceEndpoint: false, + subnet: { + id: + "/subscriptions/subscriptionid/resourcegroups/resourcegroupid/providers/Microsoft.Network/virtualNetworks/myvn/subnets/subnet3" + } + }, + { + ignoreMissingVnetServiceEndpoint: false, + subnet: { + id: + "/subscriptions/subscriptionid/resourcegroups/resourcegroupid/providers/Microsoft.Network/virtualNetworks/myvn/subnets/subnet6" + } + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.createOrUpdateNetworkRuleSet( + resourceGroupName, + namespaceName, + parameters + ); + console.log(result); +} + +nameSpaceNetworkRuleSetCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/namespacesCreateOrUpdateSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/namespacesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..ab081c0da190 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/namespacesCreateOrUpdateSample.ts @@ -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. +import { EHNamespace, EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates a namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. + * + * @summary Creates or updates a namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceCreate.json + */ +async function namespaceCreate() { + const subscriptionId = "SampleSubscription"; + const resourceGroupName = "ResurceGroupSample"; + const namespaceName = "NamespaceSample"; + const parameters: EHNamespace = { + clusterArmId: + "/subscriptions/SampleSubscription/resourceGroups/ResurceGroupSample/providers/Microsoft.EventHub/clusters/enc-test", + encryption: { + keySource: "Microsoft.KeyVault", + keyVaultProperties: [ + { + identity: { + userAssignedIdentity: + "/subscriptions/SampleSubscription/resourceGroups/ResurceGroupSample/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ud1" + }, + keyName: "Samplekey", + keyVaultUri: "https://aprao-keyvault-user.vault-int.azure-int.net/" + } + ] + }, + identity: { + type: "SystemAssigned, UserAssigned", + userAssignedIdentities: { + "/subscriptions/SampleSubscription/resourceGroups/ResurceGroupSample/providers/MicrosoftManagedIdentity/userAssignedIdentities/ud1": {}, + "/subscriptions/SampleSubscription/resourceGroups/ResurceGroupSample/providers/MicrosoftManagedIdentity/userAssignedIdentities/ud2": {} + } + }, + location: "East US" + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.beginCreateOrUpdateAndWait( + resourceGroupName, + namespaceName, + parameters + ); + console.log(result); +} + +namespaceCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/namespacesDeleteAuthorizationRuleSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/namespacesDeleteAuthorizationRuleSample.ts new file mode 100644 index 000000000000..94f8f1d46f80 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/namespacesDeleteAuthorizationRuleSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes an AuthorizationRule for a Namespace. + * + * @summary Deletes an AuthorizationRule for a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleDelete.json + */ +async function nameSpaceAuthorizationRuleDelete() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-8980"; + const authorizationRuleName = "sdk-Authrules-8929"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.deleteAuthorizationRule( + resourceGroupName, + namespaceName, + authorizationRuleName + ); + console.log(result); +} + +nameSpaceAuthorizationRuleDelete().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/namespacesDeleteSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/namespacesDeleteSample.ts new file mode 100644 index 000000000000..35b0f71b5dc3 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/namespacesDeleteSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes an existing namespace. This operation also removes all associated resources under the namespace. + * + * @summary Deletes an existing namespace. This operation also removes all associated resources under the namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceDelete.json + */ +async function nameSpaceDelete() { + const subscriptionId = "SampleSubscription"; + const resourceGroupName = "ResurceGroupSample"; + const namespaceName = "NamespaceSample"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.beginDeleteAndWait( + resourceGroupName, + namespaceName + ); + console.log(result); +} + +nameSpaceDelete().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/namespacesGetAuthorizationRuleSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/namespacesGetAuthorizationRuleSample.ts new file mode 100644 index 000000000000..ca443bf6e60b --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/namespacesGetAuthorizationRuleSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets an AuthorizationRule for a Namespace by rule name. + * + * @summary Gets an AuthorizationRule for a Namespace by rule name. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleGet.json + */ +async function nameSpaceAuthorizationRuleGet() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2702"; + const authorizationRuleName = "sdk-Authrules-1746"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.getAuthorizationRule( + resourceGroupName, + namespaceName, + authorizationRuleName + ); + console.log(result); +} + +nameSpaceAuthorizationRuleGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/namespacesGetNetworkRuleSetSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/namespacesGetNetworkRuleSetSample.ts new file mode 100644 index 000000000000..b8a66031c12a --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/namespacesGetNetworkRuleSetSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets NetworkRuleSet for a Namespace. + * + * @summary Gets NetworkRuleSet for a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/VirtualNetworkRule/EHNetworkRuleSetGet.json + */ +async function nameSpaceNetworkRuleSetGet() { + const subscriptionId = "Subscription"; + const resourceGroupName = "ResourceGroup"; + const namespaceName = "sdk-Namespace-6019"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.getNetworkRuleSet( + resourceGroupName, + namespaceName + ); + console.log(result); +} + +nameSpaceNetworkRuleSetGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/namespacesGetSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/namespacesGetSample.ts new file mode 100644 index 000000000000..efff6daa1677 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/namespacesGetSample.ts @@ -0,0 +1,30 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the description of the specified namespace. + * + * @summary Gets the description of the specified namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceGet.json + */ +async function nameSpaceGet() { + const subscriptionId = "SampleSubscription"; + const resourceGroupName = "ResurceGroupSample"; + const namespaceName = "NamespaceSample"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.get(resourceGroupName, namespaceName); + console.log(result); +} + +nameSpaceGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/namespacesListAuthorizationRulesSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/namespacesListAuthorizationRulesSample.ts new file mode 100644 index 000000000000..70f8ca15c487 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/namespacesListAuthorizationRulesSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets a list of authorization rules for a Namespace. + * + * @summary Gets a list of authorization rules for a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleListAll.json + */ +async function listAuthorizationRules() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2702"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.namespaces.listAuthorizationRules( + resourceGroupName, + namespaceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listAuthorizationRules().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/namespacesListByResourceGroupSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/namespacesListByResourceGroupSample.ts new file mode 100644 index 000000000000..ad44bc0a3522 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/namespacesListByResourceGroupSample.ts @@ -0,0 +1,34 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists the available Namespaces within a resource group. + * + * @summary Lists the available Namespaces within a resource group. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceListByResourceGroup.json + */ +async function namespaceListByResourceGroup() { + const subscriptionId = "SampleSubscription"; + const resourceGroupName = "ResurceGroupSample"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.namespaces.listByResourceGroup( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +namespaceListByResourceGroup().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/namespacesListKeysSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/namespacesListKeysSample.ts new file mode 100644 index 000000000000..2856863240cf --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/namespacesListKeysSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the primary and secondary connection strings for the Namespace. + * + * @summary Gets the primary and secondary connection strings for the Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleListKey.json + */ +async function nameSpaceAuthorizationRuleListKey() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2702"; + const authorizationRuleName = "sdk-Authrules-1746"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.listKeys( + resourceGroupName, + namespaceName, + authorizationRuleName + ); + console.log(result); +} + +nameSpaceAuthorizationRuleListKey().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/namespacesListNetworkRuleSetSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/namespacesListNetworkRuleSetSample.ts new file mode 100644 index 000000000000..066db077b5ea --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/namespacesListNetworkRuleSetSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets NetworkRuleSet for a Namespace. + * + * @summary Gets NetworkRuleSet for a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/VirtualNetworkRule/EHNetworkRuleSetList.json + */ +async function nameSpaceNetworkRuleSetList() { + const subscriptionId = "Subscription"; + const resourceGroupName = "ResourceGroup"; + const namespaceName = "sdk-Namespace-6019"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.listNetworkRuleSet( + resourceGroupName, + namespaceName + ); + console.log(result); +} + +nameSpaceNetworkRuleSetList().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/namespacesListSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/namespacesListSample.ts new file mode 100644 index 000000000000..0f3c125ca1d1 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/namespacesListSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists all the available Namespaces within a subscription, irrespective of the resource groups. + * + * @summary Lists all the available Namespaces within a subscription, irrespective of the resource groups. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceList.json + */ +async function namespacesListBySubscription() { + const subscriptionId = "SampleSubscription"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.namespaces.list()) { + resArray.push(item); + } + console.log(resArray); +} + +namespacesListBySubscription().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/namespacesRegenerateKeysSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/namespacesRegenerateKeysSample.ts new file mode 100644 index 000000000000..1af5bfb4d106 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/namespacesRegenerateKeysSample.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 { + RegenerateAccessKeyParameters, + EventHubManagementClient +} from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Regenerates the primary or secondary connection strings for the specified Namespace. + * + * @summary Regenerates the primary or secondary connection strings for the specified Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleRegenerateKey.json + */ +async function nameSpaceAuthorizationRuleRegenerateKey() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-8980"; + const authorizationRuleName = "sdk-Authrules-8929"; + const parameters: RegenerateAccessKeyParameters = { keyType: "PrimaryKey" }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.regenerateKeys( + resourceGroupName, + namespaceName, + authorizationRuleName, + parameters + ); + console.log(result); +} + +nameSpaceAuthorizationRuleRegenerateKey().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/namespacesUpdateSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/namespacesUpdateSample.ts new file mode 100644 index 000000000000..b33f53561870 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/namespacesUpdateSample.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 { EHNamespace, EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates a namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. + * + * @summary Creates or updates a namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceUpdate.json + */ +async function namespacesUpdate() { + const subscriptionId = "SampleSubscription"; + const resourceGroupName = "ResurceGroupSample"; + const namespaceName = "NamespaceSample"; + const parameters: EHNamespace = { + identity: { + type: "SystemAssigned, UserAssigned", + userAssignedIdentities: { + "/subscriptions/SampleSubscription/resourceGroups/ResurceGroupSample/providers/MicrosoftManagedIdentity/userAssignedIdentities/ud2": {} + } + }, + location: "East US" + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.update( + resourceGroupName, + namespaceName, + parameters + ); + console.log(result); +} + +namespacesUpdate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/operationsListSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/operationsListSample.ts new file mode 100644 index 000000000000..2bc5ff38253a --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/operationsListSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists all of the available Event Hub REST API operations. + * + * @summary Lists all of the available Event Hub REST API operations. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EHOperations_List.json + */ +async function ehOperationsList() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +ehOperationsList().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/privateEndpointConnectionsCreateOrUpdateSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/privateEndpointConnectionsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..26844e1e7bb8 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/privateEndpointConnectionsCreateOrUpdateSample.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 { + PrivateEndpointConnection, + EventHubManagementClient +} from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates PrivateEndpointConnections of service namespace. + * + * @summary Creates or updates PrivateEndpointConnections of service namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/PrivateEndPointConnectionCreate.json + */ +async function nameSpacePrivateEndPointConnectionCreate() { + const subscriptionId = "subID"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2924"; + const privateEndpointConnectionName = "privateEndpointConnectionName"; + const parameters: PrivateEndpointConnection = { + privateEndpoint: { + id: + "/subscriptions/dbedb4e0-40e6-4145-81f3-f1314c150774/resourceGroups/SDK-EventHub-8396/providers/Microsoft.Network/privateEndpoints/sdk-Namespace-2847" + }, + privateLinkServiceConnectionState: { + description: "testing", + status: "Rejected" + }, + provisioningState: "Succeeded" + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.createOrUpdate( + resourceGroupName, + namespaceName, + privateEndpointConnectionName, + parameters + ); + console.log(result); +} + +nameSpacePrivateEndPointConnectionCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/privateEndpointConnectionsDeleteSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/privateEndpointConnectionsDeleteSample.ts new file mode 100644 index 000000000000..52eddef5653e --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/privateEndpointConnectionsDeleteSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes an existing namespace. This operation also removes all associated resources under the namespace. + * + * @summary Deletes an existing namespace. This operation also removes all associated resources under the namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/PrivateEndPointConnectionDelete.json + */ +async function nameSpacePrivateEndPointConnectionDelete() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-3285"; + const privateEndpointConnectionName = "928c44d5-b7c6-423b-b6fa-811e0c27b3e0"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.beginDeleteAndWait( + resourceGroupName, + namespaceName, + privateEndpointConnectionName + ); + console.log(result); +} + +nameSpacePrivateEndPointConnectionDelete().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/privateEndpointConnectionsGetSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/privateEndpointConnectionsGetSample.ts new file mode 100644 index 000000000000..06a565d923e3 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/privateEndpointConnectionsGetSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets a description for the specified Private Endpoint Connection name. + * + * @summary Gets a description for the specified Private Endpoint Connection name. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/PrivateEndPointConnectionGet.json + */ +async function nameSpacePrivateEndPointConnectionGet() { + const subscriptionId = "subID"; + const resourceGroupName = "SDK-EventHub-4794"; + const namespaceName = "sdk-Namespace-5828"; + const privateEndpointConnectionName = "privateEndpointConnectionName"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.get( + resourceGroupName, + namespaceName, + privateEndpointConnectionName + ); + console.log(result); +} + +nameSpacePrivateEndPointConnectionGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/privateEndpointConnectionsListSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/privateEndpointConnectionsListSample.ts new file mode 100644 index 000000000000..2d55b48e06a1 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/privateEndpointConnectionsListSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the available PrivateEndpointConnections within a namespace. + * + * @summary Gets the available PrivateEndpointConnections within a namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/PrivateEndPointConnectionList.json + */ +async function nameSpaceCreate() { + const subscriptionId = "subID"; + const resourceGroupName = "SDK-EventHub-4794"; + const namespaceName = "sdk-Namespace-5828"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.privateEndpointConnections.list( + resourceGroupName, + namespaceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +nameSpaceCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/privateLinkResourcesGetSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/privateLinkResourcesGetSample.ts new file mode 100644 index 000000000000..98436c1844b7 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/privateLinkResourcesGetSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets lists of resources that supports Privatelinks. + * + * @summary Gets lists of resources that supports Privatelinks. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/PrivateLinkResourcesGet.json + */ +async function nameSpacePrivateLinkResourcesGet() { + const subscriptionId = "subID"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2924"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.privateLinkResources.get( + resourceGroupName, + namespaceName + ); + console.log(result); +} + +nameSpacePrivateLinkResourcesGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/schemaRegistryCreateOrUpdateSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/schemaRegistryCreateOrUpdateSample.ts new file mode 100644 index 000000000000..8962f0185e45 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/schemaRegistryCreateOrUpdateSample.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 { SchemaGroup, EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to + * + * @summary + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/SchemaRegistry/SchemaRegistryCreate.json + */ +async function schemaRegistryCreate() { + const subscriptionId = "e8baea74-64ce-459b-bee3-5aa4c47b3ae3"; + const resourceGroupName = "alitest"; + const namespaceName = "ali-ua-test-eh-system-1"; + const schemaGroupName = "testSchemaGroup1"; + const parameters: SchemaGroup = { + groupProperties: {}, + schemaCompatibility: "Forward", + schemaType: "Avro" + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.schemaRegistry.createOrUpdate( + resourceGroupName, + namespaceName, + schemaGroupName, + parameters + ); + console.log(result); +} + +schemaRegistryCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/schemaRegistryDeleteSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/schemaRegistryDeleteSample.ts new file mode 100644 index 000000000000..914ad2ee1afe --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/schemaRegistryDeleteSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to + * + * @summary + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/SchemaRegistry/SchemaRegistryDelete.json + */ +async function schemaRegistryDelete() { + const subscriptionId = "e8baea74-64ce-459b-bee3-5aa4c47b3ae3"; + const resourceGroupName = "alitest"; + const namespaceName = "ali-ua-test-eh-system-1"; + const schemaGroupName = "testSchemaGroup1"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.schemaRegistry.delete( + resourceGroupName, + namespaceName, + schemaGroupName + ); + console.log(result); +} + +schemaRegistryDelete().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/schemaRegistryGetSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/schemaRegistryGetSample.ts new file mode 100644 index 000000000000..43c05954d938 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/schemaRegistryGetSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to + * + * @summary + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/SchemaRegistry/SchemaRegistryGet.json + */ +async function schemaRegistryGet() { + const subscriptionId = "e8baea74-64ce-459b-bee3-5aa4c47b3ae3"; + const resourceGroupName = "alitest"; + const namespaceName = "ali-ua-test-eh-system-1"; + const schemaGroupName = "testSchemaGroup1"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.schemaRegistry.get( + resourceGroupName, + namespaceName, + schemaGroupName + ); + console.log(result); +} + +schemaRegistryGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples-dev/schemaRegistryListByNamespaceSample.ts b/sdk/eventhub/arm-eventhub/samples-dev/schemaRegistryListByNamespaceSample.ts new file mode 100644 index 000000000000..31d8f0e85b91 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples-dev/schemaRegistryListByNamespaceSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all the Schema Groups in a Namespace. + * + * @summary Gets all the Schema Groups in a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/SchemaRegistry/SchemaRegistryListByNamespace.json + */ +async function schemaRegistryListAll() { + const subscriptionId = "e8baea74-64ce-459b-bee3-5aa4c47b3ae3"; + const resourceGroupName = "alitest"; + const namespaceName = "ali-ua-test-eh-system-1"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.schemaRegistry.listByNamespace( + resourceGroupName, + namespaceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +schemaRegistryListAll().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/README.md b/sdk/eventhub/arm-eventhub/samples/v5/javascript/README.md new file mode 100644 index 000000000000..da5f797b72db --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/README.md @@ -0,0 +1,168 @@ +# client library samples for JavaScript + +These sample programs show how to use the JavaScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| ------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [clustersCreateOrUpdateSample.js][clusterscreateorupdatesample] | Creates or updates an instance of an Event Hubs Cluster. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterPut.json | +| [clustersDeleteSample.js][clustersdeletesample] | Deletes an existing Event Hubs Cluster. This operation is idempotent. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterDelete.json | +| [clustersGetSample.js][clustersgetsample] | Gets the resource description of the specified Event Hubs Cluster. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterGet.json | +| [clustersListAvailableClusterRegionSample.js][clusterslistavailableclusterregionsample] | List the quantity of available pre-provisioned Event Hubs Clusters, indexed by Azure region. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ListAvailableClustersGet.json | +| [clustersListByResourceGroupSample.js][clusterslistbyresourcegroupsample] | Lists the available Event Hubs Clusters within an ARM resource group x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClustersListByResourceGroup.json | +| [clustersListBySubscriptionSample.js][clusterslistbysubscriptionsample] | Lists the available Event Hubs Clusters within an ARM resource group x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClustersListBySubscription.json | +| [clustersListNamespacesSample.js][clusterslistnamespacessample] | List all Event Hubs Namespace IDs in an Event Hubs Dedicated Cluster. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ListNamespacesInClusterGet.json | +| [clustersUpdateSample.js][clustersupdatesample] | Modifies mutable properties on the Event Hubs Cluster. This operation is idempotent. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterPatch.json | +| [configurationGetSample.js][configurationgetsample] | Get all Event Hubs Cluster settings - a collection of key/value pairs which represent the quotas and settings imposed on the cluster. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterQuotaConfigurationGet.json | +| [configurationPatchSample.js][configurationpatchsample] | Replace all specified Event Hubs Cluster settings with those contained in the request body. Leaves the settings not specified in the request body unmodified. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterQuotaConfigurationPatch.json | +| [consumerGroupsCreateOrUpdateSample.js][consumergroupscreateorupdatesample] | Creates or updates an Event Hubs consumer group as a nested resource within a Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/ConsumerGroup/EHConsumerGroupCreate.json | +| [consumerGroupsDeleteSample.js][consumergroupsdeletesample] | Deletes a consumer group from the specified Event Hub and resource group. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/ConsumerGroup/EHConsumerGroupDelete.json | +| [consumerGroupsGetSample.js][consumergroupsgetsample] | Gets a description for the specified consumer group. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/ConsumerGroup/EHConsumerGroupGet.json | +| [consumerGroupsListByEventHubSample.js][consumergroupslistbyeventhubsample] | Gets all the consumer groups in a Namespace. An empty feed is returned if no consumer group exists in the Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/ConsumerGroup/EHConsumerGroupListByEventHub.json | +| [disasterRecoveryConfigsBreakPairingSample.js][disasterrecoveryconfigsbreakpairingsample] | This operation disables the Disaster Recovery and stops replicating changes from primary to secondary namespaces x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasBreakPairing.json | +| [disasterRecoveryConfigsCheckNameAvailabilitySample.js][disasterrecoveryconfigschecknameavailabilitysample] | Check the give Namespace name availability. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasCheckNameAvailability.json | +| [disasterRecoveryConfigsCreateOrUpdateSample.js][disasterrecoveryconfigscreateorupdatesample] | Creates or updates a new Alias(Disaster Recovery configuration) x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasCreate.json | +| [disasterRecoveryConfigsDeleteSample.js][disasterrecoveryconfigsdeletesample] | Deletes an Alias(Disaster Recovery configuration) x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasDelete.json | +| [disasterRecoveryConfigsFailOverSample.js][disasterrecoveryconfigsfailoversample] | Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasFailOver.json | +| [disasterRecoveryConfigsGetAuthorizationRuleSample.js][disasterrecoveryconfigsgetauthorizationrulesample] | Gets an AuthorizationRule for a Namespace by rule name. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasAuthorizationRuleGet.json | +| [disasterRecoveryConfigsGetSample.js][disasterrecoveryconfigsgetsample] | Retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasGet.json | +| [disasterRecoveryConfigsListAuthorizationRulesSample.js][disasterrecoveryconfigslistauthorizationrulessample] | Gets a list of authorization rules for a Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasAuthorizationRuleListAll.json | +| [disasterRecoveryConfigsListKeysSample.js][disasterrecoveryconfigslistkeyssample] | Gets the primary and secondary connection strings for the Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasAuthorizationRuleListKey.json | +| [disasterRecoveryConfigsListSample.js][disasterrecoveryconfigslistsample] | Gets all Alias(Disaster Recovery configurations) x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasList.json | +| [eventHubsCreateOrUpdateAuthorizationRuleSample.js][eventhubscreateorupdateauthorizationrulesample] | Creates or updates an AuthorizationRule for the specified Event Hub. Creation/update of the AuthorizationRule will take a few seconds to take effect. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleCreate.json | +| [eventHubsCreateOrUpdateSample.js][eventhubscreateorupdatesample] | Creates or updates a new Event Hub as a nested resource within a Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubCreate.json | +| [eventHubsDeleteAuthorizationRuleSample.js][eventhubsdeleteauthorizationrulesample] | Deletes an Event Hub AuthorizationRule. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleDelete.json | +| [eventHubsDeleteSample.js][eventhubsdeletesample] | Deletes an Event Hub from the specified Namespace and resource group. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubDelete.json | +| [eventHubsGetAuthorizationRuleSample.js][eventhubsgetauthorizationrulesample] | Gets an AuthorizationRule for an Event Hub by rule name. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleGet.json | +| [eventHubsGetSample.js][eventhubsgetsample] | Gets an Event Hubs description for the specified Event Hub. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubGet.json | +| [eventHubsListAuthorizationRulesSample.js][eventhubslistauthorizationrulessample] | Gets the authorization rules for an Event Hub. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleListAll.json | +| [eventHubsListByNamespaceSample.js][eventhubslistbynamespacesample] | Gets all the Event Hubs in a Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubListByNameSpace.json | +| [eventHubsListKeysSample.js][eventhubslistkeyssample] | Gets the ACS and SAS connection strings for the Event Hub. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleListKey.json | +| [eventHubsRegenerateKeysSample.js][eventhubsregeneratekeyssample] | Regenerates the ACS and SAS connection strings for the Event Hub. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleRegenerateKey.json | +| [namespacesCheckNameAvailabilitySample.js][namespaceschecknameavailabilitysample] | Check the give Namespace name availability. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceCheckNameAvailability.json | +| [namespacesCreateOrUpdateAuthorizationRuleSample.js][namespacescreateorupdateauthorizationrulesample] | Creates or updates an AuthorizationRule for a Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleCreate.json | +| [namespacesCreateOrUpdateNetworkRuleSetSample.js][namespacescreateorupdatenetworkrulesetsample] | Create or update NetworkRuleSet for a Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/VirtualNetworkRule/EHNetworkRuleSetCreate.json | +| [namespacesCreateOrUpdateSample.js][namespacescreateorupdatesample] | Creates or updates a namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceCreate.json | +| [namespacesDeleteAuthorizationRuleSample.js][namespacesdeleteauthorizationrulesample] | Deletes an AuthorizationRule for a Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleDelete.json | +| [namespacesDeleteSample.js][namespacesdeletesample] | Deletes an existing namespace. This operation also removes all associated resources under the namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceDelete.json | +| [namespacesGetAuthorizationRuleSample.js][namespacesgetauthorizationrulesample] | Gets an AuthorizationRule for a Namespace by rule name. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleGet.json | +| [namespacesGetNetworkRuleSetSample.js][namespacesgetnetworkrulesetsample] | Gets NetworkRuleSet for a Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/VirtualNetworkRule/EHNetworkRuleSetGet.json | +| [namespacesGetSample.js][namespacesgetsample] | Gets the description of the specified namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceGet.json | +| [namespacesListAuthorizationRulesSample.js][namespaceslistauthorizationrulessample] | Gets a list of authorization rules for a Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleListAll.json | +| [namespacesListByResourceGroupSample.js][namespaceslistbyresourcegroupsample] | Lists the available Namespaces within a resource group. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceListByResourceGroup.json | +| [namespacesListKeysSample.js][namespaceslistkeyssample] | Gets the primary and secondary connection strings for the Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleListKey.json | +| [namespacesListNetworkRuleSetSample.js][namespaceslistnetworkrulesetsample] | Gets NetworkRuleSet for a Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/VirtualNetworkRule/EHNetworkRuleSetList.json | +| [namespacesListSample.js][namespaceslistsample] | Lists all the available Namespaces within a subscription, irrespective of the resource groups. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceList.json | +| [namespacesRegenerateKeysSample.js][namespacesregeneratekeyssample] | Regenerates the primary or secondary connection strings for the specified Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleRegenerateKey.json | +| [namespacesUpdateSample.js][namespacesupdatesample] | Creates or updates a namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceUpdate.json | +| [operationsListSample.js][operationslistsample] | Lists all of the available Event Hub REST API operations. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EHOperations_List.json | +| [privateEndpointConnectionsCreateOrUpdateSample.js][privateendpointconnectionscreateorupdatesample] | Creates or updates PrivateEndpointConnections of service namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/PrivateEndPointConnectionCreate.json | +| [privateEndpointConnectionsDeleteSample.js][privateendpointconnectionsdeletesample] | Deletes an existing namespace. This operation also removes all associated resources under the namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/PrivateEndPointConnectionDelete.json | +| [privateEndpointConnectionsGetSample.js][privateendpointconnectionsgetsample] | Gets a description for the specified Private Endpoint Connection name. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/PrivateEndPointConnectionGet.json | +| [privateEndpointConnectionsListSample.js][privateendpointconnectionslistsample] | Gets the available PrivateEndpointConnections within a namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/PrivateEndPointConnectionList.json | +| [privateLinkResourcesGetSample.js][privatelinkresourcesgetsample] | Gets lists of resources that supports Privatelinks. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/PrivateLinkResourcesGet.json | +| [schemaRegistryCreateOrUpdateSample.js][schemaregistrycreateorupdatesample] | x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/SchemaRegistry/SchemaRegistryCreate.json | +| [schemaRegistryDeleteSample.js][schemaregistrydeletesample] | x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/SchemaRegistry/SchemaRegistryDelete.json | +| [schemaRegistryGetSample.js][schemaregistrygetsample] | x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/SchemaRegistry/SchemaRegistryGet.json | +| [schemaRegistryListByNamespaceSample.js][schemaregistrylistbynamespacesample] | Gets all the Schema Groups in a Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/SchemaRegistry/SchemaRegistryListByNamespace.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +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 clustersCreateOrUpdateSample.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 node clustersCreateOrUpdateSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[clusterscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersCreateOrUpdateSample.js +[clustersdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersDeleteSample.js +[clustersgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersGetSample.js +[clusterslistavailableclusterregionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersListAvailableClusterRegionSample.js +[clusterslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersListByResourceGroupSample.js +[clusterslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersListBySubscriptionSample.js +[clusterslistnamespacessample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersListNamespacesSample.js +[clustersupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersUpdateSample.js +[configurationgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/configurationGetSample.js +[configurationpatchsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/configurationPatchSample.js +[consumergroupscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/consumerGroupsCreateOrUpdateSample.js +[consumergroupsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/consumerGroupsDeleteSample.js +[consumergroupsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/consumerGroupsGetSample.js +[consumergroupslistbyeventhubsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/consumerGroupsListByEventHubSample.js +[disasterrecoveryconfigsbreakpairingsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsBreakPairingSample.js +[disasterrecoveryconfigschecknameavailabilitysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsCheckNameAvailabilitySample.js +[disasterrecoveryconfigscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsCreateOrUpdateSample.js +[disasterrecoveryconfigsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsDeleteSample.js +[disasterrecoveryconfigsfailoversample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsFailOverSample.js +[disasterrecoveryconfigsgetauthorizationrulesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsGetAuthorizationRuleSample.js +[disasterrecoveryconfigsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsGetSample.js +[disasterrecoveryconfigslistauthorizationrulessample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsListAuthorizationRulesSample.js +[disasterrecoveryconfigslistkeyssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsListKeysSample.js +[disasterrecoveryconfigslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsListSample.js +[eventhubscreateorupdateauthorizationrulesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsCreateOrUpdateAuthorizationRuleSample.js +[eventhubscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsCreateOrUpdateSample.js +[eventhubsdeleteauthorizationrulesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsDeleteAuthorizationRuleSample.js +[eventhubsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsDeleteSample.js +[eventhubsgetauthorizationrulesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsGetAuthorizationRuleSample.js +[eventhubsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsGetSample.js +[eventhubslistauthorizationrulessample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsListAuthorizationRulesSample.js +[eventhubslistbynamespacesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsListByNamespaceSample.js +[eventhubslistkeyssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsListKeysSample.js +[eventhubsregeneratekeyssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsRegenerateKeysSample.js +[namespaceschecknameavailabilitysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesCheckNameAvailabilitySample.js +[namespacescreateorupdateauthorizationrulesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesCreateOrUpdateAuthorizationRuleSample.js +[namespacescreateorupdatenetworkrulesetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesCreateOrUpdateNetworkRuleSetSample.js +[namespacescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesCreateOrUpdateSample.js +[namespacesdeleteauthorizationrulesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesDeleteAuthorizationRuleSample.js +[namespacesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesDeleteSample.js +[namespacesgetauthorizationrulesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesGetAuthorizationRuleSample.js +[namespacesgetnetworkrulesetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesGetNetworkRuleSetSample.js +[namespacesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesGetSample.js +[namespaceslistauthorizationrulessample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesListAuthorizationRulesSample.js +[namespaceslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesListByResourceGroupSample.js +[namespaceslistkeyssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesListKeysSample.js +[namespaceslistnetworkrulesetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesListNetworkRuleSetSample.js +[namespaceslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesListSample.js +[namespacesregeneratekeyssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesRegenerateKeysSample.js +[namespacesupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesUpdateSample.js +[operationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/operationsListSample.js +[privateendpointconnectionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/privateEndpointConnectionsCreateOrUpdateSample.js +[privateendpointconnectionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/privateEndpointConnectionsDeleteSample.js +[privateendpointconnectionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/privateEndpointConnectionsGetSample.js +[privateendpointconnectionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/privateEndpointConnectionsListSample.js +[privatelinkresourcesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/privateLinkResourcesGetSample.js +[schemaregistrycreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/schemaRegistryCreateOrUpdateSample.js +[schemaregistrydeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/schemaRegistryDeleteSample.js +[schemaregistrygetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/schemaRegistryGetSample.js +[schemaregistrylistbynamespacesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/javascript/schemaRegistryListByNamespaceSample.js +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-eventhub?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/eventhub/arm-eventhub/README.md diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersCreateOrUpdateSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersCreateOrUpdateSample.js new file mode 100644 index 000000000000..63053569fa29 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersCreateOrUpdateSample.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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Creates or updates an instance of an Event Hubs Cluster. + * + * @summary Creates or updates an instance of an Event Hubs Cluster. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterPut.json + */ +async function clusterPut() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "myResourceGroup"; + const clusterName = "testCluster"; + const parameters = { + location: "South Central US", + sku: { name: "Dedicated", capacity: 1 }, + tags: { tag1: "value1", tag2: "value2" }, + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.clusters.beginCreateOrUpdateAndWait( + resourceGroupName, + clusterName, + parameters + ); + console.log(result); +} + +clusterPut().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersDeleteSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersDeleteSample.js new file mode 100644 index 000000000000..7a1f430a378e --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersDeleteSample.js @@ -0,0 +1,30 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes an existing Event Hubs Cluster. This operation is idempotent. + * + * @summary Deletes an existing Event Hubs Cluster. This operation is idempotent. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterDelete.json + */ +async function clusterDelete() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "myResourceGroup"; + const clusterName = "testCluster"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.clusters.beginDeleteAndWait(resourceGroupName, clusterName); + console.log(result); +} + +clusterDelete().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersGetSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersGetSample.js new file mode 100644 index 000000000000..1758940715b5 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersGetSample.js @@ -0,0 +1,30 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets the resource description of the specified Event Hubs Cluster. + * + * @summary Gets the resource description of the specified Event Hubs Cluster. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterGet.json + */ +async function clusterGet() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "myResourceGroup"; + const clusterName = "testCluster"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.clusters.get(resourceGroupName, clusterName); + console.log(result); +} + +clusterGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersListAvailableClusterRegionSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersListAvailableClusterRegionSample.js new file mode 100644 index 000000000000..048dcfb8a498 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersListAvailableClusterRegionSample.js @@ -0,0 +1,28 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to List the quantity of available pre-provisioned Event Hubs Clusters, indexed by Azure region. + * + * @summary List the quantity of available pre-provisioned Event Hubs Clusters, indexed by Azure region. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ListAvailableClustersGet.json + */ +async function listAvailableClusters() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.clusters.listAvailableClusterRegion(); + console.log(result); +} + +listAvailableClusters().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersListByResourceGroupSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersListByResourceGroupSample.js new file mode 100644 index 000000000000..230844e29545 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersListByResourceGroupSample.js @@ -0,0 +1,32 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists the available Event Hubs Clusters within an ARM resource group + * + * @summary Lists the available Event Hubs Clusters within an ARM resource group + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClustersListByResourceGroup.json + */ +async function clustersListByResourceGroup() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "myResourceGroup"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.clusters.listByResourceGroup(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +clustersListByResourceGroup().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersListBySubscriptionSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersListBySubscriptionSample.js new file mode 100644 index 000000000000..1106105ae416 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersListBySubscriptionSample.js @@ -0,0 +1,31 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists the available Event Hubs Clusters within an ARM resource group + * + * @summary Lists the available Event Hubs Clusters within an ARM resource group + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClustersListBySubscription.json + */ +async function clustersListBySubscription() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.clusters.listBySubscription()) { + resArray.push(item); + } + console.log(resArray); +} + +clustersListBySubscription().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersListNamespacesSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersListNamespacesSample.js new file mode 100644 index 000000000000..09262ca9c93c --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersListNamespacesSample.js @@ -0,0 +1,30 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to List all Event Hubs Namespace IDs in an Event Hubs Dedicated Cluster. + * + * @summary List all Event Hubs Namespace IDs in an Event Hubs Dedicated Cluster. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ListNamespacesInClusterGet.json + */ +async function listNamespacesInCluster() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "myResourceGroup"; + const clusterName = "testCluster"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.clusters.listNamespaces(resourceGroupName, clusterName); + console.log(result); +} + +listNamespacesInCluster().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersUpdateSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersUpdateSample.js new file mode 100644 index 000000000000..9ee06e09c836 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/clustersUpdateSample.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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Modifies mutable properties on the Event Hubs Cluster. This operation is idempotent. + * + * @summary Modifies mutable properties on the Event Hubs Cluster. This operation is idempotent. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterPatch.json + */ +async function clusterPatch() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "myResourceGroup"; + const clusterName = "testCluster"; + const parameters = { + location: "South Central US", + tags: { tag3: "value3", tag4: "value4" }, + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.clusters.beginUpdateAndWait( + resourceGroupName, + clusterName, + parameters + ); + console.log(result); +} + +clusterPatch().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/configurationGetSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/configurationGetSample.js new file mode 100644 index 000000000000..9d555c63e945 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/configurationGetSample.js @@ -0,0 +1,30 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Get all Event Hubs Cluster settings - a collection of key/value pairs which represent the quotas and settings imposed on the cluster. + * + * @summary Get all Event Hubs Cluster settings - a collection of key/value pairs which represent the quotas and settings imposed on the cluster. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterQuotaConfigurationGet.json + */ +async function clustersQuotasConfigurationGet() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "myResourceGroup"; + const clusterName = "testCluster"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.configuration.get(resourceGroupName, clusterName); + console.log(result); +} + +clustersQuotasConfigurationGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/configurationPatchSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/configurationPatchSample.js new file mode 100644 index 000000000000..a720c79cc17f --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/configurationPatchSample.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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Replace all specified Event Hubs Cluster settings with those contained in the request body. Leaves the settings not specified in the request body unmodified. + * + * @summary Replace all specified Event Hubs Cluster settings with those contained in the request body. Leaves the settings not specified in the request body unmodified. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterQuotaConfigurationPatch.json + */ +async function clustersQuotasConfigurationPatch() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const clusterName = "testCluster"; + const parameters = { + settings: { + eventhubPerNamespaceQuota: "20", + namespacesPerClusterQuota: "200", + }, + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.configuration.patch(resourceGroupName, clusterName, parameters); + console.log(result); +} + +clustersQuotasConfigurationPatch().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/consumerGroupsCreateOrUpdateSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/consumerGroupsCreateOrUpdateSample.js new file mode 100644 index 000000000000..973670b9d04d --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/consumerGroupsCreateOrUpdateSample.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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Creates or updates an Event Hubs consumer group as a nested resource within a Namespace. + * + * @summary Creates or updates an Event Hubs consumer group as a nested resource within a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/ConsumerGroup/EHConsumerGroupCreate.json + */ +async function consumerGroupCreate() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2661"; + const eventHubName = "sdk-EventHub-6681"; + const consumerGroupName = "sdk-ConsumerGroup-5563"; + const parameters = { userMetadata: "New consumergroup" }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.consumerGroups.createOrUpdate( + resourceGroupName, + namespaceName, + eventHubName, + consumerGroupName, + parameters + ); + console.log(result); +} + +consumerGroupCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/consumerGroupsDeleteSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/consumerGroupsDeleteSample.js new file mode 100644 index 000000000000..826db406c9ab --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/consumerGroupsDeleteSample.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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes a consumer group from the specified Event Hub and resource group. + * + * @summary Deletes a consumer group from the specified Event Hub and resource group. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/ConsumerGroup/EHConsumerGroupDelete.json + */ +async function consumerGroupDelete() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2661"; + const eventHubName = "sdk-EventHub-6681"; + const consumerGroupName = "sdk-ConsumerGroup-5563"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.consumerGroups.delete( + resourceGroupName, + namespaceName, + eventHubName, + consumerGroupName + ); + console.log(result); +} + +consumerGroupDelete().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/consumerGroupsGetSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/consumerGroupsGetSample.js new file mode 100644 index 000000000000..c7213a3c699a --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/consumerGroupsGetSample.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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets a description for the specified consumer group. + * + * @summary Gets a description for the specified consumer group. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/ConsumerGroup/EHConsumerGroupGet.json + */ +async function consumerGroupGet() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2661"; + const eventHubName = "sdk-EventHub-6681"; + const consumerGroupName = "sdk-ConsumerGroup-5563"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.consumerGroups.get( + resourceGroupName, + namespaceName, + eventHubName, + consumerGroupName + ); + console.log(result); +} + +consumerGroupGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/consumerGroupsListByEventHubSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/consumerGroupsListByEventHubSample.js new file mode 100644 index 000000000000..0e6276214924 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/consumerGroupsListByEventHubSample.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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets all the consumer groups in a Namespace. An empty feed is returned if no consumer group exists in the Namespace. + * + * @summary Gets all the consumer groups in a Namespace. An empty feed is returned if no consumer group exists in the Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/ConsumerGroup/EHConsumerGroupListByEventHub.json + */ +async function consumerGroupsListAll() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2661"; + const eventHubName = "sdk-EventHub-6681"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.consumerGroups.listByEventHub( + resourceGroupName, + namespaceName, + eventHubName + )) { + resArray.push(item); + } + console.log(resArray); +} + +consumerGroupsListAll().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsBreakPairingSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsBreakPairingSample.js new file mode 100644 index 000000000000..3adb5722be67 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsBreakPairingSample.js @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation disables the Disaster Recovery and stops replicating changes from primary to secondary namespaces + * + * @summary This operation disables the Disaster Recovery and stops replicating changes from primary to secondary namespaces + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasBreakPairing.json + */ +async function ehAliasBreakPairing() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-8859"; + const alias = "sdk-DisasterRecovery-3814"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.disasterRecoveryConfigs.breakPairing( + resourceGroupName, + namespaceName, + alias + ); + console.log(result); +} + +ehAliasBreakPairing().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsCheckNameAvailabilitySample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsCheckNameAvailabilitySample.js new file mode 100644 index 000000000000..d952de929271 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsCheckNameAvailabilitySample.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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Check the give Namespace name availability. + * + * @summary Check the give Namespace name availability. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasCheckNameAvailability.json + */ +async function namespacesCheckNameAvailability() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-9080"; + const parameters = { + name: "sdk-DisasterRecovery-9474", + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.disasterRecoveryConfigs.checkNameAvailability( + resourceGroupName, + namespaceName, + parameters + ); + console.log(result); +} + +namespacesCheckNameAvailability().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsCreateOrUpdateSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsCreateOrUpdateSample.js new file mode 100644 index 000000000000..80e02af86ff6 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsCreateOrUpdateSample.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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Creates or updates a new Alias(Disaster Recovery configuration) + * + * @summary Creates or updates a new Alias(Disaster Recovery configuration) + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasCreate.json + */ +async function ehAliasCreate() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-8859"; + const alias = "sdk-DisasterRecovery-3814"; + const parameters = { + partnerNamespace: "sdk-Namespace-37", + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.disasterRecoveryConfigs.createOrUpdate( + resourceGroupName, + namespaceName, + alias, + parameters + ); + console.log(result); +} + +ehAliasCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsDeleteSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsDeleteSample.js new file mode 100644 index 000000000000..71cec2d7e6de --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsDeleteSample.js @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes an Alias(Disaster Recovery configuration) + * + * @summary Deletes an Alias(Disaster Recovery configuration) + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasDelete.json + */ +async function ehAliasDelete() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-5849"; + const alias = "sdk-DisasterRecovery-3814"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.disasterRecoveryConfigs.delete( + resourceGroupName, + namespaceName, + alias + ); + console.log(result); +} + +ehAliasDelete().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsFailOverSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsFailOverSample.js new file mode 100644 index 000000000000..b369e58a3d3c --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsFailOverSample.js @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace + * + * @summary Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasFailOver.json + */ +async function ehAliasFailOver() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-8859"; + const alias = "sdk-DisasterRecovery-3814"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.disasterRecoveryConfigs.failOver( + resourceGroupName, + namespaceName, + alias + ); + console.log(result); +} + +ehAliasFailOver().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsGetAuthorizationRuleSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsGetAuthorizationRuleSample.js new file mode 100644 index 000000000000..5520ae6bb251 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsGetAuthorizationRuleSample.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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets an AuthorizationRule for a Namespace by rule name. + * + * @summary Gets an AuthorizationRule for a Namespace by rule name. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasAuthorizationRuleGet.json + */ +async function nameSpaceAuthorizationRuleGet() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-9080"; + const alias = "sdk-DisasterRecovery-4879"; + const authorizationRuleName = "sdk-Authrules-4879"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.disasterRecoveryConfigs.getAuthorizationRule( + resourceGroupName, + namespaceName, + alias, + authorizationRuleName + ); + console.log(result); +} + +nameSpaceAuthorizationRuleGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsGetSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsGetSample.js new file mode 100644 index 000000000000..068eeb643589 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsGetSample.js @@ -0,0 +1,31 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace + * + * @summary Retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasGet.json + */ +async function ehAliasGet() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-8859"; + const alias = "sdk-DisasterRecovery-3814"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.disasterRecoveryConfigs.get(resourceGroupName, namespaceName, alias); + console.log(result); +} + +ehAliasGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsListAuthorizationRulesSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsListAuthorizationRulesSample.js new file mode 100644 index 000000000000..57a1ecf52ee3 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsListAuthorizationRulesSample.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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets a list of authorization rules for a Namespace. + * + * @summary Gets a list of authorization rules for a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasAuthorizationRuleListAll.json + */ +async function listAuthorizationRules() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-9080"; + const alias = "sdk-DisasterRecovery-4047"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.disasterRecoveryConfigs.listAuthorizationRules( + resourceGroupName, + namespaceName, + alias + )) { + resArray.push(item); + } + console.log(resArray); +} + +listAuthorizationRules().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsListKeysSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsListKeysSample.js new file mode 100644 index 000000000000..ca9ca3797cdd --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsListKeysSample.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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets the primary and secondary connection strings for the Namespace. + * + * @summary Gets the primary and secondary connection strings for the Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasAuthorizationRuleListKey.json + */ +async function nameSpaceAuthorizationRuleListKey() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-2702"; + const alias = "sdk-DisasterRecovery-4047"; + const authorizationRuleName = "sdk-Authrules-1746"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.disasterRecoveryConfigs.listKeys( + resourceGroupName, + namespaceName, + alias, + authorizationRuleName + ); + console.log(result); +} + +nameSpaceAuthorizationRuleListKey().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsListSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsListSample.js new file mode 100644 index 000000000000..2bfe50ef51eb --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/disasterRecoveryConfigsListSample.js @@ -0,0 +1,33 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets all Alias(Disaster Recovery configurations) + * + * @summary Gets all Alias(Disaster Recovery configurations) + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasList.json + */ +async function ehAliasList() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-8859"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.disasterRecoveryConfigs.list(resourceGroupName, namespaceName)) { + resArray.push(item); + } + console.log(resArray); +} + +ehAliasList().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsCreateOrUpdateAuthorizationRuleSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsCreateOrUpdateAuthorizationRuleSample.js new file mode 100644 index 000000000000..8559148f347b --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsCreateOrUpdateAuthorizationRuleSample.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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Creates or updates an AuthorizationRule for the specified Event Hub. Creation/update of the AuthorizationRule will take a few seconds to take effect. + * + * @summary Creates or updates an AuthorizationRule for the specified Event Hub. Creation/update of the AuthorizationRule will take a few seconds to take effect. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleCreate.json + */ +async function eventHubAuthorizationRuleCreate() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-960"; + const eventHubName = "sdk-EventHub-532"; + const authorizationRuleName = "sdk-Authrules-2513"; + const parameters = { rights: ["Listen", "Send"] }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.eventHubs.createOrUpdateAuthorizationRule( + resourceGroupName, + namespaceName, + eventHubName, + authorizationRuleName, + parameters + ); + console.log(result); +} + +eventHubAuthorizationRuleCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsCreateOrUpdateSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsCreateOrUpdateSample.js new file mode 100644 index 000000000000..46ab91dc11e6 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsCreateOrUpdateSample.js @@ -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. +const { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Creates or updates a new Event Hub as a nested resource within a Namespace. + * + * @summary Creates or updates a new Event Hub as a nested resource within a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubCreate.json + */ +async function eventHubCreate() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "Default-NotificationHubs-AustraliaEast"; + const namespaceName = "sdk-Namespace-5357"; + const eventHubName = "sdk-EventHub-6547"; + const parameters = { + captureDescription: { + destination: { + name: "EventHubArchive.AzureBlockBlob", + archiveNameFormat: + "{Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}", + blobContainer: "container", + storageAccountResourceId: + "/subscriptions/e2f361f0-3b27-4503-a9cc-21cfba380093/resourceGroups/Default-Storage-SouthCentralUS/providers/Microsoft.ClassicStorage/storageAccounts/arjunteststorage", + }, + enabled: true, + encoding: "Avro", + intervalInSeconds: 120, + sizeLimitInBytes: 10485763, + }, + messageRetentionInDays: 4, + partitionCount: 4, + status: "Active", + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.eventHubs.createOrUpdate( + resourceGroupName, + namespaceName, + eventHubName, + parameters + ); + console.log(result); +} + +eventHubCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsDeleteAuthorizationRuleSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsDeleteAuthorizationRuleSample.js new file mode 100644 index 000000000000..20c60c1a094c --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsDeleteAuthorizationRuleSample.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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes an Event Hub AuthorizationRule. + * + * @summary Deletes an Event Hub AuthorizationRule. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleDelete.json + */ +async function eventHubAuthorizationRuleDelete() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-960"; + const eventHubName = "sdk-EventHub-532"; + const authorizationRuleName = "sdk-Authrules-2513"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.eventHubs.deleteAuthorizationRule( + resourceGroupName, + namespaceName, + eventHubName, + authorizationRuleName + ); + console.log(result); +} + +eventHubAuthorizationRuleDelete().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsDeleteSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsDeleteSample.js new file mode 100644 index 000000000000..27f996fbd06e --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsDeleteSample.js @@ -0,0 +1,31 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes an Event Hub from the specified Namespace and resource group. + * + * @summary Deletes an Event Hub from the specified Namespace and resource group. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubDelete.json + */ +async function eventHubDelete() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-5357"; + const eventHubName = "sdk-EventHub-6547"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.eventHubs.delete(resourceGroupName, namespaceName, eventHubName); + console.log(result); +} + +eventHubDelete().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsGetAuthorizationRuleSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsGetAuthorizationRuleSample.js new file mode 100644 index 000000000000..a1a61459e1eb --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsGetAuthorizationRuleSample.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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets an AuthorizationRule for an Event Hub by rule name. + * + * @summary Gets an AuthorizationRule for an Event Hub by rule name. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleGet.json + */ +async function eventHubAuthorizationRuleGet() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-960"; + const eventHubName = "sdk-EventHub-532"; + const authorizationRuleName = "sdk-Authrules-2513"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.eventHubs.getAuthorizationRule( + resourceGroupName, + namespaceName, + eventHubName, + authorizationRuleName + ); + console.log(result); +} + +eventHubAuthorizationRuleGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsGetSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsGetSample.js new file mode 100644 index 000000000000..2d031e6fdc69 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsGetSample.js @@ -0,0 +1,31 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets an Event Hubs description for the specified Event Hub. + * + * @summary Gets an Event Hubs description for the specified Event Hub. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubGet.json + */ +async function eventHubGet() { + const subscriptionId = "e2f361f0-3b27-4503-a9cc-21cfba380093"; + const resourceGroupName = "Default-NotificationHubs-AustraliaEast"; + const namespaceName = "sdk-Namespace-716"; + const eventHubName = "sdk-EventHub-10"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.eventHubs.get(resourceGroupName, namespaceName, eventHubName); + console.log(result); +} + +eventHubGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsListAuthorizationRulesSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsListAuthorizationRulesSample.js new file mode 100644 index 000000000000..e3cd0a3f28dd --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsListAuthorizationRulesSample.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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets the authorization rules for an Event Hub. + * + * @summary Gets the authorization rules for an Event Hub. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleListAll.json + */ +async function eventHubAuthorizationRuleListAll() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-960"; + const eventHubName = "sdk-EventHub-532"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.eventHubs.listAuthorizationRules( + resourceGroupName, + namespaceName, + eventHubName + )) { + resArray.push(item); + } + console.log(resArray); +} + +eventHubAuthorizationRuleListAll().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsListByNamespaceSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsListByNamespaceSample.js new file mode 100644 index 000000000000..54e2e8a91fe7 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsListByNamespaceSample.js @@ -0,0 +1,33 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets all the Event Hubs in a Namespace. + * + * @summary Gets all the Event Hubs in a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubListByNameSpace.json + */ +async function eventHubsListAll() { + const subscriptionId = "e2f361f0-3b27-4503-a9cc-21cfba380093"; + const resourceGroupName = "Default-NotificationHubs-AustraliaEast"; + const namespaceName = "sdk-Namespace-5357"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.eventHubs.listByNamespace(resourceGroupName, namespaceName)) { + resArray.push(item); + } + console.log(resArray); +} + +eventHubsListAll().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsListKeysSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsListKeysSample.js new file mode 100644 index 000000000000..38241a05f655 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsListKeysSample.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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets the ACS and SAS connection strings for the Event Hub. + * + * @summary Gets the ACS and SAS connection strings for the Event Hub. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleListKey.json + */ +async function eventHubAuthorizationRuleListKey() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-namespace-960"; + const eventHubName = "sdk-EventHub-532"; + const authorizationRuleName = "sdk-Authrules-2513"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.eventHubs.listKeys( + resourceGroupName, + namespaceName, + eventHubName, + authorizationRuleName + ); + console.log(result); +} + +eventHubAuthorizationRuleListKey().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsRegenerateKeysSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsRegenerateKeysSample.js new file mode 100644 index 000000000000..ba1194ee585a --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/eventHubsRegenerateKeysSample.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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Regenerates the ACS and SAS connection strings for the Event Hub. + * + * @summary Regenerates the ACS and SAS connection strings for the Event Hub. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleRegenerateKey.json + */ +async function eventHubAuthorizationRuleRegenerateKey() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-namespace-960"; + const eventHubName = "sdk-EventHub-532"; + const authorizationRuleName = "sdk-Authrules-1534"; + const parameters = { keyType: "PrimaryKey" }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.eventHubs.regenerateKeys( + resourceGroupName, + namespaceName, + eventHubName, + authorizationRuleName, + parameters + ); + console.log(result); +} + +eventHubAuthorizationRuleRegenerateKey().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesCheckNameAvailabilitySample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesCheckNameAvailabilitySample.js new file mode 100644 index 000000000000..a3dc69bb4cab --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesCheckNameAvailabilitySample.js @@ -0,0 +1,31 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Check the give Namespace name availability. + * + * @summary Check the give Namespace name availability. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceCheckNameAvailability.json + */ +async function namespacesCheckNameAvailability() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const parameters = { + name: "sdk-Namespace-8458", + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.checkNameAvailability(parameters); + console.log(result); +} + +namespacesCheckNameAvailability().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesCreateOrUpdateAuthorizationRuleSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesCreateOrUpdateAuthorizationRuleSample.js new file mode 100644 index 000000000000..20e2dc37cd90 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesCreateOrUpdateAuthorizationRuleSample.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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Creates or updates an AuthorizationRule for a Namespace. + * + * @summary Creates or updates an AuthorizationRule for a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleCreate.json + */ +async function nameSpaceAuthorizationRuleCreate() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2702"; + const authorizationRuleName = "sdk-Authrules-1746"; + const parameters = { rights: ["Listen", "Send"] }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.createOrUpdateAuthorizationRule( + resourceGroupName, + namespaceName, + authorizationRuleName, + parameters + ); + console.log(result); +} + +nameSpaceAuthorizationRuleCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesCreateOrUpdateNetworkRuleSetSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesCreateOrUpdateNetworkRuleSetSample.js new file mode 100644 index 000000000000..b44bd0515786 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesCreateOrUpdateNetworkRuleSetSample.js @@ -0,0 +1,64 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Create or update NetworkRuleSet for a Namespace. + * + * @summary Create or update NetworkRuleSet for a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/VirtualNetworkRule/EHNetworkRuleSetCreate.json + */ +async function nameSpaceNetworkRuleSetCreate() { + const subscriptionId = "Subscription"; + const resourceGroupName = "ResourceGroup"; + const namespaceName = "sdk-Namespace-6019"; + const parameters = { + defaultAction: "Deny", + ipRules: [ + { action: "Allow", ipMask: "1.1.1.1" }, + { action: "Allow", ipMask: "1.1.1.2" }, + { action: "Allow", ipMask: "1.1.1.3" }, + { action: "Allow", ipMask: "1.1.1.4" }, + { action: "Allow", ipMask: "1.1.1.5" }, + ], + virtualNetworkRules: [ + { + ignoreMissingVnetServiceEndpoint: true, + subnet: { + id: "/subscriptions/subscriptionid/resourcegroups/resourcegroupid/providers/Microsoft.Network/virtualNetworks/myvn/subnets/subnet2", + }, + }, + { + ignoreMissingVnetServiceEndpoint: false, + subnet: { + id: "/subscriptions/subscriptionid/resourcegroups/resourcegroupid/providers/Microsoft.Network/virtualNetworks/myvn/subnets/subnet3", + }, + }, + { + ignoreMissingVnetServiceEndpoint: false, + subnet: { + id: "/subscriptions/subscriptionid/resourcegroups/resourcegroupid/providers/Microsoft.Network/virtualNetworks/myvn/subnets/subnet6", + }, + }, + ], + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.createOrUpdateNetworkRuleSet( + resourceGroupName, + namespaceName, + parameters + ); + console.log(result); +} + +nameSpaceNetworkRuleSetCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesCreateOrUpdateSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesCreateOrUpdateSample.js new file mode 100644 index 000000000000..64bd6a7a3787 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesCreateOrUpdateSample.js @@ -0,0 +1,61 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Creates or updates a namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. + * + * @summary Creates or updates a namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceCreate.json + */ +async function namespaceCreate() { + const subscriptionId = "SampleSubscription"; + const resourceGroupName = "ResurceGroupSample"; + const namespaceName = "NamespaceSample"; + const parameters = { + clusterArmId: + "/subscriptions/SampleSubscription/resourceGroups/ResurceGroupSample/providers/Microsoft.EventHub/clusters/enc-test", + encryption: { + keySource: "Microsoft.KeyVault", + keyVaultProperties: [ + { + identity: { + userAssignedIdentity: + "/subscriptions/SampleSubscription/resourceGroups/ResurceGroupSample/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ud1", + }, + keyName: "Samplekey", + keyVaultUri: "https://aprao-keyvault-user.vault-int.azure-int.net/", + }, + ], + }, + identity: { + type: "SystemAssigned, UserAssigned", + userAssignedIdentities: { + "/subscriptions/SampleSubscription/resourceGroups/ResurceGroupSample/providers/MicrosoftManagedIdentity/userAssignedIdentities/ud1": + {}, + "/subscriptions/SampleSubscription/resourceGroups/ResurceGroupSample/providers/MicrosoftManagedIdentity/userAssignedIdentities/ud2": + {}, + }, + }, + location: "East US", + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.beginCreateOrUpdateAndWait( + resourceGroupName, + namespaceName, + parameters + ); + console.log(result); +} + +namespaceCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesDeleteAuthorizationRuleSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesDeleteAuthorizationRuleSample.js new file mode 100644 index 000000000000..4d63731f5373 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesDeleteAuthorizationRuleSample.js @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes an AuthorizationRule for a Namespace. + * + * @summary Deletes an AuthorizationRule for a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleDelete.json + */ +async function nameSpaceAuthorizationRuleDelete() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-8980"; + const authorizationRuleName = "sdk-Authrules-8929"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.deleteAuthorizationRule( + resourceGroupName, + namespaceName, + authorizationRuleName + ); + console.log(result); +} + +nameSpaceAuthorizationRuleDelete().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesDeleteSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesDeleteSample.js new file mode 100644 index 000000000000..79a20b3168e9 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesDeleteSample.js @@ -0,0 +1,30 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes an existing namespace. This operation also removes all associated resources under the namespace. + * + * @summary Deletes an existing namespace. This operation also removes all associated resources under the namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceDelete.json + */ +async function nameSpaceDelete() { + const subscriptionId = "SampleSubscription"; + const resourceGroupName = "ResurceGroupSample"; + const namespaceName = "NamespaceSample"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.beginDeleteAndWait(resourceGroupName, namespaceName); + console.log(result); +} + +nameSpaceDelete().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesGetAuthorizationRuleSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesGetAuthorizationRuleSample.js new file mode 100644 index 000000000000..d351e65aeae0 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesGetAuthorizationRuleSample.js @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets an AuthorizationRule for a Namespace by rule name. + * + * @summary Gets an AuthorizationRule for a Namespace by rule name. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleGet.json + */ +async function nameSpaceAuthorizationRuleGet() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2702"; + const authorizationRuleName = "sdk-Authrules-1746"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.getAuthorizationRule( + resourceGroupName, + namespaceName, + authorizationRuleName + ); + console.log(result); +} + +nameSpaceAuthorizationRuleGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesGetNetworkRuleSetSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesGetNetworkRuleSetSample.js new file mode 100644 index 000000000000..0e82c1af842e --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesGetNetworkRuleSetSample.js @@ -0,0 +1,30 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets NetworkRuleSet for a Namespace. + * + * @summary Gets NetworkRuleSet for a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/VirtualNetworkRule/EHNetworkRuleSetGet.json + */ +async function nameSpaceNetworkRuleSetGet() { + const subscriptionId = "Subscription"; + const resourceGroupName = "ResourceGroup"; + const namespaceName = "sdk-Namespace-6019"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.getNetworkRuleSet(resourceGroupName, namespaceName); + console.log(result); +} + +nameSpaceNetworkRuleSetGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesGetSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesGetSample.js new file mode 100644 index 000000000000..c430dbf6bb5f --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesGetSample.js @@ -0,0 +1,30 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets the description of the specified namespace. + * + * @summary Gets the description of the specified namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceGet.json + */ +async function nameSpaceGet() { + const subscriptionId = "SampleSubscription"; + const resourceGroupName = "ResurceGroupSample"; + const namespaceName = "NamespaceSample"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.get(resourceGroupName, namespaceName); + console.log(result); +} + +nameSpaceGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesListAuthorizationRulesSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesListAuthorizationRulesSample.js new file mode 100644 index 000000000000..2363c5e5b1e3 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesListAuthorizationRulesSample.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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets a list of authorization rules for a Namespace. + * + * @summary Gets a list of authorization rules for a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleListAll.json + */ +async function listAuthorizationRules() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2702"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.namespaces.listAuthorizationRules( + resourceGroupName, + namespaceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listAuthorizationRules().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesListByResourceGroupSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesListByResourceGroupSample.js new file mode 100644 index 000000000000..697c2a9c8f3a --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesListByResourceGroupSample.js @@ -0,0 +1,32 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists the available Namespaces within a resource group. + * + * @summary Lists the available Namespaces within a resource group. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceListByResourceGroup.json + */ +async function namespaceListByResourceGroup() { + const subscriptionId = "SampleSubscription"; + const resourceGroupName = "ResurceGroupSample"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.namespaces.listByResourceGroup(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +namespaceListByResourceGroup().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesListKeysSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesListKeysSample.js new file mode 100644 index 000000000000..7343b6d12675 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesListKeysSample.js @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets the primary and secondary connection strings for the Namespace. + * + * @summary Gets the primary and secondary connection strings for the Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleListKey.json + */ +async function nameSpaceAuthorizationRuleListKey() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2702"; + const authorizationRuleName = "sdk-Authrules-1746"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.listKeys( + resourceGroupName, + namespaceName, + authorizationRuleName + ); + console.log(result); +} + +nameSpaceAuthorizationRuleListKey().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesListNetworkRuleSetSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesListNetworkRuleSetSample.js new file mode 100644 index 000000000000..247e38377bc9 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesListNetworkRuleSetSample.js @@ -0,0 +1,30 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets NetworkRuleSet for a Namespace. + * + * @summary Gets NetworkRuleSet for a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/VirtualNetworkRule/EHNetworkRuleSetList.json + */ +async function nameSpaceNetworkRuleSetList() { + const subscriptionId = "Subscription"; + const resourceGroupName = "ResourceGroup"; + const namespaceName = "sdk-Namespace-6019"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.listNetworkRuleSet(resourceGroupName, namespaceName); + console.log(result); +} + +nameSpaceNetworkRuleSetList().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesListSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesListSample.js new file mode 100644 index 000000000000..6626b11cec09 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesListSample.js @@ -0,0 +1,31 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists all the available Namespaces within a subscription, irrespective of the resource groups. + * + * @summary Lists all the available Namespaces within a subscription, irrespective of the resource groups. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceList.json + */ +async function namespacesListBySubscription() { + const subscriptionId = "SampleSubscription"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.namespaces.list()) { + resArray.push(item); + } + console.log(resArray); +} + +namespacesListBySubscription().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesRegenerateKeysSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesRegenerateKeysSample.js new file mode 100644 index 000000000000..7256150c0565 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesRegenerateKeysSample.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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Regenerates the primary or secondary connection strings for the specified Namespace. + * + * @summary Regenerates the primary or secondary connection strings for the specified Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleRegenerateKey.json + */ +async function nameSpaceAuthorizationRuleRegenerateKey() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-8980"; + const authorizationRuleName = "sdk-Authrules-8929"; + const parameters = { keyType: "PrimaryKey" }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.regenerateKeys( + resourceGroupName, + namespaceName, + authorizationRuleName, + parameters + ); + console.log(result); +} + +nameSpaceAuthorizationRuleRegenerateKey().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesUpdateSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesUpdateSample.js new file mode 100644 index 000000000000..c68143bdc256 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/namespacesUpdateSample.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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Creates or updates a namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. + * + * @summary Creates or updates a namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceUpdate.json + */ +async function namespacesUpdate() { + const subscriptionId = "SampleSubscription"; + const resourceGroupName = "ResurceGroupSample"; + const namespaceName = "NamespaceSample"; + const parameters = { + identity: { + type: "SystemAssigned, UserAssigned", + userAssignedIdentities: { + "/subscriptions/SampleSubscription/resourceGroups/ResurceGroupSample/providers/MicrosoftManagedIdentity/userAssignedIdentities/ud2": + {}, + }, + }, + location: "East US", + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.update(resourceGroupName, namespaceName, parameters); + console.log(result); +} + +namespacesUpdate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/operationsListSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/operationsListSample.js new file mode 100644 index 000000000000..207193877e3b --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/operationsListSample.js @@ -0,0 +1,31 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists all of the available Event Hub REST API operations. + * + * @summary Lists all of the available Event Hub REST API operations. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EHOperations_List.json + */ +async function ehOperationsList() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +ehOperationsList().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/package.json b/sdk/eventhub/arm-eventhub/samples/v5/javascript/package.json new file mode 100644 index 000000000000..3212532d03bf --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/package.json @@ -0,0 +1,32 @@ +{ + "name": "@azure-samples/arm-eventhub-js", + "private": true, + "version": "1.0.0", + "description": " client library samples for JavaScript", + "engines": { + "node": ">=12.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/eventhub/arm-eventhub" + }, + "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/eventhub/arm-eventhub", + "dependencies": { + "@azure/arm-eventhub": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + } +} diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/privateEndpointConnectionsCreateOrUpdateSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/privateEndpointConnectionsCreateOrUpdateSample.js new file mode 100644 index 000000000000..3b311e63deb4 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/privateEndpointConnectionsCreateOrUpdateSample.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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Creates or updates PrivateEndpointConnections of service namespace. + * + * @summary Creates or updates PrivateEndpointConnections of service namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/PrivateEndPointConnectionCreate.json + */ +async function nameSpacePrivateEndPointConnectionCreate() { + const subscriptionId = "subID"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2924"; + const privateEndpointConnectionName = "privateEndpointConnectionName"; + const parameters = { + privateEndpoint: { + id: "/subscriptions/dbedb4e0-40e6-4145-81f3-f1314c150774/resourceGroups/SDK-EventHub-8396/providers/Microsoft.Network/privateEndpoints/sdk-Namespace-2847", + }, + privateLinkServiceConnectionState: { + description: "testing", + status: "Rejected", + }, + provisioningState: "Succeeded", + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.createOrUpdate( + resourceGroupName, + namespaceName, + privateEndpointConnectionName, + parameters + ); + console.log(result); +} + +nameSpacePrivateEndPointConnectionCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/privateEndpointConnectionsDeleteSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/privateEndpointConnectionsDeleteSample.js new file mode 100644 index 000000000000..41c96fe6628a --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/privateEndpointConnectionsDeleteSample.js @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes an existing namespace. This operation also removes all associated resources under the namespace. + * + * @summary Deletes an existing namespace. This operation also removes all associated resources under the namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/PrivateEndPointConnectionDelete.json + */ +async function nameSpacePrivateEndPointConnectionDelete() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-3285"; + const privateEndpointConnectionName = "928c44d5-b7c6-423b-b6fa-811e0c27b3e0"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.beginDeleteAndWait( + resourceGroupName, + namespaceName, + privateEndpointConnectionName + ); + console.log(result); +} + +nameSpacePrivateEndPointConnectionDelete().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/privateEndpointConnectionsGetSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/privateEndpointConnectionsGetSample.js new file mode 100644 index 000000000000..ac75b76655eb --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/privateEndpointConnectionsGetSample.js @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets a description for the specified Private Endpoint Connection name. + * + * @summary Gets a description for the specified Private Endpoint Connection name. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/PrivateEndPointConnectionGet.json + */ +async function nameSpacePrivateEndPointConnectionGet() { + const subscriptionId = "subID"; + const resourceGroupName = "SDK-EventHub-4794"; + const namespaceName = "sdk-Namespace-5828"; + const privateEndpointConnectionName = "privateEndpointConnectionName"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.get( + resourceGroupName, + namespaceName, + privateEndpointConnectionName + ); + console.log(result); +} + +nameSpacePrivateEndPointConnectionGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/privateEndpointConnectionsListSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/privateEndpointConnectionsListSample.js new file mode 100644 index 000000000000..f5b3a2853867 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/privateEndpointConnectionsListSample.js @@ -0,0 +1,33 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets the available PrivateEndpointConnections within a namespace. + * + * @summary Gets the available PrivateEndpointConnections within a namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/PrivateEndPointConnectionList.json + */ +async function nameSpaceCreate() { + const subscriptionId = "subID"; + const resourceGroupName = "SDK-EventHub-4794"; + const namespaceName = "sdk-Namespace-5828"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.privateEndpointConnections.list(resourceGroupName, namespaceName)) { + resArray.push(item); + } + console.log(resArray); +} + +nameSpaceCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/privateLinkResourcesGetSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/privateLinkResourcesGetSample.js new file mode 100644 index 000000000000..c363f2826145 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/privateLinkResourcesGetSample.js @@ -0,0 +1,30 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets lists of resources that supports Privatelinks. + * + * @summary Gets lists of resources that supports Privatelinks. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/PrivateLinkResourcesGet.json + */ +async function nameSpacePrivateLinkResourcesGet() { + const subscriptionId = "subID"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2924"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.privateLinkResources.get(resourceGroupName, namespaceName); + console.log(result); +} + +nameSpacePrivateLinkResourcesGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/sample.env b/sdk/eventhub/arm-eventhub/samples/v5/javascript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/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/eventhub/arm-eventhub/samples/v5/javascript/schemaRegistryCreateOrUpdateSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/schemaRegistryCreateOrUpdateSample.js new file mode 100644 index 000000000000..ea5e3514ff79 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/schemaRegistryCreateOrUpdateSample.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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to + * + * @summary + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/SchemaRegistry/SchemaRegistryCreate.json + */ +async function schemaRegistryCreate() { + const subscriptionId = "e8baea74-64ce-459b-bee3-5aa4c47b3ae3"; + const resourceGroupName = "alitest"; + const namespaceName = "ali-ua-test-eh-system-1"; + const schemaGroupName = "testSchemaGroup1"; + const parameters = { + groupProperties: {}, + schemaCompatibility: "Forward", + schemaType: "Avro", + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.schemaRegistry.createOrUpdate( + resourceGroupName, + namespaceName, + schemaGroupName, + parameters + ); + console.log(result); +} + +schemaRegistryCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/schemaRegistryDeleteSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/schemaRegistryDeleteSample.js new file mode 100644 index 000000000000..2bbbca220b25 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/schemaRegistryDeleteSample.js @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to + * + * @summary + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/SchemaRegistry/SchemaRegistryDelete.json + */ +async function schemaRegistryDelete() { + const subscriptionId = "e8baea74-64ce-459b-bee3-5aa4c47b3ae3"; + const resourceGroupName = "alitest"; + const namespaceName = "ali-ua-test-eh-system-1"; + const schemaGroupName = "testSchemaGroup1"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.schemaRegistry.delete( + resourceGroupName, + namespaceName, + schemaGroupName + ); + console.log(result); +} + +schemaRegistryDelete().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/schemaRegistryGetSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/schemaRegistryGetSample.js new file mode 100644 index 000000000000..0bbcd1b99254 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/schemaRegistryGetSample.js @@ -0,0 +1,31 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to + * + * @summary + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/SchemaRegistry/SchemaRegistryGet.json + */ +async function schemaRegistryGet() { + const subscriptionId = "e8baea74-64ce-459b-bee3-5aa4c47b3ae3"; + const resourceGroupName = "alitest"; + const namespaceName = "ali-ua-test-eh-system-1"; + const schemaGroupName = "testSchemaGroup1"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.schemaRegistry.get(resourceGroupName, namespaceName, schemaGroupName); + console.log(result); +} + +schemaRegistryGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/javascript/schemaRegistryListByNamespaceSample.js b/sdk/eventhub/arm-eventhub/samples/v5/javascript/schemaRegistryListByNamespaceSample.js new file mode 100644 index 000000000000..670264a96a3c --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/javascript/schemaRegistryListByNamespaceSample.js @@ -0,0 +1,33 @@ +/* + * 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 { EventHubManagementClient } = require("@azure/arm-eventhub"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets all the Schema Groups in a Namespace. + * + * @summary Gets all the Schema Groups in a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/SchemaRegistry/SchemaRegistryListByNamespace.json + */ +async function schemaRegistryListAll() { + const subscriptionId = "e8baea74-64ce-459b-bee3-5aa4c47b3ae3"; + const resourceGroupName = "alitest"; + const namespaceName = "ali-ua-test-eh-system-1"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.schemaRegistry.listByNamespace(resourceGroupName, namespaceName)) { + resArray.push(item); + } + console.log(resArray); +} + +schemaRegistryListAll().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/README.md b/sdk/eventhub/arm-eventhub/samples/v5/typescript/README.md new file mode 100644 index 000000000000..8e3f70926fce --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/README.md @@ -0,0 +1,181 @@ +# client library samples for TypeScript + +These sample programs show how to use the TypeScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| ------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [clustersCreateOrUpdateSample.ts][clusterscreateorupdatesample] | Creates or updates an instance of an Event Hubs Cluster. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterPut.json | +| [clustersDeleteSample.ts][clustersdeletesample] | Deletes an existing Event Hubs Cluster. This operation is idempotent. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterDelete.json | +| [clustersGetSample.ts][clustersgetsample] | Gets the resource description of the specified Event Hubs Cluster. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterGet.json | +| [clustersListAvailableClusterRegionSample.ts][clusterslistavailableclusterregionsample] | List the quantity of available pre-provisioned Event Hubs Clusters, indexed by Azure region. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ListAvailableClustersGet.json | +| [clustersListByResourceGroupSample.ts][clusterslistbyresourcegroupsample] | Lists the available Event Hubs Clusters within an ARM resource group x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClustersListByResourceGroup.json | +| [clustersListBySubscriptionSample.ts][clusterslistbysubscriptionsample] | Lists the available Event Hubs Clusters within an ARM resource group x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClustersListBySubscription.json | +| [clustersListNamespacesSample.ts][clusterslistnamespacessample] | List all Event Hubs Namespace IDs in an Event Hubs Dedicated Cluster. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ListNamespacesInClusterGet.json | +| [clustersUpdateSample.ts][clustersupdatesample] | Modifies mutable properties on the Event Hubs Cluster. This operation is idempotent. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterPatch.json | +| [configurationGetSample.ts][configurationgetsample] | Get all Event Hubs Cluster settings - a collection of key/value pairs which represent the quotas and settings imposed on the cluster. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterQuotaConfigurationGet.json | +| [configurationPatchSample.ts][configurationpatchsample] | Replace all specified Event Hubs Cluster settings with those contained in the request body. Leaves the settings not specified in the request body unmodified. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterQuotaConfigurationPatch.json | +| [consumerGroupsCreateOrUpdateSample.ts][consumergroupscreateorupdatesample] | Creates or updates an Event Hubs consumer group as a nested resource within a Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/ConsumerGroup/EHConsumerGroupCreate.json | +| [consumerGroupsDeleteSample.ts][consumergroupsdeletesample] | Deletes a consumer group from the specified Event Hub and resource group. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/ConsumerGroup/EHConsumerGroupDelete.json | +| [consumerGroupsGetSample.ts][consumergroupsgetsample] | Gets a description for the specified consumer group. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/ConsumerGroup/EHConsumerGroupGet.json | +| [consumerGroupsListByEventHubSample.ts][consumergroupslistbyeventhubsample] | Gets all the consumer groups in a Namespace. An empty feed is returned if no consumer group exists in the Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/ConsumerGroup/EHConsumerGroupListByEventHub.json | +| [disasterRecoveryConfigsBreakPairingSample.ts][disasterrecoveryconfigsbreakpairingsample] | This operation disables the Disaster Recovery and stops replicating changes from primary to secondary namespaces x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasBreakPairing.json | +| [disasterRecoveryConfigsCheckNameAvailabilitySample.ts][disasterrecoveryconfigschecknameavailabilitysample] | Check the give Namespace name availability. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasCheckNameAvailability.json | +| [disasterRecoveryConfigsCreateOrUpdateSample.ts][disasterrecoveryconfigscreateorupdatesample] | Creates or updates a new Alias(Disaster Recovery configuration) x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasCreate.json | +| [disasterRecoveryConfigsDeleteSample.ts][disasterrecoveryconfigsdeletesample] | Deletes an Alias(Disaster Recovery configuration) x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasDelete.json | +| [disasterRecoveryConfigsFailOverSample.ts][disasterrecoveryconfigsfailoversample] | Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasFailOver.json | +| [disasterRecoveryConfigsGetAuthorizationRuleSample.ts][disasterrecoveryconfigsgetauthorizationrulesample] | Gets an AuthorizationRule for a Namespace by rule name. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasAuthorizationRuleGet.json | +| [disasterRecoveryConfigsGetSample.ts][disasterrecoveryconfigsgetsample] | Retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasGet.json | +| [disasterRecoveryConfigsListAuthorizationRulesSample.ts][disasterrecoveryconfigslistauthorizationrulessample] | Gets a list of authorization rules for a Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasAuthorizationRuleListAll.json | +| [disasterRecoveryConfigsListKeysSample.ts][disasterrecoveryconfigslistkeyssample] | Gets the primary and secondary connection strings for the Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasAuthorizationRuleListKey.json | +| [disasterRecoveryConfigsListSample.ts][disasterrecoveryconfigslistsample] | Gets all Alias(Disaster Recovery configurations) x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasList.json | +| [eventHubsCreateOrUpdateAuthorizationRuleSample.ts][eventhubscreateorupdateauthorizationrulesample] | Creates or updates an AuthorizationRule for the specified Event Hub. Creation/update of the AuthorizationRule will take a few seconds to take effect. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleCreate.json | +| [eventHubsCreateOrUpdateSample.ts][eventhubscreateorupdatesample] | Creates or updates a new Event Hub as a nested resource within a Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubCreate.json | +| [eventHubsDeleteAuthorizationRuleSample.ts][eventhubsdeleteauthorizationrulesample] | Deletes an Event Hub AuthorizationRule. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleDelete.json | +| [eventHubsDeleteSample.ts][eventhubsdeletesample] | Deletes an Event Hub from the specified Namespace and resource group. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubDelete.json | +| [eventHubsGetAuthorizationRuleSample.ts][eventhubsgetauthorizationrulesample] | Gets an AuthorizationRule for an Event Hub by rule name. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleGet.json | +| [eventHubsGetSample.ts][eventhubsgetsample] | Gets an Event Hubs description for the specified Event Hub. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubGet.json | +| [eventHubsListAuthorizationRulesSample.ts][eventhubslistauthorizationrulessample] | Gets the authorization rules for an Event Hub. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleListAll.json | +| [eventHubsListByNamespaceSample.ts][eventhubslistbynamespacesample] | Gets all the Event Hubs in a Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubListByNameSpace.json | +| [eventHubsListKeysSample.ts][eventhubslistkeyssample] | Gets the ACS and SAS connection strings for the Event Hub. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleListKey.json | +| [eventHubsRegenerateKeysSample.ts][eventhubsregeneratekeyssample] | Regenerates the ACS and SAS connection strings for the Event Hub. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleRegenerateKey.json | +| [namespacesCheckNameAvailabilitySample.ts][namespaceschecknameavailabilitysample] | Check the give Namespace name availability. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceCheckNameAvailability.json | +| [namespacesCreateOrUpdateAuthorizationRuleSample.ts][namespacescreateorupdateauthorizationrulesample] | Creates or updates an AuthorizationRule for a Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleCreate.json | +| [namespacesCreateOrUpdateNetworkRuleSetSample.ts][namespacescreateorupdatenetworkrulesetsample] | Create or update NetworkRuleSet for a Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/VirtualNetworkRule/EHNetworkRuleSetCreate.json | +| [namespacesCreateOrUpdateSample.ts][namespacescreateorupdatesample] | Creates or updates a namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceCreate.json | +| [namespacesDeleteAuthorizationRuleSample.ts][namespacesdeleteauthorizationrulesample] | Deletes an AuthorizationRule for a Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleDelete.json | +| [namespacesDeleteSample.ts][namespacesdeletesample] | Deletes an existing namespace. This operation also removes all associated resources under the namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceDelete.json | +| [namespacesGetAuthorizationRuleSample.ts][namespacesgetauthorizationrulesample] | Gets an AuthorizationRule for a Namespace by rule name. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleGet.json | +| [namespacesGetNetworkRuleSetSample.ts][namespacesgetnetworkrulesetsample] | Gets NetworkRuleSet for a Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/VirtualNetworkRule/EHNetworkRuleSetGet.json | +| [namespacesGetSample.ts][namespacesgetsample] | Gets the description of the specified namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceGet.json | +| [namespacesListAuthorizationRulesSample.ts][namespaceslistauthorizationrulessample] | Gets a list of authorization rules for a Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleListAll.json | +| [namespacesListByResourceGroupSample.ts][namespaceslistbyresourcegroupsample] | Lists the available Namespaces within a resource group. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceListByResourceGroup.json | +| [namespacesListKeysSample.ts][namespaceslistkeyssample] | Gets the primary and secondary connection strings for the Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleListKey.json | +| [namespacesListNetworkRuleSetSample.ts][namespaceslistnetworkrulesetsample] | Gets NetworkRuleSet for a Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/VirtualNetworkRule/EHNetworkRuleSetList.json | +| [namespacesListSample.ts][namespaceslistsample] | Lists all the available Namespaces within a subscription, irrespective of the resource groups. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceList.json | +| [namespacesRegenerateKeysSample.ts][namespacesregeneratekeyssample] | Regenerates the primary or secondary connection strings for the specified Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleRegenerateKey.json | +| [namespacesUpdateSample.ts][namespacesupdatesample] | Creates or updates a namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceUpdate.json | +| [operationsListSample.ts][operationslistsample] | Lists all of the available Event Hub REST API operations. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EHOperations_List.json | +| [privateEndpointConnectionsCreateOrUpdateSample.ts][privateendpointconnectionscreateorupdatesample] | Creates or updates PrivateEndpointConnections of service namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/PrivateEndPointConnectionCreate.json | +| [privateEndpointConnectionsDeleteSample.ts][privateendpointconnectionsdeletesample] | Deletes an existing namespace. This operation also removes all associated resources under the namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/PrivateEndPointConnectionDelete.json | +| [privateEndpointConnectionsGetSample.ts][privateendpointconnectionsgetsample] | Gets a description for the specified Private Endpoint Connection name. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/PrivateEndPointConnectionGet.json | +| [privateEndpointConnectionsListSample.ts][privateendpointconnectionslistsample] | Gets the available PrivateEndpointConnections within a namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/PrivateEndPointConnectionList.json | +| [privateLinkResourcesGetSample.ts][privatelinkresourcesgetsample] | Gets lists of resources that supports Privatelinks. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/PrivateLinkResourcesGet.json | +| [schemaRegistryCreateOrUpdateSample.ts][schemaregistrycreateorupdatesample] | x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/SchemaRegistry/SchemaRegistryCreate.json | +| [schemaRegistryDeleteSample.ts][schemaregistrydeletesample] | x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/SchemaRegistry/SchemaRegistryDelete.json | +| [schemaRegistryGetSample.ts][schemaregistrygetsample] | x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/SchemaRegistry/SchemaRegistryGet.json | +| [schemaRegistryListByNamespaceSample.ts][schemaregistrylistbynamespacesample] | Gets all the Schema Groups in a Namespace. x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/SchemaRegistry/SchemaRegistryListByNamespace.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +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/clustersCreateOrUpdateSample.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 node dist/clustersCreateOrUpdateSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[clusterscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersCreateOrUpdateSample.ts +[clustersdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersDeleteSample.ts +[clustersgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersGetSample.ts +[clusterslistavailableclusterregionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersListAvailableClusterRegionSample.ts +[clusterslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersListByResourceGroupSample.ts +[clusterslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersListBySubscriptionSample.ts +[clusterslistnamespacessample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersListNamespacesSample.ts +[clustersupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersUpdateSample.ts +[configurationgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/configurationGetSample.ts +[configurationpatchsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/configurationPatchSample.ts +[consumergroupscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/consumerGroupsCreateOrUpdateSample.ts +[consumergroupsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/consumerGroupsDeleteSample.ts +[consumergroupsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/consumerGroupsGetSample.ts +[consumergroupslistbyeventhubsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/consumerGroupsListByEventHubSample.ts +[disasterrecoveryconfigsbreakpairingsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsBreakPairingSample.ts +[disasterrecoveryconfigschecknameavailabilitysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsCheckNameAvailabilitySample.ts +[disasterrecoveryconfigscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsCreateOrUpdateSample.ts +[disasterrecoveryconfigsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsDeleteSample.ts +[disasterrecoveryconfigsfailoversample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsFailOverSample.ts +[disasterrecoveryconfigsgetauthorizationrulesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsGetAuthorizationRuleSample.ts +[disasterrecoveryconfigsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsGetSample.ts +[disasterrecoveryconfigslistauthorizationrulessample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsListAuthorizationRulesSample.ts +[disasterrecoveryconfigslistkeyssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsListKeysSample.ts +[disasterrecoveryconfigslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsListSample.ts +[eventhubscreateorupdateauthorizationrulesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsCreateOrUpdateAuthorizationRuleSample.ts +[eventhubscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsCreateOrUpdateSample.ts +[eventhubsdeleteauthorizationrulesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsDeleteAuthorizationRuleSample.ts +[eventhubsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsDeleteSample.ts +[eventhubsgetauthorizationrulesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsGetAuthorizationRuleSample.ts +[eventhubsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsGetSample.ts +[eventhubslistauthorizationrulessample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsListAuthorizationRulesSample.ts +[eventhubslistbynamespacesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsListByNamespaceSample.ts +[eventhubslistkeyssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsListKeysSample.ts +[eventhubsregeneratekeyssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsRegenerateKeysSample.ts +[namespaceschecknameavailabilitysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesCheckNameAvailabilitySample.ts +[namespacescreateorupdateauthorizationrulesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesCreateOrUpdateAuthorizationRuleSample.ts +[namespacescreateorupdatenetworkrulesetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesCreateOrUpdateNetworkRuleSetSample.ts +[namespacescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesCreateOrUpdateSample.ts +[namespacesdeleteauthorizationrulesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesDeleteAuthorizationRuleSample.ts +[namespacesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesDeleteSample.ts +[namespacesgetauthorizationrulesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesGetAuthorizationRuleSample.ts +[namespacesgetnetworkrulesetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesGetNetworkRuleSetSample.ts +[namespacesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesGetSample.ts +[namespaceslistauthorizationrulessample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesListAuthorizationRulesSample.ts +[namespaceslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesListByResourceGroupSample.ts +[namespaceslistkeyssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesListKeysSample.ts +[namespaceslistnetworkrulesetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesListNetworkRuleSetSample.ts +[namespaceslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesListSample.ts +[namespacesregeneratekeyssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesRegenerateKeysSample.ts +[namespacesupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesUpdateSample.ts +[operationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/operationsListSample.ts +[privateendpointconnectionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/privateEndpointConnectionsCreateOrUpdateSample.ts +[privateendpointconnectionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/privateEndpointConnectionsDeleteSample.ts +[privateendpointconnectionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/privateEndpointConnectionsGetSample.ts +[privateendpointconnectionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/privateEndpointConnectionsListSample.ts +[privatelinkresourcesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/privateLinkResourcesGetSample.ts +[schemaregistrycreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/schemaRegistryCreateOrUpdateSample.ts +[schemaregistrydeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/schemaRegistryDeleteSample.ts +[schemaregistrygetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/schemaRegistryGetSample.ts +[schemaregistrylistbynamespacesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/schemaRegistryListByNamespaceSample.ts +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-eventhub?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/eventhub/arm-eventhub/README.md +[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/package.json b/sdk/eventhub/arm-eventhub/samples/v5/typescript/package.json new file mode 100644 index 000000000000..6515e7cbdc7a --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/package.json @@ -0,0 +1,41 @@ +{ + "name": "@azure-samples/arm-eventhub-ts", + "private": true, + "version": "1.0.0", + "description": " client library samples for TypeScript", + "engines": { + "node": ">=12.0.0" + }, + "scripts": { + "build": "tsc", + "prebuild": "rimraf dist/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/eventhub/arm-eventhub" + }, + "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/eventhub/arm-eventhub", + "dependencies": { + "@azure/arm-eventhub": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + }, + "devDependencies": { + "@types/node": "^12.0.0", + "typescript": "~4.4.0", + "rimraf": "latest" + } +} diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/sample.env b/sdk/eventhub/arm-eventhub/samples/v5/typescript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/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/eventhub/arm-eventhub/samples/v5/typescript/src/clustersCreateOrUpdateSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersCreateOrUpdateSample.ts new file mode 100644 index 000000000000..00703d2367b4 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersCreateOrUpdateSample.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 { Cluster, EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates an instance of an Event Hubs Cluster. + * + * @summary Creates or updates an instance of an Event Hubs Cluster. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterPut.json + */ +async function clusterPut() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "myResourceGroup"; + const clusterName = "testCluster"; + const parameters: Cluster = { + location: "South Central US", + sku: { name: "Dedicated", capacity: 1 }, + tags: { tag1: "value1", tag2: "value2" } + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.clusters.beginCreateOrUpdateAndWait( + resourceGroupName, + clusterName, + parameters + ); + console.log(result); +} + +clusterPut().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersDeleteSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersDeleteSample.ts new file mode 100644 index 000000000000..348046fd171f --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersDeleteSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes an existing Event Hubs Cluster. This operation is idempotent. + * + * @summary Deletes an existing Event Hubs Cluster. This operation is idempotent. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterDelete.json + */ +async function clusterDelete() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "myResourceGroup"; + const clusterName = "testCluster"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.clusters.beginDeleteAndWait( + resourceGroupName, + clusterName + ); + console.log(result); +} + +clusterDelete().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersGetSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersGetSample.ts new file mode 100644 index 000000000000..fb0784a5c4df --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersGetSample.ts @@ -0,0 +1,30 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the resource description of the specified Event Hubs Cluster. + * + * @summary Gets the resource description of the specified Event Hubs Cluster. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterGet.json + */ +async function clusterGet() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "myResourceGroup"; + const clusterName = "testCluster"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.clusters.get(resourceGroupName, clusterName); + console.log(result); +} + +clusterGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersListAvailableClusterRegionSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersListAvailableClusterRegionSample.ts new file mode 100644 index 000000000000..a87fe8f4c05a --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersListAvailableClusterRegionSample.ts @@ -0,0 +1,28 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to List the quantity of available pre-provisioned Event Hubs Clusters, indexed by Azure region. + * + * @summary List the quantity of available pre-provisioned Event Hubs Clusters, indexed by Azure region. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ListAvailableClustersGet.json + */ +async function listAvailableClusters() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.clusters.listAvailableClusterRegion(); + console.log(result); +} + +listAvailableClusters().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersListByResourceGroupSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersListByResourceGroupSample.ts new file mode 100644 index 000000000000..094f317cbb3a --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersListByResourceGroupSample.ts @@ -0,0 +1,34 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists the available Event Hubs Clusters within an ARM resource group + * + * @summary Lists the available Event Hubs Clusters within an ARM resource group + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClustersListByResourceGroup.json + */ +async function clustersListByResourceGroup() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "myResourceGroup"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.clusters.listByResourceGroup( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +clustersListByResourceGroup().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersListBySubscriptionSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersListBySubscriptionSample.ts new file mode 100644 index 000000000000..068a6294677f --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersListBySubscriptionSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists the available Event Hubs Clusters within an ARM resource group + * + * @summary Lists the available Event Hubs Clusters within an ARM resource group + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClustersListBySubscription.json + */ +async function clustersListBySubscription() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.clusters.listBySubscription()) { + resArray.push(item); + } + console.log(resArray); +} + +clustersListBySubscription().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersListNamespacesSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersListNamespacesSample.ts new file mode 100644 index 000000000000..a06bfcc4a74d --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersListNamespacesSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to List all Event Hubs Namespace IDs in an Event Hubs Dedicated Cluster. + * + * @summary List all Event Hubs Namespace IDs in an Event Hubs Dedicated Cluster. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ListNamespacesInClusterGet.json + */ +async function listNamespacesInCluster() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "myResourceGroup"; + const clusterName = "testCluster"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.clusters.listNamespaces( + resourceGroupName, + clusterName + ); + console.log(result); +} + +listNamespacesInCluster().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersUpdateSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersUpdateSample.ts new file mode 100644 index 000000000000..b3aaa6aeed5a --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/clustersUpdateSample.ts @@ -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. +import { Cluster, EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Modifies mutable properties on the Event Hubs Cluster. This operation is idempotent. + * + * @summary Modifies mutable properties on the Event Hubs Cluster. This operation is idempotent. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterPatch.json + */ +async function clusterPatch() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "myResourceGroup"; + const clusterName = "testCluster"; + const parameters: Cluster = { + location: "South Central US", + tags: { tag3: "value3", tag4: "value4" } + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.clusters.beginUpdateAndWait( + resourceGroupName, + clusterName, + parameters + ); + console.log(result); +} + +clusterPatch().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/configurationGetSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/configurationGetSample.ts new file mode 100644 index 000000000000..89079236c5ba --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/configurationGetSample.ts @@ -0,0 +1,30 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Get all Event Hubs Cluster settings - a collection of key/value pairs which represent the quotas and settings imposed on the cluster. + * + * @summary Get all Event Hubs Cluster settings - a collection of key/value pairs which represent the quotas and settings imposed on the cluster. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterQuotaConfigurationGet.json + */ +async function clustersQuotasConfigurationGet() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "myResourceGroup"; + const clusterName = "testCluster"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.configuration.get(resourceGroupName, clusterName); + console.log(result); +} + +clustersQuotasConfigurationGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/configurationPatchSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/configurationPatchSample.ts new file mode 100644 index 000000000000..3d6f063e615c --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/configurationPatchSample.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 { + ClusterQuotaConfigurationProperties, + EventHubManagementClient +} from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Replace all specified Event Hubs Cluster settings with those contained in the request body. Leaves the settings not specified in the request body unmodified. + * + * @summary Replace all specified Event Hubs Cluster settings with those contained in the request body. Leaves the settings not specified in the request body unmodified. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/Clusters/ClusterQuotaConfigurationPatch.json + */ +async function clustersQuotasConfigurationPatch() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const clusterName = "testCluster"; + const parameters: ClusterQuotaConfigurationProperties = { + settings: { + eventhubPerNamespaceQuota: "20", + namespacesPerClusterQuota: "200" + } + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.configuration.patch( + resourceGroupName, + clusterName, + parameters + ); + console.log(result); +} + +clustersQuotasConfigurationPatch().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/consumerGroupsCreateOrUpdateSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/consumerGroupsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..9f5018c65a02 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/consumerGroupsCreateOrUpdateSample.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 { ConsumerGroup, EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates an Event Hubs consumer group as a nested resource within a Namespace. + * + * @summary Creates or updates an Event Hubs consumer group as a nested resource within a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/ConsumerGroup/EHConsumerGroupCreate.json + */ +async function consumerGroupCreate() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2661"; + const eventHubName = "sdk-EventHub-6681"; + const consumerGroupName = "sdk-ConsumerGroup-5563"; + const parameters: ConsumerGroup = { userMetadata: "New consumergroup" }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.consumerGroups.createOrUpdate( + resourceGroupName, + namespaceName, + eventHubName, + consumerGroupName, + parameters + ); + console.log(result); +} + +consumerGroupCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/consumerGroupsDeleteSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/consumerGroupsDeleteSample.ts new file mode 100644 index 000000000000..620491fd42a8 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/consumerGroupsDeleteSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes a consumer group from the specified Event Hub and resource group. + * + * @summary Deletes a consumer group from the specified Event Hub and resource group. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/ConsumerGroup/EHConsumerGroupDelete.json + */ +async function consumerGroupDelete() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2661"; + const eventHubName = "sdk-EventHub-6681"; + const consumerGroupName = "sdk-ConsumerGroup-5563"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.consumerGroups.delete( + resourceGroupName, + namespaceName, + eventHubName, + consumerGroupName + ); + console.log(result); +} + +consumerGroupDelete().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/consumerGroupsGetSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/consumerGroupsGetSample.ts new file mode 100644 index 000000000000..8d3e16e089ac --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/consumerGroupsGetSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets a description for the specified consumer group. + * + * @summary Gets a description for the specified consumer group. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/ConsumerGroup/EHConsumerGroupGet.json + */ +async function consumerGroupGet() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2661"; + const eventHubName = "sdk-EventHub-6681"; + const consumerGroupName = "sdk-ConsumerGroup-5563"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.consumerGroups.get( + resourceGroupName, + namespaceName, + eventHubName, + consumerGroupName + ); + console.log(result); +} + +consumerGroupGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/consumerGroupsListByEventHubSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/consumerGroupsListByEventHubSample.ts new file mode 100644 index 000000000000..193369fb30bd --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/consumerGroupsListByEventHubSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all the consumer groups in a Namespace. An empty feed is returned if no consumer group exists in the Namespace. + * + * @summary Gets all the consumer groups in a Namespace. An empty feed is returned if no consumer group exists in the Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/ConsumerGroup/EHConsumerGroupListByEventHub.json + */ +async function consumerGroupsListAll() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2661"; + const eventHubName = "sdk-EventHub-6681"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.consumerGroups.listByEventHub( + resourceGroupName, + namespaceName, + eventHubName + )) { + resArray.push(item); + } + console.log(resArray); +} + +consumerGroupsListAll().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsBreakPairingSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsBreakPairingSample.ts new file mode 100644 index 000000000000..c67ce5388161 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsBreakPairingSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation disables the Disaster Recovery and stops replicating changes from primary to secondary namespaces + * + * @summary This operation disables the Disaster Recovery and stops replicating changes from primary to secondary namespaces + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasBreakPairing.json + */ +async function ehAliasBreakPairing() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-8859"; + const alias = "sdk-DisasterRecovery-3814"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.disasterRecoveryConfigs.breakPairing( + resourceGroupName, + namespaceName, + alias + ); + console.log(result); +} + +ehAliasBreakPairing().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsCheckNameAvailabilitySample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsCheckNameAvailabilitySample.ts new file mode 100644 index 000000000000..3b617da055ac --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsCheckNameAvailabilitySample.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 { + CheckNameAvailabilityParameter, + EventHubManagementClient +} from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Check the give Namespace name availability. + * + * @summary Check the give Namespace name availability. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasCheckNameAvailability.json + */ +async function namespacesCheckNameAvailability() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-9080"; + const parameters: CheckNameAvailabilityParameter = { + name: "sdk-DisasterRecovery-9474" + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.disasterRecoveryConfigs.checkNameAvailability( + resourceGroupName, + namespaceName, + parameters + ); + console.log(result); +} + +namespacesCheckNameAvailability().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsCreateOrUpdateSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..d050b27dceb3 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsCreateOrUpdateSample.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 { + ArmDisasterRecovery, + EventHubManagementClient +} from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates a new Alias(Disaster Recovery configuration) + * + * @summary Creates or updates a new Alias(Disaster Recovery configuration) + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasCreate.json + */ +async function ehAliasCreate() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-8859"; + const alias = "sdk-DisasterRecovery-3814"; + const parameters: ArmDisasterRecovery = { + partnerNamespace: "sdk-Namespace-37" + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.disasterRecoveryConfigs.createOrUpdate( + resourceGroupName, + namespaceName, + alias, + parameters + ); + console.log(result); +} + +ehAliasCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsDeleteSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsDeleteSample.ts new file mode 100644 index 000000000000..858dd48ea0eb --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsDeleteSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes an Alias(Disaster Recovery configuration) + * + * @summary Deletes an Alias(Disaster Recovery configuration) + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasDelete.json + */ +async function ehAliasDelete() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-5849"; + const alias = "sdk-DisasterRecovery-3814"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.disasterRecoveryConfigs.delete( + resourceGroupName, + namespaceName, + alias + ); + console.log(result); +} + +ehAliasDelete().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsFailOverSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsFailOverSample.ts new file mode 100644 index 000000000000..c3e9a5cfe1cd --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsFailOverSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace + * + * @summary Invokes GEO DR failover and reconfigure the alias to point to the secondary namespace + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasFailOver.json + */ +async function ehAliasFailOver() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-8859"; + const alias = "sdk-DisasterRecovery-3814"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.disasterRecoveryConfigs.failOver( + resourceGroupName, + namespaceName, + alias + ); + console.log(result); +} + +ehAliasFailOver().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsGetAuthorizationRuleSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsGetAuthorizationRuleSample.ts new file mode 100644 index 000000000000..33a02e180ef0 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsGetAuthorizationRuleSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets an AuthorizationRule for a Namespace by rule name. + * + * @summary Gets an AuthorizationRule for a Namespace by rule name. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasAuthorizationRuleGet.json + */ +async function nameSpaceAuthorizationRuleGet() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-9080"; + const alias = "sdk-DisasterRecovery-4879"; + const authorizationRuleName = "sdk-Authrules-4879"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.disasterRecoveryConfigs.getAuthorizationRule( + resourceGroupName, + namespaceName, + alias, + authorizationRuleName + ); + console.log(result); +} + +nameSpaceAuthorizationRuleGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsGetSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsGetSample.ts new file mode 100644 index 000000000000..f2d3a0d9cb18 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsGetSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace + * + * @summary Retrieves Alias(Disaster Recovery configuration) for primary or secondary namespace + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasGet.json + */ +async function ehAliasGet() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-8859"; + const alias = "sdk-DisasterRecovery-3814"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.disasterRecoveryConfigs.get( + resourceGroupName, + namespaceName, + alias + ); + console.log(result); +} + +ehAliasGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsListAuthorizationRulesSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsListAuthorizationRulesSample.ts new file mode 100644 index 000000000000..05eb6f67c974 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsListAuthorizationRulesSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets a list of authorization rules for a Namespace. + * + * @summary Gets a list of authorization rules for a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasAuthorizationRuleListAll.json + */ +async function listAuthorizationRules() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-9080"; + const alias = "sdk-DisasterRecovery-4047"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.disasterRecoveryConfigs.listAuthorizationRules( + resourceGroupName, + namespaceName, + alias + )) { + resArray.push(item); + } + console.log(resArray); +} + +listAuthorizationRules().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsListKeysSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsListKeysSample.ts new file mode 100644 index 000000000000..db0ef16fe24e --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsListKeysSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the primary and secondary connection strings for the Namespace. + * + * @summary Gets the primary and secondary connection strings for the Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasAuthorizationRuleListKey.json + */ +async function nameSpaceAuthorizationRuleListKey() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-2702"; + const alias = "sdk-DisasterRecovery-4047"; + const authorizationRuleName = "sdk-Authrules-1746"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.disasterRecoveryConfigs.listKeys( + resourceGroupName, + namespaceName, + alias, + authorizationRuleName + ); + console.log(result); +} + +nameSpaceAuthorizationRuleListKey().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsListSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsListSample.ts new file mode 100644 index 000000000000..c9d9eaeb64ac --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/disasterRecoveryConfigsListSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all Alias(Disaster Recovery configurations) + * + * @summary Gets all Alias(Disaster Recovery configurations) + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/disasterRecoveryConfigs/EHAliasList.json + */ +async function ehAliasList() { + const subscriptionId = "exampleSubscriptionId"; + const resourceGroupName = "exampleResourceGroup"; + const namespaceName = "sdk-Namespace-8859"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.disasterRecoveryConfigs.list( + resourceGroupName, + namespaceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +ehAliasList().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsCreateOrUpdateAuthorizationRuleSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsCreateOrUpdateAuthorizationRuleSample.ts new file mode 100644 index 000000000000..04cab867c1e1 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsCreateOrUpdateAuthorizationRuleSample.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 { + AuthorizationRule, + EventHubManagementClient +} from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates an AuthorizationRule for the specified Event Hub. Creation/update of the AuthorizationRule will take a few seconds to take effect. + * + * @summary Creates or updates an AuthorizationRule for the specified Event Hub. Creation/update of the AuthorizationRule will take a few seconds to take effect. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleCreate.json + */ +async function eventHubAuthorizationRuleCreate() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-960"; + const eventHubName = "sdk-EventHub-532"; + const authorizationRuleName = "sdk-Authrules-2513"; + const parameters: AuthorizationRule = { rights: ["Listen", "Send"] }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.eventHubs.createOrUpdateAuthorizationRule( + resourceGroupName, + namespaceName, + eventHubName, + authorizationRuleName, + parameters + ); + console.log(result); +} + +eventHubAuthorizationRuleCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsCreateOrUpdateSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..03aae26de590 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsCreateOrUpdateSample.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 { Eventhub, EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates a new Event Hub as a nested resource within a Namespace. + * + * @summary Creates or updates a new Event Hub as a nested resource within a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubCreate.json + */ +async function eventHubCreate() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "Default-NotificationHubs-AustraliaEast"; + const namespaceName = "sdk-Namespace-5357"; + const eventHubName = "sdk-EventHub-6547"; + const parameters: Eventhub = { + captureDescription: { + destination: { + name: "EventHubArchive.AzureBlockBlob", + archiveNameFormat: + "{Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}", + blobContainer: "container", + storageAccountResourceId: + "/subscriptions/e2f361f0-3b27-4503-a9cc-21cfba380093/resourceGroups/Default-Storage-SouthCentralUS/providers/Microsoft.ClassicStorage/storageAccounts/arjunteststorage" + }, + enabled: true, + encoding: "Avro", + intervalInSeconds: 120, + sizeLimitInBytes: 10485763 + }, + messageRetentionInDays: 4, + partitionCount: 4, + status: "Active" + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.eventHubs.createOrUpdate( + resourceGroupName, + namespaceName, + eventHubName, + parameters + ); + console.log(result); +} + +eventHubCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsDeleteAuthorizationRuleSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsDeleteAuthorizationRuleSample.ts new file mode 100644 index 000000000000..531a5446e2d4 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsDeleteAuthorizationRuleSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes an Event Hub AuthorizationRule. + * + * @summary Deletes an Event Hub AuthorizationRule. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleDelete.json + */ +async function eventHubAuthorizationRuleDelete() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-960"; + const eventHubName = "sdk-EventHub-532"; + const authorizationRuleName = "sdk-Authrules-2513"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.eventHubs.deleteAuthorizationRule( + resourceGroupName, + namespaceName, + eventHubName, + authorizationRuleName + ); + console.log(result); +} + +eventHubAuthorizationRuleDelete().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsDeleteSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsDeleteSample.ts new file mode 100644 index 000000000000..523593903fb2 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsDeleteSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes an Event Hub from the specified Namespace and resource group. + * + * @summary Deletes an Event Hub from the specified Namespace and resource group. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubDelete.json + */ +async function eventHubDelete() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-5357"; + const eventHubName = "sdk-EventHub-6547"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.eventHubs.delete( + resourceGroupName, + namespaceName, + eventHubName + ); + console.log(result); +} + +eventHubDelete().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsGetAuthorizationRuleSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsGetAuthorizationRuleSample.ts new file mode 100644 index 000000000000..e52c34b3fada --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsGetAuthorizationRuleSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets an AuthorizationRule for an Event Hub by rule name. + * + * @summary Gets an AuthorizationRule for an Event Hub by rule name. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleGet.json + */ +async function eventHubAuthorizationRuleGet() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-960"; + const eventHubName = "sdk-EventHub-532"; + const authorizationRuleName = "sdk-Authrules-2513"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.eventHubs.getAuthorizationRule( + resourceGroupName, + namespaceName, + eventHubName, + authorizationRuleName + ); + console.log(result); +} + +eventHubAuthorizationRuleGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsGetSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsGetSample.ts new file mode 100644 index 000000000000..ba1a96c779ce --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsGetSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets an Event Hubs description for the specified Event Hub. + * + * @summary Gets an Event Hubs description for the specified Event Hub. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubGet.json + */ +async function eventHubGet() { + const subscriptionId = "e2f361f0-3b27-4503-a9cc-21cfba380093"; + const resourceGroupName = "Default-NotificationHubs-AustraliaEast"; + const namespaceName = "sdk-Namespace-716"; + const eventHubName = "sdk-EventHub-10"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.eventHubs.get( + resourceGroupName, + namespaceName, + eventHubName + ); + console.log(result); +} + +eventHubGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsListAuthorizationRulesSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsListAuthorizationRulesSample.ts new file mode 100644 index 000000000000..bac573436734 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsListAuthorizationRulesSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the authorization rules for an Event Hub. + * + * @summary Gets the authorization rules for an Event Hub. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleListAll.json + */ +async function eventHubAuthorizationRuleListAll() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-960"; + const eventHubName = "sdk-EventHub-532"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.eventHubs.listAuthorizationRules( + resourceGroupName, + namespaceName, + eventHubName + )) { + resArray.push(item); + } + console.log(resArray); +} + +eventHubAuthorizationRuleListAll().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsListByNamespaceSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsListByNamespaceSample.ts new file mode 100644 index 000000000000..ace9f8d546e8 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsListByNamespaceSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all the Event Hubs in a Namespace. + * + * @summary Gets all the Event Hubs in a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubListByNameSpace.json + */ +async function eventHubsListAll() { + const subscriptionId = "e2f361f0-3b27-4503-a9cc-21cfba380093"; + const resourceGroupName = "Default-NotificationHubs-AustraliaEast"; + const namespaceName = "sdk-Namespace-5357"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.eventHubs.listByNamespace( + resourceGroupName, + namespaceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +eventHubsListAll().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsListKeysSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsListKeysSample.ts new file mode 100644 index 000000000000..59fb74b9a3ab --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsListKeysSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the ACS and SAS connection strings for the Event Hub. + * + * @summary Gets the ACS and SAS connection strings for the Event Hub. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleListKey.json + */ +async function eventHubAuthorizationRuleListKey() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-namespace-960"; + const eventHubName = "sdk-EventHub-532"; + const authorizationRuleName = "sdk-Authrules-2513"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.eventHubs.listKeys( + resourceGroupName, + namespaceName, + eventHubName, + authorizationRuleName + ); + console.log(result); +} + +eventHubAuthorizationRuleListKey().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsRegenerateKeysSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsRegenerateKeysSample.ts new file mode 100644 index 000000000000..27ac68b3d5ee --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/eventHubsRegenerateKeysSample.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 { + RegenerateAccessKeyParameters, + EventHubManagementClient +} from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Regenerates the ACS and SAS connection strings for the Event Hub. + * + * @summary Regenerates the ACS and SAS connection strings for the Event Hub. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EventHubs/EHEventHubAuthorizationRuleRegenerateKey.json + */ +async function eventHubAuthorizationRuleRegenerateKey() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-namespace-960"; + const eventHubName = "sdk-EventHub-532"; + const authorizationRuleName = "sdk-Authrules-1534"; + const parameters: RegenerateAccessKeyParameters = { keyType: "PrimaryKey" }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.eventHubs.regenerateKeys( + resourceGroupName, + namespaceName, + eventHubName, + authorizationRuleName, + parameters + ); + console.log(result); +} + +eventHubAuthorizationRuleRegenerateKey().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesCheckNameAvailabilitySample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesCheckNameAvailabilitySample.ts new file mode 100644 index 000000000000..6532fa37870e --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesCheckNameAvailabilitySample.ts @@ -0,0 +1,34 @@ +/* + * 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 { + CheckNameAvailabilityParameter, + EventHubManagementClient +} from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Check the give Namespace name availability. + * + * @summary Check the give Namespace name availability. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceCheckNameAvailability.json + */ +async function namespacesCheckNameAvailability() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const parameters: CheckNameAvailabilityParameter = { + name: "sdk-Namespace-8458" + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.checkNameAvailability(parameters); + console.log(result); +} + +namespacesCheckNameAvailability().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesCreateOrUpdateAuthorizationRuleSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesCreateOrUpdateAuthorizationRuleSample.ts new file mode 100644 index 000000000000..38aaf91201b8 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesCreateOrUpdateAuthorizationRuleSample.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 { + AuthorizationRule, + EventHubManagementClient +} from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates an AuthorizationRule for a Namespace. + * + * @summary Creates or updates an AuthorizationRule for a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleCreate.json + */ +async function nameSpaceAuthorizationRuleCreate() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2702"; + const authorizationRuleName = "sdk-Authrules-1746"; + const parameters: AuthorizationRule = { rights: ["Listen", "Send"] }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.createOrUpdateAuthorizationRule( + resourceGroupName, + namespaceName, + authorizationRuleName, + parameters + ); + console.log(result); +} + +nameSpaceAuthorizationRuleCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesCreateOrUpdateNetworkRuleSetSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesCreateOrUpdateNetworkRuleSetSample.ts new file mode 100644 index 000000000000..c29b4e7f3e1f --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesCreateOrUpdateNetworkRuleSetSample.ts @@ -0,0 +1,67 @@ +/* + * 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 { NetworkRuleSet, EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Create or update NetworkRuleSet for a Namespace. + * + * @summary Create or update NetworkRuleSet for a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/VirtualNetworkRule/EHNetworkRuleSetCreate.json + */ +async function nameSpaceNetworkRuleSetCreate() { + const subscriptionId = "Subscription"; + const resourceGroupName = "ResourceGroup"; + const namespaceName = "sdk-Namespace-6019"; + const parameters: NetworkRuleSet = { + defaultAction: "Deny", + ipRules: [ + { action: "Allow", ipMask: "1.1.1.1" }, + { action: "Allow", ipMask: "1.1.1.2" }, + { action: "Allow", ipMask: "1.1.1.3" }, + { action: "Allow", ipMask: "1.1.1.4" }, + { action: "Allow", ipMask: "1.1.1.5" } + ], + virtualNetworkRules: [ + { + ignoreMissingVnetServiceEndpoint: true, + subnet: { + id: + "/subscriptions/subscriptionid/resourcegroups/resourcegroupid/providers/Microsoft.Network/virtualNetworks/myvn/subnets/subnet2" + } + }, + { + ignoreMissingVnetServiceEndpoint: false, + subnet: { + id: + "/subscriptions/subscriptionid/resourcegroups/resourcegroupid/providers/Microsoft.Network/virtualNetworks/myvn/subnets/subnet3" + } + }, + { + ignoreMissingVnetServiceEndpoint: false, + subnet: { + id: + "/subscriptions/subscriptionid/resourcegroups/resourcegroupid/providers/Microsoft.Network/virtualNetworks/myvn/subnets/subnet6" + } + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.createOrUpdateNetworkRuleSet( + resourceGroupName, + namespaceName, + parameters + ); + console.log(result); +} + +nameSpaceNetworkRuleSetCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesCreateOrUpdateSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..ab081c0da190 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesCreateOrUpdateSample.ts @@ -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. +import { EHNamespace, EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates a namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. + * + * @summary Creates or updates a namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceCreate.json + */ +async function namespaceCreate() { + const subscriptionId = "SampleSubscription"; + const resourceGroupName = "ResurceGroupSample"; + const namespaceName = "NamespaceSample"; + const parameters: EHNamespace = { + clusterArmId: + "/subscriptions/SampleSubscription/resourceGroups/ResurceGroupSample/providers/Microsoft.EventHub/clusters/enc-test", + encryption: { + keySource: "Microsoft.KeyVault", + keyVaultProperties: [ + { + identity: { + userAssignedIdentity: + "/subscriptions/SampleSubscription/resourceGroups/ResurceGroupSample/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ud1" + }, + keyName: "Samplekey", + keyVaultUri: "https://aprao-keyvault-user.vault-int.azure-int.net/" + } + ] + }, + identity: { + type: "SystemAssigned, UserAssigned", + userAssignedIdentities: { + "/subscriptions/SampleSubscription/resourceGroups/ResurceGroupSample/providers/MicrosoftManagedIdentity/userAssignedIdentities/ud1": {}, + "/subscriptions/SampleSubscription/resourceGroups/ResurceGroupSample/providers/MicrosoftManagedIdentity/userAssignedIdentities/ud2": {} + } + }, + location: "East US" + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.beginCreateOrUpdateAndWait( + resourceGroupName, + namespaceName, + parameters + ); + console.log(result); +} + +namespaceCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesDeleteAuthorizationRuleSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesDeleteAuthorizationRuleSample.ts new file mode 100644 index 000000000000..94f8f1d46f80 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesDeleteAuthorizationRuleSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes an AuthorizationRule for a Namespace. + * + * @summary Deletes an AuthorizationRule for a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleDelete.json + */ +async function nameSpaceAuthorizationRuleDelete() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-8980"; + const authorizationRuleName = "sdk-Authrules-8929"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.deleteAuthorizationRule( + resourceGroupName, + namespaceName, + authorizationRuleName + ); + console.log(result); +} + +nameSpaceAuthorizationRuleDelete().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesDeleteSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesDeleteSample.ts new file mode 100644 index 000000000000..35b0f71b5dc3 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesDeleteSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes an existing namespace. This operation also removes all associated resources under the namespace. + * + * @summary Deletes an existing namespace. This operation also removes all associated resources under the namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceDelete.json + */ +async function nameSpaceDelete() { + const subscriptionId = "SampleSubscription"; + const resourceGroupName = "ResurceGroupSample"; + const namespaceName = "NamespaceSample"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.beginDeleteAndWait( + resourceGroupName, + namespaceName + ); + console.log(result); +} + +nameSpaceDelete().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesGetAuthorizationRuleSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesGetAuthorizationRuleSample.ts new file mode 100644 index 000000000000..ca443bf6e60b --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesGetAuthorizationRuleSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets an AuthorizationRule for a Namespace by rule name. + * + * @summary Gets an AuthorizationRule for a Namespace by rule name. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleGet.json + */ +async function nameSpaceAuthorizationRuleGet() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2702"; + const authorizationRuleName = "sdk-Authrules-1746"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.getAuthorizationRule( + resourceGroupName, + namespaceName, + authorizationRuleName + ); + console.log(result); +} + +nameSpaceAuthorizationRuleGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesGetNetworkRuleSetSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesGetNetworkRuleSetSample.ts new file mode 100644 index 000000000000..b8a66031c12a --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesGetNetworkRuleSetSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets NetworkRuleSet for a Namespace. + * + * @summary Gets NetworkRuleSet for a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/VirtualNetworkRule/EHNetworkRuleSetGet.json + */ +async function nameSpaceNetworkRuleSetGet() { + const subscriptionId = "Subscription"; + const resourceGroupName = "ResourceGroup"; + const namespaceName = "sdk-Namespace-6019"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.getNetworkRuleSet( + resourceGroupName, + namespaceName + ); + console.log(result); +} + +nameSpaceNetworkRuleSetGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesGetSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesGetSample.ts new file mode 100644 index 000000000000..efff6daa1677 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesGetSample.ts @@ -0,0 +1,30 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the description of the specified namespace. + * + * @summary Gets the description of the specified namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceGet.json + */ +async function nameSpaceGet() { + const subscriptionId = "SampleSubscription"; + const resourceGroupName = "ResurceGroupSample"; + const namespaceName = "NamespaceSample"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.get(resourceGroupName, namespaceName); + console.log(result); +} + +nameSpaceGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesListAuthorizationRulesSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesListAuthorizationRulesSample.ts new file mode 100644 index 000000000000..70f8ca15c487 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesListAuthorizationRulesSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets a list of authorization rules for a Namespace. + * + * @summary Gets a list of authorization rules for a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleListAll.json + */ +async function listAuthorizationRules() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2702"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.namespaces.listAuthorizationRules( + resourceGroupName, + namespaceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listAuthorizationRules().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesListByResourceGroupSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesListByResourceGroupSample.ts new file mode 100644 index 000000000000..ad44bc0a3522 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesListByResourceGroupSample.ts @@ -0,0 +1,34 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists the available Namespaces within a resource group. + * + * @summary Lists the available Namespaces within a resource group. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceListByResourceGroup.json + */ +async function namespaceListByResourceGroup() { + const subscriptionId = "SampleSubscription"; + const resourceGroupName = "ResurceGroupSample"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.namespaces.listByResourceGroup( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +namespaceListByResourceGroup().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesListKeysSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesListKeysSample.ts new file mode 100644 index 000000000000..2856863240cf --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesListKeysSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the primary and secondary connection strings for the Namespace. + * + * @summary Gets the primary and secondary connection strings for the Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleListKey.json + */ +async function nameSpaceAuthorizationRuleListKey() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2702"; + const authorizationRuleName = "sdk-Authrules-1746"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.listKeys( + resourceGroupName, + namespaceName, + authorizationRuleName + ); + console.log(result); +} + +nameSpaceAuthorizationRuleListKey().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesListNetworkRuleSetSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesListNetworkRuleSetSample.ts new file mode 100644 index 000000000000..066db077b5ea --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesListNetworkRuleSetSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets NetworkRuleSet for a Namespace. + * + * @summary Gets NetworkRuleSet for a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/VirtualNetworkRule/EHNetworkRuleSetList.json + */ +async function nameSpaceNetworkRuleSetList() { + const subscriptionId = "Subscription"; + const resourceGroupName = "ResourceGroup"; + const namespaceName = "sdk-Namespace-6019"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.listNetworkRuleSet( + resourceGroupName, + namespaceName + ); + console.log(result); +} + +nameSpaceNetworkRuleSetList().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesListSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesListSample.ts new file mode 100644 index 000000000000..0f3c125ca1d1 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesListSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists all the available Namespaces within a subscription, irrespective of the resource groups. + * + * @summary Lists all the available Namespaces within a subscription, irrespective of the resource groups. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceList.json + */ +async function namespacesListBySubscription() { + const subscriptionId = "SampleSubscription"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.namespaces.list()) { + resArray.push(item); + } + console.log(resArray); +} + +namespacesListBySubscription().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesRegenerateKeysSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesRegenerateKeysSample.ts new file mode 100644 index 000000000000..1af5bfb4d106 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesRegenerateKeysSample.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 { + RegenerateAccessKeyParameters, + EventHubManagementClient +} from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Regenerates the primary or secondary connection strings for the specified Namespace. + * + * @summary Regenerates the primary or secondary connection strings for the specified Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleRegenerateKey.json + */ +async function nameSpaceAuthorizationRuleRegenerateKey() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-8980"; + const authorizationRuleName = "sdk-Authrules-8929"; + const parameters: RegenerateAccessKeyParameters = { keyType: "PrimaryKey" }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.regenerateKeys( + resourceGroupName, + namespaceName, + authorizationRuleName, + parameters + ); + console.log(result); +} + +nameSpaceAuthorizationRuleRegenerateKey().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesUpdateSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesUpdateSample.ts new file mode 100644 index 000000000000..b33f53561870 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/namespacesUpdateSample.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 { EHNamespace, EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates a namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. + * + * @summary Creates or updates a namespace. Once created, this namespace's resource manifest is immutable. This operation is idempotent. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/EHNameSpaceUpdate.json + */ +async function namespacesUpdate() { + const subscriptionId = "SampleSubscription"; + const resourceGroupName = "ResurceGroupSample"; + const namespaceName = "NamespaceSample"; + const parameters: EHNamespace = { + identity: { + type: "SystemAssigned, UserAssigned", + userAssignedIdentities: { + "/subscriptions/SampleSubscription/resourceGroups/ResurceGroupSample/providers/MicrosoftManagedIdentity/userAssignedIdentities/ud2": {} + } + }, + location: "East US" + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.namespaces.update( + resourceGroupName, + namespaceName, + parameters + ); + console.log(result); +} + +namespacesUpdate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/operationsListSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/operationsListSample.ts new file mode 100644 index 000000000000..2bc5ff38253a --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/operationsListSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists all of the available Event Hub REST API operations. + * + * @summary Lists all of the available Event Hub REST API operations. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/EHOperations_List.json + */ +async function ehOperationsList() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +ehOperationsList().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/privateEndpointConnectionsCreateOrUpdateSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/privateEndpointConnectionsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..26844e1e7bb8 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/privateEndpointConnectionsCreateOrUpdateSample.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 { + PrivateEndpointConnection, + EventHubManagementClient +} from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates PrivateEndpointConnections of service namespace. + * + * @summary Creates or updates PrivateEndpointConnections of service namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/PrivateEndPointConnectionCreate.json + */ +async function nameSpacePrivateEndPointConnectionCreate() { + const subscriptionId = "subID"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2924"; + const privateEndpointConnectionName = "privateEndpointConnectionName"; + const parameters: PrivateEndpointConnection = { + privateEndpoint: { + id: + "/subscriptions/dbedb4e0-40e6-4145-81f3-f1314c150774/resourceGroups/SDK-EventHub-8396/providers/Microsoft.Network/privateEndpoints/sdk-Namespace-2847" + }, + privateLinkServiceConnectionState: { + description: "testing", + status: "Rejected" + }, + provisioningState: "Succeeded" + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.createOrUpdate( + resourceGroupName, + namespaceName, + privateEndpointConnectionName, + parameters + ); + console.log(result); +} + +nameSpacePrivateEndPointConnectionCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/privateEndpointConnectionsDeleteSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/privateEndpointConnectionsDeleteSample.ts new file mode 100644 index 000000000000..52eddef5653e --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/privateEndpointConnectionsDeleteSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes an existing namespace. This operation also removes all associated resources under the namespace. + * + * @summary Deletes an existing namespace. This operation also removes all associated resources under the namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/PrivateEndPointConnectionDelete.json + */ +async function nameSpacePrivateEndPointConnectionDelete() { + const subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-3285"; + const privateEndpointConnectionName = "928c44d5-b7c6-423b-b6fa-811e0c27b3e0"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.beginDeleteAndWait( + resourceGroupName, + namespaceName, + privateEndpointConnectionName + ); + console.log(result); +} + +nameSpacePrivateEndPointConnectionDelete().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/privateEndpointConnectionsGetSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/privateEndpointConnectionsGetSample.ts new file mode 100644 index 000000000000..06a565d923e3 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/privateEndpointConnectionsGetSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets a description for the specified Private Endpoint Connection name. + * + * @summary Gets a description for the specified Private Endpoint Connection name. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/PrivateEndPointConnectionGet.json + */ +async function nameSpacePrivateEndPointConnectionGet() { + const subscriptionId = "subID"; + const resourceGroupName = "SDK-EventHub-4794"; + const namespaceName = "sdk-Namespace-5828"; + const privateEndpointConnectionName = "privateEndpointConnectionName"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.get( + resourceGroupName, + namespaceName, + privateEndpointConnectionName + ); + console.log(result); +} + +nameSpacePrivateEndPointConnectionGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/privateEndpointConnectionsListSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/privateEndpointConnectionsListSample.ts new file mode 100644 index 000000000000..2d55b48e06a1 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/privateEndpointConnectionsListSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the available PrivateEndpointConnections within a namespace. + * + * @summary Gets the available PrivateEndpointConnections within a namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/PrivateEndPointConnectionList.json + */ +async function nameSpaceCreate() { + const subscriptionId = "subID"; + const resourceGroupName = "SDK-EventHub-4794"; + const namespaceName = "sdk-Namespace-5828"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.privateEndpointConnections.list( + resourceGroupName, + namespaceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +nameSpaceCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/privateLinkResourcesGetSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/privateLinkResourcesGetSample.ts new file mode 100644 index 000000000000..98436c1844b7 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/privateLinkResourcesGetSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets lists of resources that supports Privatelinks. + * + * @summary Gets lists of resources that supports Privatelinks. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/NameSpaces/PrivateLinkResourcesGet.json + */ +async function nameSpacePrivateLinkResourcesGet() { + const subscriptionId = "subID"; + const resourceGroupName = "ArunMonocle"; + const namespaceName = "sdk-Namespace-2924"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.privateLinkResources.get( + resourceGroupName, + namespaceName + ); + console.log(result); +} + +nameSpacePrivateLinkResourcesGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/schemaRegistryCreateOrUpdateSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/schemaRegistryCreateOrUpdateSample.ts new file mode 100644 index 000000000000..8962f0185e45 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/schemaRegistryCreateOrUpdateSample.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 { SchemaGroup, EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to + * + * @summary + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/SchemaRegistry/SchemaRegistryCreate.json + */ +async function schemaRegistryCreate() { + const subscriptionId = "e8baea74-64ce-459b-bee3-5aa4c47b3ae3"; + const resourceGroupName = "alitest"; + const namespaceName = "ali-ua-test-eh-system-1"; + const schemaGroupName = "testSchemaGroup1"; + const parameters: SchemaGroup = { + groupProperties: {}, + schemaCompatibility: "Forward", + schemaType: "Avro" + }; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.schemaRegistry.createOrUpdate( + resourceGroupName, + namespaceName, + schemaGroupName, + parameters + ); + console.log(result); +} + +schemaRegistryCreate().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/schemaRegistryDeleteSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/schemaRegistryDeleteSample.ts new file mode 100644 index 000000000000..914ad2ee1afe --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/schemaRegistryDeleteSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to + * + * @summary + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/SchemaRegistry/SchemaRegistryDelete.json + */ +async function schemaRegistryDelete() { + const subscriptionId = "e8baea74-64ce-459b-bee3-5aa4c47b3ae3"; + const resourceGroupName = "alitest"; + const namespaceName = "ali-ua-test-eh-system-1"; + const schemaGroupName = "testSchemaGroup1"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.schemaRegistry.delete( + resourceGroupName, + namespaceName, + schemaGroupName + ); + console.log(result); +} + +schemaRegistryDelete().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/schemaRegistryGetSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/schemaRegistryGetSample.ts new file mode 100644 index 000000000000..43c05954d938 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/schemaRegistryGetSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to + * + * @summary + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/SchemaRegistry/SchemaRegistryGet.json + */ +async function schemaRegistryGet() { + const subscriptionId = "e8baea74-64ce-459b-bee3-5aa4c47b3ae3"; + const resourceGroupName = "alitest"; + const namespaceName = "ali-ua-test-eh-system-1"; + const schemaGroupName = "testSchemaGroup1"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const result = await client.schemaRegistry.get( + resourceGroupName, + namespaceName, + schemaGroupName + ); + console.log(result); +} + +schemaRegistryGet().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/schemaRegistryListByNamespaceSample.ts b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/schemaRegistryListByNamespaceSample.ts new file mode 100644 index 000000000000..31d8f0e85b91 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/src/schemaRegistryListByNamespaceSample.ts @@ -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. +import { EventHubManagementClient } from "@azure/arm-eventhub"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all the Schema Groups in a Namespace. + * + * @summary Gets all the Schema Groups in a Namespace. + * x-ms-original-file: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2021-11-01/examples/SchemaRegistry/SchemaRegistryListByNamespace.json + */ +async function schemaRegistryListAll() { + const subscriptionId = "e8baea74-64ce-459b-bee3-5aa4c47b3ae3"; + const resourceGroupName = "alitest"; + const namespaceName = "ali-ua-test-eh-system-1"; + const credential = new DefaultAzureCredential(); + const client = new EventHubManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.schemaRegistry.listByNamespace( + resourceGroupName, + namespaceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +schemaRegistryListAll().catch(console.error); diff --git a/sdk/eventhub/arm-eventhub/samples/v5/typescript/tsconfig.json b/sdk/eventhub/arm-eventhub/samples/v5/typescript/tsconfig.json new file mode 100644 index 000000000000..416c2dd82e00 --- /dev/null +++ b/sdk/eventhub/arm-eventhub/samples/v5/typescript/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2018", + "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/eventhub/arm-eventhub/src/eventHubManagementClient.ts b/sdk/eventhub/arm-eventhub/src/eventHubManagementClient.ts index ee6a8c7c45f5..80413ae77865 100644 --- a/sdk/eventhub/arm-eventhub/src/eventHubManagementClient.ts +++ b/sdk/eventhub/arm-eventhub/src/eventHubManagementClient.ts @@ -7,6 +7,7 @@ */ import * as coreClient from "@azure/core-client"; +import * as coreRestPipeline from "@azure/core-rest-pipeline"; import * as coreAuth from "@azure/core-auth"; import { ClustersImpl, @@ -67,7 +68,7 @@ export class EventHubManagementClient extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-eventhub/5.0.0`; + const packageDetails = `azsdk-js-arm-eventhub/5.0.1`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` @@ -82,9 +83,33 @@ export class EventHubManagementClient extends coreClient.ServiceClient { userAgentOptions: { userAgentPrefix }, - baseUri: options.endpoint || "https://management.azure.com" + baseUri: + options.endpoint ?? options.baseUri ?? "https://management.azure.com" }; super(optionsWithDefaults); + + if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { + const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies(); + const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( + (pipelinePolicy) => + pipelinePolicy.name === + coreRestPipeline.bearerTokenAuthenticationPolicyName + ); + if (!bearerTokenAuthenticationPolicyFound) { + this.pipeline.removePolicy({ + name: coreRestPipeline.bearerTokenAuthenticationPolicyName + }); + this.pipeline.addPolicy( + coreRestPipeline.bearerTokenAuthenticationPolicy({ + scopes: `${optionsWithDefaults.baseUri}/.default`, + challengeCallbacks: { + authorizeRequestOnChallenge: + coreClient.authorizeRequestOnClaimChallenge + } + }) + ); + } + } // Parameter assignments this.subscriptionId = subscriptionId; diff --git a/sdk/eventhub/arm-eventhub/src/operations/clusters.ts b/sdk/eventhub/arm-eventhub/src/operations/clusters.ts index 1aefed96f132..30aa09559f96 100644 --- a/sdk/eventhub/arm-eventhub/src/operations/clusters.ts +++ b/sdk/eventhub/arm-eventhub/src/operations/clusters.ts @@ -265,10 +265,12 @@ export class ClustersImpl implements Clusters { { resourceGroupName, clusterName, parameters, options }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -355,10 +357,12 @@ export class ClustersImpl implements Clusters { { resourceGroupName, clusterName, parameters, options }, updateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -438,10 +442,12 @@ export class ClustersImpl implements Clusters { { resourceGroupName, clusterName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** diff --git a/sdk/eventhub/arm-eventhub/src/operations/namespaces.ts b/sdk/eventhub/arm-eventhub/src/operations/namespaces.ts index 336ea57e6b5d..dbb17e7cea2b 100644 --- a/sdk/eventhub/arm-eventhub/src/operations/namespaces.ts +++ b/sdk/eventhub/arm-eventhub/src/operations/namespaces.ts @@ -325,10 +325,12 @@ export class NamespacesImpl implements Namespaces { { resourceGroupName, namespaceName, parameters, options }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -410,10 +412,12 @@ export class NamespacesImpl implements Namespaces { { resourceGroupName, namespaceName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** diff --git a/sdk/eventhub/arm-eventhub/src/operations/privateEndpointConnections.ts b/sdk/eventhub/arm-eventhub/src/operations/privateEndpointConnections.ts index ab51b792fa89..ea2e92582aea 100644 --- a/sdk/eventhub/arm-eventhub/src/operations/privateEndpointConnections.ts +++ b/sdk/eventhub/arm-eventhub/src/operations/privateEndpointConnections.ts @@ -208,10 +208,12 @@ export class PrivateEndpointConnectionsImpl }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** diff --git a/sdk/eventhub/arm-eventhub/tsconfig.json b/sdk/eventhub/arm-eventhub/tsconfig.json index 6e3251194117..f1fddb077683 100644 --- a/sdk/eventhub/arm-eventhub/tsconfig.json +++ b/sdk/eventhub/arm-eventhub/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-eventhub": [ + "./src/index" + ] + } }, - "include": ["./src/**/*.ts", "./test/**/*.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/eventhub/ci.mgmt.yml b/sdk/eventhub/ci.mgmt.yml index a39b3069f73c..5cf577214524 100644 --- a/sdk/eventhub/ci.mgmt.yml +++ b/sdk/eventhub/ci.mgmt.yml @@ -9,8 +9,8 @@ trigger: paths: include: - sdk/eventhub/ci.mgmt.yml - - sdk/eventhub/arm-eventhub/ - sdk/eventhub/arm-eventhub-profile-2020-09-01-hybrid + - sdk/eventhub/arm-eventhub pr: branches: include: @@ -23,8 +23,8 @@ pr: paths: include: - sdk/eventhub/ci.mgmt.yml - - sdk/eventhub/arm-eventhub/ - sdk/eventhub/arm-eventhub-profile-2020-09-01-hybrid + - sdk/eventhub/arm-eventhub extends: template: /eng/pipelines/templates/stages/archetype-sdk-client.yml parameters: diff --git a/sdk/eventhub/ci.yml b/sdk/eventhub/ci.yml index f1ccbd0f3913..5dc84b6b90e6 100644 --- a/sdk/eventhub/ci.yml +++ b/sdk/eventhub/ci.yml @@ -11,8 +11,8 @@ trigger: - sdk/eventhub/ exclude: - sdk/eventhub/ci.mgmt.yml - - sdk/eventhub/arm-eventhub/ - sdk/eventhub/arm-eventhub-profile-2020-09-01-hybrid + - sdk/eventhub/arm-eventhub pr: branches: include: @@ -27,8 +27,8 @@ pr: - sdk/eventhub/ exclude: - sdk/eventhub/ci.mgmt.yml - - sdk/eventhub/arm-eventhub/ - sdk/eventhub/arm-eventhub-profile-2020-09-01-hybrid + - sdk/eventhub/arm-eventhub extends: template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml parameters: diff --git a/sdk/features/arm-features/CHANGELOG.md b/sdk/features/arm-features/CHANGELOG.md index 2df030a5b146..7f01a169c721 100644 --- a/sdk/features/arm-features/CHANGELOG.md +++ b/sdk/features/arm-features/CHANGELOG.md @@ -1,14 +1,10 @@ # Release History -## 3.0.1 (Unreleased) +## 3.0.1 (2022-04-18) -### Features Added +**features** -### Breaking Changes - -### Bugs Fixed - -### Other Changes + - Bug fix ## 3.0.0 (2021-12-07) diff --git a/sdk/features/arm-features/LICENSE b/sdk/features/arm-features/LICENSE index ccb63b166732..5d1d36e0af80 100644 --- a/sdk/features/arm-features/LICENSE +++ b/sdk/features/arm-features/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2021 Microsoft +Copyright (c) 2022 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/features/arm-features/README.md b/sdk/features/arm-features/README.md index 4fc0b96747f6..b333a62fbe99 100644 --- a/sdk/features/arm-features/README.md +++ b/sdk/features/arm-features/README.md @@ -16,6 +16,8 @@ Azure Feature Exposure Control (AFEC) provides a mechanism for the resource prov - [LTS versions of Node.js](https://nodejs.org/about/releases/) - 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]. @@ -49,8 +51,17 @@ For more information about how to create an Azure AD Application check out [this ```javascript const { FeatureClient } = require("@azure/arm-features"); 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 FeatureClient(new DefaultAzureCredential(), subscriptionId); + +// For client-side applications running in the browser, use this code instead: +// const credential = new InteractiveBrowserCredential({ +// tenantId: "", +// clientId: "" +// }); +// const client = new FeatureClient(credential, subscriptionId); ``` diff --git a/sdk/features/arm-features/_meta.json b/sdk/features/arm-features/_meta.json index 0551b4fe18f8..c6765ba542bb 100644 --- a/sdk/features/arm-features/_meta.json +++ b/sdk/features/arm-features/_meta.json @@ -1,7 +1,8 @@ { "commit": "a42f1b58607091c4f255ead152a8ef323fa0b280", - "readme": "specification/resources/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 --generate-test --typescript-sdks-folder=D:\\mydev\\azure-sdk-for-js ../azure-rest-api-specs/specification/resources/resource-manager/readme.md --use=@autorest/typescript@6.0.0-alpha.16.20211130.1", + "readme": "specification\\resources\\resource-manager\\readme.md", + "autorest_command": "autorest --version=3.7.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\work\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\resources\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-alpha.19.20220408.1 --generate-sample=true", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "use": "@autorest/typescript@6.0.0-alpha.16.20211130.1" + "release_tool": "@azure-tools/js-sdk-release-tools@2.2.6", + "use": "@autorest/typescript@6.0.0-alpha.19.20220408.1" } \ No newline at end of file diff --git a/sdk/features/arm-features/api-extractor.json b/sdk/features/arm-features/api-extractor.json index 494666de9c7c..1279529db2df 100644 --- a/sdk/features/arm-features/api-extractor.json +++ b/sdk/features/arm-features/api-extractor.json @@ -1,18 +1,31 @@ { "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", "mainEntryPointFilePath": "./dist-esm/src/index.d.ts", - "docModel": { "enabled": true }, - "apiReport": { "enabled": true, "reportFolder": "./review" }, + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, "dtsRollup": { "enabled": true, "untrimmedFilePath": "", "publicTrimmedFilePath": "./types/arm-features.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/features/arm-features/package.json b/sdk/features/arm-features/package.json index 2d00668cac35..69cdc09e1cab 100644 --- a/sdk/features/arm-features/package.json +++ b/sdk/features/arm-features/package.json @@ -9,9 +9,9 @@ }, "dependencies": { "@azure/core-paging": "^1.2.0", - "@azure/core-client": "^1.0.0", + "@azure/core-client": "^1.5.0", "@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": [ @@ -28,12 +28,12 @@ "devDependencies": { "@microsoft/api-extractor": "^7.18.11", "@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-plugin-sourcemaps": "^0.4.2", + "rollup": "^2.66.1", + "rollup-plugin-sourcemaps": "^0.6.3", "typescript": "~4.2.0", "uglify-js": "^3.4.9", "rimraf": "^3.0.0", @@ -96,5 +96,21 @@ "docs": "echo skipped" }, "sideEffects": false, - "autoPublish": true + "//metadata": { + "constantPaths": [ + { + "path": "src/featureClient.ts", + "prefix": "packageDetails" + } + ] + }, + "autoPublish": true, + "//sampleConfiguration": { + "productName": "", + "productSlugs": [ + "azure" + ], + "disableDocsMs": true, + "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-features?view=azure-node-preview" + } } diff --git a/sdk/features/arm-features/rollup.config.js b/sdk/features/arm-features/rollup.config.js index 9be1955eb7f1..3f89d7309da5 100644 --- a/sdk/features/arm-features/rollup.config.js +++ b/sdk/features/arm-features/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/features/arm-features/sample.env b/sdk/features/arm-features/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/features/arm-features/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/features/arm-features/samples-dev/featuresGetSample.ts b/sdk/features/arm-features/samples-dev/featuresGetSample.ts new file mode 100644 index 000000000000..4a1ed81055a0 --- /dev/null +++ b/sdk/features/arm-features/samples-dev/featuresGetSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { FeatureClient } from "@azure/arm-features"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the preview feature with the specified name. + * + * @summary Gets the preview feature with the specified name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/getFeature.json + */ +async function getFeature() { + const subscriptionId = "subid"; + const resourceProviderNamespace = "Resource Provider Namespace"; + const featureName = "feature"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const result = await client.features.get( + resourceProviderNamespace, + featureName + ); + console.log(result); +} + +getFeature().catch(console.error); diff --git a/sdk/features/arm-features/samples-dev/featuresListAllSample.ts b/sdk/features/arm-features/samples-dev/featuresListAllSample.ts new file mode 100644 index 000000000000..22c07d5a78e7 --- /dev/null +++ b/sdk/features/arm-features/samples-dev/featuresListAllSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { FeatureClient } from "@azure/arm-features"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all the preview features that are available through AFEC for the subscription. + * + * @summary Gets all the preview features that are available through AFEC for the subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/listSubscriptionFeatures.json + */ +async function listSubscriptionFeatures() { + const subscriptionId = "subid"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.features.listAll()) { + resArray.push(item); + } + console.log(resArray); +} + +listSubscriptionFeatures().catch(console.error); diff --git a/sdk/features/arm-features/samples-dev/featuresListSample.ts b/sdk/features/arm-features/samples-dev/featuresListSample.ts new file mode 100644 index 000000000000..893040e4761d --- /dev/null +++ b/sdk/features/arm-features/samples-dev/featuresListSample.ts @@ -0,0 +1,32 @@ +/* + * 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 { FeatureClient } from "@azure/arm-features"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all the preview features in a provider namespace that are available through AFEC for the subscription. + * + * @summary Gets all the preview features in a provider namespace that are available through AFEC for the subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/listProviderFeatures.json + */ +async function listProviderFeatures() { + const subscriptionId = "subid"; + const resourceProviderNamespace = "Resource Provider Namespace"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.features.list(resourceProviderNamespace)) { + resArray.push(item); + } + console.log(resArray); +} + +listProviderFeatures().catch(console.error); diff --git a/sdk/features/arm-features/samples-dev/featuresRegisterSample.ts b/sdk/features/arm-features/samples-dev/featuresRegisterSample.ts new file mode 100644 index 000000000000..834a9e6ca2d2 --- /dev/null +++ b/sdk/features/arm-features/samples-dev/featuresRegisterSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { FeatureClient } from "@azure/arm-features"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Registers the preview feature for the subscription. + * + * @summary Registers the preview feature for the subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/registerFeature.json + */ +async function registerFeature() { + const subscriptionId = "subid"; + const resourceProviderNamespace = "Resource Provider Namespace"; + const featureName = "feature"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const result = await client.features.register( + resourceProviderNamespace, + featureName + ); + console.log(result); +} + +registerFeature().catch(console.error); diff --git a/sdk/features/arm-features/samples-dev/featuresUnregisterSample.ts b/sdk/features/arm-features/samples-dev/featuresUnregisterSample.ts new file mode 100644 index 000000000000..a436dce00915 --- /dev/null +++ b/sdk/features/arm-features/samples-dev/featuresUnregisterSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { FeatureClient } from "@azure/arm-features"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Unregisters the preview feature for the subscription. + * + * @summary Unregisters the preview feature for the subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/unregisterFeature.json + */ +async function registerFeature() { + const subscriptionId = "ff23096b-f5a2-46ea-bd62-59c3e93fef9a"; + const resourceProviderNamespace = "Resource Provider Namespace"; + const featureName = "feature"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const result = await client.features.unregister( + resourceProviderNamespace, + featureName + ); + console.log(result); +} + +registerFeature().catch(console.error); diff --git a/sdk/features/arm-features/samples-dev/listOperationsSample.ts b/sdk/features/arm-features/samples-dev/listOperationsSample.ts new file mode 100644 index 000000000000..6865e4aa35c3 --- /dev/null +++ b/sdk/features/arm-features/samples-dev/listOperationsSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { FeatureClient } from "@azure/arm-features"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists all of the available Microsoft.Features REST API operations. + * + * @summary Lists all of the available Microsoft.Features REST API operations. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/listFeaturesOperations.json + */ +async function listFeaturesOperations() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.listOperations()) { + resArray.push(item); + } + console.log(resArray); +} + +listFeaturesOperations().catch(console.error); diff --git a/sdk/features/arm-features/samples-dev/subscriptionFeatureRegistrationsCreateOrUpdateSample.ts b/sdk/features/arm-features/samples-dev/subscriptionFeatureRegistrationsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..b641a3568227 --- /dev/null +++ b/sdk/features/arm-features/samples-dev/subscriptionFeatureRegistrationsCreateOrUpdateSample.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 { + SubscriptionFeatureRegistration, + SubscriptionFeatureRegistrationsCreateOrUpdateOptionalParams, + FeatureClient +} from "@azure/arm-features"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Create or update a feature registration. + * + * @summary Create or update a feature registration. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationPUT.json + */ +async function createsAFeatureRegistration() { + const subscriptionId = "00000000-1111-2222-3333-444444444444"; + const providerNamespace = "subscriptionFeatureRegistrationGroupTestRG"; + const featureName = "testFeature"; + const subscriptionFeatureRegistrationType: SubscriptionFeatureRegistration = { + properties: {} + }; + const options: SubscriptionFeatureRegistrationsCreateOrUpdateOptionalParams = { + subscriptionFeatureRegistrationType + }; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const result = await client.subscriptionFeatureRegistrations.createOrUpdate( + providerNamespace, + featureName, + options + ); + console.log(result); +} + +createsAFeatureRegistration().catch(console.error); diff --git a/sdk/features/arm-features/samples-dev/subscriptionFeatureRegistrationsDeleteSample.ts b/sdk/features/arm-features/samples-dev/subscriptionFeatureRegistrationsDeleteSample.ts new file mode 100644 index 000000000000..38d44a8257bd --- /dev/null +++ b/sdk/features/arm-features/samples-dev/subscriptionFeatureRegistrationsDeleteSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { FeatureClient } from "@azure/arm-features"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes a feature registration + * + * @summary Deletes a feature registration + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationDELETE.json + */ +async function deletesAFeatureRegistration() { + const subscriptionId = "00000000-1111-2222-3333-444444444444"; + const providerNamespace = "subscriptionFeatureRegistrationGroupTestRG"; + const featureName = "testFeature"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const result = await client.subscriptionFeatureRegistrations.delete( + providerNamespace, + featureName + ); + console.log(result); +} + +deletesAFeatureRegistration().catch(console.error); diff --git a/sdk/features/arm-features/samples-dev/subscriptionFeatureRegistrationsGetSample.ts b/sdk/features/arm-features/samples-dev/subscriptionFeatureRegistrationsGetSample.ts new file mode 100644 index 000000000000..c35f13808d35 --- /dev/null +++ b/sdk/features/arm-features/samples-dev/subscriptionFeatureRegistrationsGetSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { FeatureClient } from "@azure/arm-features"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Returns a feature registration + * + * @summary Returns a feature registration + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationGET.json + */ +async function getsAFeatureRegistration() { + const subscriptionId = "00000000-1111-2222-3333-444444444444"; + const providerNamespace = "subscriptionFeatureRegistrationGroupTestRG"; + const featureName = "testFeature"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const result = await client.subscriptionFeatureRegistrations.get( + providerNamespace, + featureName + ); + console.log(result); +} + +getsAFeatureRegistration().catch(console.error); diff --git a/sdk/features/arm-features/samples-dev/subscriptionFeatureRegistrationsListAllBySubscriptionSample.ts b/sdk/features/arm-features/samples-dev/subscriptionFeatureRegistrationsListAllBySubscriptionSample.ts new file mode 100644 index 000000000000..d98c5a874556 --- /dev/null +++ b/sdk/features/arm-features/samples-dev/subscriptionFeatureRegistrationsListAllBySubscriptionSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { FeatureClient } from "@azure/arm-features"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Returns subscription feature registrations for given subscription. + * + * @summary Returns subscription feature registrations for given subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationLISTALL.json + */ +async function getsAListOfFeatureRegistrations() { + const subscriptionId = "00000000-1111-2222-3333-444444444444"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.subscriptionFeatureRegistrations.listAllBySubscription()) { + resArray.push(item); + } + console.log(resArray); +} + +getsAListOfFeatureRegistrations().catch(console.error); diff --git a/sdk/features/arm-features/samples-dev/subscriptionFeatureRegistrationsListBySubscriptionSample.ts b/sdk/features/arm-features/samples-dev/subscriptionFeatureRegistrationsListBySubscriptionSample.ts new file mode 100644 index 000000000000..88d3642e1bea --- /dev/null +++ b/sdk/features/arm-features/samples-dev/subscriptionFeatureRegistrationsListBySubscriptionSample.ts @@ -0,0 +1,34 @@ +/* + * 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 { FeatureClient } from "@azure/arm-features"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Returns subscription feature registrations for given subscription and provider namespace. + * + * @summary Returns subscription feature registrations for given subscription and provider namespace. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationLIST.json + */ +async function getsAListOfFeatureRegistrations() { + const subscriptionId = "00000000-1111-2222-3333-444444444444"; + const providerNamespace = "subscriptionFeatureRegistrationGroupTestRG"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.subscriptionFeatureRegistrations.listBySubscription( + providerNamespace + )) { + resArray.push(item); + } + console.log(resArray); +} + +getsAListOfFeatureRegistrations().catch(console.error); diff --git a/sdk/features/arm-features/samples/v3/javascript/README.md b/sdk/features/arm-features/samples/v3/javascript/README.md new file mode 100644 index 000000000000..9bd9e6b231d7 --- /dev/null +++ b/sdk/features/arm-features/samples/v3/javascript/README.md @@ -0,0 +1,70 @@ +# client library samples for JavaScript + +These sample programs show how to use the JavaScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| ----------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [featuresGetSample.js][featuresgetsample] | Gets the preview feature with the specified name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/getFeature.json | +| [featuresListAllSample.js][featureslistallsample] | Gets all the preview features that are available through AFEC for the subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/listSubscriptionFeatures.json | +| [featuresListSample.js][featureslistsample] | Gets all the preview features in a provider namespace that are available through AFEC for the subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/listProviderFeatures.json | +| [featuresRegisterSample.js][featuresregistersample] | Registers the preview feature for the subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/registerFeature.json | +| [featuresUnregisterSample.js][featuresunregistersample] | Unregisters the preview feature for the subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/unregisterFeature.json | +| [listOperationsSample.js][listoperationssample] | Lists all of the available Microsoft.Features REST API operations. x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/listFeaturesOperations.json | +| [subscriptionFeatureRegistrationsCreateOrUpdateSample.js][subscriptionfeatureregistrationscreateorupdatesample] | Create or update a feature registration. x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationPUT.json | +| [subscriptionFeatureRegistrationsDeleteSample.js][subscriptionfeatureregistrationsdeletesample] | Deletes a feature registration x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationDELETE.json | +| [subscriptionFeatureRegistrationsGetSample.js][subscriptionfeatureregistrationsgetsample] | Returns a feature registration x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationGET.json | +| [subscriptionFeatureRegistrationsListAllBySubscriptionSample.js][subscriptionfeatureregistrationslistallbysubscriptionsample] | Returns subscription feature registrations for given subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationLISTALL.json | +| [subscriptionFeatureRegistrationsListBySubscriptionSample.js][subscriptionfeatureregistrationslistbysubscriptionsample] | Returns subscription feature registrations for given subscription and provider namespace. x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationLIST.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +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 featuresGetSample.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 node featuresGetSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[featuresgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/features/arm-features/samples/v3/javascript/featuresGetSample.js +[featureslistallsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/features/arm-features/samples/v3/javascript/featuresListAllSample.js +[featureslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/features/arm-features/samples/v3/javascript/featuresListSample.js +[featuresregistersample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/features/arm-features/samples/v3/javascript/featuresRegisterSample.js +[featuresunregistersample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/features/arm-features/samples/v3/javascript/featuresUnregisterSample.js +[listoperationssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/features/arm-features/samples/v3/javascript/listOperationsSample.js +[subscriptionfeatureregistrationscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/features/arm-features/samples/v3/javascript/subscriptionFeatureRegistrationsCreateOrUpdateSample.js +[subscriptionfeatureregistrationsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/features/arm-features/samples/v3/javascript/subscriptionFeatureRegistrationsDeleteSample.js +[subscriptionfeatureregistrationsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/features/arm-features/samples/v3/javascript/subscriptionFeatureRegistrationsGetSample.js +[subscriptionfeatureregistrationslistallbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/features/arm-features/samples/v3/javascript/subscriptionFeatureRegistrationsListAllBySubscriptionSample.js +[subscriptionfeatureregistrationslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/features/arm-features/samples/v3/javascript/subscriptionFeatureRegistrationsListBySubscriptionSample.js +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-features?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/features/arm-features/README.md diff --git a/sdk/features/arm-features/samples/v3/javascript/featuresGetSample.js b/sdk/features/arm-features/samples/v3/javascript/featuresGetSample.js new file mode 100644 index 000000000000..6a09b52b0c5b --- /dev/null +++ b/sdk/features/arm-features/samples/v3/javascript/featuresGetSample.js @@ -0,0 +1,30 @@ +/* + * 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 { FeatureClient } = require("@azure/arm-features"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets the preview feature with the specified name. + * + * @summary Gets the preview feature with the specified name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/getFeature.json + */ +async function getFeature() { + const subscriptionId = "subid"; + const resourceProviderNamespace = "Resource Provider Namespace"; + const featureName = "feature"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const result = await client.features.get(resourceProviderNamespace, featureName); + console.log(result); +} + +getFeature().catch(console.error); diff --git a/sdk/features/arm-features/samples/v3/javascript/featuresListAllSample.js b/sdk/features/arm-features/samples/v3/javascript/featuresListAllSample.js new file mode 100644 index 000000000000..2705af44a8d1 --- /dev/null +++ b/sdk/features/arm-features/samples/v3/javascript/featuresListAllSample.js @@ -0,0 +1,31 @@ +/* + * 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 { FeatureClient } = require("@azure/arm-features"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets all the preview features that are available through AFEC for the subscription. + * + * @summary Gets all the preview features that are available through AFEC for the subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/listSubscriptionFeatures.json + */ +async function listSubscriptionFeatures() { + const subscriptionId = "subid"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.features.listAll()) { + resArray.push(item); + } + console.log(resArray); +} + +listSubscriptionFeatures().catch(console.error); diff --git a/sdk/features/arm-features/samples/v3/javascript/featuresListSample.js b/sdk/features/arm-features/samples/v3/javascript/featuresListSample.js new file mode 100644 index 000000000000..5ec86a34d96d --- /dev/null +++ b/sdk/features/arm-features/samples/v3/javascript/featuresListSample.js @@ -0,0 +1,32 @@ +/* + * 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 { FeatureClient } = require("@azure/arm-features"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets all the preview features in a provider namespace that are available through AFEC for the subscription. + * + * @summary Gets all the preview features in a provider namespace that are available through AFEC for the subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/listProviderFeatures.json + */ +async function listProviderFeatures() { + const subscriptionId = "subid"; + const resourceProviderNamespace = "Resource Provider Namespace"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.features.list(resourceProviderNamespace)) { + resArray.push(item); + } + console.log(resArray); +} + +listProviderFeatures().catch(console.error); diff --git a/sdk/features/arm-features/samples/v3/javascript/featuresRegisterSample.js b/sdk/features/arm-features/samples/v3/javascript/featuresRegisterSample.js new file mode 100644 index 000000000000..4fbf94c9a42c --- /dev/null +++ b/sdk/features/arm-features/samples/v3/javascript/featuresRegisterSample.js @@ -0,0 +1,30 @@ +/* + * 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 { FeatureClient } = require("@azure/arm-features"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Registers the preview feature for the subscription. + * + * @summary Registers the preview feature for the subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/registerFeature.json + */ +async function registerFeature() { + const subscriptionId = "subid"; + const resourceProviderNamespace = "Resource Provider Namespace"; + const featureName = "feature"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const result = await client.features.register(resourceProviderNamespace, featureName); + console.log(result); +} + +registerFeature().catch(console.error); diff --git a/sdk/features/arm-features/samples/v3/javascript/featuresUnregisterSample.js b/sdk/features/arm-features/samples/v3/javascript/featuresUnregisterSample.js new file mode 100644 index 000000000000..77d9a9748b65 --- /dev/null +++ b/sdk/features/arm-features/samples/v3/javascript/featuresUnregisterSample.js @@ -0,0 +1,30 @@ +/* + * 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 { FeatureClient } = require("@azure/arm-features"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Unregisters the preview feature for the subscription. + * + * @summary Unregisters the preview feature for the subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/unregisterFeature.json + */ +async function registerFeature() { + const subscriptionId = "ff23096b-f5a2-46ea-bd62-59c3e93fef9a"; + const resourceProviderNamespace = "Resource Provider Namespace"; + const featureName = "feature"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const result = await client.features.unregister(resourceProviderNamespace, featureName); + console.log(result); +} + +registerFeature().catch(console.error); diff --git a/sdk/features/arm-features/samples/v3/javascript/listOperationsSample.js b/sdk/features/arm-features/samples/v3/javascript/listOperationsSample.js new file mode 100644 index 000000000000..1580519f79d8 --- /dev/null +++ b/sdk/features/arm-features/samples/v3/javascript/listOperationsSample.js @@ -0,0 +1,31 @@ +/* + * 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 { FeatureClient } = require("@azure/arm-features"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists all of the available Microsoft.Features REST API operations. + * + * @summary Lists all of the available Microsoft.Features REST API operations. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/listFeaturesOperations.json + */ +async function listFeaturesOperations() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.listOperations()) { + resArray.push(item); + } + console.log(resArray); +} + +listFeaturesOperations().catch(console.error); diff --git a/sdk/features/arm-features/samples/v3/javascript/package.json b/sdk/features/arm-features/samples/v3/javascript/package.json new file mode 100644 index 000000000000..7c7d148ffd6f --- /dev/null +++ b/sdk/features/arm-features/samples/v3/javascript/package.json @@ -0,0 +1,32 @@ +{ + "name": "@azure-samples/arm-features-js", + "private": true, + "version": "1.0.0", + "description": " client library samples for JavaScript", + "engines": { + "node": ">=12.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/features/arm-features" + }, + "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/features/arm-features", + "dependencies": { + "@azure/arm-features": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + } +} diff --git a/sdk/features/arm-features/samples/v3/javascript/sample.env b/sdk/features/arm-features/samples/v3/javascript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/features/arm-features/samples/v3/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/features/arm-features/samples/v3/javascript/subscriptionFeatureRegistrationsCreateOrUpdateSample.js b/sdk/features/arm-features/samples/v3/javascript/subscriptionFeatureRegistrationsCreateOrUpdateSample.js new file mode 100644 index 000000000000..5a291002172a --- /dev/null +++ b/sdk/features/arm-features/samples/v3/javascript/subscriptionFeatureRegistrationsCreateOrUpdateSample.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 { FeatureClient } = require("@azure/arm-features"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Create or update a feature registration. + * + * @summary Create or update a feature registration. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationPUT.json + */ +async function createsAFeatureRegistration() { + const subscriptionId = "00000000-1111-2222-3333-444444444444"; + const providerNamespace = "subscriptionFeatureRegistrationGroupTestRG"; + const featureName = "testFeature"; + const subscriptionFeatureRegistrationType = { + properties: {}, + }; + const options = { + subscriptionFeatureRegistrationType, + }; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const result = await client.subscriptionFeatureRegistrations.createOrUpdate( + providerNamespace, + featureName, + options + ); + console.log(result); +} + +createsAFeatureRegistration().catch(console.error); diff --git a/sdk/features/arm-features/samples/v3/javascript/subscriptionFeatureRegistrationsDeleteSample.js b/sdk/features/arm-features/samples/v3/javascript/subscriptionFeatureRegistrationsDeleteSample.js new file mode 100644 index 000000000000..c3e6030d8733 --- /dev/null +++ b/sdk/features/arm-features/samples/v3/javascript/subscriptionFeatureRegistrationsDeleteSample.js @@ -0,0 +1,33 @@ +/* + * 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 { FeatureClient } = require("@azure/arm-features"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes a feature registration + * + * @summary Deletes a feature registration + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationDELETE.json + */ +async function deletesAFeatureRegistration() { + const subscriptionId = "00000000-1111-2222-3333-444444444444"; + const providerNamespace = "subscriptionFeatureRegistrationGroupTestRG"; + const featureName = "testFeature"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const result = await client.subscriptionFeatureRegistrations.delete( + providerNamespace, + featureName + ); + console.log(result); +} + +deletesAFeatureRegistration().catch(console.error); diff --git a/sdk/features/arm-features/samples/v3/javascript/subscriptionFeatureRegistrationsGetSample.js b/sdk/features/arm-features/samples/v3/javascript/subscriptionFeatureRegistrationsGetSample.js new file mode 100644 index 000000000000..f30ee4f612f8 --- /dev/null +++ b/sdk/features/arm-features/samples/v3/javascript/subscriptionFeatureRegistrationsGetSample.js @@ -0,0 +1,30 @@ +/* + * 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 { FeatureClient } = require("@azure/arm-features"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Returns a feature registration + * + * @summary Returns a feature registration + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationGET.json + */ +async function getsAFeatureRegistration() { + const subscriptionId = "00000000-1111-2222-3333-444444444444"; + const providerNamespace = "subscriptionFeatureRegistrationGroupTestRG"; + const featureName = "testFeature"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const result = await client.subscriptionFeatureRegistrations.get(providerNamespace, featureName); + console.log(result); +} + +getsAFeatureRegistration().catch(console.error); diff --git a/sdk/features/arm-features/samples/v3/javascript/subscriptionFeatureRegistrationsListAllBySubscriptionSample.js b/sdk/features/arm-features/samples/v3/javascript/subscriptionFeatureRegistrationsListAllBySubscriptionSample.js new file mode 100644 index 000000000000..48632116913f --- /dev/null +++ b/sdk/features/arm-features/samples/v3/javascript/subscriptionFeatureRegistrationsListAllBySubscriptionSample.js @@ -0,0 +1,31 @@ +/* + * 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 { FeatureClient } = require("@azure/arm-features"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Returns subscription feature registrations for given subscription. + * + * @summary Returns subscription feature registrations for given subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationLISTALL.json + */ +async function getsAListOfFeatureRegistrations() { + const subscriptionId = "00000000-1111-2222-3333-444444444444"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.subscriptionFeatureRegistrations.listAllBySubscription()) { + resArray.push(item); + } + console.log(resArray); +} + +getsAListOfFeatureRegistrations().catch(console.error); diff --git a/sdk/features/arm-features/samples/v3/javascript/subscriptionFeatureRegistrationsListBySubscriptionSample.js b/sdk/features/arm-features/samples/v3/javascript/subscriptionFeatureRegistrationsListBySubscriptionSample.js new file mode 100644 index 000000000000..612888356236 --- /dev/null +++ b/sdk/features/arm-features/samples/v3/javascript/subscriptionFeatureRegistrationsListBySubscriptionSample.js @@ -0,0 +1,34 @@ +/* + * 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 { FeatureClient } = require("@azure/arm-features"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Returns subscription feature registrations for given subscription and provider namespace. + * + * @summary Returns subscription feature registrations for given subscription and provider namespace. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationLIST.json + */ +async function getsAListOfFeatureRegistrations() { + const subscriptionId = "00000000-1111-2222-3333-444444444444"; + const providerNamespace = "subscriptionFeatureRegistrationGroupTestRG"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.subscriptionFeatureRegistrations.listBySubscription( + providerNamespace + )) { + resArray.push(item); + } + console.log(resArray); +} + +getsAListOfFeatureRegistrations().catch(console.error); diff --git a/sdk/features/arm-features/samples/v3/typescript/README.md b/sdk/features/arm-features/samples/v3/typescript/README.md new file mode 100644 index 000000000000..0665feb93e46 --- /dev/null +++ b/sdk/features/arm-features/samples/v3/typescript/README.md @@ -0,0 +1,83 @@ +# client library samples for TypeScript + +These sample programs show how to use the TypeScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| ----------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [featuresGetSample.ts][featuresgetsample] | Gets the preview feature with the specified name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/getFeature.json | +| [featuresListAllSample.ts][featureslistallsample] | Gets all the preview features that are available through AFEC for the subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/listSubscriptionFeatures.json | +| [featuresListSample.ts][featureslistsample] | Gets all the preview features in a provider namespace that are available through AFEC for the subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/listProviderFeatures.json | +| [featuresRegisterSample.ts][featuresregistersample] | Registers the preview feature for the subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/registerFeature.json | +| [featuresUnregisterSample.ts][featuresunregistersample] | Unregisters the preview feature for the subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/unregisterFeature.json | +| [listOperationsSample.ts][listoperationssample] | Lists all of the available Microsoft.Features REST API operations. x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/listFeaturesOperations.json | +| [subscriptionFeatureRegistrationsCreateOrUpdateSample.ts][subscriptionfeatureregistrationscreateorupdatesample] | Create or update a feature registration. x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationPUT.json | +| [subscriptionFeatureRegistrationsDeleteSample.ts][subscriptionfeatureregistrationsdeletesample] | Deletes a feature registration x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationDELETE.json | +| [subscriptionFeatureRegistrationsGetSample.ts][subscriptionfeatureregistrationsgetsample] | Returns a feature registration x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationGET.json | +| [subscriptionFeatureRegistrationsListAllBySubscriptionSample.ts][subscriptionfeatureregistrationslistallbysubscriptionsample] | Returns subscription feature registrations for given subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationLISTALL.json | +| [subscriptionFeatureRegistrationsListBySubscriptionSample.ts][subscriptionfeatureregistrationslistbysubscriptionsample] | Returns subscription feature registrations for given subscription and provider namespace. x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationLIST.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +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/featuresGetSample.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 node dist/featuresGetSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[featuresgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/features/arm-features/samples/v3/typescript/src/featuresGetSample.ts +[featureslistallsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/features/arm-features/samples/v3/typescript/src/featuresListAllSample.ts +[featureslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/features/arm-features/samples/v3/typescript/src/featuresListSample.ts +[featuresregistersample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/features/arm-features/samples/v3/typescript/src/featuresRegisterSample.ts +[featuresunregistersample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/features/arm-features/samples/v3/typescript/src/featuresUnregisterSample.ts +[listoperationssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/features/arm-features/samples/v3/typescript/src/listOperationsSample.ts +[subscriptionfeatureregistrationscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/features/arm-features/samples/v3/typescript/src/subscriptionFeatureRegistrationsCreateOrUpdateSample.ts +[subscriptionfeatureregistrationsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/features/arm-features/samples/v3/typescript/src/subscriptionFeatureRegistrationsDeleteSample.ts +[subscriptionfeatureregistrationsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/features/arm-features/samples/v3/typescript/src/subscriptionFeatureRegistrationsGetSample.ts +[subscriptionfeatureregistrationslistallbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/features/arm-features/samples/v3/typescript/src/subscriptionFeatureRegistrationsListAllBySubscriptionSample.ts +[subscriptionfeatureregistrationslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/features/arm-features/samples/v3/typescript/src/subscriptionFeatureRegistrationsListBySubscriptionSample.ts +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-features?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/features/arm-features/README.md +[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/features/arm-features/samples/v3/typescript/package.json b/sdk/features/arm-features/samples/v3/typescript/package.json new file mode 100644 index 000000000000..09d459d47ffe --- /dev/null +++ b/sdk/features/arm-features/samples/v3/typescript/package.json @@ -0,0 +1,41 @@ +{ + "name": "@azure-samples/arm-features-ts", + "private": true, + "version": "1.0.0", + "description": " client library samples for TypeScript", + "engines": { + "node": ">=12.0.0" + }, + "scripts": { + "build": "tsc", + "prebuild": "rimraf dist/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/features/arm-features" + }, + "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/features/arm-features", + "dependencies": { + "@azure/arm-features": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + }, + "devDependencies": { + "@types/node": "^12.0.0", + "typescript": "~4.4.0", + "rimraf": "latest" + } +} diff --git a/sdk/features/arm-features/samples/v3/typescript/sample.env b/sdk/features/arm-features/samples/v3/typescript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/features/arm-features/samples/v3/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/features/arm-features/samples/v3/typescript/src/featuresGetSample.ts b/sdk/features/arm-features/samples/v3/typescript/src/featuresGetSample.ts new file mode 100644 index 000000000000..4a1ed81055a0 --- /dev/null +++ b/sdk/features/arm-features/samples/v3/typescript/src/featuresGetSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { FeatureClient } from "@azure/arm-features"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the preview feature with the specified name. + * + * @summary Gets the preview feature with the specified name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/getFeature.json + */ +async function getFeature() { + const subscriptionId = "subid"; + const resourceProviderNamespace = "Resource Provider Namespace"; + const featureName = "feature"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const result = await client.features.get( + resourceProviderNamespace, + featureName + ); + console.log(result); +} + +getFeature().catch(console.error); diff --git a/sdk/features/arm-features/samples/v3/typescript/src/featuresListAllSample.ts b/sdk/features/arm-features/samples/v3/typescript/src/featuresListAllSample.ts new file mode 100644 index 000000000000..22c07d5a78e7 --- /dev/null +++ b/sdk/features/arm-features/samples/v3/typescript/src/featuresListAllSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { FeatureClient } from "@azure/arm-features"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all the preview features that are available through AFEC for the subscription. + * + * @summary Gets all the preview features that are available through AFEC for the subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/listSubscriptionFeatures.json + */ +async function listSubscriptionFeatures() { + const subscriptionId = "subid"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.features.listAll()) { + resArray.push(item); + } + console.log(resArray); +} + +listSubscriptionFeatures().catch(console.error); diff --git a/sdk/features/arm-features/samples/v3/typescript/src/featuresListSample.ts b/sdk/features/arm-features/samples/v3/typescript/src/featuresListSample.ts new file mode 100644 index 000000000000..893040e4761d --- /dev/null +++ b/sdk/features/arm-features/samples/v3/typescript/src/featuresListSample.ts @@ -0,0 +1,32 @@ +/* + * 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 { FeatureClient } from "@azure/arm-features"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all the preview features in a provider namespace that are available through AFEC for the subscription. + * + * @summary Gets all the preview features in a provider namespace that are available through AFEC for the subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/listProviderFeatures.json + */ +async function listProviderFeatures() { + const subscriptionId = "subid"; + const resourceProviderNamespace = "Resource Provider Namespace"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.features.list(resourceProviderNamespace)) { + resArray.push(item); + } + console.log(resArray); +} + +listProviderFeatures().catch(console.error); diff --git a/sdk/features/arm-features/samples/v3/typescript/src/featuresRegisterSample.ts b/sdk/features/arm-features/samples/v3/typescript/src/featuresRegisterSample.ts new file mode 100644 index 000000000000..834a9e6ca2d2 --- /dev/null +++ b/sdk/features/arm-features/samples/v3/typescript/src/featuresRegisterSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { FeatureClient } from "@azure/arm-features"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Registers the preview feature for the subscription. + * + * @summary Registers the preview feature for the subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/registerFeature.json + */ +async function registerFeature() { + const subscriptionId = "subid"; + const resourceProviderNamespace = "Resource Provider Namespace"; + const featureName = "feature"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const result = await client.features.register( + resourceProviderNamespace, + featureName + ); + console.log(result); +} + +registerFeature().catch(console.error); diff --git a/sdk/features/arm-features/samples/v3/typescript/src/featuresUnregisterSample.ts b/sdk/features/arm-features/samples/v3/typescript/src/featuresUnregisterSample.ts new file mode 100644 index 000000000000..a436dce00915 --- /dev/null +++ b/sdk/features/arm-features/samples/v3/typescript/src/featuresUnregisterSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { FeatureClient } from "@azure/arm-features"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Unregisters the preview feature for the subscription. + * + * @summary Unregisters the preview feature for the subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/unregisterFeature.json + */ +async function registerFeature() { + const subscriptionId = "ff23096b-f5a2-46ea-bd62-59c3e93fef9a"; + const resourceProviderNamespace = "Resource Provider Namespace"; + const featureName = "feature"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const result = await client.features.unregister( + resourceProviderNamespace, + featureName + ); + console.log(result); +} + +registerFeature().catch(console.error); diff --git a/sdk/features/arm-features/samples/v3/typescript/src/listOperationsSample.ts b/sdk/features/arm-features/samples/v3/typescript/src/listOperationsSample.ts new file mode 100644 index 000000000000..6865e4aa35c3 --- /dev/null +++ b/sdk/features/arm-features/samples/v3/typescript/src/listOperationsSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { FeatureClient } from "@azure/arm-features"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists all of the available Microsoft.Features REST API operations. + * + * @summary Lists all of the available Microsoft.Features REST API operations. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/listFeaturesOperations.json + */ +async function listFeaturesOperations() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.listOperations()) { + resArray.push(item); + } + console.log(resArray); +} + +listFeaturesOperations().catch(console.error); diff --git a/sdk/features/arm-features/samples/v3/typescript/src/subscriptionFeatureRegistrationsCreateOrUpdateSample.ts b/sdk/features/arm-features/samples/v3/typescript/src/subscriptionFeatureRegistrationsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..b641a3568227 --- /dev/null +++ b/sdk/features/arm-features/samples/v3/typescript/src/subscriptionFeatureRegistrationsCreateOrUpdateSample.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 { + SubscriptionFeatureRegistration, + SubscriptionFeatureRegistrationsCreateOrUpdateOptionalParams, + FeatureClient +} from "@azure/arm-features"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Create or update a feature registration. + * + * @summary Create or update a feature registration. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationPUT.json + */ +async function createsAFeatureRegistration() { + const subscriptionId = "00000000-1111-2222-3333-444444444444"; + const providerNamespace = "subscriptionFeatureRegistrationGroupTestRG"; + const featureName = "testFeature"; + const subscriptionFeatureRegistrationType: SubscriptionFeatureRegistration = { + properties: {} + }; + const options: SubscriptionFeatureRegistrationsCreateOrUpdateOptionalParams = { + subscriptionFeatureRegistrationType + }; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const result = await client.subscriptionFeatureRegistrations.createOrUpdate( + providerNamespace, + featureName, + options + ); + console.log(result); +} + +createsAFeatureRegistration().catch(console.error); diff --git a/sdk/features/arm-features/samples/v3/typescript/src/subscriptionFeatureRegistrationsDeleteSample.ts b/sdk/features/arm-features/samples/v3/typescript/src/subscriptionFeatureRegistrationsDeleteSample.ts new file mode 100644 index 000000000000..38d44a8257bd --- /dev/null +++ b/sdk/features/arm-features/samples/v3/typescript/src/subscriptionFeatureRegistrationsDeleteSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { FeatureClient } from "@azure/arm-features"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes a feature registration + * + * @summary Deletes a feature registration + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationDELETE.json + */ +async function deletesAFeatureRegistration() { + const subscriptionId = "00000000-1111-2222-3333-444444444444"; + const providerNamespace = "subscriptionFeatureRegistrationGroupTestRG"; + const featureName = "testFeature"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const result = await client.subscriptionFeatureRegistrations.delete( + providerNamespace, + featureName + ); + console.log(result); +} + +deletesAFeatureRegistration().catch(console.error); diff --git a/sdk/features/arm-features/samples/v3/typescript/src/subscriptionFeatureRegistrationsGetSample.ts b/sdk/features/arm-features/samples/v3/typescript/src/subscriptionFeatureRegistrationsGetSample.ts new file mode 100644 index 000000000000..c35f13808d35 --- /dev/null +++ b/sdk/features/arm-features/samples/v3/typescript/src/subscriptionFeatureRegistrationsGetSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { FeatureClient } from "@azure/arm-features"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Returns a feature registration + * + * @summary Returns a feature registration + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationGET.json + */ +async function getsAFeatureRegistration() { + const subscriptionId = "00000000-1111-2222-3333-444444444444"; + const providerNamespace = "subscriptionFeatureRegistrationGroupTestRG"; + const featureName = "testFeature"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const result = await client.subscriptionFeatureRegistrations.get( + providerNamespace, + featureName + ); + console.log(result); +} + +getsAFeatureRegistration().catch(console.error); diff --git a/sdk/features/arm-features/samples/v3/typescript/src/subscriptionFeatureRegistrationsListAllBySubscriptionSample.ts b/sdk/features/arm-features/samples/v3/typescript/src/subscriptionFeatureRegistrationsListAllBySubscriptionSample.ts new file mode 100644 index 000000000000..d98c5a874556 --- /dev/null +++ b/sdk/features/arm-features/samples/v3/typescript/src/subscriptionFeatureRegistrationsListAllBySubscriptionSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { FeatureClient } from "@azure/arm-features"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Returns subscription feature registrations for given subscription. + * + * @summary Returns subscription feature registrations for given subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationLISTALL.json + */ +async function getsAListOfFeatureRegistrations() { + const subscriptionId = "00000000-1111-2222-3333-444444444444"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.subscriptionFeatureRegistrations.listAllBySubscription()) { + resArray.push(item); + } + console.log(resArray); +} + +getsAListOfFeatureRegistrations().catch(console.error); diff --git a/sdk/features/arm-features/samples/v3/typescript/src/subscriptionFeatureRegistrationsListBySubscriptionSample.ts b/sdk/features/arm-features/samples/v3/typescript/src/subscriptionFeatureRegistrationsListBySubscriptionSample.ts new file mode 100644 index 000000000000..88d3642e1bea --- /dev/null +++ b/sdk/features/arm-features/samples/v3/typescript/src/subscriptionFeatureRegistrationsListBySubscriptionSample.ts @@ -0,0 +1,34 @@ +/* + * 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 { FeatureClient } from "@azure/arm-features"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Returns subscription feature registrations for given subscription and provider namespace. + * + * @summary Returns subscription feature registrations for given subscription and provider namespace. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/FeatureRegistration/SubscriptionFeatureRegistrationLIST.json + */ +async function getsAListOfFeatureRegistrations() { + const subscriptionId = "00000000-1111-2222-3333-444444444444"; + const providerNamespace = "subscriptionFeatureRegistrationGroupTestRG"; + const credential = new DefaultAzureCredential(); + const client = new FeatureClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.subscriptionFeatureRegistrations.listBySubscription( + providerNamespace + )) { + resArray.push(item); + } + console.log(resArray); +} + +getsAListOfFeatureRegistrations().catch(console.error); diff --git a/sdk/features/arm-features/samples/v3/typescript/tsconfig.json b/sdk/features/arm-features/samples/v3/typescript/tsconfig.json new file mode 100644 index 000000000000..416c2dd82e00 --- /dev/null +++ b/sdk/features/arm-features/samples/v3/typescript/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2018", + "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/features/arm-features/src/featureClient.ts b/sdk/features/arm-features/src/featureClient.ts index 1e666690f901..744192c4bdc7 100644 --- a/sdk/features/arm-features/src/featureClient.ts +++ b/sdk/features/arm-features/src/featureClient.ts @@ -7,6 +7,7 @@ */ import * as coreClient from "@azure/core-client"; +import * as coreRestPipeline from "@azure/core-rest-pipeline"; import * as coreAuth from "@azure/core-auth"; import { PagedAsyncIterableIterator } from "@azure/core-paging"; import { @@ -61,7 +62,7 @@ export class FeatureClient extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-features/3.0.0`; + const packageDetails = `azsdk-js-arm-features/3.0.1`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` @@ -76,9 +77,33 @@ export class FeatureClient extends coreClient.ServiceClient { userAgentOptions: { userAgentPrefix }, - baseUri: options.endpoint || "https://management.azure.com" + baseUri: + options.endpoint ?? options.baseUri ?? "https://management.azure.com" }; super(optionsWithDefaults); + + if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { + const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies(); + const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( + (pipelinePolicy) => + pipelinePolicy.name === + coreRestPipeline.bearerTokenAuthenticationPolicyName + ); + if (!bearerTokenAuthenticationPolicyFound) { + this.pipeline.removePolicy({ + name: coreRestPipeline.bearerTokenAuthenticationPolicyName + }); + this.pipeline.addPolicy( + coreRestPipeline.bearerTokenAuthenticationPolicy({ + scopes: `${optionsWithDefaults.baseUri}/.default`, + challengeCallbacks: { + authorizeRequestOnChallenge: + coreClient.authorizeRequestOnClaimChallenge + } + }) + ); + } + } // Parameter assignments this.subscriptionId = subscriptionId; diff --git a/sdk/features/arm-features/tsconfig.json b/sdk/features/arm-features/tsconfig.json index 6e3251194117..8fe2cc8654c1 100644 --- a/sdk/features/arm-features/tsconfig.json +++ b/sdk/features/arm-features/tsconfig.json @@ -9,11 +9,27 @@ "esModuleInterop": true, "allowSyntheticDefaultImports": true, "forceConsistentCasingInFileNames": true, - "lib": ["es6", "dom"], + "lib": [ + "es6", + "dom" + ], "declaration": true, "outDir": "./dist-esm", - "importHelpers": true + "importHelpers": true, + "paths": { + "@azure/arm-features": [ + "./src/index" + ] + } }, - "include": ["./src/**/*.ts", "./test/**/*.ts"], - "exclude": ["node_modules"] -} + "include": [ + "./src/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts" + ], + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/sdk/features/ci.mgmt.yml b/sdk/features/ci.mgmt.yml index 808003a1ab79..dbdaf5fb01f6 100644 --- a/sdk/features/ci.mgmt.yml +++ b/sdk/features/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,7 +9,7 @@ trigger: paths: include: - sdk/features/ci.mgmt.yml - - sdk/features/arm-features/ + - sdk/features/arm-features pr: branches: include: @@ -22,12 +22,11 @@ pr: paths: include: - sdk/features/ci.mgmt.yml - - sdk/features/arm-features/ - + - sdk/features/arm-features extends: template: /eng/pipelines/templates/stages/archetype-sdk-client.yml parameters: ServiceDirectory: features Artifacts: - name: azure-arm-features - safeName: azurearmfeatures \ No newline at end of file + safeName: azurearmfeatures diff --git a/sdk/links/arm-links/CHANGELOG.md b/sdk/links/arm-links/CHANGELOG.md index 52fd777e9748..4dea27cc87f6 100644 --- a/sdk/links/arm-links/CHANGELOG.md +++ b/sdk/links/arm-links/CHANGELOG.md @@ -1,14 +1,10 @@ # Release History -## 2.0.1 (Unreleased) +## 2.0.1 (2022-04-18) -### Features Added +**features** -### Breaking Changes - -### Bugs Fixed - -### Other Changes + - Bug fix ## 2.0.0 (2021-12-07) diff --git a/sdk/links/arm-links/LICENSE b/sdk/links/arm-links/LICENSE index ccb63b166732..5d1d36e0af80 100644 --- a/sdk/links/arm-links/LICENSE +++ b/sdk/links/arm-links/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2021 Microsoft +Copyright (c) 2022 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/links/arm-links/README.md b/sdk/links/arm-links/README.md index d2d9d426109c..25cd3deac9b7 100644 --- a/sdk/links/arm-links/README.md +++ b/sdk/links/arm-links/README.md @@ -16,6 +16,8 @@ Azure resources can be linked together to form logical relationships. You can es - [LTS versions of Node.js](https://nodejs.org/about/releases/) - 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]. @@ -49,8 +51,17 @@ For more information about how to create an Azure AD Application check out [this ```javascript const { ManagementLinkClient } = require("@azure/arm-links"); 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 ManagementLinkClient(new DefaultAzureCredential(), subscriptionId); + +// For client-side applications running in the browser, use this code instead: +// const credential = new InteractiveBrowserCredential({ +// tenantId: "", +// clientId: "" +// }); +// const client = new ManagementLinkClient(credential, subscriptionId); ``` diff --git a/sdk/links/arm-links/_meta.json b/sdk/links/arm-links/_meta.json index 0551b4fe18f8..c6765ba542bb 100644 --- a/sdk/links/arm-links/_meta.json +++ b/sdk/links/arm-links/_meta.json @@ -1,7 +1,8 @@ { "commit": "a42f1b58607091c4f255ead152a8ef323fa0b280", - "readme": "specification/resources/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 --generate-test --typescript-sdks-folder=D:\\mydev\\azure-sdk-for-js ../azure-rest-api-specs/specification/resources/resource-manager/readme.md --use=@autorest/typescript@6.0.0-alpha.16.20211130.1", + "readme": "specification\\resources\\resource-manager\\readme.md", + "autorest_command": "autorest --version=3.7.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\work\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\resources\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-alpha.19.20220408.1 --generate-sample=true", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "use": "@autorest/typescript@6.0.0-alpha.16.20211130.1" + "release_tool": "@azure-tools/js-sdk-release-tools@2.2.6", + "use": "@autorest/typescript@6.0.0-alpha.19.20220408.1" } \ No newline at end of file diff --git a/sdk/links/arm-links/api-extractor.json b/sdk/links/arm-links/api-extractor.json index 444955d87a24..bc0112cb9f26 100644 --- a/sdk/links/arm-links/api-extractor.json +++ b/sdk/links/arm-links/api-extractor.json @@ -1,18 +1,31 @@ { "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", "mainEntryPointFilePath": "./dist-esm/src/index.d.ts", - "docModel": { "enabled": true }, - "apiReport": { "enabled": true, "reportFolder": "./review" }, + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, "dtsRollup": { "enabled": true, "untrimmedFilePath": "", "publicTrimmedFilePath": "./types/arm-links.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/links/arm-links/package.json b/sdk/links/arm-links/package.json index 0ed21922cdd5..1667a8223820 100644 --- a/sdk/links/arm-links/package.json +++ b/sdk/links/arm-links/package.json @@ -9,9 +9,9 @@ }, "dependencies": { "@azure/core-paging": "^1.2.0", - "@azure/core-client": "^1.0.0", + "@azure/core-client": "^1.5.0", "@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": [ @@ -28,12 +28,12 @@ "devDependencies": { "@microsoft/api-extractor": "^7.18.11", "@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-plugin-sourcemaps": "^0.4.2", + "rollup": "^2.66.1", + "rollup-plugin-sourcemaps": "^0.6.3", "typescript": "~4.2.0", "uglify-js": "^3.4.9", "rimraf": "^3.0.0", @@ -97,5 +97,13 @@ "docs": "echo skipped" }, "sideEffects": false, + "//metadata": { + "constantPaths": [ + { + "path": "src/managementLinkClient.ts", + "prefix": "packageDetails" + } + ] + }, "autoPublish": true } diff --git a/sdk/links/arm-links/rollup.config.js b/sdk/links/arm-links/rollup.config.js index 9be1955eb7f1..3f89d7309da5 100644 --- a/sdk/links/arm-links/rollup.config.js +++ b/sdk/links/arm-links/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/links/arm-links/src/managementLinkClient.ts b/sdk/links/arm-links/src/managementLinkClient.ts index 640ce635e17f..4cfd996b5315 100644 --- a/sdk/links/arm-links/src/managementLinkClient.ts +++ b/sdk/links/arm-links/src/managementLinkClient.ts @@ -7,6 +7,7 @@ */ import * as coreClient from "@azure/core-client"; +import * as coreRestPipeline from "@azure/core-rest-pipeline"; import * as coreAuth from "@azure/core-auth"; import { OperationsImpl, ResourceLinksImpl } from "./operations"; import { Operations, ResourceLinks } from "./operationsInterfaces"; @@ -44,7 +45,7 @@ export class ManagementLinkClient extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-links/2.0.0`; + const packageDetails = `azsdk-js-arm-links/2.0.2`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` @@ -59,9 +60,33 @@ export class ManagementLinkClient extends coreClient.ServiceClient { userAgentOptions: { userAgentPrefix }, - baseUri: options.endpoint || "https://management.azure.com" + baseUri: + options.endpoint ?? options.baseUri ?? "https://management.azure.com" }; super(optionsWithDefaults); + + if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { + const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies(); + const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( + (pipelinePolicy) => + pipelinePolicy.name === + coreRestPipeline.bearerTokenAuthenticationPolicyName + ); + if (!bearerTokenAuthenticationPolicyFound) { + this.pipeline.removePolicy({ + name: coreRestPipeline.bearerTokenAuthenticationPolicyName + }); + this.pipeline.addPolicy( + coreRestPipeline.bearerTokenAuthenticationPolicy({ + scopes: `${optionsWithDefaults.baseUri}/.default`, + challengeCallbacks: { + authorizeRequestOnChallenge: + coreClient.authorizeRequestOnClaimChallenge + } + }) + ); + } + } // Parameter assignments this.subscriptionId = subscriptionId; diff --git a/sdk/links/arm-links/tsconfig.json b/sdk/links/arm-links/tsconfig.json index 6e3251194117..eb954adee4c6 100644 --- a/sdk/links/arm-links/tsconfig.json +++ b/sdk/links/arm-links/tsconfig.json @@ -9,11 +9,33 @@ "esModuleInterop": true, "allowSyntheticDefaultImports": true, "forceConsistentCasingInFileNames": true, - "lib": ["es6", "dom"], + "lib": [ + "es6", + "dom" + ], "declaration": true, "outDir": "./dist-esm", - "importHelpers": true + "importHelpers": true, + "paths": { + "@azure/arm-links": [ + "./src/index" + ] + } }, - "include": ["./src/**/*.ts", "./test/**/*.ts"], - "exclude": ["node_modules"] -} + "include": [ + "./src/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts" + ], + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/sdk/links/ci.mgmt.yml b/sdk/links/ci.mgmt.yml index 2487864c5204..4c40da49b908 100644 --- a/sdk/links/ci.mgmt.yml +++ b/sdk/links/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,7 +9,7 @@ trigger: paths: include: - sdk/links/ci.mgmt.yml - - sdk/links/arm-links/ + - sdk/links/arm-links pr: branches: include: @@ -22,12 +22,11 @@ pr: paths: include: - sdk/links/ci.mgmt.yml - - sdk/links/arm-links/ - + - sdk/links/arm-links extends: template: /eng/pipelines/templates/stages/archetype-sdk-client.yml parameters: ServiceDirectory: links Artifacts: - name: azure-arm-links - safeName: azurearmlinks \ No newline at end of file + safeName: azurearmlinks diff --git a/sdk/locks/arm-locks/CHANGELOG.md b/sdk/locks/arm-locks/CHANGELOG.md index b53dea671dec..83c79a226f99 100644 --- a/sdk/locks/arm-locks/CHANGELOG.md +++ b/sdk/locks/arm-locks/CHANGELOG.md @@ -1,15 +1,19 @@ # Release History - -## 2.0.1 (Unreleased) - -### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes - + +## 2.1.0 (2022-04-18) + +**Features** + + - Added Interface ErrorAdditionalInfo + - Added Interface ErrorDetail + - Added Interface ErrorResponse + - Added Interface SystemData + - Added Type Alias CreatedByType + - Interface ManagementLockObject has a new optional parameter systemData + - Added Enum KnownCreatedByType + - Bug fix + + ## 2.0.0 (2021-12-07) The package of @azure/arm-locks is using our next generation design principles since version 2.0.0, which contains breaking changes. diff --git a/sdk/locks/arm-locks/LICENSE b/sdk/locks/arm-locks/LICENSE index ccb63b166732..5d1d36e0af80 100644 --- a/sdk/locks/arm-locks/LICENSE +++ b/sdk/locks/arm-locks/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2021 Microsoft +Copyright (c) 2022 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/locks/arm-locks/README.md b/sdk/locks/arm-locks/README.md index 938cd66fb5cd..ba64a8ff439b 100644 --- a/sdk/locks/arm-locks/README.md +++ b/sdk/locks/arm-locks/README.md @@ -16,6 +16,8 @@ Azure resources can be locked to prevent other users in your organization from d - [LTS versions of Node.js](https://nodejs.org/about/releases/) - 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]. @@ -49,8 +51,17 @@ For more information about how to create an Azure AD Application check out [this ```javascript const { ManagementLockClient } = require("@azure/arm-locks"); 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 ManagementLockClient(new DefaultAzureCredential(), subscriptionId); + +// For client-side applications running in the browser, use this code instead: +// const credential = new InteractiveBrowserCredential({ +// tenantId: "", +// clientId: "" +// }); +// const client = new ManagementLockClient(credential, subscriptionId); ``` diff --git a/sdk/locks/arm-locks/_meta.json b/sdk/locks/arm-locks/_meta.json index 0551b4fe18f8..c6765ba542bb 100644 --- a/sdk/locks/arm-locks/_meta.json +++ b/sdk/locks/arm-locks/_meta.json @@ -1,7 +1,8 @@ { "commit": "a42f1b58607091c4f255ead152a8ef323fa0b280", - "readme": "specification/resources/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 --generate-test --typescript-sdks-folder=D:\\mydev\\azure-sdk-for-js ../azure-rest-api-specs/specification/resources/resource-manager/readme.md --use=@autorest/typescript@6.0.0-alpha.16.20211130.1", + "readme": "specification\\resources\\resource-manager\\readme.md", + "autorest_command": "autorest --version=3.7.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\work\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\resources\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-alpha.19.20220408.1 --generate-sample=true", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "use": "@autorest/typescript@6.0.0-alpha.16.20211130.1" + "release_tool": "@azure-tools/js-sdk-release-tools@2.2.6", + "use": "@autorest/typescript@6.0.0-alpha.19.20220408.1" } \ No newline at end of file diff --git a/sdk/locks/arm-locks/api-extractor.json b/sdk/locks/arm-locks/api-extractor.json index e46bea0263c1..d62f01cf7a13 100644 --- a/sdk/locks/arm-locks/api-extractor.json +++ b/sdk/locks/arm-locks/api-extractor.json @@ -1,18 +1,31 @@ { "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", "mainEntryPointFilePath": "./dist-esm/src/index.d.ts", - "docModel": { "enabled": true }, - "apiReport": { "enabled": true, "reportFolder": "./review" }, + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, "dtsRollup": { "enabled": true, "untrimmedFilePath": "", "publicTrimmedFilePath": "./types/arm-locks.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/locks/arm-locks/package.json b/sdk/locks/arm-locks/package.json index 8c83b195d05f..d5bf18c915f5 100644 --- a/sdk/locks/arm-locks/package.json +++ b/sdk/locks/arm-locks/package.json @@ -3,15 +3,15 @@ "sdk-type": "mgmt", "author": "Microsoft Corporation", "description": "A generated SDK for ManagementLockClient.", - "version": "2.0.1", + "version": "2.1.0", "engines": { "node": ">=12.0.0" }, "dependencies": { "@azure/core-paging": "^1.2.0", - "@azure/core-client": "^1.0.0", + "@azure/core-client": "^1.5.0", "@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": [ @@ -28,12 +28,12 @@ "devDependencies": { "@microsoft/api-extractor": "^7.18.11", "@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-plugin-sourcemaps": "^0.4.2", + "rollup": "^2.66.1", + "rollup-plugin-sourcemaps": "^0.6.3", "typescript": "~4.2.0", "uglify-js": "^3.4.9", "rimraf": "^3.0.0", @@ -96,5 +96,21 @@ "docs": "echo skipped" }, "sideEffects": false, - "autoPublish": true + "//metadata": { + "constantPaths": [ + { + "path": "src/managementLockClient.ts", + "prefix": "packageDetails" + } + ] + }, + "autoPublish": true, + "//sampleConfiguration": { + "productName": "", + "productSlugs": [ + "azure" + ], + "disableDocsMs": true, + "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-locks?view=azure-node-preview" + } } diff --git a/sdk/locks/arm-locks/review/arm-locks.api.md b/sdk/locks/arm-locks/review/arm-locks.api.md index ee557e92a29a..ed24ef0cfafc 100644 --- a/sdk/locks/arm-locks/review/arm-locks.api.md +++ b/sdk/locks/arm-locks/review/arm-locks.api.md @@ -27,6 +27,41 @@ export interface AuthorizationOperationsListOptionalParams extends coreClient.Op // @public export type AuthorizationOperationsListResponse = OperationListResult; +// @public +export type CreatedByType = string; + +// @public +export interface ErrorAdditionalInfo { + readonly info?: Record; + readonly type?: string; +} + +// @public +export interface ErrorDetail { + readonly additionalInfo?: ErrorAdditionalInfo[]; + readonly code?: string; + readonly details?: ErrorDetail[]; + readonly message?: string; + readonly target?: string; +} + +// @public +export interface ErrorResponse { + error?: ErrorDetail; +} + +// @public +export enum KnownCreatedByType { + // (undocumented) + Application = "Application", + // (undocumented) + Key = "Key", + // (undocumented) + ManagedIdentity = "ManagedIdentity", + // (undocumented) + User = "User" +} + // @public export enum KnownLockLevel { // (undocumented) @@ -75,6 +110,7 @@ export interface ManagementLockObject { readonly name?: string; notes?: string; owners?: ManagementLockOwner[]; + readonly systemData?: SystemData; readonly type?: string; } @@ -258,6 +294,16 @@ export interface OperationListResult { value?: Operation[]; } +// @public +export interface SystemData { + createdAt?: Date; + createdBy?: string; + createdByType?: CreatedByType; + lastModifiedAt?: Date; + lastModifiedBy?: string; + lastModifiedByType?: CreatedByType; +} + // (No @packageDocumentation comment for this package) ``` diff --git a/sdk/locks/arm-locks/rollup.config.js b/sdk/locks/arm-locks/rollup.config.js index 9be1955eb7f1..3f89d7309da5 100644 --- a/sdk/locks/arm-locks/rollup.config.js +++ b/sdk/locks/arm-locks/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/locks/arm-locks/sample.env b/sdk/locks/arm-locks/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/locks/arm-locks/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/locks/arm-locks/samples-dev/authorizationOperationsListSample.ts b/sdk/locks/arm-locks/samples-dev/authorizationOperationsListSample.ts new file mode 100644 index 000000000000..5f6f16e5b1d5 --- /dev/null +++ b/sdk/locks/arm-locks/samples-dev/authorizationOperationsListSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists all of the available Microsoft.Authorization REST API operations. + * + * @summary Lists all of the available Microsoft.Authorization REST API operations. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ListProviderOperations.json + */ +async function listProviderOperations() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.authorizationOperations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listProviderOperations().catch(console.error); diff --git a/sdk/locks/arm-locks/samples-dev/managementLocksCreateOrUpdateAtResourceGroupLevelSample.ts b/sdk/locks/arm-locks/samples-dev/managementLocksCreateOrUpdateAtResourceGroupLevelSample.ts new file mode 100644 index 000000000000..19d59fcb97e1 --- /dev/null +++ b/sdk/locks/arm-locks/samples-dev/managementLocksCreateOrUpdateAtResourceGroupLevelSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { ManagementLockObject, ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * + * @summary When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtResourceGroupLevel.json + */ +async function createManagementLockAtResourceGroupLevel() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourcegroupname"; + const lockName = "testlock"; + const parameters: ManagementLockObject = { level: "ReadOnly" }; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.createOrUpdateAtResourceGroupLevel( + resourceGroupName, + lockName, + parameters + ); + console.log(result); +} + +createManagementLockAtResourceGroupLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples-dev/managementLocksCreateOrUpdateAtResourceLevelSample.ts b/sdk/locks/arm-locks/samples-dev/managementLocksCreateOrUpdateAtResourceLevelSample.ts new file mode 100644 index 000000000000..1d604e726d98 --- /dev/null +++ b/sdk/locks/arm-locks/samples-dev/managementLocksCreateOrUpdateAtResourceLevelSample.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 { ManagementLockObject, ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * + * @summary When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtResourceLevel.json + */ +async function createManagementLockAtResourceLevel() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourcegroupname"; + const resourceProviderNamespace = "Microsoft.Storage"; + const parentResourcePath = "parentResourcePath"; + const resourceType = "storageAccounts"; + const resourceName = "teststorageaccount"; + const lockName = "testlock"; + const parameters: ManagementLockObject = { level: "ReadOnly" }; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.createOrUpdateAtResourceLevel( + resourceGroupName, + resourceProviderNamespace, + parentResourcePath, + resourceType, + resourceName, + lockName, + parameters + ); + console.log(result); +} + +createManagementLockAtResourceLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples-dev/managementLocksCreateOrUpdateAtSubscriptionLevelSample.ts b/sdk/locks/arm-locks/samples-dev/managementLocksCreateOrUpdateAtSubscriptionLevelSample.ts new file mode 100644 index 000000000000..b1e9c1b1dddc --- /dev/null +++ b/sdk/locks/arm-locks/samples-dev/managementLocksCreateOrUpdateAtSubscriptionLevelSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { ManagementLockObject, ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * + * @summary When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtSubscriptionLevel.json + */ +async function createManagementLockAtSubscriptionLevel() { + const subscriptionId = "subscriptionId"; + const lockName = "testlock"; + const parameters: ManagementLockObject = { level: "ReadOnly" }; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.createOrUpdateAtSubscriptionLevel( + lockName, + parameters + ); + console.log(result); +} + +createManagementLockAtSubscriptionLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples-dev/managementLocksCreateOrUpdateByScopeSample.ts b/sdk/locks/arm-locks/samples-dev/managementLocksCreateOrUpdateByScopeSample.ts new file mode 100644 index 000000000000..088dbf79801d --- /dev/null +++ b/sdk/locks/arm-locks/samples-dev/managementLocksCreateOrUpdateByScopeSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { ManagementLockObject, ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Create or update a management lock by scope. + * + * @summary Create or update a management lock by scope. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtScope.json + */ +async function createManagementLockAtScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/subscriptionId"; + const lockName = "testlock"; + const parameters: ManagementLockObject = { level: "ReadOnly" }; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.createOrUpdateByScope( + scope, + lockName, + parameters + ); + console.log(result); +} + +createManagementLockAtScope().catch(console.error); diff --git a/sdk/locks/arm-locks/samples-dev/managementLocksDeleteAtResourceGroupLevelSample.ts b/sdk/locks/arm-locks/samples-dev/managementLocksDeleteAtResourceGroupLevelSample.ts new file mode 100644 index 000000000000..e6830815a4f7 --- /dev/null +++ b/sdk/locks/arm-locks/samples-dev/managementLocksDeleteAtResourceGroupLevelSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to To delete management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * + * @summary To delete management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtResourceGroupLevel.json + */ +async function deleteManagementLockAtResourceGroupLevel() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourcegroupname"; + const lockName = "testlock"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.deleteAtResourceGroupLevel( + resourceGroupName, + lockName + ); + console.log(result); +} + +deleteManagementLockAtResourceGroupLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples-dev/managementLocksDeleteAtResourceLevelSample.ts b/sdk/locks/arm-locks/samples-dev/managementLocksDeleteAtResourceLevelSample.ts new file mode 100644 index 000000000000..f80fced90ab7 --- /dev/null +++ b/sdk/locks/arm-locks/samples-dev/managementLocksDeleteAtResourceLevelSample.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 { ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to To delete management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * + * @summary To delete management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtResourceLevel.json + */ +async function deleteManagementLockAtResourceLevel() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourcegroupname"; + const resourceProviderNamespace = "Microsoft.Storage"; + const parentResourcePath = "parentResourcePath"; + const resourceType = "storageAccounts"; + const resourceName = "teststorageaccount"; + const lockName = "testlock"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.deleteAtResourceLevel( + resourceGroupName, + resourceProviderNamespace, + parentResourcePath, + resourceType, + resourceName, + lockName + ); + console.log(result); +} + +deleteManagementLockAtResourceLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples-dev/managementLocksDeleteAtSubscriptionLevelSample.ts b/sdk/locks/arm-locks/samples-dev/managementLocksDeleteAtSubscriptionLevelSample.ts new file mode 100644 index 000000000000..33e7bc6a810c --- /dev/null +++ b/sdk/locks/arm-locks/samples-dev/managementLocksDeleteAtSubscriptionLevelSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to To delete management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * + * @summary To delete management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtSubscriptionLevel.json + */ +async function deleteManagementLockAtSubscriptionLevel() { + const subscriptionId = "subscriptionId"; + const lockName = "testlock"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.deleteAtSubscriptionLevel( + lockName + ); + console.log(result); +} + +deleteManagementLockAtSubscriptionLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples-dev/managementLocksDeleteByScopeSample.ts b/sdk/locks/arm-locks/samples-dev/managementLocksDeleteByScopeSample.ts new file mode 100644 index 000000000000..ebb32dbcbb3b --- /dev/null +++ b/sdk/locks/arm-locks/samples-dev/managementLocksDeleteByScopeSample.ts @@ -0,0 +1,30 @@ +/* + * 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 { ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Delete a management lock by scope. + * + * @summary Delete a management lock by scope. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtScope.json + */ +async function deleteManagementLockAtScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/subscriptionId"; + const lockName = "testlock"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.deleteByScope(scope, lockName); + console.log(result); +} + +deleteManagementLockAtScope().catch(console.error); diff --git a/sdk/locks/arm-locks/samples-dev/managementLocksGetAtResourceGroupLevelSample.ts b/sdk/locks/arm-locks/samples-dev/managementLocksGetAtResourceGroupLevelSample.ts new file mode 100644 index 000000000000..5b58dd881eb8 --- /dev/null +++ b/sdk/locks/arm-locks/samples-dev/managementLocksGetAtResourceGroupLevelSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets a management lock at the resource group level. + * + * @summary Gets a management lock at the resource group level. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtResourceGroupLevel.json + */ +async function getManagementLockAtResourceGroupLevel() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourcegroupname"; + const lockName = "testlock"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.getAtResourceGroupLevel( + resourceGroupName, + lockName + ); + console.log(result); +} + +getManagementLockAtResourceGroupLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples-dev/managementLocksGetAtResourceLevelSample.ts b/sdk/locks/arm-locks/samples-dev/managementLocksGetAtResourceLevelSample.ts new file mode 100644 index 000000000000..1e99727135e8 --- /dev/null +++ b/sdk/locks/arm-locks/samples-dev/managementLocksGetAtResourceLevelSample.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 { ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Get the management lock of a resource or any level below resource. + * + * @summary Get the management lock of a resource or any level below resource. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtResourceLevel.json + */ +async function getManagementLockAtResourceLevel() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourcegroupname"; + const resourceProviderNamespace = "Microsoft.Storage"; + const parentResourcePath = "parentResourcePath"; + const resourceType = "storageAccounts"; + const resourceName = "teststorageaccount"; + const lockName = "testlock"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.getAtResourceLevel( + resourceGroupName, + resourceProviderNamespace, + parentResourcePath, + resourceType, + resourceName, + lockName + ); + console.log(result); +} + +getManagementLockAtResourceLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples-dev/managementLocksGetAtSubscriptionLevelSample.ts b/sdk/locks/arm-locks/samples-dev/managementLocksGetAtSubscriptionLevelSample.ts new file mode 100644 index 000000000000..008385778b9f --- /dev/null +++ b/sdk/locks/arm-locks/samples-dev/managementLocksGetAtSubscriptionLevelSample.ts @@ -0,0 +1,29 @@ +/* + * 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 { ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets a management lock at the subscription level. + * + * @summary Gets a management lock at the subscription level. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtSubscriptionLevel.json + */ +async function getManagementLockAtSubscriptionLevel() { + const subscriptionId = "subscriptionId"; + const lockName = "testlock"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.getAtSubscriptionLevel(lockName); + console.log(result); +} + +getManagementLockAtSubscriptionLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples-dev/managementLocksGetByScopeSample.ts b/sdk/locks/arm-locks/samples-dev/managementLocksGetByScopeSample.ts new file mode 100644 index 000000000000..a13c4472d6cd --- /dev/null +++ b/sdk/locks/arm-locks/samples-dev/managementLocksGetByScopeSample.ts @@ -0,0 +1,30 @@ +/* + * 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 { ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Get a management lock by scope. + * + * @summary Get a management lock by scope. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtScope.json + */ +async function getManagementLockAtScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/subscriptionId"; + const lockName = "testlock"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.getByScope(scope, lockName); + console.log(result); +} + +getManagementLockAtScope().catch(console.error); diff --git a/sdk/locks/arm-locks/samples-dev/managementLocksListAtResourceGroupLevelSample.ts b/sdk/locks/arm-locks/samples-dev/managementLocksListAtResourceGroupLevelSample.ts new file mode 100644 index 000000000000..8c32a115a722 --- /dev/null +++ b/sdk/locks/arm-locks/samples-dev/managementLocksListAtResourceGroupLevelSample.ts @@ -0,0 +1,34 @@ +/* + * 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 { ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all the management locks for a resource group. + * + * @summary Gets all the management locks for a resource group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtResourceGroupLevel.json + */ +async function listManagementGroupsAtResourceGroupLevel() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourcegroupname"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.managementLocks.listAtResourceGroupLevel( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listManagementGroupsAtResourceGroupLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples-dev/managementLocksListAtResourceLevelSample.ts b/sdk/locks/arm-locks/samples-dev/managementLocksListAtResourceLevelSample.ts new file mode 100644 index 000000000000..a3474aa8824e --- /dev/null +++ b/sdk/locks/arm-locks/samples-dev/managementLocksListAtResourceLevelSample.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 { ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all the management locks for a resource or any level below resource. + * + * @summary Gets all the management locks for a resource or any level below resource. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtResourceLevel.json + */ +async function listManagementLocksAtResourceLevel() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourcegroupname"; + const resourceProviderNamespace = "Microsoft.Storage"; + const parentResourcePath = "parentResourcePath"; + const resourceType = "storageAccounts"; + const resourceName = "teststorageaccount"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.managementLocks.listAtResourceLevel( + resourceGroupName, + resourceProviderNamespace, + parentResourcePath, + resourceType, + resourceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listManagementLocksAtResourceLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples-dev/managementLocksListAtSubscriptionLevelSample.ts b/sdk/locks/arm-locks/samples-dev/managementLocksListAtSubscriptionLevelSample.ts new file mode 100644 index 000000000000..5c7a9478e2fa --- /dev/null +++ b/sdk/locks/arm-locks/samples-dev/managementLocksListAtSubscriptionLevelSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all the management locks for a subscription. + * + * @summary Gets all the management locks for a subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtSubscriptionLevel.json + */ +async function listManagementLocksAtSubscriptionLevel() { + const subscriptionId = "subscriptionId"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.managementLocks.listAtSubscriptionLevel()) { + resArray.push(item); + } + console.log(resArray); +} + +listManagementLocksAtSubscriptionLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples-dev/managementLocksListByScopeSample.ts b/sdk/locks/arm-locks/samples-dev/managementLocksListByScopeSample.ts new file mode 100644 index 000000000000..f59c3d18fc66 --- /dev/null +++ b/sdk/locks/arm-locks/samples-dev/managementLocksListByScopeSample.ts @@ -0,0 +1,32 @@ +/* + * 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 { ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all the management locks for a scope. + * + * @summary Gets all the management locks for a scope. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtScope.json + */ +async function listManagementLocksAtScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/subscriptionId"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.managementLocks.listByScope(scope)) { + resArray.push(item); + } + console.log(resArray); +} + +listManagementLocksAtScope().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/javascript/README.md b/sdk/locks/arm-locks/samples/v2/javascript/README.md new file mode 100644 index 000000000000..86a8964eb59a --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/javascript/README.md @@ -0,0 +1,82 @@ +# client library samples for JavaScript + +These sample programs show how to use the JavaScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| --------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [authorizationOperationsListSample.js][authorizationoperationslistsample] | Lists all of the available Microsoft.Authorization REST API operations. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ListProviderOperations.json | +| [managementLocksCreateOrUpdateAtResourceGroupLevelSample.js][managementlockscreateorupdateatresourcegrouplevelsample] | When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/_ or Microsoft.Authorization/locks/_ actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtResourceGroupLevel.json | +| [managementLocksCreateOrUpdateAtResourceLevelSample.js][managementlockscreateorupdateatresourcelevelsample] | When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/_ or Microsoft.Authorization/locks/_ actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtResourceLevel.json | +| [managementLocksCreateOrUpdateAtSubscriptionLevelSample.js][managementlockscreateorupdateatsubscriptionlevelsample] | When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/_ or Microsoft.Authorization/locks/_ actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtSubscriptionLevel.json | +| [managementLocksCreateOrUpdateByScopeSample.js][managementlockscreateorupdatebyscopesample] | Create or update a management lock by scope. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtScope.json | +| [managementLocksDeleteAtResourceGroupLevelSample.js][managementlocksdeleteatresourcegrouplevelsample] | To delete management locks, you must have access to Microsoft.Authorization/_ or Microsoft.Authorization/locks/_ actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtResourceGroupLevel.json | +| [managementLocksDeleteAtResourceLevelSample.js][managementlocksdeleteatresourcelevelsample] | To delete management locks, you must have access to Microsoft.Authorization/_ or Microsoft.Authorization/locks/_ actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtResourceLevel.json | +| [managementLocksDeleteAtSubscriptionLevelSample.js][managementlocksdeleteatsubscriptionlevelsample] | To delete management locks, you must have access to Microsoft.Authorization/_ or Microsoft.Authorization/locks/_ actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtSubscriptionLevel.json | +| [managementLocksDeleteByScopeSample.js][managementlocksdeletebyscopesample] | Delete a management lock by scope. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtScope.json | +| [managementLocksGetAtResourceGroupLevelSample.js][managementlocksgetatresourcegrouplevelsample] | Gets a management lock at the resource group level. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtResourceGroupLevel.json | +| [managementLocksGetAtResourceLevelSample.js][managementlocksgetatresourcelevelsample] | Get the management lock of a resource or any level below resource. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtResourceLevel.json | +| [managementLocksGetAtSubscriptionLevelSample.js][managementlocksgetatsubscriptionlevelsample] | Gets a management lock at the subscription level. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtSubscriptionLevel.json | +| [managementLocksGetByScopeSample.js][managementlocksgetbyscopesample] | Get a management lock by scope. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtScope.json | +| [managementLocksListAtResourceGroupLevelSample.js][managementlockslistatresourcegrouplevelsample] | Gets all the management locks for a resource group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtResourceGroupLevel.json | +| [managementLocksListAtResourceLevelSample.js][managementlockslistatresourcelevelsample] | Gets all the management locks for a resource or any level below resource. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtResourceLevel.json | +| [managementLocksListAtSubscriptionLevelSample.js][managementlockslistatsubscriptionlevelsample] | Gets all the management locks for a subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtSubscriptionLevel.json | +| [managementLocksListByScopeSample.js][managementlockslistbyscopesample] | Gets all the management locks for a scope. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtScope.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +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 authorizationOperationsListSample.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 node authorizationOperationsListSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[authorizationoperationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/javascript/authorizationOperationsListSample.js +[managementlockscreateorupdateatresourcegrouplevelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/javascript/managementLocksCreateOrUpdateAtResourceGroupLevelSample.js +[managementlockscreateorupdateatresourcelevelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/javascript/managementLocksCreateOrUpdateAtResourceLevelSample.js +[managementlockscreateorupdateatsubscriptionlevelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/javascript/managementLocksCreateOrUpdateAtSubscriptionLevelSample.js +[managementlockscreateorupdatebyscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/javascript/managementLocksCreateOrUpdateByScopeSample.js +[managementlocksdeleteatresourcegrouplevelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/javascript/managementLocksDeleteAtResourceGroupLevelSample.js +[managementlocksdeleteatresourcelevelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/javascript/managementLocksDeleteAtResourceLevelSample.js +[managementlocksdeleteatsubscriptionlevelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/javascript/managementLocksDeleteAtSubscriptionLevelSample.js +[managementlocksdeletebyscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/javascript/managementLocksDeleteByScopeSample.js +[managementlocksgetatresourcegrouplevelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/javascript/managementLocksGetAtResourceGroupLevelSample.js +[managementlocksgetatresourcelevelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/javascript/managementLocksGetAtResourceLevelSample.js +[managementlocksgetatsubscriptionlevelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/javascript/managementLocksGetAtSubscriptionLevelSample.js +[managementlocksgetbyscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/javascript/managementLocksGetByScopeSample.js +[managementlockslistatresourcegrouplevelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/javascript/managementLocksListAtResourceGroupLevelSample.js +[managementlockslistatresourcelevelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/javascript/managementLocksListAtResourceLevelSample.js +[managementlockslistatsubscriptionlevelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/javascript/managementLocksListAtSubscriptionLevelSample.js +[managementlockslistbyscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/javascript/managementLocksListByScopeSample.js +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-locks?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/locks/arm-locks/README.md diff --git a/sdk/locks/arm-locks/samples/v2/javascript/authorizationOperationsListSample.js b/sdk/locks/arm-locks/samples/v2/javascript/authorizationOperationsListSample.js new file mode 100644 index 000000000000..e5521cf7aa31 --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/javascript/authorizationOperationsListSample.js @@ -0,0 +1,31 @@ +/* + * 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 { ManagementLockClient } = require("@azure/arm-locks"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists all of the available Microsoft.Authorization REST API operations. + * + * @summary Lists all of the available Microsoft.Authorization REST API operations. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ListProviderOperations.json + */ +async function listProviderOperations() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.authorizationOperations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listProviderOperations().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/javascript/managementLocksCreateOrUpdateAtResourceGroupLevelSample.js b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksCreateOrUpdateAtResourceGroupLevelSample.js new file mode 100644 index 000000000000..48d2e08ad671 --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksCreateOrUpdateAtResourceGroupLevelSample.js @@ -0,0 +1,35 @@ +/* + * 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 { ManagementLockClient } = require("@azure/arm-locks"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * + * @summary When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtResourceGroupLevel.json + */ +async function createManagementLockAtResourceGroupLevel() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourcegroupname"; + const lockName = "testlock"; + const parameters = { level: "ReadOnly" }; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.createOrUpdateAtResourceGroupLevel( + resourceGroupName, + lockName, + parameters + ); + console.log(result); +} + +createManagementLockAtResourceGroupLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/javascript/managementLocksCreateOrUpdateAtResourceLevelSample.js b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksCreateOrUpdateAtResourceLevelSample.js new file mode 100644 index 000000000000..c85441f01744 --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksCreateOrUpdateAtResourceLevelSample.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 { ManagementLockClient } = require("@azure/arm-locks"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * + * @summary When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtResourceLevel.json + */ +async function createManagementLockAtResourceLevel() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourcegroupname"; + const resourceProviderNamespace = "Microsoft.Storage"; + const parentResourcePath = "parentResourcePath"; + const resourceType = "storageAccounts"; + const resourceName = "teststorageaccount"; + const lockName = "testlock"; + const parameters = { level: "ReadOnly" }; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.createOrUpdateAtResourceLevel( + resourceGroupName, + resourceProviderNamespace, + parentResourcePath, + resourceType, + resourceName, + lockName, + parameters + ); + console.log(result); +} + +createManagementLockAtResourceLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/javascript/managementLocksCreateOrUpdateAtSubscriptionLevelSample.js b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksCreateOrUpdateAtSubscriptionLevelSample.js new file mode 100644 index 000000000000..392f61d4f086 --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksCreateOrUpdateAtSubscriptionLevelSample.js @@ -0,0 +1,33 @@ +/* + * 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 { ManagementLockClient } = require("@azure/arm-locks"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * + * @summary When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtSubscriptionLevel.json + */ +async function createManagementLockAtSubscriptionLevel() { + const subscriptionId = "subscriptionId"; + const lockName = "testlock"; + const parameters = { level: "ReadOnly" }; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.createOrUpdateAtSubscriptionLevel( + lockName, + parameters + ); + console.log(result); +} + +createManagementLockAtSubscriptionLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/javascript/managementLocksCreateOrUpdateByScopeSample.js b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksCreateOrUpdateByScopeSample.js new file mode 100644 index 000000000000..ef975daa8705 --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksCreateOrUpdateByScopeSample.js @@ -0,0 +1,31 @@ +/* + * 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 { ManagementLockClient } = require("@azure/arm-locks"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Create or update a management lock by scope. + * + * @summary Create or update a management lock by scope. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtScope.json + */ +async function createManagementLockAtScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/subscriptionId"; + const lockName = "testlock"; + const parameters = { level: "ReadOnly" }; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.createOrUpdateByScope(scope, lockName, parameters); + console.log(result); +} + +createManagementLockAtScope().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/javascript/managementLocksDeleteAtResourceGroupLevelSample.js b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksDeleteAtResourceGroupLevelSample.js new file mode 100644 index 000000000000..b7726258f582 --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksDeleteAtResourceGroupLevelSample.js @@ -0,0 +1,33 @@ +/* + * 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 { ManagementLockClient } = require("@azure/arm-locks"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to To delete management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * + * @summary To delete management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtResourceGroupLevel.json + */ +async function deleteManagementLockAtResourceGroupLevel() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourcegroupname"; + const lockName = "testlock"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.deleteAtResourceGroupLevel( + resourceGroupName, + lockName + ); + console.log(result); +} + +deleteManagementLockAtResourceGroupLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/javascript/managementLocksDeleteAtResourceLevelSample.js b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksDeleteAtResourceLevelSample.js new file mode 100644 index 000000000000..5885fc1c38bb --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksDeleteAtResourceLevelSample.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 { ManagementLockClient } = require("@azure/arm-locks"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to To delete management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * + * @summary To delete management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtResourceLevel.json + */ +async function deleteManagementLockAtResourceLevel() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourcegroupname"; + const resourceProviderNamespace = "Microsoft.Storage"; + const parentResourcePath = "parentResourcePath"; + const resourceType = "storageAccounts"; + const resourceName = "teststorageaccount"; + const lockName = "testlock"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.deleteAtResourceLevel( + resourceGroupName, + resourceProviderNamespace, + parentResourcePath, + resourceType, + resourceName, + lockName + ); + console.log(result); +} + +deleteManagementLockAtResourceLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/javascript/managementLocksDeleteAtSubscriptionLevelSample.js b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksDeleteAtSubscriptionLevelSample.js new file mode 100644 index 000000000000..b8ea2e3b8d9a --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksDeleteAtSubscriptionLevelSample.js @@ -0,0 +1,29 @@ +/* + * 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 { ManagementLockClient } = require("@azure/arm-locks"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to To delete management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * + * @summary To delete management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtSubscriptionLevel.json + */ +async function deleteManagementLockAtSubscriptionLevel() { + const subscriptionId = "subscriptionId"; + const lockName = "testlock"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.deleteAtSubscriptionLevel(lockName); + console.log(result); +} + +deleteManagementLockAtSubscriptionLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/javascript/managementLocksDeleteByScopeSample.js b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksDeleteByScopeSample.js new file mode 100644 index 000000000000..34444656f212 --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksDeleteByScopeSample.js @@ -0,0 +1,30 @@ +/* + * 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 { ManagementLockClient } = require("@azure/arm-locks"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Delete a management lock by scope. + * + * @summary Delete a management lock by scope. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtScope.json + */ +async function deleteManagementLockAtScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/subscriptionId"; + const lockName = "testlock"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.deleteByScope(scope, lockName); + console.log(result); +} + +deleteManagementLockAtScope().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/javascript/managementLocksGetAtResourceGroupLevelSample.js b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksGetAtResourceGroupLevelSample.js new file mode 100644 index 000000000000..f70738d023bc --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksGetAtResourceGroupLevelSample.js @@ -0,0 +1,30 @@ +/* + * 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 { ManagementLockClient } = require("@azure/arm-locks"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets a management lock at the resource group level. + * + * @summary Gets a management lock at the resource group level. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtResourceGroupLevel.json + */ +async function getManagementLockAtResourceGroupLevel() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourcegroupname"; + const lockName = "testlock"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.getAtResourceGroupLevel(resourceGroupName, lockName); + console.log(result); +} + +getManagementLockAtResourceGroupLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/javascript/managementLocksGetAtResourceLevelSample.js b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksGetAtResourceLevelSample.js new file mode 100644 index 000000000000..f1ea7cc45b9d --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksGetAtResourceLevelSample.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 { ManagementLockClient } = require("@azure/arm-locks"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Get the management lock of a resource or any level below resource. + * + * @summary Get the management lock of a resource or any level below resource. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtResourceLevel.json + */ +async function getManagementLockAtResourceLevel() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourcegroupname"; + const resourceProviderNamespace = "Microsoft.Storage"; + const parentResourcePath = "parentResourcePath"; + const resourceType = "storageAccounts"; + const resourceName = "teststorageaccount"; + const lockName = "testlock"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.getAtResourceLevel( + resourceGroupName, + resourceProviderNamespace, + parentResourcePath, + resourceType, + resourceName, + lockName + ); + console.log(result); +} + +getManagementLockAtResourceLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/javascript/managementLocksGetAtSubscriptionLevelSample.js b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksGetAtSubscriptionLevelSample.js new file mode 100644 index 000000000000..5ff70d2887f1 --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksGetAtSubscriptionLevelSample.js @@ -0,0 +1,29 @@ +/* + * 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 { ManagementLockClient } = require("@azure/arm-locks"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets a management lock at the subscription level. + * + * @summary Gets a management lock at the subscription level. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtSubscriptionLevel.json + */ +async function getManagementLockAtSubscriptionLevel() { + const subscriptionId = "subscriptionId"; + const lockName = "testlock"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.getAtSubscriptionLevel(lockName); + console.log(result); +} + +getManagementLockAtSubscriptionLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/javascript/managementLocksGetByScopeSample.js b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksGetByScopeSample.js new file mode 100644 index 000000000000..fb3480ffd09c --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksGetByScopeSample.js @@ -0,0 +1,30 @@ +/* + * 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 { ManagementLockClient } = require("@azure/arm-locks"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Get a management lock by scope. + * + * @summary Get a management lock by scope. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtScope.json + */ +async function getManagementLockAtScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/subscriptionId"; + const lockName = "testlock"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.getByScope(scope, lockName); + console.log(result); +} + +getManagementLockAtScope().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/javascript/managementLocksListAtResourceGroupLevelSample.js b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksListAtResourceGroupLevelSample.js new file mode 100644 index 000000000000..d05a061f0ea5 --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksListAtResourceGroupLevelSample.js @@ -0,0 +1,32 @@ +/* + * 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 { ManagementLockClient } = require("@azure/arm-locks"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets all the management locks for a resource group. + * + * @summary Gets all the management locks for a resource group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtResourceGroupLevel.json + */ +async function listManagementGroupsAtResourceGroupLevel() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourcegroupname"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.managementLocks.listAtResourceGroupLevel(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +listManagementGroupsAtResourceGroupLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/javascript/managementLocksListAtResourceLevelSample.js b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksListAtResourceLevelSample.js new file mode 100644 index 000000000000..9420da7d2ef2 --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksListAtResourceLevelSample.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 { ManagementLockClient } = require("@azure/arm-locks"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets all the management locks for a resource or any level below resource. + * + * @summary Gets all the management locks for a resource or any level below resource. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtResourceLevel.json + */ +async function listManagementLocksAtResourceLevel() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourcegroupname"; + const resourceProviderNamespace = "Microsoft.Storage"; + const parentResourcePath = "parentResourcePath"; + const resourceType = "storageAccounts"; + const resourceName = "teststorageaccount"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.managementLocks.listAtResourceLevel( + resourceGroupName, + resourceProviderNamespace, + parentResourcePath, + resourceType, + resourceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listManagementLocksAtResourceLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/javascript/managementLocksListAtSubscriptionLevelSample.js b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksListAtSubscriptionLevelSample.js new file mode 100644 index 000000000000..0bd7468973e2 --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksListAtSubscriptionLevelSample.js @@ -0,0 +1,31 @@ +/* + * 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 { ManagementLockClient } = require("@azure/arm-locks"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets all the management locks for a subscription. + * + * @summary Gets all the management locks for a subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtSubscriptionLevel.json + */ +async function listManagementLocksAtSubscriptionLevel() { + const subscriptionId = "subscriptionId"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.managementLocks.listAtSubscriptionLevel()) { + resArray.push(item); + } + console.log(resArray); +} + +listManagementLocksAtSubscriptionLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/javascript/managementLocksListByScopeSample.js b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksListByScopeSample.js new file mode 100644 index 000000000000..4c21f8a60005 --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/javascript/managementLocksListByScopeSample.js @@ -0,0 +1,32 @@ +/* + * 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 { ManagementLockClient } = require("@azure/arm-locks"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets all the management locks for a scope. + * + * @summary Gets all the management locks for a scope. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtScope.json + */ +async function listManagementLocksAtScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/subscriptionId"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.managementLocks.listByScope(scope)) { + resArray.push(item); + } + console.log(resArray); +} + +listManagementLocksAtScope().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/javascript/package.json b/sdk/locks/arm-locks/samples/v2/javascript/package.json new file mode 100644 index 000000000000..ae16543ca84e --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/javascript/package.json @@ -0,0 +1,32 @@ +{ + "name": "@azure-samples/arm-locks-js", + "private": true, + "version": "1.0.0", + "description": " client library samples for JavaScript", + "engines": { + "node": ">=12.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/locks/arm-locks" + }, + "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/locks/arm-locks", + "dependencies": { + "@azure/arm-locks": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + } +} diff --git a/sdk/locks/arm-locks/samples/v2/javascript/sample.env b/sdk/locks/arm-locks/samples/v2/javascript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/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/locks/arm-locks/samples/v2/typescript/README.md b/sdk/locks/arm-locks/samples/v2/typescript/README.md new file mode 100644 index 000000000000..3a8de901ff1c --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/typescript/README.md @@ -0,0 +1,95 @@ +# client library samples for TypeScript + +These sample programs show how to use the TypeScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| --------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [authorizationOperationsListSample.ts][authorizationoperationslistsample] | Lists all of the available Microsoft.Authorization REST API operations. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ListProviderOperations.json | +| [managementLocksCreateOrUpdateAtResourceGroupLevelSample.ts][managementlockscreateorupdateatresourcegrouplevelsample] | When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/_ or Microsoft.Authorization/locks/_ actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtResourceGroupLevel.json | +| [managementLocksCreateOrUpdateAtResourceLevelSample.ts][managementlockscreateorupdateatresourcelevelsample] | When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/_ or Microsoft.Authorization/locks/_ actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtResourceLevel.json | +| [managementLocksCreateOrUpdateAtSubscriptionLevelSample.ts][managementlockscreateorupdateatsubscriptionlevelsample] | When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/_ or Microsoft.Authorization/locks/_ actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtSubscriptionLevel.json | +| [managementLocksCreateOrUpdateByScopeSample.ts][managementlockscreateorupdatebyscopesample] | Create or update a management lock by scope. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtScope.json | +| [managementLocksDeleteAtResourceGroupLevelSample.ts][managementlocksdeleteatresourcegrouplevelsample] | To delete management locks, you must have access to Microsoft.Authorization/_ or Microsoft.Authorization/locks/_ actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtResourceGroupLevel.json | +| [managementLocksDeleteAtResourceLevelSample.ts][managementlocksdeleteatresourcelevelsample] | To delete management locks, you must have access to Microsoft.Authorization/_ or Microsoft.Authorization/locks/_ actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtResourceLevel.json | +| [managementLocksDeleteAtSubscriptionLevelSample.ts][managementlocksdeleteatsubscriptionlevelsample] | To delete management locks, you must have access to Microsoft.Authorization/_ or Microsoft.Authorization/locks/_ actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtSubscriptionLevel.json | +| [managementLocksDeleteByScopeSample.ts][managementlocksdeletebyscopesample] | Delete a management lock by scope. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtScope.json | +| [managementLocksGetAtResourceGroupLevelSample.ts][managementlocksgetatresourcegrouplevelsample] | Gets a management lock at the resource group level. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtResourceGroupLevel.json | +| [managementLocksGetAtResourceLevelSample.ts][managementlocksgetatresourcelevelsample] | Get the management lock of a resource or any level below resource. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtResourceLevel.json | +| [managementLocksGetAtSubscriptionLevelSample.ts][managementlocksgetatsubscriptionlevelsample] | Gets a management lock at the subscription level. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtSubscriptionLevel.json | +| [managementLocksGetByScopeSample.ts][managementlocksgetbyscopesample] | Get a management lock by scope. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtScope.json | +| [managementLocksListAtResourceGroupLevelSample.ts][managementlockslistatresourcegrouplevelsample] | Gets all the management locks for a resource group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtResourceGroupLevel.json | +| [managementLocksListAtResourceLevelSample.ts][managementlockslistatresourcelevelsample] | Gets all the management locks for a resource or any level below resource. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtResourceLevel.json | +| [managementLocksListAtSubscriptionLevelSample.ts][managementlockslistatsubscriptionlevelsample] | Gets all the management locks for a subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtSubscriptionLevel.json | +| [managementLocksListByScopeSample.ts][managementlockslistbyscopesample] | Gets all the management locks for a scope. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtScope.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +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/authorizationOperationsListSample.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 node dist/authorizationOperationsListSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[authorizationoperationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/typescript/src/authorizationOperationsListSample.ts +[managementlockscreateorupdateatresourcegrouplevelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksCreateOrUpdateAtResourceGroupLevelSample.ts +[managementlockscreateorupdateatresourcelevelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksCreateOrUpdateAtResourceLevelSample.ts +[managementlockscreateorupdateatsubscriptionlevelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksCreateOrUpdateAtSubscriptionLevelSample.ts +[managementlockscreateorupdatebyscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksCreateOrUpdateByScopeSample.ts +[managementlocksdeleteatresourcegrouplevelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksDeleteAtResourceGroupLevelSample.ts +[managementlocksdeleteatresourcelevelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksDeleteAtResourceLevelSample.ts +[managementlocksdeleteatsubscriptionlevelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksDeleteAtSubscriptionLevelSample.ts +[managementlocksdeletebyscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksDeleteByScopeSample.ts +[managementlocksgetatresourcegrouplevelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksGetAtResourceGroupLevelSample.ts +[managementlocksgetatresourcelevelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksGetAtResourceLevelSample.ts +[managementlocksgetatsubscriptionlevelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksGetAtSubscriptionLevelSample.ts +[managementlocksgetbyscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksGetByScopeSample.ts +[managementlockslistatresourcegrouplevelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksListAtResourceGroupLevelSample.ts +[managementlockslistatresourcelevelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksListAtResourceLevelSample.ts +[managementlockslistatsubscriptionlevelsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksListAtSubscriptionLevelSample.ts +[managementlockslistbyscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksListByScopeSample.ts +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-locks?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/locks/arm-locks/README.md +[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/locks/arm-locks/samples/v2/typescript/package.json b/sdk/locks/arm-locks/samples/v2/typescript/package.json new file mode 100644 index 000000000000..6e30dac5c607 --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/typescript/package.json @@ -0,0 +1,41 @@ +{ + "name": "@azure-samples/arm-locks-ts", + "private": true, + "version": "1.0.0", + "description": " client library samples for TypeScript", + "engines": { + "node": ">=12.0.0" + }, + "scripts": { + "build": "tsc", + "prebuild": "rimraf dist/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/locks/arm-locks" + }, + "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/locks/arm-locks", + "dependencies": { + "@azure/arm-locks": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + }, + "devDependencies": { + "@types/node": "^12.0.0", + "typescript": "~4.4.0", + "rimraf": "latest" + } +} diff --git a/sdk/locks/arm-locks/samples/v2/typescript/sample.env b/sdk/locks/arm-locks/samples/v2/typescript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/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/locks/arm-locks/samples/v2/typescript/src/authorizationOperationsListSample.ts b/sdk/locks/arm-locks/samples/v2/typescript/src/authorizationOperationsListSample.ts new file mode 100644 index 000000000000..5f6f16e5b1d5 --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/typescript/src/authorizationOperationsListSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists all of the available Microsoft.Authorization REST API operations. + * + * @summary Lists all of the available Microsoft.Authorization REST API operations. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ListProviderOperations.json + */ +async function listProviderOperations() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.authorizationOperations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listProviderOperations().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksCreateOrUpdateAtResourceGroupLevelSample.ts b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksCreateOrUpdateAtResourceGroupLevelSample.ts new file mode 100644 index 000000000000..19d59fcb97e1 --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksCreateOrUpdateAtResourceGroupLevelSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { ManagementLockObject, ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * + * @summary When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtResourceGroupLevel.json + */ +async function createManagementLockAtResourceGroupLevel() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourcegroupname"; + const lockName = "testlock"; + const parameters: ManagementLockObject = { level: "ReadOnly" }; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.createOrUpdateAtResourceGroupLevel( + resourceGroupName, + lockName, + parameters + ); + console.log(result); +} + +createManagementLockAtResourceGroupLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksCreateOrUpdateAtResourceLevelSample.ts b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksCreateOrUpdateAtResourceLevelSample.ts new file mode 100644 index 000000000000..1d604e726d98 --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksCreateOrUpdateAtResourceLevelSample.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 { ManagementLockObject, ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * + * @summary When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtResourceLevel.json + */ +async function createManagementLockAtResourceLevel() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourcegroupname"; + const resourceProviderNamespace = "Microsoft.Storage"; + const parentResourcePath = "parentResourcePath"; + const resourceType = "storageAccounts"; + const resourceName = "teststorageaccount"; + const lockName = "testlock"; + const parameters: ManagementLockObject = { level: "ReadOnly" }; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.createOrUpdateAtResourceLevel( + resourceGroupName, + resourceProviderNamespace, + parentResourcePath, + resourceType, + resourceName, + lockName, + parameters + ); + console.log(result); +} + +createManagementLockAtResourceLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksCreateOrUpdateAtSubscriptionLevelSample.ts b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksCreateOrUpdateAtSubscriptionLevelSample.ts new file mode 100644 index 000000000000..b1e9c1b1dddc --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksCreateOrUpdateAtSubscriptionLevelSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { ManagementLockObject, ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * + * @summary When you apply a lock at a parent scope, all child resources inherit the same lock. To create management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtSubscriptionLevel.json + */ +async function createManagementLockAtSubscriptionLevel() { + const subscriptionId = "subscriptionId"; + const lockName = "testlock"; + const parameters: ManagementLockObject = { level: "ReadOnly" }; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.createOrUpdateAtSubscriptionLevel( + lockName, + parameters + ); + console.log(result); +} + +createManagementLockAtSubscriptionLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksCreateOrUpdateByScopeSample.ts b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksCreateOrUpdateByScopeSample.ts new file mode 100644 index 000000000000..088dbf79801d --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksCreateOrUpdateByScopeSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { ManagementLockObject, ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Create or update a management lock by scope. + * + * @summary Create or update a management lock by scope. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtScope.json + */ +async function createManagementLockAtScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/subscriptionId"; + const lockName = "testlock"; + const parameters: ManagementLockObject = { level: "ReadOnly" }; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.createOrUpdateByScope( + scope, + lockName, + parameters + ); + console.log(result); +} + +createManagementLockAtScope().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksDeleteAtResourceGroupLevelSample.ts b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksDeleteAtResourceGroupLevelSample.ts new file mode 100644 index 000000000000..e6830815a4f7 --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksDeleteAtResourceGroupLevelSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to To delete management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * + * @summary To delete management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtResourceGroupLevel.json + */ +async function deleteManagementLockAtResourceGroupLevel() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourcegroupname"; + const lockName = "testlock"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.deleteAtResourceGroupLevel( + resourceGroupName, + lockName + ); + console.log(result); +} + +deleteManagementLockAtResourceGroupLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksDeleteAtResourceLevelSample.ts b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksDeleteAtResourceLevelSample.ts new file mode 100644 index 000000000000..f80fced90ab7 --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksDeleteAtResourceLevelSample.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 { ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to To delete management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * + * @summary To delete management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtResourceLevel.json + */ +async function deleteManagementLockAtResourceLevel() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourcegroupname"; + const resourceProviderNamespace = "Microsoft.Storage"; + const parentResourcePath = "parentResourcePath"; + const resourceType = "storageAccounts"; + const resourceName = "teststorageaccount"; + const lockName = "testlock"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.deleteAtResourceLevel( + resourceGroupName, + resourceProviderNamespace, + parentResourcePath, + resourceType, + resourceName, + lockName + ); + console.log(result); +} + +deleteManagementLockAtResourceLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksDeleteAtSubscriptionLevelSample.ts b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksDeleteAtSubscriptionLevelSample.ts new file mode 100644 index 000000000000..33e7bc6a810c --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksDeleteAtSubscriptionLevelSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to To delete management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * + * @summary To delete management locks, you must have access to Microsoft.Authorization/* or Microsoft.Authorization/locks/* actions. Of the built-in roles, only Owner and User Access Administrator are granted those actions. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtSubscriptionLevel.json + */ +async function deleteManagementLockAtSubscriptionLevel() { + const subscriptionId = "subscriptionId"; + const lockName = "testlock"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.deleteAtSubscriptionLevel( + lockName + ); + console.log(result); +} + +deleteManagementLockAtSubscriptionLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksDeleteByScopeSample.ts b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksDeleteByScopeSample.ts new file mode 100644 index 000000000000..ebb32dbcbb3b --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksDeleteByScopeSample.ts @@ -0,0 +1,30 @@ +/* + * 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 { ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Delete a management lock by scope. + * + * @summary Delete a management lock by scope. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_DeleteAtScope.json + */ +async function deleteManagementLockAtScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/subscriptionId"; + const lockName = "testlock"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.deleteByScope(scope, lockName); + console.log(result); +} + +deleteManagementLockAtScope().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksGetAtResourceGroupLevelSample.ts b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksGetAtResourceGroupLevelSample.ts new file mode 100644 index 000000000000..5b58dd881eb8 --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksGetAtResourceGroupLevelSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets a management lock at the resource group level. + * + * @summary Gets a management lock at the resource group level. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtResourceGroupLevel.json + */ +async function getManagementLockAtResourceGroupLevel() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourcegroupname"; + const lockName = "testlock"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.getAtResourceGroupLevel( + resourceGroupName, + lockName + ); + console.log(result); +} + +getManagementLockAtResourceGroupLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksGetAtResourceLevelSample.ts b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksGetAtResourceLevelSample.ts new file mode 100644 index 000000000000..1e99727135e8 --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksGetAtResourceLevelSample.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 { ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Get the management lock of a resource or any level below resource. + * + * @summary Get the management lock of a resource or any level below resource. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtResourceLevel.json + */ +async function getManagementLockAtResourceLevel() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourcegroupname"; + const resourceProviderNamespace = "Microsoft.Storage"; + const parentResourcePath = "parentResourcePath"; + const resourceType = "storageAccounts"; + const resourceName = "teststorageaccount"; + const lockName = "testlock"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.getAtResourceLevel( + resourceGroupName, + resourceProviderNamespace, + parentResourcePath, + resourceType, + resourceName, + lockName + ); + console.log(result); +} + +getManagementLockAtResourceLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksGetAtSubscriptionLevelSample.ts b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksGetAtSubscriptionLevelSample.ts new file mode 100644 index 000000000000..008385778b9f --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksGetAtSubscriptionLevelSample.ts @@ -0,0 +1,29 @@ +/* + * 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 { ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets a management lock at the subscription level. + * + * @summary Gets a management lock at the subscription level. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtSubscriptionLevel.json + */ +async function getManagementLockAtSubscriptionLevel() { + const subscriptionId = "subscriptionId"; + const lockName = "testlock"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.getAtSubscriptionLevel(lockName); + console.log(result); +} + +getManagementLockAtSubscriptionLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksGetByScopeSample.ts b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksGetByScopeSample.ts new file mode 100644 index 000000000000..a13c4472d6cd --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksGetByScopeSample.ts @@ -0,0 +1,30 @@ +/* + * 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 { ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Get a management lock by scope. + * + * @summary Get a management lock by scope. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtScope.json + */ +async function getManagementLockAtScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/subscriptionId"; + const lockName = "testlock"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const result = await client.managementLocks.getByScope(scope, lockName); + console.log(result); +} + +getManagementLockAtScope().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksListAtResourceGroupLevelSample.ts b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksListAtResourceGroupLevelSample.ts new file mode 100644 index 000000000000..8c32a115a722 --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksListAtResourceGroupLevelSample.ts @@ -0,0 +1,34 @@ +/* + * 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 { ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all the management locks for a resource group. + * + * @summary Gets all the management locks for a resource group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtResourceGroupLevel.json + */ +async function listManagementGroupsAtResourceGroupLevel() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourcegroupname"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.managementLocks.listAtResourceGroupLevel( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listManagementGroupsAtResourceGroupLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksListAtResourceLevelSample.ts b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksListAtResourceLevelSample.ts new file mode 100644 index 000000000000..a3474aa8824e --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksListAtResourceLevelSample.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 { ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all the management locks for a resource or any level below resource. + * + * @summary Gets all the management locks for a resource or any level below resource. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtResourceLevel.json + */ +async function listManagementLocksAtResourceLevel() { + const subscriptionId = "subscriptionId"; + const resourceGroupName = "resourcegroupname"; + const resourceProviderNamespace = "Microsoft.Storage"; + const parentResourcePath = "parentResourcePath"; + const resourceType = "storageAccounts"; + const resourceName = "teststorageaccount"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.managementLocks.listAtResourceLevel( + resourceGroupName, + resourceProviderNamespace, + parentResourcePath, + resourceType, + resourceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listManagementLocksAtResourceLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksListAtSubscriptionLevelSample.ts b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksListAtSubscriptionLevelSample.ts new file mode 100644 index 000000000000..5c7a9478e2fa --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksListAtSubscriptionLevelSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all the management locks for a subscription. + * + * @summary Gets all the management locks for a subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtSubscriptionLevel.json + */ +async function listManagementLocksAtSubscriptionLevel() { + const subscriptionId = "subscriptionId"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.managementLocks.listAtSubscriptionLevel()) { + resArray.push(item); + } + console.log(resArray); +} + +listManagementLocksAtSubscriptionLevel().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksListByScopeSample.ts b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksListByScopeSample.ts new file mode 100644 index 000000000000..f59c3d18fc66 --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/typescript/src/managementLocksListByScopeSample.ts @@ -0,0 +1,32 @@ +/* + * 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 { ManagementLockClient } from "@azure/arm-locks"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all the management locks for a scope. + * + * @summary Gets all the management locks for a scope. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtScope.json + */ +async function listManagementLocksAtScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/subscriptionId"; + const credential = new DefaultAzureCredential(); + const client = new ManagementLockClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.managementLocks.listByScope(scope)) { + resArray.push(item); + } + console.log(resArray); +} + +listManagementLocksAtScope().catch(console.error); diff --git a/sdk/locks/arm-locks/samples/v2/typescript/tsconfig.json b/sdk/locks/arm-locks/samples/v2/typescript/tsconfig.json new file mode 100644 index 000000000000..416c2dd82e00 --- /dev/null +++ b/sdk/locks/arm-locks/samples/v2/typescript/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2018", + "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/locks/arm-locks/src/managementLockClient.ts b/sdk/locks/arm-locks/src/managementLockClient.ts index 2ee5e068cdf0..0dd1f1705b0e 100644 --- a/sdk/locks/arm-locks/src/managementLockClient.ts +++ b/sdk/locks/arm-locks/src/managementLockClient.ts @@ -7,6 +7,7 @@ */ import * as coreClient from "@azure/core-client"; +import * as coreRestPipeline from "@azure/core-rest-pipeline"; import * as coreAuth from "@azure/core-auth"; import { AuthorizationOperationsImpl, ManagementLocksImpl } from "./operations"; import { @@ -47,7 +48,7 @@ export class ManagementLockClient extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-locks/2.0.0`; + const packageDetails = `azsdk-js-arm-locks/2.1.0`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` @@ -62,15 +63,39 @@ export class ManagementLockClient extends coreClient.ServiceClient { userAgentOptions: { userAgentPrefix }, - baseUri: options.endpoint || "https://management.azure.com" + baseUri: + options.endpoint ?? options.baseUri ?? "https://management.azure.com" }; super(optionsWithDefaults); + + if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { + const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies(); + const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( + (pipelinePolicy) => + pipelinePolicy.name === + coreRestPipeline.bearerTokenAuthenticationPolicyName + ); + if (!bearerTokenAuthenticationPolicyFound) { + this.pipeline.removePolicy({ + name: coreRestPipeline.bearerTokenAuthenticationPolicyName + }); + this.pipeline.addPolicy( + coreRestPipeline.bearerTokenAuthenticationPolicy({ + scopes: `${optionsWithDefaults.baseUri}/.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 || "2016-09-01"; + this.apiVersion = options.apiVersion || "2020-05-01"; this.authorizationOperations = new AuthorizationOperationsImpl(this); this.managementLocks = new ManagementLocksImpl(this); } diff --git a/sdk/locks/arm-locks/src/models/index.ts b/sdk/locks/arm-locks/src/models/index.ts index f6a3353be403..29afc984fb9c 100644 --- a/sdk/locks/arm-locks/src/models/index.ts +++ b/sdk/locks/arm-locks/src/models/index.ts @@ -34,6 +34,55 @@ export interface OperationDisplay { operation?: string; } +/** Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). */ +export interface ErrorResponse { + /** The error object. */ + error?: ErrorDetail; +} + +/** The error detail. */ +export interface ErrorDetail { + /** + * The error code. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly code?: string; + /** + * The error message. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly message?: string; + /** + * The error target. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly target?: string; + /** + * The error details. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly details?: ErrorDetail[]; + /** + * The error additional info. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly additionalInfo?: ErrorAdditionalInfo[]; +} + +/** The resource management error additional info. */ +export interface ErrorAdditionalInfo { + /** + * The additional info type. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly type?: string; + /** + * The additional info. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly info?: Record; +} + /** The lock information. */ export interface ManagementLockObject { /** @@ -51,6 +100,11 @@ export interface ManagementLockObject { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly name?: string; + /** + * Metadata pertaining to creation and last modification of the resource. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly systemData?: SystemData; /** The level of the lock. Possible values are: NotSpecified, CanNotDelete, ReadOnly. CanNotDelete means authorized users are able to read and modify the resources, but not delete. ReadOnly means authorized users can only read from a resource, but they can't modify or delete it. */ level: LockLevel; /** Notes about the lock. Maximum of 512 characters. */ @@ -65,6 +119,22 @@ export interface ManagementLockOwner { applicationId?: string; } +/** Metadata pertaining to creation and last modification of the resource. */ +export interface SystemData { + /** The identity that created the resource. */ + createdBy?: string; + /** The type of identity that created the resource. */ + createdByType?: CreatedByType; + /** The timestamp of resource creation (UTC). */ + createdAt?: Date; + /** The identity that last modified the resource. */ + lastModifiedBy?: string; + /** The type of identity that last modified the resource. */ + lastModifiedByType?: CreatedByType; + /** The timestamp of resource last modification (UTC) */ + lastModifiedAt?: Date; +} + /** The list of locks. */ export interface ManagementLockListResult { /** The list of locks. */ @@ -91,6 +161,26 @@ export enum KnownLockLevel { */ export type LockLevel = string; +/** Known values of {@link CreatedByType} that the service accepts. */ +export enum KnownCreatedByType { + User = "User", + Application = "Application", + ManagedIdentity = "ManagedIdentity", + Key = "Key" +} + +/** + * Defines values for CreatedByType. \ + * {@link KnownCreatedByType} can be used interchangeably with CreatedByType, + * this enum contains the known values that the service supports. + * ### Known values supported by the service + * **User** \ + * **Application** \ + * **ManagedIdentity** \ + * **Key** + */ +export type CreatedByType = string; + /** Optional parameters. */ export interface AuthorizationOperationsListOptionalParams extends coreClient.OperationOptions {} diff --git a/sdk/locks/arm-locks/src/models/mappers.ts b/sdk/locks/arm-locks/src/models/mappers.ts index df8752f1895d..f165718080fd 100644 --- a/sdk/locks/arm-locks/src/models/mappers.ts +++ b/sdk/locks/arm-locks/src/models/mappers.ts @@ -84,6 +84,102 @@ export const OperationDisplay: coreClient.CompositeMapper = { } }; +export const ErrorResponse: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ErrorResponse", + modelProperties: { + error: { + serializedName: "error", + type: { + name: "Composite", + className: "ErrorDetail" + } + } + } + } +}; + +export const ErrorDetail: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ErrorDetail", + modelProperties: { + code: { + serializedName: "code", + readOnly: true, + type: { + name: "String" + } + }, + message: { + serializedName: "message", + readOnly: true, + type: { + name: "String" + } + }, + target: { + serializedName: "target", + readOnly: true, + type: { + name: "String" + } + }, + details: { + serializedName: "details", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ErrorDetail" + } + } + } + }, + additionalInfo: { + serializedName: "additionalInfo", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ErrorAdditionalInfo" + } + } + } + } + } + } +}; + +export const ErrorAdditionalInfo: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ErrorAdditionalInfo", + modelProperties: { + type: { + serializedName: "type", + readOnly: true, + type: { + name: "String" + } + }, + info: { + serializedName: "info", + readOnly: true, + type: { + name: "Dictionary", + value: { type: { name: "any" } } + } + } + } + } +}; + export const ManagementLockObject: coreClient.CompositeMapper = { type: { name: "Composite", @@ -110,6 +206,13 @@ export const ManagementLockObject: coreClient.CompositeMapper = { name: "String" } }, + systemData: { + serializedName: "systemData", + type: { + name: "Composite", + className: "SystemData" + } + }, level: { serializedName: "properties.level", required: true, @@ -154,6 +257,51 @@ export const ManagementLockOwner: coreClient.CompositeMapper = { } }; +export const SystemData: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "SystemData", + modelProperties: { + createdBy: { + serializedName: "createdBy", + type: { + name: "String" + } + }, + createdByType: { + serializedName: "createdByType", + type: { + name: "String" + } + }, + createdAt: { + serializedName: "createdAt", + type: { + name: "DateTime" + } + }, + lastModifiedBy: { + serializedName: "lastModifiedBy", + type: { + name: "String" + } + }, + lastModifiedByType: { + serializedName: "lastModifiedByType", + type: { + name: "String" + } + }, + lastModifiedAt: { + serializedName: "lastModifiedAt", + type: { + name: "DateTime" + } + } + } + } +}; + export const ManagementLockListResult: coreClient.CompositeMapper = { type: { name: "Composite", diff --git a/sdk/locks/arm-locks/src/models/parameters.ts b/sdk/locks/arm-locks/src/models/parameters.ts index 936bb3919e07..6df49f707d76 100644 --- a/sdk/locks/arm-locks/src/models/parameters.ts +++ b/sdk/locks/arm-locks/src/models/parameters.ts @@ -40,7 +40,7 @@ export const $host: OperationURLParameter = { export const apiVersion: OperationQueryParameter = { parameterPath: "apiVersion", mapper: { - defaultValue: "2016-09-01", + defaultValue: "2020-05-01", isConstant: true, serializedName: "api-version", type: { diff --git a/sdk/locks/arm-locks/src/operations/authorizationOperations.ts b/sdk/locks/arm-locks/src/operations/authorizationOperations.ts index 75981ed9b691..e50ea4539228 100644 --- a/sdk/locks/arm-locks/src/operations/authorizationOperations.ts +++ b/sdk/locks/arm-locks/src/operations/authorizationOperations.ts @@ -109,6 +109,9 @@ const listOperationSpec: coreClient.OperationSpec = { responses: { 200: { bodyMapper: Mappers.OperationListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse } }, queryParameters: [Parameters.apiVersion], @@ -122,6 +125,9 @@ const listNextOperationSpec: coreClient.OperationSpec = { responses: { 200: { bodyMapper: Mappers.OperationListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse } }, queryParameters: [Parameters.apiVersion], diff --git a/sdk/locks/arm-locks/src/operations/managementLocks.ts b/sdk/locks/arm-locks/src/operations/managementLocks.ts index 5415f161e012..ef00559c4ca6 100644 --- a/sdk/locks/arm-locks/src/operations/managementLocks.ts +++ b/sdk/locks/arm-locks/src/operations/managementLocks.ts @@ -780,6 +780,9 @@ const createOrUpdateAtResourceGroupLevelOperationSpec: coreClient.OperationSpec }, 201: { bodyMapper: Mappers.ManagementLockObject + }, + default: { + bodyMapper: Mappers.ErrorResponse } }, requestBody: Parameters.parameters, @@ -798,7 +801,13 @@ const deleteAtResourceGroupLevelOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Authorization/locks/{lockName}", httpMethod: "DELETE", - responses: { 200: {}, 204: {} }, + responses: { + 200: {}, + 204: {}, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, @@ -806,6 +815,7 @@ const deleteAtResourceGroupLevelOperationSpec: coreClient.OperationSpec = { Parameters.lockName, Parameters.subscriptionId ], + headerParameters: [Parameters.accept], serializer }; const getAtResourceGroupLevelOperationSpec: coreClient.OperationSpec = { @@ -815,6 +825,9 @@ const getAtResourceGroupLevelOperationSpec: coreClient.OperationSpec = { responses: { 200: { bodyMapper: Mappers.ManagementLockObject + }, + default: { + bodyMapper: Mappers.ErrorResponse } }, queryParameters: [Parameters.apiVersion], @@ -836,6 +849,9 @@ const createOrUpdateByScopeOperationSpec: coreClient.OperationSpec = { }, 201: { bodyMapper: Mappers.ManagementLockObject + }, + default: { + bodyMapper: Mappers.ErrorResponse } }, requestBody: Parameters.parameters, @@ -848,9 +864,16 @@ const createOrUpdateByScopeOperationSpec: coreClient.OperationSpec = { const deleteByScopeOperationSpec: coreClient.OperationSpec = { path: "/{scope}/providers/Microsoft.Authorization/locks/{lockName}", httpMethod: "DELETE", - responses: { 200: {}, 204: {} }, + responses: { + 200: {}, + 204: {}, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.$host, Parameters.lockName, Parameters.scope], + headerParameters: [Parameters.accept], serializer }; const getByScopeOperationSpec: coreClient.OperationSpec = { @@ -859,6 +882,9 @@ const getByScopeOperationSpec: coreClient.OperationSpec = { responses: { 200: { bodyMapper: Mappers.ManagementLockObject + }, + default: { + bodyMapper: Mappers.ErrorResponse } }, queryParameters: [Parameters.apiVersion], @@ -876,6 +902,9 @@ const createOrUpdateAtResourceLevelOperationSpec: coreClient.OperationSpec = { }, 201: { bodyMapper: Mappers.ManagementLockObject + }, + default: { + bodyMapper: Mappers.ErrorResponse } }, requestBody: Parameters.parameters, @@ -898,7 +927,13 @@ const deleteAtResourceLevelOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/locks/{lockName}", httpMethod: "DELETE", - responses: { 200: {}, 204: {} }, + responses: { + 200: {}, + 204: {}, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, @@ -910,6 +945,7 @@ const deleteAtResourceLevelOperationSpec: coreClient.OperationSpec = { Parameters.resourceType, Parameters.resourceName ], + headerParameters: [Parameters.accept], serializer }; const getAtResourceLevelOperationSpec: coreClient.OperationSpec = { @@ -919,6 +955,9 @@ const getAtResourceLevelOperationSpec: coreClient.OperationSpec = { responses: { 200: { bodyMapper: Mappers.ManagementLockObject + }, + default: { + bodyMapper: Mappers.ErrorResponse } }, queryParameters: [Parameters.apiVersion], @@ -945,6 +984,9 @@ const createOrUpdateAtSubscriptionLevelOperationSpec: coreClient.OperationSpec = }, 201: { bodyMapper: Mappers.ManagementLockObject + }, + default: { + bodyMapper: Mappers.ErrorResponse } }, requestBody: Parameters.parameters, @@ -962,13 +1004,20 @@ const deleteAtSubscriptionLevelOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/locks/{lockName}", httpMethod: "DELETE", - responses: { 200: {}, 204: {} }, + responses: { + 200: {}, + 204: {}, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.lockName, Parameters.subscriptionId ], + headerParameters: [Parameters.accept], serializer }; const getAtSubscriptionLevelOperationSpec: coreClient.OperationSpec = { @@ -978,6 +1027,9 @@ const getAtSubscriptionLevelOperationSpec: coreClient.OperationSpec = { responses: { 200: { bodyMapper: Mappers.ManagementLockObject + }, + default: { + bodyMapper: Mappers.ErrorResponse } }, queryParameters: [Parameters.apiVersion], @@ -996,6 +1048,9 @@ const listAtResourceGroupLevelOperationSpec: coreClient.OperationSpec = { responses: { 200: { bodyMapper: Mappers.ManagementLockListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse } }, queryParameters: [Parameters.apiVersion, Parameters.filter], @@ -1014,6 +1069,9 @@ const listAtResourceLevelOperationSpec: coreClient.OperationSpec = { responses: { 200: { bodyMapper: Mappers.ManagementLockListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse } }, queryParameters: [Parameters.apiVersion, Parameters.filter], @@ -1036,6 +1094,9 @@ const listAtSubscriptionLevelOperationSpec: coreClient.OperationSpec = { responses: { 200: { bodyMapper: Mappers.ManagementLockListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse } }, queryParameters: [Parameters.apiVersion, Parameters.filter], @@ -1049,6 +1110,9 @@ const listByScopeOperationSpec: coreClient.OperationSpec = { responses: { 200: { bodyMapper: Mappers.ManagementLockListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse } }, queryParameters: [Parameters.apiVersion, Parameters.filter], @@ -1062,6 +1126,9 @@ const listAtResourceGroupLevelNextOperationSpec: coreClient.OperationSpec = { responses: { 200: { bodyMapper: Mappers.ManagementLockListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse } }, queryParameters: [Parameters.apiVersion, Parameters.filter], @@ -1080,6 +1147,9 @@ const listAtResourceLevelNextOperationSpec: coreClient.OperationSpec = { responses: { 200: { bodyMapper: Mappers.ManagementLockListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse } }, queryParameters: [Parameters.apiVersion, Parameters.filter], @@ -1102,6 +1172,9 @@ const listAtSubscriptionLevelNextOperationSpec: coreClient.OperationSpec = { responses: { 200: { bodyMapper: Mappers.ManagementLockListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse } }, queryParameters: [Parameters.apiVersion, Parameters.filter], @@ -1119,6 +1192,9 @@ const listByScopeNextOperationSpec: coreClient.OperationSpec = { responses: { 200: { bodyMapper: Mappers.ManagementLockListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse } }, queryParameters: [Parameters.apiVersion, Parameters.filter], diff --git a/sdk/locks/arm-locks/tsconfig.json b/sdk/locks/arm-locks/tsconfig.json index 6e3251194117..780bb99fd478 100644 --- a/sdk/locks/arm-locks/tsconfig.json +++ b/sdk/locks/arm-locks/tsconfig.json @@ -9,11 +9,29 @@ "esModuleInterop": true, "allowSyntheticDefaultImports": true, "forceConsistentCasingInFileNames": true, - "lib": ["es6", "dom"], + "lib": [ + "es6", + "dom" + ], "declaration": true, "outDir": "./dist-esm", - "importHelpers": true + "importHelpers": true, + "paths": { + "@azure/arm-locks": [ + "./src/index" + ] + } }, - "include": ["./src/**/*.ts", "./test/**/*.ts"], - "exclude": ["node_modules"] -} + "include": [ + "./src/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts" + ], + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/sdk/locks/ci.mgmt.yml b/sdk/locks/ci.mgmt.yml index e462a362d454..0a2384a3157e 100644 --- a/sdk/locks/ci.mgmt.yml +++ b/sdk/locks/ci.mgmt.yml @@ -9,8 +9,8 @@ trigger: paths: include: - sdk/locks/ci.mgmt.yml - - sdk/locks/arm-locks/ - sdk/locks/arm-locks-profile-2020-09-01-hybrid + - sdk/locks/arm-locks pr: branches: include: @@ -23,8 +23,8 @@ pr: paths: include: - sdk/locks/ci.mgmt.yml - - sdk/locks/arm-locks/ - sdk/locks/arm-locks-profile-2020-09-01-hybrid + - sdk/locks/arm-locks extends: template: /eng/pipelines/templates/stages/archetype-sdk-client.yml parameters: diff --git a/sdk/managedapplications/arm-managedapplications/CHANGELOG.md b/sdk/managedapplications/arm-managedapplications/CHANGELOG.md index 89179de40c99..c48564253a7b 100644 --- a/sdk/managedapplications/arm-managedapplications/CHANGELOG.md +++ b/sdk/managedapplications/arm-managedapplications/CHANGELOG.md @@ -1,14 +1,10 @@ # Release History -## 2.0.1 (Unreleased) +## 2.0.1 (2022-04-18) -### Features Added +**features** -### Breaking Changes - -### Bugs Fixed - -### Other Changes + - Bug fix ## 2.0.0 (2021-12-07) diff --git a/sdk/managedapplications/arm-managedapplications/LICENSE b/sdk/managedapplications/arm-managedapplications/LICENSE index ccb63b166732..5d1d36e0af80 100644 --- a/sdk/managedapplications/arm-managedapplications/LICENSE +++ b/sdk/managedapplications/arm-managedapplications/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2021 Microsoft +Copyright (c) 2022 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/managedapplications/arm-managedapplications/README.md b/sdk/managedapplications/arm-managedapplications/README.md index a0fcbc2fcca8..c42570ee4e0a 100644 --- a/sdk/managedapplications/arm-managedapplications/README.md +++ b/sdk/managedapplications/arm-managedapplications/README.md @@ -16,6 +16,8 @@ ARM applications - [LTS versions of Node.js](https://nodejs.org/about/releases/) - 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]. @@ -49,8 +51,17 @@ For more information about how to create an Azure AD Application check out [this ```javascript const { ApplicationClient } = require("@azure/arm-managedapplications"); 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 ApplicationClient(new DefaultAzureCredential(), subscriptionId); + +// For client-side applications running in the browser, use this code instead: +// const credential = new InteractiveBrowserCredential({ +// tenantId: "", +// clientId: "" +// }); +// const client = new ApplicationClient(credential, subscriptionId); ``` diff --git a/sdk/managedapplications/arm-managedapplications/_meta.json b/sdk/managedapplications/arm-managedapplications/_meta.json index 0551b4fe18f8..c6765ba542bb 100644 --- a/sdk/managedapplications/arm-managedapplications/_meta.json +++ b/sdk/managedapplications/arm-managedapplications/_meta.json @@ -1,7 +1,8 @@ { "commit": "a42f1b58607091c4f255ead152a8ef323fa0b280", - "readme": "specification/resources/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 --generate-test --typescript-sdks-folder=D:\\mydev\\azure-sdk-for-js ../azure-rest-api-specs/specification/resources/resource-manager/readme.md --use=@autorest/typescript@6.0.0-alpha.16.20211130.1", + "readme": "specification\\resources\\resource-manager\\readme.md", + "autorest_command": "autorest --version=3.7.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\work\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\resources\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-alpha.19.20220408.1 --generate-sample=true", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "use": "@autorest/typescript@6.0.0-alpha.16.20211130.1" + "release_tool": "@azure-tools/js-sdk-release-tools@2.2.6", + "use": "@autorest/typescript@6.0.0-alpha.19.20220408.1" } \ No newline at end of file diff --git a/sdk/managedapplications/arm-managedapplications/api-extractor.json b/sdk/managedapplications/arm-managedapplications/api-extractor.json index 94097af91205..5788fd065335 100644 --- a/sdk/managedapplications/arm-managedapplications/api-extractor.json +++ b/sdk/managedapplications/arm-managedapplications/api-extractor.json @@ -1,18 +1,31 @@ { "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", "mainEntryPointFilePath": "./dist-esm/src/index.d.ts", - "docModel": { "enabled": true }, - "apiReport": { "enabled": true, "reportFolder": "./review" }, + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, "dtsRollup": { "enabled": true, "untrimmedFilePath": "", "publicTrimmedFilePath": "./types/arm-managedapplications.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/managedapplications/arm-managedapplications/package.json b/sdk/managedapplications/arm-managedapplications/package.json index 9b2bb95f45fa..275cc21a6708 100644 --- a/sdk/managedapplications/arm-managedapplications/package.json +++ b/sdk/managedapplications/arm-managedapplications/package.json @@ -11,9 +11,9 @@ "@azure/core-lro": "^2.2.0", "@azure/abort-controller": "^1.0.0", "@azure/core-paging": "^1.2.0", - "@azure/core-client": "^1.0.0", + "@azure/core-client": "^1.5.0", "@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": [ @@ -30,12 +30,12 @@ "devDependencies": { "@microsoft/api-extractor": "^7.18.11", "@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-plugin-sourcemaps": "^0.4.2", + "rollup": "^2.66.1", + "rollup-plugin-sourcemaps": "^0.6.3", "typescript": "~4.2.0", "uglify-js": "^3.4.9", "rimraf": "^3.0.0", @@ -98,5 +98,21 @@ "docs": "echo skipped" }, "sideEffects": false, - "autoPublish": true + "//metadata": { + "constantPaths": [ + { + "path": "src/applicationClient.ts", + "prefix": "packageDetails" + } + ] + }, + "autoPublish": true, + "//sampleConfiguration": { + "productName": "", + "productSlugs": [ + "azure" + ], + "disableDocsMs": true, + "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-managedapplications?view=azure-node-preview" + } } diff --git a/sdk/managedapplications/arm-managedapplications/rollup.config.js b/sdk/managedapplications/arm-managedapplications/rollup.config.js index 9be1955eb7f1..3f89d7309da5 100644 --- a/sdk/managedapplications/arm-managedapplications/rollup.config.js +++ b/sdk/managedapplications/arm-managedapplications/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/managedapplications/arm-managedapplications/sample.env b/sdk/managedapplications/arm-managedapplications/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/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/managedapplications/arm-managedapplications/samples-dev/applicationDefinitionsCreateOrUpdateByIdSample.ts b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationDefinitionsCreateOrUpdateByIdSample.ts new file mode 100644 index 000000000000..a6602f4c64b0 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationDefinitionsCreateOrUpdateByIdSample.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 { + ApplicationDefinition, + ApplicationClient +} from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates a new managed application definition. + * + * @summary Creates a new managed application definition. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/createOrUpdateApplicationDefinition.json + */ +async function createOrUpdateManagedApplicationDefinition() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationDefinitionName = "myManagedApplicationDef"; + const parameters: ApplicationDefinition = { + description: "myManagedApplicationDef description", + authorizations: [ + { principalId: "validprincipalguid", roleDefinitionId: "validroleguid" } + ], + displayName: "myManagedApplicationDef", + location: "East US 2", + lockLevel: "None", + packageFileUri: "https://path/to/packagezipfile" + }; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applicationDefinitions.beginCreateOrUpdateByIdAndWait( + resourceGroupName, + applicationDefinitionName, + parameters + ); + console.log(result); +} + +createOrUpdateManagedApplicationDefinition().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples-dev/applicationDefinitionsCreateOrUpdateSample.ts b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationDefinitionsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..3caa1c7c00dd --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationDefinitionsCreateOrUpdateSample.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 { + ApplicationDefinition, + ApplicationClient +} from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates a new managed application definition. + * + * @summary Creates a new managed application definition. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/createOrUpdateApplicationDefinition.json + */ +async function createOrUpdateManagedApplicationDefinition() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationDefinitionName = "myManagedApplicationDef"; + const parameters: ApplicationDefinition = { + description: "myManagedApplicationDef description", + authorizations: [ + { principalId: "validprincipalguid", roleDefinitionId: "validroleguid" } + ], + displayName: "myManagedApplicationDef", + location: "East US 2", + lockLevel: "None", + packageFileUri: "https://path/to/packagezipfile" + }; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applicationDefinitions.beginCreateOrUpdateAndWait( + resourceGroupName, + applicationDefinitionName, + parameters + ); + console.log(result); +} + +createOrUpdateManagedApplicationDefinition().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples-dev/applicationDefinitionsDeleteByIdSample.ts b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationDefinitionsDeleteByIdSample.ts new file mode 100644 index 000000000000..028f75fb3443 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationDefinitionsDeleteByIdSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes the managed application definition. + * + * @summary Deletes the managed application definition. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/deleteApplicationDefinition.json + */ +async function deleteApplicationDefinition() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationDefinitionName = "myManagedApplicationDef"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applicationDefinitions.beginDeleteByIdAndWait( + resourceGroupName, + applicationDefinitionName + ); + console.log(result); +} + +deleteApplicationDefinition().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples-dev/applicationDefinitionsDeleteSample.ts b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationDefinitionsDeleteSample.ts new file mode 100644 index 000000000000..62b514f814f5 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationDefinitionsDeleteSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes the managed application definition. + * + * @summary Deletes the managed application definition. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/deleteApplicationDefinition.json + */ +async function deletesAManagedApplication() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationDefinitionName = "myManagedApplicationDef"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applicationDefinitions.beginDeleteAndWait( + resourceGroupName, + applicationDefinitionName + ); + console.log(result); +} + +deletesAManagedApplication().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples-dev/applicationDefinitionsGetByIdSample.ts b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationDefinitionsGetByIdSample.ts new file mode 100644 index 000000000000..738cd2058851 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationDefinitionsGetByIdSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the managed application definition. + * + * @summary Gets the managed application definition. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/getApplicationDefinition.json + */ +async function getManagedApplicationDefinition() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationDefinitionName = "myManagedApplicationDef"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applicationDefinitions.getById( + resourceGroupName, + applicationDefinitionName + ); + console.log(result); +} + +getManagedApplicationDefinition().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples-dev/applicationDefinitionsGetSample.ts b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationDefinitionsGetSample.ts new file mode 100644 index 000000000000..a6625f74824a --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationDefinitionsGetSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the managed application definition. + * + * @summary Gets the managed application definition. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/getApplicationDefinition.json + */ +async function getManagedApplicationDefinition() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationDefinitionName = "myManagedApplicationDef"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applicationDefinitions.get( + resourceGroupName, + applicationDefinitionName + ); + console.log(result); +} + +getManagedApplicationDefinition().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples-dev/applicationDefinitionsListByResourceGroupSample.ts b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationDefinitionsListByResourceGroupSample.ts new file mode 100644 index 000000000000..84ebd7a751c9 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationDefinitionsListByResourceGroupSample.ts @@ -0,0 +1,34 @@ +/* + * 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 { ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists the managed application definitions in a resource group. + * + * @summary Lists the managed application definitions in a resource group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listApplicationDefinitionsByResourceGroup.json + */ +async function listManagedApplicationDefinitions() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.applicationDefinitions.listByResourceGroup( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listManagedApplicationDefinitions().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsCreateOrUpdateByIdSample.ts b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsCreateOrUpdateByIdSample.ts new file mode 100644 index 000000000000..55f5fc24c432 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsCreateOrUpdateByIdSample.ts @@ -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. +import { Application, ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates a new managed application. + * + * @summary Creates a new managed application. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/createOrUpdateApplicationById.json + */ +async function createOrUpdateApplicationById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const applicationId = "myApplicationId"; + const parameters: Application = { + kind: "ServiceCatalog", + location: "East US 2", + managedResourceGroupId: "/subscriptions/subid/resourceGroups/myManagedRG" + }; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applications.beginCreateOrUpdateByIdAndWait( + applicationId, + parameters + ); + console.log(result); +} + +createOrUpdateApplicationById().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsCreateOrUpdateSample.ts b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..c48dc884ec56 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsCreateOrUpdateSample.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 { Application, ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates a new managed application. + * + * @summary Creates a new managed application. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/createOrUpdateApplication.json + */ +async function createOrUpdateManagedApplication() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationName = "myManagedApplication"; + const parameters: Application = { + kind: "ServiceCatalog", + location: "East US 2", + managedResourceGroupId: "/subscriptions/subid/resourceGroups/myManagedRG" + }; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applications.beginCreateOrUpdateAndWait( + resourceGroupName, + applicationName, + parameters + ); + console.log(result); +} + +createOrUpdateManagedApplication().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsDeleteByIdSample.ts b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsDeleteByIdSample.ts new file mode 100644 index 000000000000..0ef271e020a4 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsDeleteByIdSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes the managed application. + * + * @summary Deletes the managed application. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/deleteApplicationById.json + */ +async function deleteApplicationById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const applicationId = "myApplicationId"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applications.beginDeleteByIdAndWait( + applicationId + ); + console.log(result); +} + +deleteApplicationById().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsDeleteSample.ts b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsDeleteSample.ts new file mode 100644 index 000000000000..7766bc6a2798 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsDeleteSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes the managed application. + * + * @summary Deletes the managed application. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/deleteApplication.json + */ +async function deletesAManagedApplication() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationName = "myManagedApplication"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applications.beginDeleteAndWait( + resourceGroupName, + applicationName + ); + console.log(result); +} + +deletesAManagedApplication().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsGetByIdSample.ts b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsGetByIdSample.ts new file mode 100644 index 000000000000..e182c48385ef --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsGetByIdSample.ts @@ -0,0 +1,29 @@ +/* + * 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 { ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the managed application. + * + * @summary Gets the managed application. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/getApplicationById.json + */ +async function getApplicationById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const applicationId = "myApplicationId"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applications.getById(applicationId); + console.log(result); +} + +getApplicationById().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsGetSample.ts b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsGetSample.ts new file mode 100644 index 000000000000..d3a648717eac --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsGetSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the managed application. + * + * @summary Gets the managed application. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/getApplication.json + */ +async function getAManagedApplication() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationName = "myManagedApplication"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applications.get( + resourceGroupName, + applicationName + ); + console.log(result); +} + +getAManagedApplication().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsListByResourceGroupSample.ts b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsListByResourceGroupSample.ts new file mode 100644 index 000000000000..04fbb9de0c19 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsListByResourceGroupSample.ts @@ -0,0 +1,34 @@ +/* + * 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 { ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all the applications within a resource group. + * + * @summary Gets all the applications within a resource group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listApplicationsByResourceGroup.json + */ +async function listsApplications() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.applications.listByResourceGroup( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listsApplications().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsListBySubscriptionSample.ts b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsListBySubscriptionSample.ts new file mode 100644 index 000000000000..375ff8d8605f --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsListBySubscriptionSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all the applications within a subscription. + * + * @summary Gets all the applications within a subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listApplicationsBySubscription.json + */ +async function listsApplicationsBySubscription() { + const subscriptionId = "subid"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.applications.listBySubscription()) { + resArray.push(item); + } + console.log(resArray); +} + +listsApplicationsBySubscription().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsUpdateByIdSample.ts b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsUpdateByIdSample.ts new file mode 100644 index 000000000000..cc0849b517aa --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsUpdateByIdSample.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 { + Application, + ApplicationsUpdateByIdOptionalParams, + ApplicationClient +} from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Updates an existing managed application. The only value that can be updated via PATCH currently is the tags. + * + * @summary Updates an existing managed application. The only value that can be updated via PATCH currently is the tags. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/updateApplicationById.json + */ +async function updateApplicationById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const applicationId = "myApplicationId"; + const parameters: Application = { + applicationDefinitionId: + "/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myAppDef", + kind: "ServiceCatalog", + managedResourceGroupId: "/subscriptions/subid/resourceGroups/myManagedRG" + }; + const options: ApplicationsUpdateByIdOptionalParams = { parameters }; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applications.updateById(applicationId, options); + console.log(result); +} + +updateApplicationById().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsUpdateSample.ts b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsUpdateSample.ts new file mode 100644 index 000000000000..3df704b2d511 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples-dev/applicationsUpdateSample.ts @@ -0,0 +1,45 @@ +/* + * 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 { + ApplicationPatchable, + ApplicationsUpdateOptionalParams, + ApplicationClient +} from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Updates an existing managed application. The only value that can be updated via PATCH currently is the tags. + * + * @summary Updates an existing managed application. The only value that can be updated via PATCH currently is the tags. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/updateApplication.json + */ +async function updatesAManagedApplication() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationName = "myManagedApplication"; + const parameters: ApplicationPatchable = { + applicationDefinitionId: + "/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myAppDef", + kind: "ServiceCatalog", + managedResourceGroupId: "/subscriptions/subid/resourceGroups/myManagedRG" + }; + const options: ApplicationsUpdateOptionalParams = { parameters }; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applications.update( + resourceGroupName, + applicationName, + options + ); + console.log(result); +} + +updatesAManagedApplication().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples-dev/listOperationsSample.ts b/sdk/managedapplications/arm-managedapplications/samples-dev/listOperationsSample.ts new file mode 100644 index 000000000000..5f55f29bf6ca --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples-dev/listOperationsSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists all of the available Microsoft.Solutions REST API operations. + * + * @summary Lists all of the available Microsoft.Solutions REST API operations. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listSolutionsOperations.json + */ +async function listSolutionsOperations() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.listOperations()) { + resArray.push(item); + } + console.log(resArray); +} + +listSolutionsOperations().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/README.md b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/README.md new file mode 100644 index 000000000000..7c91d57525a8 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/README.md @@ -0,0 +1,84 @@ +# client library samples for JavaScript + +These sample programs show how to use the JavaScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| ----------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [applicationDefinitionsCreateOrUpdateByIdSample.js][applicationdefinitionscreateorupdatebyidsample] | Creates a new managed application definition. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/createOrUpdateApplicationDefinition.json | +| [applicationDefinitionsCreateOrUpdateSample.js][applicationdefinitionscreateorupdatesample] | Creates a new managed application definition. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/createOrUpdateApplicationDefinition.json | +| [applicationDefinitionsDeleteByIdSample.js][applicationdefinitionsdeletebyidsample] | Deletes the managed application definition. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/deleteApplicationDefinition.json | +| [applicationDefinitionsDeleteSample.js][applicationdefinitionsdeletesample] | Deletes the managed application definition. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/deleteApplicationDefinition.json | +| [applicationDefinitionsGetByIdSample.js][applicationdefinitionsgetbyidsample] | Gets the managed application definition. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/getApplicationDefinition.json | +| [applicationDefinitionsGetSample.js][applicationdefinitionsgetsample] | Gets the managed application definition. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/getApplicationDefinition.json | +| [applicationDefinitionsListByResourceGroupSample.js][applicationdefinitionslistbyresourcegroupsample] | Lists the managed application definitions in a resource group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listApplicationDefinitionsByResourceGroup.json | +| [applicationsCreateOrUpdateByIdSample.js][applicationscreateorupdatebyidsample] | Creates a new managed application. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/createOrUpdateApplicationById.json | +| [applicationsCreateOrUpdateSample.js][applicationscreateorupdatesample] | Creates a new managed application. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/createOrUpdateApplication.json | +| [applicationsDeleteByIdSample.js][applicationsdeletebyidsample] | Deletes the managed application. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/deleteApplicationById.json | +| [applicationsDeleteSample.js][applicationsdeletesample] | Deletes the managed application. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/deleteApplication.json | +| [applicationsGetByIdSample.js][applicationsgetbyidsample] | Gets the managed application. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/getApplicationById.json | +| [applicationsGetSample.js][applicationsgetsample] | Gets the managed application. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/getApplication.json | +| [applicationsListByResourceGroupSample.js][applicationslistbyresourcegroupsample] | Gets all the applications within a resource group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listApplicationsByResourceGroup.json | +| [applicationsListBySubscriptionSample.js][applicationslistbysubscriptionsample] | Gets all the applications within a subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listApplicationsBySubscription.json | +| [applicationsUpdateByIdSample.js][applicationsupdatebyidsample] | Updates an existing managed application. The only value that can be updated via PATCH currently is the tags. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/updateApplicationById.json | +| [applicationsUpdateSample.js][applicationsupdatesample] | Updates an existing managed application. The only value that can be updated via PATCH currently is the tags. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/updateApplication.json | +| [listOperationsSample.js][listoperationssample] | Lists all of the available Microsoft.Solutions REST API operations. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listSolutionsOperations.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +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 applicationDefinitionsCreateOrUpdateByIdSample.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 node applicationDefinitionsCreateOrUpdateByIdSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[applicationdefinitionscreateorupdatebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsCreateOrUpdateByIdSample.js +[applicationdefinitionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsCreateOrUpdateSample.js +[applicationdefinitionsdeletebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsDeleteByIdSample.js +[applicationdefinitionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsDeleteSample.js +[applicationdefinitionsgetbyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsGetByIdSample.js +[applicationdefinitionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsGetSample.js +[applicationdefinitionslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsListByResourceGroupSample.js +[applicationscreateorupdatebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsCreateOrUpdateByIdSample.js +[applicationscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsCreateOrUpdateSample.js +[applicationsdeletebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsDeleteByIdSample.js +[applicationsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsDeleteSample.js +[applicationsgetbyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsGetByIdSample.js +[applicationsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsGetSample.js +[applicationslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsListByResourceGroupSample.js +[applicationslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsListBySubscriptionSample.js +[applicationsupdatebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsUpdateByIdSample.js +[applicationsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsUpdateSample.js +[listoperationssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/listOperationsSample.js +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-managedapplications?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/managedapplications/arm-managedapplications/README.md diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsCreateOrUpdateByIdSample.js b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsCreateOrUpdateByIdSample.js new file mode 100644 index 000000000000..0171c97f1689 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsCreateOrUpdateByIdSample.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 { ApplicationClient } = require("@azure/arm-managedapplications"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Creates a new managed application definition. + * + * @summary Creates a new managed application definition. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/createOrUpdateApplicationDefinition.json + */ +async function createOrUpdateManagedApplicationDefinition() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationDefinitionName = "myManagedApplicationDef"; + const parameters = { + description: "myManagedApplicationDef description", + authorizations: [{ principalId: "validprincipalguid", roleDefinitionId: "validroleguid" }], + displayName: "myManagedApplicationDef", + location: "East US 2", + lockLevel: "None", + packageFileUri: "https://path/to/packagezipfile", + }; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applicationDefinitions.beginCreateOrUpdateByIdAndWait( + resourceGroupName, + applicationDefinitionName, + parameters + ); + console.log(result); +} + +createOrUpdateManagedApplicationDefinition().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsCreateOrUpdateSample.js b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsCreateOrUpdateSample.js new file mode 100644 index 000000000000..543f0854ba4e --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsCreateOrUpdateSample.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 { ApplicationClient } = require("@azure/arm-managedapplications"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Creates a new managed application definition. + * + * @summary Creates a new managed application definition. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/createOrUpdateApplicationDefinition.json + */ +async function createOrUpdateManagedApplicationDefinition() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationDefinitionName = "myManagedApplicationDef"; + const parameters = { + description: "myManagedApplicationDef description", + authorizations: [{ principalId: "validprincipalguid", roleDefinitionId: "validroleguid" }], + displayName: "myManagedApplicationDef", + location: "East US 2", + lockLevel: "None", + packageFileUri: "https://path/to/packagezipfile", + }; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applicationDefinitions.beginCreateOrUpdateAndWait( + resourceGroupName, + applicationDefinitionName, + parameters + ); + console.log(result); +} + +createOrUpdateManagedApplicationDefinition().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsDeleteByIdSample.js b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsDeleteByIdSample.js new file mode 100644 index 000000000000..02af067f9666 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsDeleteByIdSample.js @@ -0,0 +1,33 @@ +/* + * 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 { ApplicationClient } = require("@azure/arm-managedapplications"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes the managed application definition. + * + * @summary Deletes the managed application definition. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/deleteApplicationDefinition.json + */ +async function deleteApplicationDefinition() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationDefinitionName = "myManagedApplicationDef"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applicationDefinitions.beginDeleteByIdAndWait( + resourceGroupName, + applicationDefinitionName + ); + console.log(result); +} + +deleteApplicationDefinition().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsDeleteSample.js b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsDeleteSample.js new file mode 100644 index 000000000000..3af72ea8599b --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsDeleteSample.js @@ -0,0 +1,33 @@ +/* + * 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 { ApplicationClient } = require("@azure/arm-managedapplications"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes the managed application definition. + * + * @summary Deletes the managed application definition. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/deleteApplicationDefinition.json + */ +async function deletesAManagedApplication() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationDefinitionName = "myManagedApplicationDef"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applicationDefinitions.beginDeleteAndWait( + resourceGroupName, + applicationDefinitionName + ); + console.log(result); +} + +deletesAManagedApplication().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsGetByIdSample.js b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsGetByIdSample.js new file mode 100644 index 000000000000..5552f177b3ec --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsGetByIdSample.js @@ -0,0 +1,33 @@ +/* + * 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 { ApplicationClient } = require("@azure/arm-managedapplications"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets the managed application definition. + * + * @summary Gets the managed application definition. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/getApplicationDefinition.json + */ +async function getManagedApplicationDefinition() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationDefinitionName = "myManagedApplicationDef"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applicationDefinitions.getById( + resourceGroupName, + applicationDefinitionName + ); + console.log(result); +} + +getManagedApplicationDefinition().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsGetSample.js b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsGetSample.js new file mode 100644 index 000000000000..ebe1ad3ba287 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsGetSample.js @@ -0,0 +1,33 @@ +/* + * 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 { ApplicationClient } = require("@azure/arm-managedapplications"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets the managed application definition. + * + * @summary Gets the managed application definition. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/getApplicationDefinition.json + */ +async function getManagedApplicationDefinition() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationDefinitionName = "myManagedApplicationDef"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applicationDefinitions.get( + resourceGroupName, + applicationDefinitionName + ); + console.log(result); +} + +getManagedApplicationDefinition().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsListByResourceGroupSample.js b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsListByResourceGroupSample.js new file mode 100644 index 000000000000..776b237e5a3f --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationDefinitionsListByResourceGroupSample.js @@ -0,0 +1,32 @@ +/* + * 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 { ApplicationClient } = require("@azure/arm-managedapplications"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists the managed application definitions in a resource group. + * + * @summary Lists the managed application definitions in a resource group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listApplicationDefinitionsByResourceGroup.json + */ +async function listManagedApplicationDefinitions() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.applicationDefinitions.listByResourceGroup(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +listManagedApplicationDefinitions().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsCreateOrUpdateByIdSample.js b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsCreateOrUpdateByIdSample.js new file mode 100644 index 000000000000..bd4a0970dacc --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsCreateOrUpdateByIdSample.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 { ApplicationClient } = require("@azure/arm-managedapplications"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Creates a new managed application. + * + * @summary Creates a new managed application. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/createOrUpdateApplicationById.json + */ +async function createOrUpdateApplicationById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const applicationId = "myApplicationId"; + const parameters = { + kind: "ServiceCatalog", + location: "East US 2", + managedResourceGroupId: "/subscriptions/subid/resourceGroups/myManagedRG", + }; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applications.beginCreateOrUpdateByIdAndWait( + applicationId, + parameters + ); + console.log(result); +} + +createOrUpdateApplicationById().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsCreateOrUpdateSample.js b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsCreateOrUpdateSample.js new file mode 100644 index 000000000000..3363ceb97c3b --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsCreateOrUpdateSample.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 { ApplicationClient } = require("@azure/arm-managedapplications"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Creates a new managed application. + * + * @summary Creates a new managed application. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/createOrUpdateApplication.json + */ +async function createOrUpdateManagedApplication() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationName = "myManagedApplication"; + const parameters = { + kind: "ServiceCatalog", + location: "East US 2", + managedResourceGroupId: "/subscriptions/subid/resourceGroups/myManagedRG", + }; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applications.beginCreateOrUpdateAndWait( + resourceGroupName, + applicationName, + parameters + ); + console.log(result); +} + +createOrUpdateManagedApplication().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsDeleteByIdSample.js b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsDeleteByIdSample.js new file mode 100644 index 000000000000..1ef5bb1eff0f --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsDeleteByIdSample.js @@ -0,0 +1,29 @@ +/* + * 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 { ApplicationClient } = require("@azure/arm-managedapplications"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes the managed application. + * + * @summary Deletes the managed application. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/deleteApplicationById.json + */ +async function deleteApplicationById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const applicationId = "myApplicationId"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applications.beginDeleteByIdAndWait(applicationId); + console.log(result); +} + +deleteApplicationById().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsDeleteSample.js b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsDeleteSample.js new file mode 100644 index 000000000000..75dc886df58b --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsDeleteSample.js @@ -0,0 +1,30 @@ +/* + * 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 { ApplicationClient } = require("@azure/arm-managedapplications"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes the managed application. + * + * @summary Deletes the managed application. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/deleteApplication.json + */ +async function deletesAManagedApplication() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationName = "myManagedApplication"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applications.beginDeleteAndWait(resourceGroupName, applicationName); + console.log(result); +} + +deletesAManagedApplication().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsGetByIdSample.js b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsGetByIdSample.js new file mode 100644 index 000000000000..97883db73083 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsGetByIdSample.js @@ -0,0 +1,29 @@ +/* + * 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 { ApplicationClient } = require("@azure/arm-managedapplications"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets the managed application. + * + * @summary Gets the managed application. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/getApplicationById.json + */ +async function getApplicationById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const applicationId = "myApplicationId"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applications.getById(applicationId); + console.log(result); +} + +getApplicationById().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsGetSample.js b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsGetSample.js new file mode 100644 index 000000000000..016d2b662580 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsGetSample.js @@ -0,0 +1,30 @@ +/* + * 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 { ApplicationClient } = require("@azure/arm-managedapplications"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets the managed application. + * + * @summary Gets the managed application. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/getApplication.json + */ +async function getAManagedApplication() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationName = "myManagedApplication"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applications.get(resourceGroupName, applicationName); + console.log(result); +} + +getAManagedApplication().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsListByResourceGroupSample.js b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsListByResourceGroupSample.js new file mode 100644 index 000000000000..3f652e0e2c02 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsListByResourceGroupSample.js @@ -0,0 +1,32 @@ +/* + * 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 { ApplicationClient } = require("@azure/arm-managedapplications"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets all the applications within a resource group. + * + * @summary Gets all the applications within a resource group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listApplicationsByResourceGroup.json + */ +async function listsApplications() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.applications.listByResourceGroup(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +listsApplications().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsListBySubscriptionSample.js b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsListBySubscriptionSample.js new file mode 100644 index 000000000000..bfe3eaef8f66 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsListBySubscriptionSample.js @@ -0,0 +1,31 @@ +/* + * 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 { ApplicationClient } = require("@azure/arm-managedapplications"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets all the applications within a subscription. + * + * @summary Gets all the applications within a subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listApplicationsBySubscription.json + */ +async function listsApplicationsBySubscription() { + const subscriptionId = "subid"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.applications.listBySubscription()) { + resArray.push(item); + } + console.log(resArray); +} + +listsApplicationsBySubscription().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsUpdateByIdSample.js b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsUpdateByIdSample.js new file mode 100644 index 000000000000..250a479e87b3 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsUpdateByIdSample.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 { ApplicationClient } = require("@azure/arm-managedapplications"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Updates an existing managed application. The only value that can be updated via PATCH currently is the tags. + * + * @summary Updates an existing managed application. The only value that can be updated via PATCH currently is the tags. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/updateApplicationById.json + */ +async function updateApplicationById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const applicationId = "myApplicationId"; + const parameters = { + applicationDefinitionId: + "/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myAppDef", + kind: "ServiceCatalog", + managedResourceGroupId: "/subscriptions/subid/resourceGroups/myManagedRG", + }; + const options = { parameters }; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applications.updateById(applicationId, options); + console.log(result); +} + +updateApplicationById().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsUpdateSample.js b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsUpdateSample.js new file mode 100644 index 000000000000..5abbac0de1f5 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/applicationsUpdateSample.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 { ApplicationClient } = require("@azure/arm-managedapplications"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Updates an existing managed application. The only value that can be updated via PATCH currently is the tags. + * + * @summary Updates an existing managed application. The only value that can be updated via PATCH currently is the tags. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/updateApplication.json + */ +async function updatesAManagedApplication() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationName = "myManagedApplication"; + const parameters = { + applicationDefinitionId: + "/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myAppDef", + kind: "ServiceCatalog", + managedResourceGroupId: "/subscriptions/subid/resourceGroups/myManagedRG", + }; + const options = { parameters }; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applications.update(resourceGroupName, applicationName, options); + console.log(result); +} + +updatesAManagedApplication().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/listOperationsSample.js b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/listOperationsSample.js new file mode 100644 index 000000000000..36586e941163 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/listOperationsSample.js @@ -0,0 +1,31 @@ +/* + * 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 { ApplicationClient } = require("@azure/arm-managedapplications"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists all of the available Microsoft.Solutions REST API operations. + * + * @summary Lists all of the available Microsoft.Solutions REST API operations. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listSolutionsOperations.json + */ +async function listSolutionsOperations() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.listOperations()) { + resArray.push(item); + } + console.log(resArray); +} + +listSolutionsOperations().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/package.json b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/package.json new file mode 100644 index 000000000000..e366a6e5715d --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/package.json @@ -0,0 +1,32 @@ +{ + "name": "@azure-samples/arm-managedapplications-js", + "private": true, + "version": "1.0.0", + "description": " client library samples for JavaScript", + "engines": { + "node": ">=12.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/managedapplications/arm-managedapplications" + }, + "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/managedapplications/arm-managedapplications", + "dependencies": { + "@azure/arm-managedapplications": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + } +} diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/sample.env b/sdk/managedapplications/arm-managedapplications/samples/v2/javascript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/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/managedapplications/arm-managedapplications/samples/v2/typescript/README.md b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/README.md new file mode 100644 index 000000000000..7011a50cb50d --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/README.md @@ -0,0 +1,97 @@ +# client library samples for TypeScript + +These sample programs show how to use the TypeScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| ----------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [applicationDefinitionsCreateOrUpdateByIdSample.ts][applicationdefinitionscreateorupdatebyidsample] | Creates a new managed application definition. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/createOrUpdateApplicationDefinition.json | +| [applicationDefinitionsCreateOrUpdateSample.ts][applicationdefinitionscreateorupdatesample] | Creates a new managed application definition. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/createOrUpdateApplicationDefinition.json | +| [applicationDefinitionsDeleteByIdSample.ts][applicationdefinitionsdeletebyidsample] | Deletes the managed application definition. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/deleteApplicationDefinition.json | +| [applicationDefinitionsDeleteSample.ts][applicationdefinitionsdeletesample] | Deletes the managed application definition. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/deleteApplicationDefinition.json | +| [applicationDefinitionsGetByIdSample.ts][applicationdefinitionsgetbyidsample] | Gets the managed application definition. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/getApplicationDefinition.json | +| [applicationDefinitionsGetSample.ts][applicationdefinitionsgetsample] | Gets the managed application definition. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/getApplicationDefinition.json | +| [applicationDefinitionsListByResourceGroupSample.ts][applicationdefinitionslistbyresourcegroupsample] | Lists the managed application definitions in a resource group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listApplicationDefinitionsByResourceGroup.json | +| [applicationsCreateOrUpdateByIdSample.ts][applicationscreateorupdatebyidsample] | Creates a new managed application. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/createOrUpdateApplicationById.json | +| [applicationsCreateOrUpdateSample.ts][applicationscreateorupdatesample] | Creates a new managed application. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/createOrUpdateApplication.json | +| [applicationsDeleteByIdSample.ts][applicationsdeletebyidsample] | Deletes the managed application. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/deleteApplicationById.json | +| [applicationsDeleteSample.ts][applicationsdeletesample] | Deletes the managed application. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/deleteApplication.json | +| [applicationsGetByIdSample.ts][applicationsgetbyidsample] | Gets the managed application. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/getApplicationById.json | +| [applicationsGetSample.ts][applicationsgetsample] | Gets the managed application. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/getApplication.json | +| [applicationsListByResourceGroupSample.ts][applicationslistbyresourcegroupsample] | Gets all the applications within a resource group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listApplicationsByResourceGroup.json | +| [applicationsListBySubscriptionSample.ts][applicationslistbysubscriptionsample] | Gets all the applications within a subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listApplicationsBySubscription.json | +| [applicationsUpdateByIdSample.ts][applicationsupdatebyidsample] | Updates an existing managed application. The only value that can be updated via PATCH currently is the tags. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/updateApplicationById.json | +| [applicationsUpdateSample.ts][applicationsupdatesample] | Updates an existing managed application. The only value that can be updated via PATCH currently is the tags. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/updateApplication.json | +| [listOperationsSample.ts][listoperationssample] | Lists all of the available Microsoft.Solutions REST API operations. x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listSolutionsOperations.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +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/applicationDefinitionsCreateOrUpdateByIdSample.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 node dist/applicationDefinitionsCreateOrUpdateByIdSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[applicationdefinitionscreateorupdatebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsCreateOrUpdateByIdSample.ts +[applicationdefinitionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsCreateOrUpdateSample.ts +[applicationdefinitionsdeletebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsDeleteByIdSample.ts +[applicationdefinitionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsDeleteSample.ts +[applicationdefinitionsgetbyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsGetByIdSample.ts +[applicationdefinitionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsGetSample.ts +[applicationdefinitionslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsListByResourceGroupSample.ts +[applicationscreateorupdatebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsCreateOrUpdateByIdSample.ts +[applicationscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsCreateOrUpdateSample.ts +[applicationsdeletebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsDeleteByIdSample.ts +[applicationsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsDeleteSample.ts +[applicationsgetbyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsGetByIdSample.ts +[applicationsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsGetSample.ts +[applicationslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsListByResourceGroupSample.ts +[applicationslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsListBySubscriptionSample.ts +[applicationsupdatebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsUpdateByIdSample.ts +[applicationsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsUpdateSample.ts +[listoperationssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/listOperationsSample.ts +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-managedapplications?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/managedapplications/arm-managedapplications/README.md +[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/package.json b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/package.json new file mode 100644 index 000000000000..de200563a0d8 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/package.json @@ -0,0 +1,41 @@ +{ + "name": "@azure-samples/arm-managedapplications-ts", + "private": true, + "version": "1.0.0", + "description": " client library samples for TypeScript", + "engines": { + "node": ">=12.0.0" + }, + "scripts": { + "build": "tsc", + "prebuild": "rimraf dist/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/managedapplications/arm-managedapplications" + }, + "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/managedapplications/arm-managedapplications", + "dependencies": { + "@azure/arm-managedapplications": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + }, + "devDependencies": { + "@types/node": "^12.0.0", + "typescript": "~4.4.0", + "rimraf": "latest" + } +} diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/sample.env b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/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/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsCreateOrUpdateByIdSample.ts b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsCreateOrUpdateByIdSample.ts new file mode 100644 index 000000000000..a6602f4c64b0 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsCreateOrUpdateByIdSample.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 { + ApplicationDefinition, + ApplicationClient +} from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates a new managed application definition. + * + * @summary Creates a new managed application definition. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/createOrUpdateApplicationDefinition.json + */ +async function createOrUpdateManagedApplicationDefinition() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationDefinitionName = "myManagedApplicationDef"; + const parameters: ApplicationDefinition = { + description: "myManagedApplicationDef description", + authorizations: [ + { principalId: "validprincipalguid", roleDefinitionId: "validroleguid" } + ], + displayName: "myManagedApplicationDef", + location: "East US 2", + lockLevel: "None", + packageFileUri: "https://path/to/packagezipfile" + }; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applicationDefinitions.beginCreateOrUpdateByIdAndWait( + resourceGroupName, + applicationDefinitionName, + parameters + ); + console.log(result); +} + +createOrUpdateManagedApplicationDefinition().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsCreateOrUpdateSample.ts b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..3caa1c7c00dd --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsCreateOrUpdateSample.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 { + ApplicationDefinition, + ApplicationClient +} from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates a new managed application definition. + * + * @summary Creates a new managed application definition. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/createOrUpdateApplicationDefinition.json + */ +async function createOrUpdateManagedApplicationDefinition() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationDefinitionName = "myManagedApplicationDef"; + const parameters: ApplicationDefinition = { + description: "myManagedApplicationDef description", + authorizations: [ + { principalId: "validprincipalguid", roleDefinitionId: "validroleguid" } + ], + displayName: "myManagedApplicationDef", + location: "East US 2", + lockLevel: "None", + packageFileUri: "https://path/to/packagezipfile" + }; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applicationDefinitions.beginCreateOrUpdateAndWait( + resourceGroupName, + applicationDefinitionName, + parameters + ); + console.log(result); +} + +createOrUpdateManagedApplicationDefinition().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsDeleteByIdSample.ts b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsDeleteByIdSample.ts new file mode 100644 index 000000000000..028f75fb3443 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsDeleteByIdSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes the managed application definition. + * + * @summary Deletes the managed application definition. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/deleteApplicationDefinition.json + */ +async function deleteApplicationDefinition() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationDefinitionName = "myManagedApplicationDef"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applicationDefinitions.beginDeleteByIdAndWait( + resourceGroupName, + applicationDefinitionName + ); + console.log(result); +} + +deleteApplicationDefinition().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsDeleteSample.ts b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsDeleteSample.ts new file mode 100644 index 000000000000..62b514f814f5 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsDeleteSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes the managed application definition. + * + * @summary Deletes the managed application definition. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/deleteApplicationDefinition.json + */ +async function deletesAManagedApplication() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationDefinitionName = "myManagedApplicationDef"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applicationDefinitions.beginDeleteAndWait( + resourceGroupName, + applicationDefinitionName + ); + console.log(result); +} + +deletesAManagedApplication().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsGetByIdSample.ts b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsGetByIdSample.ts new file mode 100644 index 000000000000..738cd2058851 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsGetByIdSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the managed application definition. + * + * @summary Gets the managed application definition. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/getApplicationDefinition.json + */ +async function getManagedApplicationDefinition() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationDefinitionName = "myManagedApplicationDef"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applicationDefinitions.getById( + resourceGroupName, + applicationDefinitionName + ); + console.log(result); +} + +getManagedApplicationDefinition().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsGetSample.ts b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsGetSample.ts new file mode 100644 index 000000000000..a6625f74824a --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsGetSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the managed application definition. + * + * @summary Gets the managed application definition. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/getApplicationDefinition.json + */ +async function getManagedApplicationDefinition() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationDefinitionName = "myManagedApplicationDef"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applicationDefinitions.get( + resourceGroupName, + applicationDefinitionName + ); + console.log(result); +} + +getManagedApplicationDefinition().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsListByResourceGroupSample.ts b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsListByResourceGroupSample.ts new file mode 100644 index 000000000000..84ebd7a751c9 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationDefinitionsListByResourceGroupSample.ts @@ -0,0 +1,34 @@ +/* + * 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 { ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists the managed application definitions in a resource group. + * + * @summary Lists the managed application definitions in a resource group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listApplicationDefinitionsByResourceGroup.json + */ +async function listManagedApplicationDefinitions() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.applicationDefinitions.listByResourceGroup( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listManagedApplicationDefinitions().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsCreateOrUpdateByIdSample.ts b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsCreateOrUpdateByIdSample.ts new file mode 100644 index 000000000000..55f5fc24c432 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsCreateOrUpdateByIdSample.ts @@ -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. +import { Application, ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates a new managed application. + * + * @summary Creates a new managed application. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/createOrUpdateApplicationById.json + */ +async function createOrUpdateApplicationById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const applicationId = "myApplicationId"; + const parameters: Application = { + kind: "ServiceCatalog", + location: "East US 2", + managedResourceGroupId: "/subscriptions/subid/resourceGroups/myManagedRG" + }; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applications.beginCreateOrUpdateByIdAndWait( + applicationId, + parameters + ); + console.log(result); +} + +createOrUpdateApplicationById().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsCreateOrUpdateSample.ts b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..c48dc884ec56 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsCreateOrUpdateSample.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 { Application, ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates a new managed application. + * + * @summary Creates a new managed application. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/createOrUpdateApplication.json + */ +async function createOrUpdateManagedApplication() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationName = "myManagedApplication"; + const parameters: Application = { + kind: "ServiceCatalog", + location: "East US 2", + managedResourceGroupId: "/subscriptions/subid/resourceGroups/myManagedRG" + }; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applications.beginCreateOrUpdateAndWait( + resourceGroupName, + applicationName, + parameters + ); + console.log(result); +} + +createOrUpdateManagedApplication().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsDeleteByIdSample.ts b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsDeleteByIdSample.ts new file mode 100644 index 000000000000..0ef271e020a4 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsDeleteByIdSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes the managed application. + * + * @summary Deletes the managed application. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/deleteApplicationById.json + */ +async function deleteApplicationById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const applicationId = "myApplicationId"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applications.beginDeleteByIdAndWait( + applicationId + ); + console.log(result); +} + +deleteApplicationById().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsDeleteSample.ts b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsDeleteSample.ts new file mode 100644 index 000000000000..7766bc6a2798 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsDeleteSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes the managed application. + * + * @summary Deletes the managed application. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/deleteApplication.json + */ +async function deletesAManagedApplication() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationName = "myManagedApplication"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applications.beginDeleteAndWait( + resourceGroupName, + applicationName + ); + console.log(result); +} + +deletesAManagedApplication().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsGetByIdSample.ts b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsGetByIdSample.ts new file mode 100644 index 000000000000..e182c48385ef --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsGetByIdSample.ts @@ -0,0 +1,29 @@ +/* + * 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 { ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the managed application. + * + * @summary Gets the managed application. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/getApplicationById.json + */ +async function getApplicationById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const applicationId = "myApplicationId"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applications.getById(applicationId); + console.log(result); +} + +getApplicationById().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsGetSample.ts b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsGetSample.ts new file mode 100644 index 000000000000..d3a648717eac --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsGetSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the managed application. + * + * @summary Gets the managed application. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/getApplication.json + */ +async function getAManagedApplication() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationName = "myManagedApplication"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applications.get( + resourceGroupName, + applicationName + ); + console.log(result); +} + +getAManagedApplication().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsListByResourceGroupSample.ts b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsListByResourceGroupSample.ts new file mode 100644 index 000000000000..04fbb9de0c19 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsListByResourceGroupSample.ts @@ -0,0 +1,34 @@ +/* + * 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 { ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all the applications within a resource group. + * + * @summary Gets all the applications within a resource group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listApplicationsByResourceGroup.json + */ +async function listsApplications() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.applications.listByResourceGroup( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listsApplications().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsListBySubscriptionSample.ts b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsListBySubscriptionSample.ts new file mode 100644 index 000000000000..375ff8d8605f --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsListBySubscriptionSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all the applications within a subscription. + * + * @summary Gets all the applications within a subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listApplicationsBySubscription.json + */ +async function listsApplicationsBySubscription() { + const subscriptionId = "subid"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.applications.listBySubscription()) { + resArray.push(item); + } + console.log(resArray); +} + +listsApplicationsBySubscription().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsUpdateByIdSample.ts b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsUpdateByIdSample.ts new file mode 100644 index 000000000000..cc0849b517aa --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsUpdateByIdSample.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 { + Application, + ApplicationsUpdateByIdOptionalParams, + ApplicationClient +} from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Updates an existing managed application. The only value that can be updated via PATCH currently is the tags. + * + * @summary Updates an existing managed application. The only value that can be updated via PATCH currently is the tags. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/updateApplicationById.json + */ +async function updateApplicationById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const applicationId = "myApplicationId"; + const parameters: Application = { + applicationDefinitionId: + "/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myAppDef", + kind: "ServiceCatalog", + managedResourceGroupId: "/subscriptions/subid/resourceGroups/myManagedRG" + }; + const options: ApplicationsUpdateByIdOptionalParams = { parameters }; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applications.updateById(applicationId, options); + console.log(result); +} + +updateApplicationById().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsUpdateSample.ts b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsUpdateSample.ts new file mode 100644 index 000000000000..3df704b2d511 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/applicationsUpdateSample.ts @@ -0,0 +1,45 @@ +/* + * 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 { + ApplicationPatchable, + ApplicationsUpdateOptionalParams, + ApplicationClient +} from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Updates an existing managed application. The only value that can be updated via PATCH currently is the tags. + * + * @summary Updates an existing managed application. The only value that can be updated via PATCH currently is the tags. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/updateApplication.json + */ +async function updatesAManagedApplication() { + const subscriptionId = "subid"; + const resourceGroupName = "rg"; + const applicationName = "myManagedApplication"; + const parameters: ApplicationPatchable = { + applicationDefinitionId: + "/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myAppDef", + kind: "ServiceCatalog", + managedResourceGroupId: "/subscriptions/subid/resourceGroups/myManagedRG" + }; + const options: ApplicationsUpdateOptionalParams = { parameters }; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const result = await client.applications.update( + resourceGroupName, + applicationName, + options + ); + console.log(result); +} + +updatesAManagedApplication().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/listOperationsSample.ts b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/listOperationsSample.ts new file mode 100644 index 000000000000..5f55f29bf6ca --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/src/listOperationsSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { ApplicationClient } from "@azure/arm-managedapplications"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists all of the available Microsoft.Solutions REST API operations. + * + * @summary Lists all of the available Microsoft.Solutions REST API operations. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Solutions/stable/2018-06-01/examples/listSolutionsOperations.json + */ +async function listSolutionsOperations() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new ApplicationClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.listOperations()) { + resArray.push(item); + } + console.log(resArray); +} + +listSolutionsOperations().catch(console.error); diff --git a/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/tsconfig.json b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/tsconfig.json new file mode 100644 index 000000000000..416c2dd82e00 --- /dev/null +++ b/sdk/managedapplications/arm-managedapplications/samples/v2/typescript/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2018", + "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/managedapplications/arm-managedapplications/src/applicationClient.ts b/sdk/managedapplications/arm-managedapplications/src/applicationClient.ts index 9d50847da990..936e53823dd5 100644 --- a/sdk/managedapplications/arm-managedapplications/src/applicationClient.ts +++ b/sdk/managedapplications/arm-managedapplications/src/applicationClient.ts @@ -7,6 +7,7 @@ */ import * as coreClient from "@azure/core-client"; +import * as coreRestPipeline from "@azure/core-rest-pipeline"; import * as coreAuth from "@azure/core-auth"; import { PagedAsyncIterableIterator } from "@azure/core-paging"; import { ApplicationsImpl, ApplicationDefinitionsImpl } from "./operations"; @@ -55,7 +56,7 @@ export class ApplicationClient extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-managedapplications/2.0.0`; + const packageDetails = `azsdk-js-arm-managedapplications/2.0.1`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` @@ -70,9 +71,33 @@ export class ApplicationClient extends coreClient.ServiceClient { userAgentOptions: { userAgentPrefix }, - baseUri: options.endpoint || "https://management.azure.com" + baseUri: + options.endpoint ?? options.baseUri ?? "https://management.azure.com" }; super(optionsWithDefaults); + + if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { + const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies(); + const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( + (pipelinePolicy) => + pipelinePolicy.name === + coreRestPipeline.bearerTokenAuthenticationPolicyName + ); + if (!bearerTokenAuthenticationPolicyFound) { + this.pipeline.removePolicy({ + name: coreRestPipeline.bearerTokenAuthenticationPolicyName + }); + this.pipeline.addPolicy( + coreRestPipeline.bearerTokenAuthenticationPolicy({ + scopes: `${optionsWithDefaults.baseUri}/.default`, + challengeCallbacks: { + authorizeRequestOnChallenge: + coreClient.authorizeRequestOnClaimChallenge + } + }) + ); + } + } // Parameter assignments this.subscriptionId = subscriptionId; diff --git a/sdk/managedapplications/arm-managedapplications/src/operations/applicationDefinitions.ts b/sdk/managedapplications/arm-managedapplications/src/operations/applicationDefinitions.ts index 88b8d4ee1e65..0b93e7c5c69e 100644 --- a/sdk/managedapplications/arm-managedapplications/src/operations/applicationDefinitions.ts +++ b/sdk/managedapplications/arm-managedapplications/src/operations/applicationDefinitions.ts @@ -170,10 +170,12 @@ export class ApplicationDefinitionsImpl implements ApplicationDefinitions { { resourceGroupName, applicationDefinitionName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -257,10 +259,12 @@ export class ApplicationDefinitionsImpl implements ApplicationDefinitions { { resourceGroupName, applicationDefinitionName, parameters, options }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -372,10 +376,12 @@ export class ApplicationDefinitionsImpl implements ApplicationDefinitions { { resourceGroupName, applicationDefinitionName, options }, deleteByIdOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -459,10 +465,12 @@ export class ApplicationDefinitionsImpl implements ApplicationDefinitions { { resourceGroupName, applicationDefinitionName, parameters, options }, createOrUpdateByIdOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** diff --git a/sdk/managedapplications/arm-managedapplications/src/operations/applications.ts b/sdk/managedapplications/arm-managedapplications/src/operations/applications.ts index d7d287bf1eec..ffa2f9bb0c47 100644 --- a/sdk/managedapplications/arm-managedapplications/src/operations/applications.ts +++ b/sdk/managedapplications/arm-managedapplications/src/operations/applications.ts @@ -220,10 +220,12 @@ export class ApplicationsImpl implements Applications { { resourceGroupName, applicationName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -307,10 +309,12 @@ export class ApplicationsImpl implements Applications { { resourceGroupName, applicationName, parameters, options }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -453,10 +457,12 @@ export class ApplicationsImpl implements Applications { { applicationId, options }, deleteByIdOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -536,10 +542,12 @@ export class ApplicationsImpl implements Applications { { applicationId, parameters, options }, createOrUpdateByIdOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** diff --git a/sdk/managedapplications/arm-managedapplications/tsconfig.json b/sdk/managedapplications/arm-managedapplications/tsconfig.json index 6e3251194117..8d319ccbe518 100644 --- a/sdk/managedapplications/arm-managedapplications/tsconfig.json +++ b/sdk/managedapplications/arm-managedapplications/tsconfig.json @@ -9,11 +9,35 @@ "esModuleInterop": true, "allowSyntheticDefaultImports": true, "forceConsistentCasingInFileNames": true, - "lib": ["es6", "dom"], + "lib": [ + "es6", + "dom" + ], "declaration": true, "outDir": "./dist-esm", - "importHelpers": true + "importHelpers": true, + "paths": { + "@azure/arm-managedapplications": [ + "./src/index" + ] + } }, - "include": ["./src/**/*.ts", "./test/**/*.ts"], - "exclude": ["node_modules"] -} + "include": [ + "./src/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts" + ], + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/sdk/managedapplications/ci.mgmt.yml b/sdk/managedapplications/ci.mgmt.yml index c6244e062f17..600e68d1eead 100644 --- a/sdk/managedapplications/ci.mgmt.yml +++ b/sdk/managedapplications/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,7 +9,7 @@ trigger: paths: include: - sdk/managedapplications/ci.mgmt.yml - - sdk/managedapplications/arm-managedapplications/ + - sdk/managedapplications/arm-managedapplications pr: branches: include: @@ -22,12 +22,11 @@ pr: paths: include: - sdk/managedapplications/ci.mgmt.yml - - sdk/managedapplications/arm-managedapplications/ - + - sdk/managedapplications/arm-managedapplications extends: template: /eng/pipelines/templates/stages/archetype-sdk-client.yml parameters: ServiceDirectory: managedapplications Artifacts: - name: azure-arm-managedapplications - safeName: azurearmmanagedapplications \ No newline at end of file + safeName: azurearmmanagedapplications diff --git a/sdk/policy/arm-policy/CHANGELOG.md b/sdk/policy/arm-policy/CHANGELOG.md index d334350dd9fd..d853324540c5 100644 --- a/sdk/policy/arm-policy/CHANGELOG.md +++ b/sdk/policy/arm-policy/CHANGELOG.md @@ -1,14 +1,10 @@ # Release History -## 5.0.1 (Unreleased) +## 5.0.1 (2022-04-18) -### Features Added +**features** -### Breaking Changes - -### Bugs Fixed - -### Other Changes + - Bug fix ## 5.0.0 (2021-12-07) diff --git a/sdk/policy/arm-policy/LICENSE b/sdk/policy/arm-policy/LICENSE index ccb63b166732..5d1d36e0af80 100644 --- a/sdk/policy/arm-policy/LICENSE +++ b/sdk/policy/arm-policy/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2021 Microsoft +Copyright (c) 2022 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/policy/arm-policy/README.md b/sdk/policy/arm-policy/README.md index 9f16f23e0a80..ae321a598c65 100644 --- a/sdk/policy/arm-policy/README.md +++ b/sdk/policy/arm-policy/README.md @@ -16,6 +16,8 @@ To manage and control access to your resources, you can define customized polici - [LTS versions of Node.js](https://nodejs.org/about/releases/) - 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]. @@ -49,8 +51,17 @@ For more information about how to create an Azure AD Application check out [this ```javascript const { PolicyClient } = require("@azure/arm-policy"); 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 PolicyClient(new DefaultAzureCredential(), subscriptionId); + +// For client-side applications running in the browser, use this code instead: +// const credential = new InteractiveBrowserCredential({ +// tenantId: "", +// clientId: "" +// }); +// const client = new PolicyClient(credential, subscriptionId); ``` diff --git a/sdk/policy/arm-policy/_meta.json b/sdk/policy/arm-policy/_meta.json index 0551b4fe18f8..c6765ba542bb 100644 --- a/sdk/policy/arm-policy/_meta.json +++ b/sdk/policy/arm-policy/_meta.json @@ -1,7 +1,8 @@ { "commit": "a42f1b58607091c4f255ead152a8ef323fa0b280", - "readme": "specification/resources/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 --generate-test --typescript-sdks-folder=D:\\mydev\\azure-sdk-for-js ../azure-rest-api-specs/specification/resources/resource-manager/readme.md --use=@autorest/typescript@6.0.0-alpha.16.20211130.1", + "readme": "specification\\resources\\resource-manager\\readme.md", + "autorest_command": "autorest --version=3.7.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\work\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\resources\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-alpha.19.20220408.1 --generate-sample=true", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "use": "@autorest/typescript@6.0.0-alpha.16.20211130.1" + "release_tool": "@azure-tools/js-sdk-release-tools@2.2.6", + "use": "@autorest/typescript@6.0.0-alpha.19.20220408.1" } \ No newline at end of file diff --git a/sdk/policy/arm-policy/api-extractor.json b/sdk/policy/arm-policy/api-extractor.json index b86ea1c77d22..312311c56461 100644 --- a/sdk/policy/arm-policy/api-extractor.json +++ b/sdk/policy/arm-policy/api-extractor.json @@ -1,18 +1,31 @@ { "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", "mainEntryPointFilePath": "./dist-esm/src/index.d.ts", - "docModel": { "enabled": true }, - "apiReport": { "enabled": true, "reportFolder": "./review" }, + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, "dtsRollup": { "enabled": true, "untrimmedFilePath": "", "publicTrimmedFilePath": "./types/arm-policy.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/policy/arm-policy/package.json b/sdk/policy/arm-policy/package.json index 27676ab7af8a..c31ac2cd1817 100644 --- a/sdk/policy/arm-policy/package.json +++ b/sdk/policy/arm-policy/package.json @@ -9,9 +9,9 @@ }, "dependencies": { "@azure/core-paging": "^1.2.0", - "@azure/core-client": "^1.0.0", + "@azure/core-client": "^1.5.0", "@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": [ @@ -28,12 +28,12 @@ "devDependencies": { "@microsoft/api-extractor": "^7.18.11", "@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-plugin-sourcemaps": "^0.4.2", + "rollup": "^2.66.1", + "rollup-plugin-sourcemaps": "^0.6.3", "typescript": "~4.2.0", "uglify-js": "^3.4.9", "rimraf": "^3.0.0", @@ -96,5 +96,21 @@ "docs": "echo skipped" }, "sideEffects": false, - "autoPublish": true + "//metadata": { + "constantPaths": [ + { + "path": "src/policyClient.ts", + "prefix": "packageDetails" + } + ] + }, + "autoPublish": true, + "//sampleConfiguration": { + "productName": "", + "productSlugs": [ + "azure" + ], + "disableDocsMs": true, + "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-policy?view=azure-node-preview" + } } diff --git a/sdk/policy/arm-policy/rollup.config.js b/sdk/policy/arm-policy/rollup.config.js index 9be1955eb7f1..3f89d7309da5 100644 --- a/sdk/policy/arm-policy/rollup.config.js +++ b/sdk/policy/arm-policy/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/policy/arm-policy/sample.env b/sdk/policy/arm-policy/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/policy/arm-policy/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/policy/arm-policy/samples-dev/dataPolicyManifestsGetByPolicyModeSample.ts b/sdk/policy/arm-policy/samples-dev/dataPolicyManifestsGetByPolicyModeSample.ts new file mode 100644 index 000000000000..956226d4552c --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/dataPolicyManifestsGetByPolicyModeSample.ts @@ -0,0 +1,29 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the data policy manifest with the given policy mode. + * + * @summary This operation retrieves the data policy manifest with the given policy mode. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/getDataPolicyManifest.json + */ +async function retrieveADataPolicyManifestByPolicyMode() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyMode = "Microsoft.KeyVault.Data"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.dataPolicyManifests.getByPolicyMode(policyMode); + console.log(result); +} + +retrieveADataPolicyManifestByPolicyMode().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/dataPolicyManifestsListSample.ts b/sdk/policy/arm-policy/samples-dev/dataPolicyManifestsListSample.ts new file mode 100644 index 000000000000..b9a1e68ed467 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/dataPolicyManifestsListSample.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 { + DataPolicyManifestsListOptionalParams, + PolicyClient +} from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves a list of all the data policy manifests that match the optional given $filter. Valid values for $filter are: "$filter=namespace eq '{0}'". If $filter is not provided, the unfiltered list includes all data policy manifests for data resource types. If $filter=namespace is provided, the returned list only includes all data policy manifests that have a namespace matching the provided value. + * + * @summary This operation retrieves a list of all the data policy manifests that match the optional given $filter. Valid values for $filter are: "$filter=namespace eq '{0}'". If $filter is not provided, the unfiltered list includes all data policy manifests for data resource types. If $filter=namespace is provided, the returned list only includes all data policy manifests that have a namespace matching the provided value. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/listDataPolicyManifests.json + */ +async function listDataPolicyManifests() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.dataPolicyManifests.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listDataPolicyManifests().catch(console.error); + +/** + * This sample demonstrates how to This operation retrieves a list of all the data policy manifests that match the optional given $filter. Valid values for $filter are: "$filter=namespace eq '{0}'". If $filter is not provided, the unfiltered list includes all data policy manifests for data resource types. If $filter=namespace is provided, the returned list only includes all data policy manifests that have a namespace matching the provided value. + * + * @summary This operation retrieves a list of all the data policy manifests that match the optional given $filter. Valid values for $filter are: "$filter=namespace eq '{0}'". If $filter is not provided, the unfiltered list includes all data policy manifests for data resource types. If $filter=namespace is provided, the returned list only includes all data policy manifests that have a namespace matching the provided value. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/listDataPolicyManifestsNamespaceFilter.json + */ +async function listDataPolicyManifestsWithNamespaceFilter() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const filter = "namespace eq 'Microsoft.KeyVault'"; + const options: DataPolicyManifestsListOptionalParams = { filter }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.dataPolicyManifests.list(options)) { + resArray.push(item); + } + console.log(resArray); +} + +listDataPolicyManifestsWithNamespaceFilter().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyAssignmentsCreateByIdSample.ts b/sdk/policy/arm-policy/samples-dev/policyAssignmentsCreateByIdSample.ts new file mode 100644 index 000000000000..509edf57313f --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyAssignmentsCreateByIdSample.ts @@ -0,0 +1,80 @@ +/* + * 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 { PolicyAssignment, PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * + * @summary This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignmentById.json + */ +async function createOrUpdatePolicyAssignmentById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyAssignmentId = + "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; + const parameters: PolicyAssignment = { + description: + "Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created", + displayName: "Enforce storage account SKU", + enforcementMode: "Default", + metadata: { assignedBy: "Cheapskate Boss" }, + parameters: { + listOfAllowedSKUs: {} + }, + policyDefinitionId: + "/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1" + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.createById( + policyAssignmentId, + parameters + ); + console.log(result); +} + +createOrUpdatePolicyAssignmentById().catch(console.error); + +/** + * This sample demonstrates how to This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * + * @summary This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignmentWithIdentityById.json + */ +async function createOrUpdatePolicyAssignmentWithAManagedIdentityById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyAssignmentId = + "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; + const parameters: PolicyAssignment = { + description: + "Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created", + displayName: "Enforce storage account SKU", + enforcementMode: "Default", + identity: { type: "SystemAssigned" }, + location: "eastus", + metadata: { assignedBy: "Cheapskate Boss" }, + parameters: { + listOfAllowedSKUs: {} + }, + policyDefinitionId: + "/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1" + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.createById( + policyAssignmentId, + parameters + ); + console.log(result); +} + +createOrUpdatePolicyAssignmentWithAManagedIdentityById().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyAssignmentsCreateSample.ts b/sdk/policy/arm-policy/samples-dev/policyAssignmentsCreateSample.ts new file mode 100644 index 000000000000..889356ea7b92 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyAssignmentsCreateSample.ts @@ -0,0 +1,198 @@ +/* + * 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 { PolicyAssignment, PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignment.json + */ +async function createOrUpdateAPolicyAssignment() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const parameters: PolicyAssignment = { + description: + "Force resource names to begin with given DeptA and end with -LC", + displayName: "Enforce resource naming rules", + metadata: { assignedBy: "Special Someone" }, + nonComplianceMessages: [ + { message: "Resource names must start with 'DeptA' and end with '-LC'." } + ], + parameters: { prefix: {}, suffix: {} }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming" + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.create( + scope, + policyAssignmentName, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicyAssignment().catch(console.error); + +/** + * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignmentWithIdentity.json + */ +async function createOrUpdateAPolicyAssignmentWithASystemAssignedIdentity() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const parameters: PolicyAssignment = { + description: + "Force resource names to begin with given DeptA and end with -LC", + displayName: "Enforce resource naming rules", + enforcementMode: "Default", + identity: { type: "SystemAssigned" }, + location: "eastus", + metadata: { assignedBy: "Foo Bar" }, + parameters: { prefix: {}, suffix: {} }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming" + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.create( + scope, + policyAssignmentName, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicyAssignmentWithASystemAssignedIdentity().catch( + console.error +); + +/** + * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignmentWithUserAssignedIdentity.json + */ +async function createOrUpdateAPolicyAssignmentWithAUserAssignedIdentity() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const parameters: PolicyAssignment = { + description: + "Force resource names to begin with given DeptA and end with -LC", + displayName: "Enforce resource naming rules", + enforcementMode: "Default", + identity: { + type: "UserAssigned", + userAssignedIdentities: { + "/subscriptions/ae640e6bBa3e42569d622993eecfa6f2/resourceGroups/testResourceGroup/providers/MicrosoftManagedIdentity/userAssignedIdentities/testIdentity": {} + } + }, + location: "eastus", + metadata: { assignedBy: "Foo Bar" }, + parameters: { prefix: {}, suffix: {} }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming" + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.create( + scope, + policyAssignmentName, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicyAssignmentWithAUserAssignedIdentity().catch(console.error); + +/** + * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignmentNonComplianceMessages.json + */ +async function createOrUpdateAPolicyAssignmentWithMultipleNonComplianceMessages() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "securityInitAssignment"; + const parameters: PolicyAssignment = { + displayName: "Enforce security policies", + nonComplianceMessages: [ + { + message: + "Resources must comply with all internal security policies. See for more info." + }, + { + message: "Resource names must start with 'DeptA' and end with '-LC'.", + policyDefinitionReferenceId: "10420126870854049575" + }, + { + message: "Storage accounts must have firewall rules configured.", + policyDefinitionReferenceId: "8572513655450389710" + } + ], + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/securityInitiative" + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.create( + scope, + policyAssignmentName, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicyAssignmentWithMultipleNonComplianceMessages().catch( + console.error +); + +/** + * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignmentWithoutEnforcement.json + */ +async function createOrUpdateAPolicyAssignmentWithoutEnforcingPolicyEffectDuringResourceCreationOrUpdate() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const parameters: PolicyAssignment = { + description: + "Force resource names to begin with given DeptA and end with -LC", + displayName: "Enforce resource naming rules", + enforcementMode: "DoNotEnforce", + metadata: { assignedBy: "Special Someone" }, + parameters: { prefix: {}, suffix: {} }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming" + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.create( + scope, + policyAssignmentName, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicyAssignmentWithoutEnforcingPolicyEffectDuringResourceCreationOrUpdate().catch( + console.error +); diff --git a/sdk/policy/arm-policy/samples-dev/policyAssignmentsDeleteByIdSample.ts b/sdk/policy/arm-policy/samples-dev/policyAssignmentsDeleteByIdSample.ts new file mode 100644 index 000000000000..d35b62115dc8 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyAssignmentsDeleteByIdSample.ts @@ -0,0 +1,30 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). + * + * @summary This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicyAssignmentById.json + */ +async function deleteAPolicyAssignmentById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyAssignmentId = + "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.deleteById(policyAssignmentId); + console.log(result); +} + +deleteAPolicyAssignmentById().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyAssignmentsDeleteSample.ts b/sdk/policy/arm-policy/samples-dev/policyAssignmentsDeleteSample.ts new file mode 100644 index 000000000000..e2976b8ac214 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyAssignmentsDeleteSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * + * @summary This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicyAssignment.json + */ +async function deleteAPolicyAssignment() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.delete( + scope, + policyAssignmentName + ); + console.log(result); +} + +deleteAPolicyAssignment().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyAssignmentsGetByIdSample.ts b/sdk/policy/arm-policy/samples-dev/policyAssignmentsGetByIdSample.ts new file mode 100644 index 000000000000..1733f93e2cd9 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyAssignmentsGetByIdSample.ts @@ -0,0 +1,48 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * + * @summary The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyAssignmentById.json + */ +async function retrieveAPolicyAssignmentById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyAssignmentId = + "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.getById(policyAssignmentId); + console.log(result); +} + +retrieveAPolicyAssignmentById().catch(console.error); + +/** + * This sample demonstrates how to The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * + * @summary The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyAssignmentWithIdentityById.json + */ +async function retrieveAPolicyAssignmentWithAManagedIdentityById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyAssignmentId = + "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.getById(policyAssignmentId); + console.log(result); +} + +retrieveAPolicyAssignmentWithAManagedIdentityById().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyAssignmentsGetSample.ts b/sdk/policy/arm-policy/samples-dev/policyAssignmentsGetSample.ts new file mode 100644 index 000000000000..0b98df70f83a --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyAssignmentsGetSample.ts @@ -0,0 +1,75 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at. + * + * @summary This operation retrieves a single policy assignment, given its name and the scope it was created at. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyAssignment.json + */ +async function retrieveAPolicyAssignment() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.get( + scope, + policyAssignmentName + ); + console.log(result); +} + +retrieveAPolicyAssignment().catch(console.error); + +/** + * This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at. + * + * @summary This operation retrieves a single policy assignment, given its name and the scope it was created at. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyAssignmentWithIdentity.json + */ +async function retrieveAPolicyAssignmentWithASystemAssignedIdentity() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.get( + scope, + policyAssignmentName + ); + console.log(result); +} + +retrieveAPolicyAssignmentWithASystemAssignedIdentity().catch(console.error); + +/** + * This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at. + * + * @summary This operation retrieves a single policy assignment, given its name and the scope it was created at. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyAssignmentWithUserAssignedIdentity.json + */ +async function retrieveAPolicyAssignmentWithAUserAssignedIdentity() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.get( + scope, + policyAssignmentName + ); + console.log(result); +} + +retrieveAPolicyAssignmentWithAUserAssignedIdentity().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyAssignmentsListForManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policyAssignmentsListForManagementGroupSample.ts new file mode 100644 index 000000000000..dacf306881b2 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyAssignmentsListForManagementGroupSample.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 { + PolicyAssignmentsListForManagementGroupOptionalParams, + PolicyClient +} from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. + * + * @summary This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyAssignmentsForManagementGroup.json + */ +async function listPolicyAssignmentsThatApplyToAManagementGroup() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const managementGroupId = "TestManagementGroup"; + const filter = "atScope()"; + const options: PolicyAssignmentsListForManagementGroupOptionalParams = { + filter + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyAssignments.listForManagementGroup( + managementGroupId, + options + )) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicyAssignmentsThatApplyToAManagementGroup().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyAssignmentsListForResourceGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policyAssignmentsListForResourceGroupSample.ts new file mode 100644 index 000000000000..43679b8ae4c8 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyAssignmentsListForResourceGroupSample.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 { + PolicyAssignmentsListForResourceGroupOptionalParams, + PolicyClient +} from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + * + * @summary This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyAssignmentsForResourceGroup.json + */ +async function listPolicyAssignmentsThatApplyToAResourceGroup() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const resourceGroupName = "TestResourceGroup"; + const filter = "atScope()"; + const options: PolicyAssignmentsListForResourceGroupOptionalParams = { + filter + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyAssignments.listForResourceGroup( + resourceGroupName, + options + )) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicyAssignmentsThatApplyToAResourceGroup().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyAssignmentsListForResourceSample.ts b/sdk/policy/arm-policy/samples-dev/policyAssignmentsListForResourceSample.ts new file mode 100644 index 000000000000..0d43e41446b9 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyAssignmentsListForResourceSample.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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * + * @summary This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyAssignmentsForResource.json + */ +async function listAllPolicyAssignmentsThatApplyToAResource() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const resourceGroupName = "TestResourceGroup"; + const resourceProviderNamespace = "Microsoft.Compute"; + const parentResourcePath = "virtualMachines/MyTestVm"; + const resourceType = "domainNames"; + const resourceName = "MyTestComputer.cloudapp.net"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyAssignments.listForResource( + resourceGroupName, + resourceProviderNamespace, + parentResourcePath, + resourceType, + resourceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listAllPolicyAssignmentsThatApplyToAResource().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyAssignmentsListSample.ts b/sdk/policy/arm-policy/samples-dev/policyAssignmentsListSample.ts new file mode 100644 index 000000000000..c3e9575f594c --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyAssignmentsListSample.ts @@ -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. +import { + PolicyAssignmentsListOptionalParams, + PolicyClient +} from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + * + * @summary This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyAssignments.json + */ +async function listPolicyAssignmentsThatApplyToASubscription() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const filter = "atScope()"; + const options: PolicyAssignmentsListOptionalParams = { filter }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyAssignments.list(options)) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicyAssignmentsThatApplyToASubscription().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyAssignmentsUpdateByIdSample.ts b/sdk/policy/arm-policy/samples-dev/policyAssignmentsUpdateByIdSample.ts new file mode 100644 index 000000000000..3f654336a500 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyAssignmentsUpdateByIdSample.ts @@ -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. +import { PolicyAssignmentUpdate, PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * + * @summary This operation updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/updatePolicyAssignmentWithIdentityById.json + */ +async function updatePolicyAssignmentWithAManagedIdentityById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyAssignmentId = + "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; + const parameters: PolicyAssignmentUpdate = { + identity: { type: "SystemAssigned" }, + location: "eastus" + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.updateById( + policyAssignmentId, + parameters + ); + console.log(result); +} + +updatePolicyAssignmentWithAManagedIdentityById().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyAssignmentsUpdateSample.ts b/sdk/policy/arm-policy/samples-dev/policyAssignmentsUpdateSample.ts new file mode 100644 index 000000000000..2c5ad77e13d0 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyAssignmentsUpdateSample.ts @@ -0,0 +1,69 @@ +/* + * 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 { PolicyAssignmentUpdate, PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/updatePolicyAssignmentWithIdentity.json + */ +async function updateAPolicyAssignmentWithASystemAssignedIdentity() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const parameters: PolicyAssignmentUpdate = { + identity: { type: "SystemAssigned" }, + location: "eastus" + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.update( + scope, + policyAssignmentName, + parameters + ); + console.log(result); +} + +updateAPolicyAssignmentWithASystemAssignedIdentity().catch(console.error); + +/** + * This sample demonstrates how to This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/updatePolicyAssignmentWithUserAssignedIdentity.json + */ +async function updateAPolicyAssignmentWithAUserAssignedIdentity() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const parameters: PolicyAssignmentUpdate = { + identity: { + type: "UserAssigned", + userAssignedIdentities: { + "/subscriptions/ae640e6bBa3e42569d622993eecfa6f2/resourceGroups/testResourceGroup/providers/MicrosoftManagedIdentity/userAssignedIdentities/testIdentity": {} + } + }, + location: "eastus" + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.update( + scope, + policyAssignmentName, + parameters + ); + console.log(result); +} + +updateAPolicyAssignmentWithAUserAssignedIdentity().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionsCreateOrUpdateAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionsCreateOrUpdateAtManagementGroupSample.ts new file mode 100644 index 000000000000..eb6f78d43180 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionsCreateOrUpdateAtManagementGroupSample.ts @@ -0,0 +1,60 @@ +/* + * 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 { PolicyDefinition, PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation creates or updates a policy definition in the given management group with the given name. + * + * @summary This operation creates or updates a policy definition in the given management group with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicyDefinitionAtManagementGroup.json + */ +async function createOrUpdateAPolicyDefinitionAtManagementGroupLevel() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyDefinitionName = "ResourceNaming"; + const managementGroupId = "MyManagementGroup"; + const parameters: PolicyDefinition = { + description: + "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", + displayName: "Enforce resource naming convention", + metadata: { category: "Naming" }, + mode: "All", + parameters: { + prefix: { + type: "String", + metadata: { description: "Resource name prefix", displayName: "Prefix" } + }, + suffix: { + type: "String", + metadata: { description: "Resource name suffix", displayName: "Suffix" } + } + }, + policyRule: { + if: { + not: { + field: "name", + like: "[concat(parameters('prefix'), '*', parameters('suffix'))]" + } + }, + then: { effect: "deny" } + } + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.createOrUpdateAtManagementGroup( + policyDefinitionName, + managementGroupId, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicyDefinitionAtManagementGroupLevel().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionsCreateOrUpdateSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..dc9d35597de9 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionsCreateOrUpdateSample.ts @@ -0,0 +1,117 @@ +/* + * 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 { PolicyDefinition, PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation creates or updates a policy definition in the given subscription with the given name. + * + * @summary This operation creates or updates a policy definition in the given subscription with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicyDefinition.json + */ +async function createOrUpdateAPolicyDefinition() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyDefinitionName = "ResourceNaming"; + const parameters: PolicyDefinition = { + description: + "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", + displayName: "Enforce resource naming convention", + metadata: { category: "Naming" }, + mode: "All", + parameters: { + prefix: { + type: "String", + metadata: { description: "Resource name prefix", displayName: "Prefix" } + }, + suffix: { + type: "String", + metadata: { description: "Resource name suffix", displayName: "Suffix" } + } + }, + policyRule: { + if: { + not: { + field: "name", + like: "[concat(parameters('prefix'), '*', parameters('suffix'))]" + } + }, + then: { effect: "deny" } + } + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.createOrUpdate( + policyDefinitionName, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicyDefinition().catch(console.error); + +/** + * This sample demonstrates how to This operation creates or updates a policy definition in the given subscription with the given name. + * + * @summary This operation creates or updates a policy definition in the given subscription with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicyDefinitionAdvancedParams.json + */ +async function createOrUpdateAPolicyDefinitionWithAdvancedParameters() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyDefinitionName = "EventHubDiagnosticLogs"; + const parameters: PolicyDefinition = { + description: + "Audit enabling of logs and retain them up to a year. This enables recreation of activity trails for investigation purposes when a security incident occurs or your network is compromised", + displayName: "Event Hubs should have diagnostic logging enabled", + metadata: { category: "Event Hub" }, + mode: "Indexed", + parameters: { + requiredRetentionDays: { + type: "Integer", + metadata: { + description: "The required diagnostic logs retention in days", + displayName: "Required retention (days)" + } + } + }, + policyRule: { + if: { equals: "Microsoft.EventHub/namespaces", field: "type" }, + then: { + effect: "AuditIfNotExists", + details: { + type: "Microsoft.Insights/diagnosticSettings", + existenceCondition: { + allOf: [ + { + equals: "true", + field: + "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.enabled" + }, + { + equals: "[parameters('requiredRetentionDays')]", + field: + "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.days" + } + ] + } + } + } + } + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.createOrUpdate( + policyDefinitionName, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicyDefinitionWithAdvancedParameters().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionsDeleteAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionsDeleteAtManagementGroupSample.ts new file mode 100644 index 000000000000..f21e0b672e3c --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionsDeleteAtManagementGroupSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation deletes the policy definition in the given management group with the given name. + * + * @summary This operation deletes the policy definition in the given management group with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicyDefinitionAtManagementGroup.json + */ +async function deleteAPolicyDefinitionAtManagementGroupLevel() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyDefinitionName = "ResourceNaming"; + const managementGroupId = "MyManagementGroup"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.deleteAtManagementGroup( + policyDefinitionName, + managementGroupId + ); + console.log(result); +} + +deleteAPolicyDefinitionAtManagementGroupLevel().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionsDeleteSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionsDeleteSample.ts new file mode 100644 index 000000000000..ba4d5422c2ae --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionsDeleteSample.ts @@ -0,0 +1,29 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation deletes the policy definition in the given subscription with the given name. + * + * @summary This operation deletes the policy definition in the given subscription with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicyDefinition.json + */ +async function deleteAPolicyDefinition() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyDefinitionName = "ResourceNaming"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.delete(policyDefinitionName); + console.log(result); +} + +deleteAPolicyDefinition().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionsGetAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionsGetAtManagementGroupSample.ts new file mode 100644 index 000000000000..27fcab9e3087 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionsGetAtManagementGroupSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the policy definition in the given management group with the given name. + * + * @summary This operation retrieves the policy definition in the given management group with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinitionAtManagementGroup.json + */ +async function retrieveAPolicyDefinitionAtManagementGroupLevel() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyDefinitionName = "ResourceNaming"; + const managementGroupId = "MyManagementGroup"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.getAtManagementGroup( + policyDefinitionName, + managementGroupId + ); + console.log(result); +} + +retrieveAPolicyDefinitionAtManagementGroupLevel().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionsGetBuiltInSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionsGetBuiltInSample.ts new file mode 100644 index 000000000000..f719a34a23bf --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionsGetBuiltInSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the built-in policy definition with the given name. + * + * @summary This operation retrieves the built-in policy definition with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getBuiltinPolicyDefinition.json + */ +async function retrieveABuiltInPolicyDefinition() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyDefinitionName = "7433c107-6db4-4ad1-b57a-a76dce0154a1"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.getBuiltIn( + policyDefinitionName + ); + console.log(result); +} + +retrieveABuiltInPolicyDefinition().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionsGetSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionsGetSample.ts new file mode 100644 index 000000000000..ce61f8060856 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionsGetSample.ts @@ -0,0 +1,29 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the policy definition in the given subscription with the given name. + * + * @summary This operation retrieves the policy definition in the given subscription with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinition.json + */ +async function retrieveAPolicyDefinition() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyDefinitionName = "ResourceNaming"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.get(policyDefinitionName); + console.log(result); +} + +retrieveAPolicyDefinition().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionsListBuiltInSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionsListBuiltInSample.ts new file mode 100644 index 000000000000..b565261b76cf --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionsListBuiltInSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves a list of all the built-in policy definitions that match the optional given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose category match the {value}. + * + * @summary This operation retrieves a list of all the built-in policy definitions that match the optional given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose category match the {value}. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listBuiltInPolicyDefinitions.json + */ +async function listBuiltInPolicyDefinitions() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyDefinitions.listBuiltIn()) { + resArray.push(item); + } + console.log(resArray); +} + +listBuiltInPolicyDefinitions().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionsListByManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionsListByManagementGroupSample.ts new file mode 100644 index 000000000000..0d588d20df2b --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionsListByManagementGroupSample.ts @@ -0,0 +1,34 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves a list of all the policy definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. + * + * @summary This operation retrieves a list of all the policy definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyDefinitionsByManagementGroup.json + */ +async function listPolicyDefinitionsByManagementGroup() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const managementGroupId = "MyManagementGroup"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyDefinitions.listByManagementGroup( + managementGroupId + )) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicyDefinitionsByManagementGroup().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyDefinitionsListSample.ts b/sdk/policy/arm-policy/samples-dev/policyDefinitionsListSample.ts new file mode 100644 index 000000000000..b98016d43e38 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyDefinitionsListSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves a list of all the policy definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. + * + * @summary This operation retrieves a list of all the policy definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyDefinitions.json + */ +async function listPolicyDefinitionsBySubscription() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyDefinitions.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicyDefinitionsBySubscription().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyExemptionsCreateOrUpdateSample.ts b/sdk/policy/arm-policy/samples-dev/policyExemptionsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..d8baa98d0f63 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyExemptionsCreateOrUpdateSample.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 { PolicyExemption, PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation creates or updates a policy exemption with the given scope and name. Policy exemptions apply to all resources contained within their scope. For example, when you create a policy exemption at resource group scope for a policy assignment at the same or above level, the exemption exempts to all applicable resources in the resource group. + * + * @summary This operation creates or updates a policy exemption with the given scope and name. Policy exemptions apply to all resources contained within their scope. For example, when you create a policy exemption at resource group scope for a policy assignment at the same or above level, the exemption exempts to all applicable resources in the resource group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/createOrUpdatePolicyExemption.json + */ +async function createOrUpdateAPolicyExemption() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster"; + const policyExemptionName = "DemoExpensiveVM"; + const parameters: PolicyExemption = { + description: "Exempt demo cluster from limit sku", + displayName: "Exempt demo cluster", + exemptionCategory: "Waiver", + metadata: { reason: "Temporary exemption for a expensive VM demo" }, + policyAssignmentId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement", + policyDefinitionReferenceIds: ["Limit_Skus"] + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyExemptions.createOrUpdate( + scope, + policyExemptionName, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicyExemption().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyExemptionsDeleteSample.ts b/sdk/policy/arm-policy/samples-dev/policyExemptionsDeleteSample.ts new file mode 100644 index 000000000000..333235e2aff4 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyExemptionsDeleteSample.ts @@ -0,0 +1,34 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation deletes a policy exemption, given its name and the scope it was created in. The scope of a policy exemption is the part of its ID preceding '/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'. + * + * @summary This operation deletes a policy exemption, given its name and the scope it was created in. The scope of a policy exemption is the part of its ID preceding '/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/deletePolicyExemption.json + */ +async function deleteAPolicyExemption() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster"; + const policyExemptionName = "DemoExpensiveVM"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyExemptions.delete( + scope, + policyExemptionName + ); + console.log(result); +} + +deleteAPolicyExemption().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyExemptionsGetSample.ts b/sdk/policy/arm-policy/samples-dev/policyExemptionsGetSample.ts new file mode 100644 index 000000000000..04416e7965c0 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyExemptionsGetSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves a single policy exemption, given its name and the scope it was created at. + * + * @summary This operation retrieves a single policy exemption, given its name and the scope it was created at. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/getPolicyExemption.json + */ +async function retrieveAPolicyExemption() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster"; + const policyExemptionName = "DemoExpensiveVM"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyExemptions.get(scope, policyExemptionName); + console.log(result); +} + +retrieveAPolicyExemption().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyExemptionsListForManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policyExemptionsListForManagementGroupSample.ts new file mode 100644 index 000000000000..7efc527ef9a4 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyExemptionsListForManagementGroupSample.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 { + PolicyExemptionsListForManagementGroupOptionalParams, + PolicyClient +} from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the list of all policy exemptions applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy exemptions that are assigned to the management group or the management group's ancestors. + * + * @summary This operation retrieves the list of all policy exemptions applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy exemptions that are assigned to the management group or the management group's ancestors. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/listPolicyExemptionsForManagementGroup.json + */ +async function listPolicyExemptionsThatApplyToAManagementGroup() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const managementGroupId = "DevOrg"; + const filter = "atScope()"; + const options: PolicyExemptionsListForManagementGroupOptionalParams = { + filter + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyExemptions.listForManagementGroup( + managementGroupId, + options + )) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicyExemptionsThatApplyToAManagementGroup().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyExemptionsListForResourceGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policyExemptionsListForResourceGroupSample.ts new file mode 100644 index 000000000000..71b11bd79266 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyExemptionsListForResourceGroupSample.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 { + PolicyExemptionsListForResourceGroupOptionalParams, + PolicyClient +} from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the list of all policy exemptions associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. + * + * @summary This operation retrieves the list of all policy exemptions associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/listPolicyExemptionsForResourceGroup.json + */ +async function listPolicyExemptionsThatApplyToAResourceGroup() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const resourceGroupName = "TestResourceGroup"; + const filter = "atScope()"; + const options: PolicyExemptionsListForResourceGroupOptionalParams = { + filter + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyExemptions.listForResourceGroup( + resourceGroupName, + options + )) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicyExemptionsThatApplyToAResourceGroup().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyExemptionsListForResourceSample.ts b/sdk/policy/arm-policy/samples-dev/policyExemptionsListForResourceSample.ts new file mode 100644 index 000000000000..d244bccee220 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyExemptionsListForResourceSample.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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the list of all policy exemptions associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * + * @summary This operation retrieves the list of all policy exemptions associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/listPolicyExemptionsForResource.json + */ +async function listAllPolicyExemptionsThatApplyToAResource() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const resourceGroupName = "TestResourceGroup"; + const resourceProviderNamespace = "Microsoft.Compute"; + const parentResourcePath = "virtualMachines/MyTestVm"; + const resourceType = "domainNames"; + const resourceName = "MyTestComputer.cloudapp.net"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyExemptions.listForResource( + resourceGroupName, + resourceProviderNamespace, + parentResourcePath, + resourceType, + resourceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listAllPolicyExemptionsThatApplyToAResource().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policyExemptionsListSample.ts b/sdk/policy/arm-policy/samples-dev/policyExemptionsListSample.ts new file mode 100644 index 000000000000..60c1219dbbf3 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policyExemptionsListSample.ts @@ -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. +import { + PolicyExemptionsListOptionalParams, + PolicyClient +} from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the list of all policy exemptions associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. + * + * @summary This operation retrieves the list of all policy exemptions associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/listPolicyExemptionsForSubscription.json + */ +async function listPolicyExemptionsThatApplyToASubscription() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const filter = "atScope()"; + const options: PolicyExemptionsListOptionalParams = { filter }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyExemptions.list(options)) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicyExemptionsThatApplyToASubscription().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.ts new file mode 100644 index 000000000000..401b6b4f47a6 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.ts @@ -0,0 +1,116 @@ +/* + * 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 { PolicySetDefinition, PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation creates or updates a policy set definition in the given management group with the given name. + * + * @summary This operation creates or updates a policy set definition in the given management group with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinitionAtManagementGroup.json + */ +async function createOrUpdateAPolicySetDefinitionAtManagementGroupLevel() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policySetDefinitionName = "CostManagement"; + const managementGroupId = "MyManagementGroup"; + const parameters: PolicySetDefinition = { + description: "Policies to enforce low cost storage SKUs", + displayName: "Cost Management", + metadata: { category: "Cost Management" }, + policyDefinitions: [ + { + parameters: { + listOfAllowedSKUs: {} + }, + policyDefinitionId: + "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + policyDefinitionReferenceId: "Limit_Skus" + }, + { + parameters: { prefix: {}, suffix: {} }, + policyDefinitionId: + "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + policyDefinitionReferenceId: "Resource_Naming" + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.createOrUpdateAtManagementGroup( + policySetDefinitionName, + managementGroupId, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicySetDefinitionAtManagementGroupLevel().catch(console.error); + +/** + * This sample demonstrates how to This operation creates or updates a policy set definition in the given management group with the given name. + * + * @summary This operation creates or updates a policy set definition in the given management group with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinitionWithGroupsAtManagementGroup.json + */ +async function createOrUpdateAPolicySetDefinitionWithGroupsAtManagementGroupLevel() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policySetDefinitionName = "CostManagement"; + const managementGroupId = "MyManagementGroup"; + const parameters: PolicySetDefinition = { + description: "Policies to enforce low cost storage SKUs", + displayName: "Cost Management", + metadata: { category: "Cost Management" }, + policyDefinitionGroups: [ + { + name: "CostSaving", + description: + "Policies designed to control spend within a subscription.", + displayName: "Cost Management Policies" + }, + { + name: "Organizational", + description: + "Policies that help enforce resource organization standards within a subscription.", + displayName: "Organizational Policies" + } + ], + policyDefinitions: [ + { + groupNames: ["CostSaving"], + parameters: { + listOfAllowedSKUs: {} + }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + policyDefinitionReferenceId: "Limit_Skus" + }, + { + groupNames: ["Organizational"], + parameters: { prefix: {}, suffix: {} }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + policyDefinitionReferenceId: "Resource_Naming" + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.createOrUpdateAtManagementGroup( + policySetDefinitionName, + managementGroupId, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicySetDefinitionWithGroupsAtManagementGroupLevel().catch( + console.error +); diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsCreateOrUpdateSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..84c58398d239 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsCreateOrUpdateSample.ts @@ -0,0 +1,116 @@ +/* + * 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 { PolicySetDefinition, PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation creates or updates a policy set definition in the given subscription with the given name. + * + * @summary This operation creates or updates a policy set definition in the given subscription with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinition.json + */ +async function createOrUpdateAPolicySetDefinition() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policySetDefinitionName = "CostManagement"; + const parameters: PolicySetDefinition = { + description: "Policies to enforce low cost storage SKUs", + displayName: "Cost Management", + metadata: { category: "Cost Management" }, + parameters: { + namePrefix: {} + }, + policyDefinitions: [ + { + parameters: { + listOfAllowedSKUs: {} + }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + policyDefinitionReferenceId: "Limit_Skus" + }, + { + parameters: { + prefix: {}, + suffix: {} + }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + policyDefinitionReferenceId: "Resource_Naming" + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.createOrUpdate( + policySetDefinitionName, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicySetDefinition().catch(console.error); + +/** + * This sample demonstrates how to This operation creates or updates a policy set definition in the given subscription with the given name. + * + * @summary This operation creates or updates a policy set definition in the given subscription with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinitionWithGroups.json + */ +async function createOrUpdateAPolicySetDefinitionWithGroups() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policySetDefinitionName = "CostManagement"; + const parameters: PolicySetDefinition = { + description: "Policies to enforce low cost storage SKUs", + displayName: "Cost Management", + metadata: { category: "Cost Management" }, + policyDefinitionGroups: [ + { + name: "CostSaving", + description: + "Policies designed to control spend within a subscription.", + displayName: "Cost Management Policies" + }, + { + name: "Organizational", + description: + "Policies that help enforce resource organization standards within a subscription.", + displayName: "Organizational Policies" + } + ], + policyDefinitions: [ + { + groupNames: ["CostSaving"], + parameters: { + listOfAllowedSKUs: {} + }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + policyDefinitionReferenceId: "Limit_Skus" + }, + { + groupNames: ["Organizational"], + parameters: { prefix: {}, suffix: {} }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + policyDefinitionReferenceId: "Resource_Naming" + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.createOrUpdate( + policySetDefinitionName, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicySetDefinitionWithGroups().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsDeleteAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsDeleteAtManagementGroupSample.ts new file mode 100644 index 000000000000..049650909401 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsDeleteAtManagementGroupSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation deletes the policy set definition in the given management group with the given name. + * + * @summary This operation deletes the policy set definition in the given management group with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicySetDefinitionAtManagementGroup.json + */ +async function deleteAPolicySetDefinitionAtManagementGroupLevel() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policySetDefinitionName = "CostManagement"; + const managementGroupId = "MyManagementGroup"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.deleteAtManagementGroup( + policySetDefinitionName, + managementGroupId + ); + console.log(result); +} + +deleteAPolicySetDefinitionAtManagementGroupLevel().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsDeleteSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsDeleteSample.ts new file mode 100644 index 000000000000..f677be46c467 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsDeleteSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation deletes the policy set definition in the given subscription with the given name. + * + * @summary This operation deletes the policy set definition in the given subscription with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicySetDefinition.json + */ +async function deleteAPolicySetDefinition() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policySetDefinitionName = "CostManagement"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.delete( + policySetDefinitionName + ); + console.log(result); +} + +deleteAPolicySetDefinition().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsGetAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsGetAtManagementGroupSample.ts new file mode 100644 index 000000000000..5bc3ae6bc005 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsGetAtManagementGroupSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the policy set definition in the given management group with the given name. + * + * @summary This operation retrieves the policy set definition in the given management group with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinitionAtManagementGroup.json + */ +async function retrieveAPolicySetDefinitionAtManagementGroupLevel() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policySetDefinitionName = "CostManagement"; + const managementGroupId = "MyManagementGroup"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.getAtManagementGroup( + policySetDefinitionName, + managementGroupId + ); + console.log(result); +} + +retrieveAPolicySetDefinitionAtManagementGroupLevel().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsGetBuiltInSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsGetBuiltInSample.ts new file mode 100644 index 000000000000..eaa2ab035acc --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsGetBuiltInSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the built-in policy set definition with the given name. + * + * @summary This operation retrieves the built-in policy set definition with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getBuiltInPolicySetDefinition.json + */ +async function retrieveABuiltInPolicySetDefinition() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policySetDefinitionName = "1f3afdf9-d0c9-4c3d-847f-89da613e70a8"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.getBuiltIn( + policySetDefinitionName + ); + console.log(result); +} + +retrieveABuiltInPolicySetDefinition().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsGetSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsGetSample.ts new file mode 100644 index 000000000000..f157eb34c168 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsGetSample.ts @@ -0,0 +1,29 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the policy set definition in the given subscription with the given name. + * + * @summary This operation retrieves the policy set definition in the given subscription with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinition.json + */ +async function retrieveAPolicySetDefinition() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policySetDefinitionName = "CostManagement"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.get(policySetDefinitionName); + console.log(result); +} + +retrieveAPolicySetDefinition().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsListBuiltInSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsListBuiltInSample.ts new file mode 100644 index 000000000000..39c0fa42c3b7 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsListBuiltInSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves a list of all the built-in policy set definitions that match the optional given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy set definitions whose category match the {value}. + * + * @summary This operation retrieves a list of all the built-in policy set definitions that match the optional given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy set definitions whose category match the {value}. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listBuiltInPolicySetDefinitions.json + */ +async function listBuiltInPolicySetDefinitions() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policySetDefinitions.listBuiltIn()) { + resArray.push(item); + } + console.log(resArray); +} + +listBuiltInPolicySetDefinitions().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsListByManagementGroupSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsListByManagementGroupSample.ts new file mode 100644 index 000000000000..7ad9f07b3d79 --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsListByManagementGroupSample.ts @@ -0,0 +1,34 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves a list of all the policy set definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. + * + * @summary This operation retrieves a list of all the policy set definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicySetDefinitionsByManagementGroup.json + */ +async function listPolicySetDefinitionsAtManagementGroupLevel() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const managementGroupId = "MyManagementGroup"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policySetDefinitions.listByManagementGroup( + managementGroupId + )) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicySetDefinitionsAtManagementGroupLevel().catch(console.error); diff --git a/sdk/policy/arm-policy/samples-dev/policySetDefinitionsListSample.ts b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsListSample.ts new file mode 100644 index 000000000000..9f7ffe53961a --- /dev/null +++ b/sdk/policy/arm-policy/samples-dev/policySetDefinitionsListSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves a list of all the policy set definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. + * + * @summary This operation retrieves a list of all the policy set definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicySetDefinitions.json + */ +async function listPolicySetDefinitions() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policySetDefinitions.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicySetDefinitions().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/README.md b/sdk/policy/arm-policy/samples/v5/javascript/README.md new file mode 100644 index 000000000000..b1831cc8fae5 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/README.md @@ -0,0 +1,130 @@ +# client library samples for JavaScript + +These sample programs show how to use the JavaScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| ------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [dataPolicyManifestsGetByPolicyModeSample.js][datapolicymanifestsgetbypolicymodesample] | This operation retrieves the data policy manifest with the given policy mode. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/getDataPolicyManifest.json | +| [dataPolicyManifestsListSample.js][datapolicymanifestslistsample] | This operation retrieves a list of all the data policy manifests that match the optional given $filter. Valid values for $filter are: "$filter=namespace eq '{0}'". If $filter is not provided, the unfiltered list includes all data policy manifests for data resource types. If $filter=namespace is provided, the returned list only includes all data policy manifests that have a namespace matching the provided value. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/listDataPolicyManifests.json | +| [policyAssignmentsCreateByIdSample.js][policyassignmentscreatebyidsample] | This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignmentById.json | +| [policyAssignmentsCreateSample.js][policyassignmentscreatesample] | This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignment.json | +| [policyAssignmentsDeleteByIdSample.js][policyassignmentsdeletebyidsample] | This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicyAssignmentById.json | +| [policyAssignmentsDeleteSample.js][policyassignmentsdeletesample] | This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicyAssignment.json | +| [policyAssignmentsGetByIdSample.js][policyassignmentsgetbyidsample] | The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyAssignmentById.json | +| [policyAssignmentsGetSample.js][policyassignmentsgetsample] | This operation retrieves a single policy assignment, given its name and the scope it was created at. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyAssignment.json | +| [policyAssignmentsListForManagementGroupSample.js][policyassignmentslistformanagementgroupsample] | This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyAssignmentsForManagementGroup.json | +| [policyAssignmentsListForResourceGroupSample.js][policyassignmentslistforresourcegroupsample] | This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyAssignmentsForResourceGroup.json | +| [policyAssignmentsListForResourceSample.js][policyassignmentslistforresourcesample] | This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyAssignmentsForResource.json | +| [policyAssignmentsListSample.js][policyassignmentslistsample] | This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyAssignments.json | +| [policyAssignmentsUpdateByIdSample.js][policyassignmentsupdatebyidsample] | This operation updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/updatePolicyAssignmentWithIdentityById.json | +| [policyAssignmentsUpdateSample.js][policyassignmentsupdatesample] | This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/updatePolicyAssignmentWithIdentity.json | +| [policyDefinitionsCreateOrUpdateAtManagementGroupSample.js][policydefinitionscreateorupdateatmanagementgroupsample] | This operation creates or updates a policy definition in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicyDefinitionAtManagementGroup.json | +| [policyDefinitionsCreateOrUpdateSample.js][policydefinitionscreateorupdatesample] | This operation creates or updates a policy definition in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicyDefinition.json | +| [policyDefinitionsDeleteAtManagementGroupSample.js][policydefinitionsdeleteatmanagementgroupsample] | This operation deletes the policy definition in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicyDefinitionAtManagementGroup.json | +| [policyDefinitionsDeleteSample.js][policydefinitionsdeletesample] | This operation deletes the policy definition in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicyDefinition.json | +| [policyDefinitionsGetAtManagementGroupSample.js][policydefinitionsgetatmanagementgroupsample] | This operation retrieves the policy definition in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinitionAtManagementGroup.json | +| [policyDefinitionsGetBuiltInSample.js][policydefinitionsgetbuiltinsample] | This operation retrieves the built-in policy definition with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getBuiltinPolicyDefinition.json | +| [policyDefinitionsGetSample.js][policydefinitionsgetsample] | This operation retrieves the policy definition in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinition.json | +| [policyDefinitionsListBuiltInSample.js][policydefinitionslistbuiltinsample] | This operation retrieves a list of all the built-in policy definitions that match the optional given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose category match the {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listBuiltInPolicyDefinitions.json | +| [policyDefinitionsListByManagementGroupSample.js][policydefinitionslistbymanagementgroupsample] | This operation retrieves a list of all the policy definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyDefinitionsByManagementGroup.json | +| [policyDefinitionsListSample.js][policydefinitionslistsample] | This operation retrieves a list of all the policy definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyDefinitions.json | +| [policyExemptionsCreateOrUpdateSample.js][policyexemptionscreateorupdatesample] | This operation creates or updates a policy exemption with the given scope and name. Policy exemptions apply to all resources contained within their scope. For example, when you create a policy exemption at resource group scope for a policy assignment at the same or above level, the exemption exempts to all applicable resources in the resource group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/createOrUpdatePolicyExemption.json | +| [policyExemptionsDeleteSample.js][policyexemptionsdeletesample] | This operation deletes a policy exemption, given its name and the scope it was created in. The scope of a policy exemption is the part of its ID preceding '/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/deletePolicyExemption.json | +| [policyExemptionsGetSample.js][policyexemptionsgetsample] | This operation retrieves a single policy exemption, given its name and the scope it was created at. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/getPolicyExemption.json | +| [policyExemptionsListForManagementGroupSample.js][policyexemptionslistformanagementgroupsample] | This operation retrieves the list of all policy exemptions applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy exemptions that are assigned to the management group or the management group's ancestors. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/listPolicyExemptionsForManagementGroup.json | +| [policyExemptionsListForResourceGroupSample.js][policyexemptionslistforresourcegroupsample] | This operation retrieves the list of all policy exemptions associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/listPolicyExemptionsForResourceGroup.json | +| [policyExemptionsListForResourceSample.js][policyexemptionslistforresourcesample] | This operation retrieves the list of all policy exemptions associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/listPolicyExemptionsForResource.json | +| [policyExemptionsListSample.js][policyexemptionslistsample] | This operation retrieves the list of all policy exemptions associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/listPolicyExemptionsForSubscription.json | +| [policySetDefinitionsCreateOrUpdateAtManagementGroupSample.js][policysetdefinitionscreateorupdateatmanagementgroupsample] | This operation creates or updates a policy set definition in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinitionAtManagementGroup.json | +| [policySetDefinitionsCreateOrUpdateSample.js][policysetdefinitionscreateorupdatesample] | This operation creates or updates a policy set definition in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinition.json | +| [policySetDefinitionsDeleteAtManagementGroupSample.js][policysetdefinitionsdeleteatmanagementgroupsample] | This operation deletes the policy set definition in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicySetDefinitionAtManagementGroup.json | +| [policySetDefinitionsDeleteSample.js][policysetdefinitionsdeletesample] | This operation deletes the policy set definition in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicySetDefinition.json | +| [policySetDefinitionsGetAtManagementGroupSample.js][policysetdefinitionsgetatmanagementgroupsample] | This operation retrieves the policy set definition in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinitionAtManagementGroup.json | +| [policySetDefinitionsGetBuiltInSample.js][policysetdefinitionsgetbuiltinsample] | This operation retrieves the built-in policy set definition with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getBuiltInPolicySetDefinition.json | +| [policySetDefinitionsGetSample.js][policysetdefinitionsgetsample] | This operation retrieves the policy set definition in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinition.json | +| [policySetDefinitionsListBuiltInSample.js][policysetdefinitionslistbuiltinsample] | This operation retrieves a list of all the built-in policy set definitions that match the optional given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy set definitions whose category match the {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listBuiltInPolicySetDefinitions.json | +| [policySetDefinitionsListByManagementGroupSample.js][policysetdefinitionslistbymanagementgroupsample] | This operation retrieves a list of all the policy set definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicySetDefinitionsByManagementGroup.json | +| [policySetDefinitionsListSample.js][policysetdefinitionslistsample] | This operation retrieves a list of all the policy set definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicySetDefinitions.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +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 dataPolicyManifestsGetByPolicyModeSample.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 node dataPolicyManifestsGetByPolicyModeSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[datapolicymanifestsgetbypolicymodesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/dataPolicyManifestsGetByPolicyModeSample.js +[datapolicymanifestslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/dataPolicyManifestsListSample.js +[policyassignmentscreatebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsCreateByIdSample.js +[policyassignmentscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsCreateSample.js +[policyassignmentsdeletebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsDeleteByIdSample.js +[policyassignmentsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsDeleteSample.js +[policyassignmentsgetbyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsGetByIdSample.js +[policyassignmentsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsGetSample.js +[policyassignmentslistformanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsListForManagementGroupSample.js +[policyassignmentslistforresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsListForResourceGroupSample.js +[policyassignmentslistforresourcesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsListForResourceSample.js +[policyassignmentslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsListSample.js +[policyassignmentsupdatebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsUpdateByIdSample.js +[policyassignmentsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsUpdateSample.js +[policydefinitionscreateorupdateatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsCreateOrUpdateAtManagementGroupSample.js +[policydefinitionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsCreateOrUpdateSample.js +[policydefinitionsdeleteatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsDeleteAtManagementGroupSample.js +[policydefinitionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsDeleteSample.js +[policydefinitionsgetatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsGetAtManagementGroupSample.js +[policydefinitionsgetbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsGetBuiltInSample.js +[policydefinitionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsGetSample.js +[policydefinitionslistbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsListBuiltInSample.js +[policydefinitionslistbymanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsListByManagementGroupSample.js +[policydefinitionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsListSample.js +[policyexemptionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsCreateOrUpdateSample.js +[policyexemptionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsDeleteSample.js +[policyexemptionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsGetSample.js +[policyexemptionslistformanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsListForManagementGroupSample.js +[policyexemptionslistforresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsListForResourceGroupSample.js +[policyexemptionslistforresourcesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsListForResourceSample.js +[policyexemptionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsListSample.js +[policysetdefinitionscreateorupdateatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.js +[policysetdefinitionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsCreateOrUpdateSample.js +[policysetdefinitionsdeleteatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsDeleteAtManagementGroupSample.js +[policysetdefinitionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsDeleteSample.js +[policysetdefinitionsgetatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsGetAtManagementGroupSample.js +[policysetdefinitionsgetbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsGetBuiltInSample.js +[policysetdefinitionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsGetSample.js +[policysetdefinitionslistbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsListBuiltInSample.js +[policysetdefinitionslistbymanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsListByManagementGroupSample.js +[policysetdefinitionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsListSample.js +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-policy?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/policy/arm-policy/README.md diff --git a/sdk/policy/arm-policy/samples/v5/javascript/dataPolicyManifestsGetByPolicyModeSample.js b/sdk/policy/arm-policy/samples/v5/javascript/dataPolicyManifestsGetByPolicyModeSample.js new file mode 100644 index 000000000000..e434bd96f694 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/dataPolicyManifestsGetByPolicyModeSample.js @@ -0,0 +1,29 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation retrieves the data policy manifest with the given policy mode. + * + * @summary This operation retrieves the data policy manifest with the given policy mode. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/getDataPolicyManifest.json + */ +async function retrieveADataPolicyManifestByPolicyMode() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyMode = "Microsoft.KeyVault.Data"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.dataPolicyManifests.getByPolicyMode(policyMode); + console.log(result); +} + +retrieveADataPolicyManifestByPolicyMode().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/dataPolicyManifestsListSample.js b/sdk/policy/arm-policy/samples/v5/javascript/dataPolicyManifestsListSample.js new file mode 100644 index 000000000000..ead1d7d79fa9 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/dataPolicyManifestsListSample.js @@ -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. +const { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation retrieves a list of all the data policy manifests that match the optional given $filter. Valid values for $filter are: "$filter=namespace eq '{0}'". If $filter is not provided, the unfiltered list includes all data policy manifests for data resource types. If $filter=namespace is provided, the returned list only includes all data policy manifests that have a namespace matching the provided value. + * + * @summary This operation retrieves a list of all the data policy manifests that match the optional given $filter. Valid values for $filter are: "$filter=namespace eq '{0}'". If $filter is not provided, the unfiltered list includes all data policy manifests for data resource types. If $filter=namespace is provided, the returned list only includes all data policy manifests that have a namespace matching the provided value. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/listDataPolicyManifests.json + */ +async function listDataPolicyManifests() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.dataPolicyManifests.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listDataPolicyManifests().catch(console.error); + +/** + * This sample demonstrates how to This operation retrieves a list of all the data policy manifests that match the optional given $filter. Valid values for $filter are: "$filter=namespace eq '{0}'". If $filter is not provided, the unfiltered list includes all data policy manifests for data resource types. If $filter=namespace is provided, the returned list only includes all data policy manifests that have a namespace matching the provided value. + * + * @summary This operation retrieves a list of all the data policy manifests that match the optional given $filter. Valid values for $filter are: "$filter=namespace eq '{0}'". If $filter is not provided, the unfiltered list includes all data policy manifests for data resource types. If $filter=namespace is provided, the returned list only includes all data policy manifests that have a namespace matching the provided value. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/listDataPolicyManifestsNamespaceFilter.json + */ +async function listDataPolicyManifestsWithNamespaceFilter() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const filter = "namespace eq 'Microsoft.KeyVault'"; + const options = { filter }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.dataPolicyManifests.list(options)) { + resArray.push(item); + } + console.log(resArray); +} + +listDataPolicyManifestsWithNamespaceFilter().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/package.json b/sdk/policy/arm-policy/samples/v5/javascript/package.json new file mode 100644 index 000000000000..475787f5a7e8 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/package.json @@ -0,0 +1,32 @@ +{ + "name": "@azure-samples/arm-policy-js", + "private": true, + "version": "1.0.0", + "description": " client library samples for JavaScript", + "engines": { + "node": ">=12.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/policy/arm-policy" + }, + "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/policy/arm-policy", + "dependencies": { + "@azure/arm-policy": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + } +} diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsCreateByIdSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsCreateByIdSample.js new file mode 100644 index 000000000000..628884071a17 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsCreateByIdSample.js @@ -0,0 +1,72 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * + * @summary This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignmentById.json + */ +async function createOrUpdatePolicyAssignmentById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyAssignmentId = + "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; + const parameters = { + description: "Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created", + displayName: "Enforce storage account SKU", + enforcementMode: "Default", + metadata: { assignedBy: "Cheapskate Boss" }, + parameters: { + listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, + }, + policyDefinitionId: + "/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.createById(policyAssignmentId, parameters); + console.log(result); +} + +createOrUpdatePolicyAssignmentById().catch(console.error); + +/** + * This sample demonstrates how to This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * + * @summary This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignmentWithIdentityById.json + */ +async function createOrUpdatePolicyAssignmentWithAManagedIdentityById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyAssignmentId = + "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; + const parameters = { + description: "Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created", + displayName: "Enforce storage account SKU", + enforcementMode: "Default", + identity: { type: "SystemAssigned" }, + location: "eastus", + metadata: { assignedBy: "Cheapskate Boss" }, + parameters: { + listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, + }, + policyDefinitionId: + "/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.createById(policyAssignmentId, parameters); + console.log(result); +} + +createOrUpdatePolicyAssignmentWithAManagedIdentityById().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsCreateSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsCreateSample.js new file mode 100644 index 000000000000..b2ee6242e0b1 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsCreateSample.js @@ -0,0 +1,171 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignment.json + */ +async function createOrUpdateAPolicyAssignment() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const parameters = { + description: "Force resource names to begin with given DeptA and end with -LC", + displayName: "Enforce resource naming rules", + metadata: { assignedBy: "Special Someone" }, + nonComplianceMessages: [ + { message: "Resource names must start with 'DeptA' and end with '-LC'." }, + ], + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.create(scope, policyAssignmentName, parameters); + console.log(result); +} + +createOrUpdateAPolicyAssignment().catch(console.error); + +/** + * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignmentWithIdentity.json + */ +async function createOrUpdateAPolicyAssignmentWithASystemAssignedIdentity() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const parameters = { + description: "Force resource names to begin with given DeptA and end with -LC", + displayName: "Enforce resource naming rules", + enforcementMode: "Default", + identity: { type: "SystemAssigned" }, + location: "eastus", + metadata: { assignedBy: "Foo Bar" }, + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.create(scope, policyAssignmentName, parameters); + console.log(result); +} + +createOrUpdateAPolicyAssignmentWithASystemAssignedIdentity().catch(console.error); + +/** + * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignmentWithUserAssignedIdentity.json + */ +async function createOrUpdateAPolicyAssignmentWithAUserAssignedIdentity() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const parameters = { + description: "Force resource names to begin with given DeptA and end with -LC", + displayName: "Enforce resource naming rules", + enforcementMode: "Default", + identity: { + type: "UserAssigned", + userAssignedIdentities: { + "/subscriptions/ae640e6bBa3e42569d622993eecfa6f2/resourceGroups/testResourceGroup/providers/MicrosoftManagedIdentity/userAssignedIdentities/testIdentity": + {}, + }, + }, + location: "eastus", + metadata: { assignedBy: "Foo Bar" }, + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.create(scope, policyAssignmentName, parameters); + console.log(result); +} + +createOrUpdateAPolicyAssignmentWithAUserAssignedIdentity().catch(console.error); + +/** + * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignmentNonComplianceMessages.json + */ +async function createOrUpdateAPolicyAssignmentWithMultipleNonComplianceMessages() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "securityInitAssignment"; + const parameters = { + displayName: "Enforce security policies", + nonComplianceMessages: [ + { + message: + "Resources must comply with all internal security policies. See for more info.", + }, + { + message: "Resource names must start with 'DeptA' and end with '-LC'.", + policyDefinitionReferenceId: "10420126870854049575", + }, + { + message: "Storage accounts must have firewall rules configured.", + policyDefinitionReferenceId: "8572513655450389710", + }, + ], + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/securityInitiative", + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.create(scope, policyAssignmentName, parameters); + console.log(result); +} + +createOrUpdateAPolicyAssignmentWithMultipleNonComplianceMessages().catch(console.error); + +/** + * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignmentWithoutEnforcement.json + */ +async function createOrUpdateAPolicyAssignmentWithoutEnforcingPolicyEffectDuringResourceCreationOrUpdate() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const parameters = { + description: "Force resource names to begin with given DeptA and end with -LC", + displayName: "Enforce resource naming rules", + enforcementMode: "DoNotEnforce", + metadata: { assignedBy: "Special Someone" }, + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.create(scope, policyAssignmentName, parameters); + console.log(result); +} + +createOrUpdateAPolicyAssignmentWithoutEnforcingPolicyEffectDuringResourceCreationOrUpdate().catch( + console.error +); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsDeleteByIdSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsDeleteByIdSample.js new file mode 100644 index 000000000000..28bd13e3bf6a --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsDeleteByIdSample.js @@ -0,0 +1,30 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). + * + * @summary This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicyAssignmentById.json + */ +async function deleteAPolicyAssignmentById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyAssignmentId = + "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.deleteById(policyAssignmentId); + console.log(result); +} + +deleteAPolicyAssignmentById().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsDeleteSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsDeleteSample.js new file mode 100644 index 000000000000..9f955d4ff856 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsDeleteSample.js @@ -0,0 +1,30 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * + * @summary This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicyAssignment.json + */ +async function deleteAPolicyAssignment() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.delete(scope, policyAssignmentName); + console.log(result); +} + +deleteAPolicyAssignment().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsGetByIdSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsGetByIdSample.js new file mode 100644 index 000000000000..23eb9d549953 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsGetByIdSample.js @@ -0,0 +1,48 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * + * @summary The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyAssignmentById.json + */ +async function retrieveAPolicyAssignmentById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyAssignmentId = + "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.getById(policyAssignmentId); + console.log(result); +} + +retrieveAPolicyAssignmentById().catch(console.error); + +/** + * This sample demonstrates how to The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * + * @summary The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyAssignmentWithIdentityById.json + */ +async function retrieveAPolicyAssignmentWithAManagedIdentityById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyAssignmentId = + "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.getById(policyAssignmentId); + console.log(result); +} + +retrieveAPolicyAssignmentWithAManagedIdentityById().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsGetSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsGetSample.js new file mode 100644 index 000000000000..b0667ec71e34 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsGetSample.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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at. + * + * @summary This operation retrieves a single policy assignment, given its name and the scope it was created at. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyAssignment.json + */ +async function retrieveAPolicyAssignment() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.get(scope, policyAssignmentName); + console.log(result); +} + +retrieveAPolicyAssignment().catch(console.error); + +/** + * This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at. + * + * @summary This operation retrieves a single policy assignment, given its name and the scope it was created at. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyAssignmentWithIdentity.json + */ +async function retrieveAPolicyAssignmentWithASystemAssignedIdentity() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.get(scope, policyAssignmentName); + console.log(result); +} + +retrieveAPolicyAssignmentWithASystemAssignedIdentity().catch(console.error); + +/** + * This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at. + * + * @summary This operation retrieves a single policy assignment, given its name and the scope it was created at. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyAssignmentWithUserAssignedIdentity.json + */ +async function retrieveAPolicyAssignmentWithAUserAssignedIdentity() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.get(scope, policyAssignmentName); + console.log(result); +} + +retrieveAPolicyAssignmentWithAUserAssignedIdentity().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsListForManagementGroupSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsListForManagementGroupSample.js new file mode 100644 index 000000000000..16744fdc4d72 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsListForManagementGroupSample.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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. + * + * @summary This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyAssignmentsForManagementGroup.json + */ +async function listPolicyAssignmentsThatApplyToAManagementGroup() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const managementGroupId = "TestManagementGroup"; + const filter = "atScope()"; + const options = { + filter, + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyAssignments.listForManagementGroup( + managementGroupId, + options + )) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicyAssignmentsThatApplyToAManagementGroup().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsListForResourceGroupSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsListForResourceGroupSample.js new file mode 100644 index 000000000000..c699aea3df68 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsListForResourceGroupSample.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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + * + * @summary This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyAssignmentsForResourceGroup.json + */ +async function listPolicyAssignmentsThatApplyToAResourceGroup() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const resourceGroupName = "TestResourceGroup"; + const filter = "atScope()"; + const options = { + filter, + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyAssignments.listForResourceGroup( + resourceGroupName, + options + )) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicyAssignmentsThatApplyToAResourceGroup().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsListForResourceSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsListForResourceSample.js new file mode 100644 index 000000000000..8311c9d34011 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsListForResourceSample.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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * + * @summary This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyAssignmentsForResource.json + */ +async function listAllPolicyAssignmentsThatApplyToAResource() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const resourceGroupName = "TestResourceGroup"; + const resourceProviderNamespace = "Microsoft.Compute"; + const parentResourcePath = "virtualMachines/MyTestVm"; + const resourceType = "domainNames"; + const resourceName = "MyTestComputer.cloudapp.net"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyAssignments.listForResource( + resourceGroupName, + resourceProviderNamespace, + parentResourcePath, + resourceType, + resourceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listAllPolicyAssignmentsThatApplyToAResource().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsListSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsListSample.js new file mode 100644 index 000000000000..01b74d637f23 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsListSample.js @@ -0,0 +1,33 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + * + * @summary This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyAssignments.json + */ +async function listPolicyAssignmentsThatApplyToASubscription() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const filter = "atScope()"; + const options = { filter }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyAssignments.list(options)) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicyAssignmentsThatApplyToASubscription().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsUpdateByIdSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsUpdateByIdSample.js new file mode 100644 index 000000000000..86078b842424 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsUpdateByIdSample.js @@ -0,0 +1,34 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * + * @summary This operation updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/updatePolicyAssignmentWithIdentityById.json + */ +async function updatePolicyAssignmentWithAManagedIdentityById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyAssignmentId = + "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; + const parameters = { + identity: { type: "SystemAssigned" }, + location: "eastus", + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.updateById(policyAssignmentId, parameters); + console.log(result); +} + +updatePolicyAssignmentWithAManagedIdentityById().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsUpdateSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsUpdateSample.js new file mode 100644 index 000000000000..8465244f6d08 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyAssignmentsUpdateSample.js @@ -0,0 +1,62 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/updatePolicyAssignmentWithIdentity.json + */ +async function updateAPolicyAssignmentWithASystemAssignedIdentity() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const parameters = { + identity: { type: "SystemAssigned" }, + location: "eastus", + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.update(scope, policyAssignmentName, parameters); + console.log(result); +} + +updateAPolicyAssignmentWithASystemAssignedIdentity().catch(console.error); + +/** + * This sample demonstrates how to This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/updatePolicyAssignmentWithUserAssignedIdentity.json + */ +async function updateAPolicyAssignmentWithAUserAssignedIdentity() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const parameters = { + identity: { + type: "UserAssigned", + userAssignedIdentities: { + "/subscriptions/ae640e6bBa3e42569d622993eecfa6f2/resourceGroups/testResourceGroup/providers/MicrosoftManagedIdentity/userAssignedIdentities/testIdentity": + {}, + }, + }, + location: "eastus", + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.update(scope, policyAssignmentName, parameters); + console.log(result); +} + +updateAPolicyAssignmentWithAUserAssignedIdentity().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsCreateOrUpdateAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsCreateOrUpdateAtManagementGroupSample.js new file mode 100644 index 000000000000..2204a61d30e1 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsCreateOrUpdateAtManagementGroupSample.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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation creates or updates a policy definition in the given management group with the given name. + * + * @summary This operation creates or updates a policy definition in the given management group with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicyDefinitionAtManagementGroup.json + */ +async function createOrUpdateAPolicyDefinitionAtManagementGroupLevel() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyDefinitionName = "ResourceNaming"; + const managementGroupId = "MyManagementGroup"; + const parameters = { + description: "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", + displayName: "Enforce resource naming convention", + metadata: { category: "Naming" }, + mode: "All", + parameters: { + prefix: { + type: "String", + metadata: { description: "Resource name prefix", displayName: "Prefix" }, + }, + suffix: { + type: "String", + metadata: { description: "Resource name suffix", displayName: "Suffix" }, + }, + }, + policyRule: { + if: { + not: { + field: "name", + like: "[concat(parameters('prefix'), '*', parameters('suffix'))]", + }, + }, + then: { effect: "deny" }, + }, + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.createOrUpdateAtManagementGroup( + policyDefinitionName, + managementGroupId, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicyDefinitionAtManagementGroupLevel().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsCreateOrUpdateSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsCreateOrUpdateSample.js new file mode 100644 index 000000000000..847afc4944d2 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsCreateOrUpdateSample.js @@ -0,0 +1,110 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation creates or updates a policy definition in the given subscription with the given name. + * + * @summary This operation creates or updates a policy definition in the given subscription with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicyDefinition.json + */ +async function createOrUpdateAPolicyDefinition() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyDefinitionName = "ResourceNaming"; + const parameters = { + description: "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", + displayName: "Enforce resource naming convention", + metadata: { category: "Naming" }, + mode: "All", + parameters: { + prefix: { + type: "String", + metadata: { description: "Resource name prefix", displayName: "Prefix" }, + }, + suffix: { + type: "String", + metadata: { description: "Resource name suffix", displayName: "Suffix" }, + }, + }, + policyRule: { + if: { + not: { + field: "name", + like: "[concat(parameters('prefix'), '*', parameters('suffix'))]", + }, + }, + then: { effect: "deny" }, + }, + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.createOrUpdate(policyDefinitionName, parameters); + console.log(result); +} + +createOrUpdateAPolicyDefinition().catch(console.error); + +/** + * This sample demonstrates how to This operation creates or updates a policy definition in the given subscription with the given name. + * + * @summary This operation creates or updates a policy definition in the given subscription with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicyDefinitionAdvancedParams.json + */ +async function createOrUpdateAPolicyDefinitionWithAdvancedParameters() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyDefinitionName = "EventHubDiagnosticLogs"; + const parameters = { + description: + "Audit enabling of logs and retain them up to a year. This enables recreation of activity trails for investigation purposes when a security incident occurs or your network is compromised", + displayName: "Event Hubs should have diagnostic logging enabled", + metadata: { category: "Event Hub" }, + mode: "Indexed", + parameters: { + requiredRetentionDays: { + type: "Integer", + allowedValues: [0, 30, 90, 180, 365], + defaultValue: 365, + metadata: { + description: "The required diagnostic logs retention in days", + displayName: "Required retention (days)", + }, + }, + }, + policyRule: { + if: { equals: "Microsoft.EventHub/namespaces", field: "type" }, + then: { + effect: "AuditIfNotExists", + details: { + type: "Microsoft.Insights/diagnosticSettings", + existenceCondition: { + allOf: [ + { + equals: "true", + field: "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.enabled", + }, + { + equals: "[parameters('requiredRetentionDays')]", + field: "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.days", + }, + ], + }, + }, + }, + }, + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.createOrUpdate(policyDefinitionName, parameters); + console.log(result); +} + +createOrUpdateAPolicyDefinitionWithAdvancedParameters().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsDeleteAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsDeleteAtManagementGroupSample.js new file mode 100644 index 000000000000..6b847c0826f7 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsDeleteAtManagementGroupSample.js @@ -0,0 +1,33 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation deletes the policy definition in the given management group with the given name. + * + * @summary This operation deletes the policy definition in the given management group with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicyDefinitionAtManagementGroup.json + */ +async function deleteAPolicyDefinitionAtManagementGroupLevel() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyDefinitionName = "ResourceNaming"; + const managementGroupId = "MyManagementGroup"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.deleteAtManagementGroup( + policyDefinitionName, + managementGroupId + ); + console.log(result); +} + +deleteAPolicyDefinitionAtManagementGroupLevel().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsDeleteSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsDeleteSample.js new file mode 100644 index 000000000000..e938da8a4b02 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsDeleteSample.js @@ -0,0 +1,29 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation deletes the policy definition in the given subscription with the given name. + * + * @summary This operation deletes the policy definition in the given subscription with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicyDefinition.json + */ +async function deleteAPolicyDefinition() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyDefinitionName = "ResourceNaming"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.delete(policyDefinitionName); + console.log(result); +} + +deleteAPolicyDefinition().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsGetAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsGetAtManagementGroupSample.js new file mode 100644 index 000000000000..2a3c6f40536f --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsGetAtManagementGroupSample.js @@ -0,0 +1,33 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation retrieves the policy definition in the given management group with the given name. + * + * @summary This operation retrieves the policy definition in the given management group with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinitionAtManagementGroup.json + */ +async function retrieveAPolicyDefinitionAtManagementGroupLevel() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyDefinitionName = "ResourceNaming"; + const managementGroupId = "MyManagementGroup"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.getAtManagementGroup( + policyDefinitionName, + managementGroupId + ); + console.log(result); +} + +retrieveAPolicyDefinitionAtManagementGroupLevel().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsGetBuiltInSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsGetBuiltInSample.js new file mode 100644 index 000000000000..49d4d57cc05a --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsGetBuiltInSample.js @@ -0,0 +1,29 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation retrieves the built-in policy definition with the given name. + * + * @summary This operation retrieves the built-in policy definition with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getBuiltinPolicyDefinition.json + */ +async function retrieveABuiltInPolicyDefinition() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyDefinitionName = "7433c107-6db4-4ad1-b57a-a76dce0154a1"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.getBuiltIn(policyDefinitionName); + console.log(result); +} + +retrieveABuiltInPolicyDefinition().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsGetSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsGetSample.js new file mode 100644 index 000000000000..5b93fe00a2e4 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsGetSample.js @@ -0,0 +1,29 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation retrieves the policy definition in the given subscription with the given name. + * + * @summary This operation retrieves the policy definition in the given subscription with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinition.json + */ +async function retrieveAPolicyDefinition() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyDefinitionName = "ResourceNaming"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.get(policyDefinitionName); + console.log(result); +} + +retrieveAPolicyDefinition().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsListBuiltInSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsListBuiltInSample.js new file mode 100644 index 000000000000..5fed649ed8e0 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsListBuiltInSample.js @@ -0,0 +1,31 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation retrieves a list of all the built-in policy definitions that match the optional given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose category match the {value}. + * + * @summary This operation retrieves a list of all the built-in policy definitions that match the optional given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose category match the {value}. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listBuiltInPolicyDefinitions.json + */ +async function listBuiltInPolicyDefinitions() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyDefinitions.listBuiltIn()) { + resArray.push(item); + } + console.log(resArray); +} + +listBuiltInPolicyDefinitions().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsListByManagementGroupSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsListByManagementGroupSample.js new file mode 100644 index 000000000000..939dc7af0244 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsListByManagementGroupSample.js @@ -0,0 +1,32 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation retrieves a list of all the policy definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. + * + * @summary This operation retrieves a list of all the policy definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyDefinitionsByManagementGroup.json + */ +async function listPolicyDefinitionsByManagementGroup() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const managementGroupId = "MyManagementGroup"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyDefinitions.listByManagementGroup(managementGroupId)) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicyDefinitionsByManagementGroup().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsListSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsListSample.js new file mode 100644 index 000000000000..da8a8b0acad1 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyDefinitionsListSample.js @@ -0,0 +1,31 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation retrieves a list of all the policy definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. + * + * @summary This operation retrieves a list of all the policy definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyDefinitions.json + */ +async function listPolicyDefinitionsBySubscription() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyDefinitions.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicyDefinitionsBySubscription().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsCreateOrUpdateSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsCreateOrUpdateSample.js new file mode 100644 index 000000000000..77a5b5871cf4 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsCreateOrUpdateSample.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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation creates or updates a policy exemption with the given scope and name. Policy exemptions apply to all resources contained within their scope. For example, when you create a policy exemption at resource group scope for a policy assignment at the same or above level, the exemption exempts to all applicable resources in the resource group. + * + * @summary This operation creates or updates a policy exemption with the given scope and name. Policy exemptions apply to all resources contained within their scope. For example, when you create a policy exemption at resource group scope for a policy assignment at the same or above level, the exemption exempts to all applicable resources in the resource group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/createOrUpdatePolicyExemption.json + */ +async function createOrUpdateAPolicyExemption() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster"; + const policyExemptionName = "DemoExpensiveVM"; + const parameters = { + description: "Exempt demo cluster from limit sku", + displayName: "Exempt demo cluster", + exemptionCategory: "Waiver", + metadata: { reason: "Temporary exemption for a expensive VM demo" }, + policyAssignmentId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement", + policyDefinitionReferenceIds: ["Limit_Skus"], + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyExemptions.createOrUpdate( + scope, + policyExemptionName, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicyExemption().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsDeleteSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsDeleteSample.js new file mode 100644 index 000000000000..ca947377201e --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsDeleteSample.js @@ -0,0 +1,30 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation deletes a policy exemption, given its name and the scope it was created in. The scope of a policy exemption is the part of its ID preceding '/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'. + * + * @summary This operation deletes a policy exemption, given its name and the scope it was created in. The scope of a policy exemption is the part of its ID preceding '/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/deletePolicyExemption.json + */ +async function deleteAPolicyExemption() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster"; + const policyExemptionName = "DemoExpensiveVM"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyExemptions.delete(scope, policyExemptionName); + console.log(result); +} + +deleteAPolicyExemption().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsGetSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsGetSample.js new file mode 100644 index 000000000000..db8555d7bdcb --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsGetSample.js @@ -0,0 +1,30 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation retrieves a single policy exemption, given its name and the scope it was created at. + * + * @summary This operation retrieves a single policy exemption, given its name and the scope it was created at. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/getPolicyExemption.json + */ +async function retrieveAPolicyExemption() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster"; + const policyExemptionName = "DemoExpensiveVM"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyExemptions.get(scope, policyExemptionName); + console.log(result); +} + +retrieveAPolicyExemption().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsListForManagementGroupSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsListForManagementGroupSample.js new file mode 100644 index 000000000000..72b2cb070e56 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsListForManagementGroupSample.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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation retrieves the list of all policy exemptions applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy exemptions that are assigned to the management group or the management group's ancestors. + * + * @summary This operation retrieves the list of all policy exemptions applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy exemptions that are assigned to the management group or the management group's ancestors. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/listPolicyExemptionsForManagementGroup.json + */ +async function listPolicyExemptionsThatApplyToAManagementGroup() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const managementGroupId = "DevOrg"; + const filter = "atScope()"; + const options = { + filter, + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyExemptions.listForManagementGroup( + managementGroupId, + options + )) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicyExemptionsThatApplyToAManagementGroup().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsListForResourceGroupSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsListForResourceGroupSample.js new file mode 100644 index 000000000000..b941162a00b2 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsListForResourceGroupSample.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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation retrieves the list of all policy exemptions associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. + * + * @summary This operation retrieves the list of all policy exemptions associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/listPolicyExemptionsForResourceGroup.json + */ +async function listPolicyExemptionsThatApplyToAResourceGroup() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const resourceGroupName = "TestResourceGroup"; + const filter = "atScope()"; + const options = { + filter, + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyExemptions.listForResourceGroup(resourceGroupName, options)) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicyExemptionsThatApplyToAResourceGroup().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsListForResourceSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsListForResourceSample.js new file mode 100644 index 000000000000..d715078b25a9 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsListForResourceSample.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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation retrieves the list of all policy exemptions associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * + * @summary This operation retrieves the list of all policy exemptions associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/listPolicyExemptionsForResource.json + */ +async function listAllPolicyExemptionsThatApplyToAResource() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const resourceGroupName = "TestResourceGroup"; + const resourceProviderNamespace = "Microsoft.Compute"; + const parentResourcePath = "virtualMachines/MyTestVm"; + const resourceType = "domainNames"; + const resourceName = "MyTestComputer.cloudapp.net"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyExemptions.listForResource( + resourceGroupName, + resourceProviderNamespace, + parentResourcePath, + resourceType, + resourceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listAllPolicyExemptionsThatApplyToAResource().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsListSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsListSample.js new file mode 100644 index 000000000000..f2e8c684c1aa --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policyExemptionsListSample.js @@ -0,0 +1,33 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation retrieves the list of all policy exemptions associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. + * + * @summary This operation retrieves the list of all policy exemptions associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/listPolicyExemptionsForSubscription.json + */ +async function listPolicyExemptionsThatApplyToASubscription() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const filter = "atScope()"; + const options = { filter }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyExemptions.list(options)) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicyExemptionsThatApplyToASubscription().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.js new file mode 100644 index 000000000000..2c3fd91a824d --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.js @@ -0,0 +1,113 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation creates or updates a policy set definition in the given management group with the given name. + * + * @summary This operation creates or updates a policy set definition in the given management group with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinitionAtManagementGroup.json + */ +async function createOrUpdateAPolicySetDefinitionAtManagementGroupLevel() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policySetDefinitionName = "CostManagement"; + const managementGroupId = "MyManagementGroup"; + const parameters = { + description: "Policies to enforce low cost storage SKUs", + displayName: "Cost Management", + metadata: { category: "Cost Management" }, + policyDefinitions: [ + { + parameters: { + listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, + }, + policyDefinitionId: + "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + policyDefinitionReferenceId: "Limit_Skus", + }, + { + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + policyDefinitionReferenceId: "Resource_Naming", + }, + ], + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.createOrUpdateAtManagementGroup( + policySetDefinitionName, + managementGroupId, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicySetDefinitionAtManagementGroupLevel().catch(console.error); + +/** + * This sample demonstrates how to This operation creates or updates a policy set definition in the given management group with the given name. + * + * @summary This operation creates or updates a policy set definition in the given management group with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinitionWithGroupsAtManagementGroup.json + */ +async function createOrUpdateAPolicySetDefinitionWithGroupsAtManagementGroupLevel() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policySetDefinitionName = "CostManagement"; + const managementGroupId = "MyManagementGroup"; + const parameters = { + description: "Policies to enforce low cost storage SKUs", + displayName: "Cost Management", + metadata: { category: "Cost Management" }, + policyDefinitionGroups: [ + { + name: "CostSaving", + description: "Policies designed to control spend within a subscription.", + displayName: "Cost Management Policies", + }, + { + name: "Organizational", + description: + "Policies that help enforce resource organization standards within a subscription.", + displayName: "Organizational Policies", + }, + ], + policyDefinitions: [ + { + groupNames: ["CostSaving"], + parameters: { + listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, + }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + policyDefinitionReferenceId: "Limit_Skus", + }, + { + groupNames: ["Organizational"], + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + policyDefinitionReferenceId: "Resource_Naming", + }, + ], + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.createOrUpdateAtManagementGroup( + policySetDefinitionName, + managementGroupId, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicySetDefinitionWithGroupsAtManagementGroupLevel().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsCreateOrUpdateSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsCreateOrUpdateSample.js new file mode 100644 index 000000000000..c21849cfae97 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsCreateOrUpdateSample.js @@ -0,0 +1,119 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation creates or updates a policy set definition in the given subscription with the given name. + * + * @summary This operation creates or updates a policy set definition in the given subscription with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinition.json + */ +async function createOrUpdateAPolicySetDefinition() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policySetDefinitionName = "CostManagement"; + const parameters = { + description: "Policies to enforce low cost storage SKUs", + displayName: "Cost Management", + metadata: { category: "Cost Management" }, + parameters: { + namePrefix: { + type: "String", + defaultValue: "myPrefix", + metadata: { displayName: "Prefix to enforce on resource names" }, + }, + }, + policyDefinitions: [ + { + parameters: { + listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, + }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + policyDefinitionReferenceId: "Limit_Skus", + }, + { + parameters: { + prefix: { value: "[parameters('namePrefix')]" }, + suffix: { value: "-LC" }, + }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + policyDefinitionReferenceId: "Resource_Naming", + }, + ], + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.createOrUpdate( + policySetDefinitionName, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicySetDefinition().catch(console.error); + +/** + * This sample demonstrates how to This operation creates or updates a policy set definition in the given subscription with the given name. + * + * @summary This operation creates or updates a policy set definition in the given subscription with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinitionWithGroups.json + */ +async function createOrUpdateAPolicySetDefinitionWithGroups() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policySetDefinitionName = "CostManagement"; + const parameters = { + description: "Policies to enforce low cost storage SKUs", + displayName: "Cost Management", + metadata: { category: "Cost Management" }, + policyDefinitionGroups: [ + { + name: "CostSaving", + description: "Policies designed to control spend within a subscription.", + displayName: "Cost Management Policies", + }, + { + name: "Organizational", + description: + "Policies that help enforce resource organization standards within a subscription.", + displayName: "Organizational Policies", + }, + ], + policyDefinitions: [ + { + groupNames: ["CostSaving"], + parameters: { + listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] }, + }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + policyDefinitionReferenceId: "Limit_Skus", + }, + { + groupNames: ["Organizational"], + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + policyDefinitionReferenceId: "Resource_Naming", + }, + ], + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.createOrUpdate( + policySetDefinitionName, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicySetDefinitionWithGroups().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsDeleteAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsDeleteAtManagementGroupSample.js new file mode 100644 index 000000000000..1505ed63eb38 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsDeleteAtManagementGroupSample.js @@ -0,0 +1,33 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation deletes the policy set definition in the given management group with the given name. + * + * @summary This operation deletes the policy set definition in the given management group with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicySetDefinitionAtManagementGroup.json + */ +async function deleteAPolicySetDefinitionAtManagementGroupLevel() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policySetDefinitionName = "CostManagement"; + const managementGroupId = "MyManagementGroup"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.deleteAtManagementGroup( + policySetDefinitionName, + managementGroupId + ); + console.log(result); +} + +deleteAPolicySetDefinitionAtManagementGroupLevel().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsDeleteSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsDeleteSample.js new file mode 100644 index 000000000000..82c0bbdf4037 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsDeleteSample.js @@ -0,0 +1,29 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation deletes the policy set definition in the given subscription with the given name. + * + * @summary This operation deletes the policy set definition in the given subscription with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicySetDefinition.json + */ +async function deleteAPolicySetDefinition() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policySetDefinitionName = "CostManagement"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.delete(policySetDefinitionName); + console.log(result); +} + +deleteAPolicySetDefinition().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsGetAtManagementGroupSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsGetAtManagementGroupSample.js new file mode 100644 index 000000000000..470ff8e6957a --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsGetAtManagementGroupSample.js @@ -0,0 +1,33 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation retrieves the policy set definition in the given management group with the given name. + * + * @summary This operation retrieves the policy set definition in the given management group with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinitionAtManagementGroup.json + */ +async function retrieveAPolicySetDefinitionAtManagementGroupLevel() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policySetDefinitionName = "CostManagement"; + const managementGroupId = "MyManagementGroup"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.getAtManagementGroup( + policySetDefinitionName, + managementGroupId + ); + console.log(result); +} + +retrieveAPolicySetDefinitionAtManagementGroupLevel().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsGetBuiltInSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsGetBuiltInSample.js new file mode 100644 index 000000000000..05a606ff70d1 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsGetBuiltInSample.js @@ -0,0 +1,29 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation retrieves the built-in policy set definition with the given name. + * + * @summary This operation retrieves the built-in policy set definition with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getBuiltInPolicySetDefinition.json + */ +async function retrieveABuiltInPolicySetDefinition() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policySetDefinitionName = "1f3afdf9-d0c9-4c3d-847f-89da613e70a8"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.getBuiltIn(policySetDefinitionName); + console.log(result); +} + +retrieveABuiltInPolicySetDefinition().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsGetSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsGetSample.js new file mode 100644 index 000000000000..fc3ee534ddc4 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsGetSample.js @@ -0,0 +1,29 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation retrieves the policy set definition in the given subscription with the given name. + * + * @summary This operation retrieves the policy set definition in the given subscription with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinition.json + */ +async function retrieveAPolicySetDefinition() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policySetDefinitionName = "CostManagement"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.get(policySetDefinitionName); + console.log(result); +} + +retrieveAPolicySetDefinition().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsListBuiltInSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsListBuiltInSample.js new file mode 100644 index 000000000000..7a549d2479dc --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsListBuiltInSample.js @@ -0,0 +1,31 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation retrieves a list of all the built-in policy set definitions that match the optional given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy set definitions whose category match the {value}. + * + * @summary This operation retrieves a list of all the built-in policy set definitions that match the optional given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy set definitions whose category match the {value}. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listBuiltInPolicySetDefinitions.json + */ +async function listBuiltInPolicySetDefinitions() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policySetDefinitions.listBuiltIn()) { + resArray.push(item); + } + console.log(resArray); +} + +listBuiltInPolicySetDefinitions().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsListByManagementGroupSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsListByManagementGroupSample.js new file mode 100644 index 000000000000..5021224359a1 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsListByManagementGroupSample.js @@ -0,0 +1,32 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation retrieves a list of all the policy set definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. + * + * @summary This operation retrieves a list of all the policy set definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicySetDefinitionsByManagementGroup.json + */ +async function listPolicySetDefinitionsAtManagementGroupLevel() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const managementGroupId = "MyManagementGroup"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policySetDefinitions.listByManagementGroup(managementGroupId)) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicySetDefinitionsAtManagementGroupLevel().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsListSample.js b/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsListSample.js new file mode 100644 index 000000000000..ede475ffeaac --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/javascript/policySetDefinitionsListSample.js @@ -0,0 +1,31 @@ +/* + * 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 { PolicyClient } = require("@azure/arm-policy"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation retrieves a list of all the policy set definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. + * + * @summary This operation retrieves a list of all the policy set definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicySetDefinitions.json + */ +async function listPolicySetDefinitions() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policySetDefinitions.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicySetDefinitions().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/javascript/sample.env b/sdk/policy/arm-policy/samples/v5/javascript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/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/policy/arm-policy/samples/v5/typescript/README.md b/sdk/policy/arm-policy/samples/v5/typescript/README.md new file mode 100644 index 000000000000..7e9d4d53249a --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/README.md @@ -0,0 +1,143 @@ +# client library samples for TypeScript + +These sample programs show how to use the TypeScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| ------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [dataPolicyManifestsGetByPolicyModeSample.ts][datapolicymanifestsgetbypolicymodesample] | This operation retrieves the data policy manifest with the given policy mode. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/getDataPolicyManifest.json | +| [dataPolicyManifestsListSample.ts][datapolicymanifestslistsample] | This operation retrieves a list of all the data policy manifests that match the optional given $filter. Valid values for $filter are: "$filter=namespace eq '{0}'". If $filter is not provided, the unfiltered list includes all data policy manifests for data resource types. If $filter=namespace is provided, the returned list only includes all data policy manifests that have a namespace matching the provided value. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/listDataPolicyManifests.json | +| [policyAssignmentsCreateByIdSample.ts][policyassignmentscreatebyidsample] | This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignmentById.json | +| [policyAssignmentsCreateSample.ts][policyassignmentscreatesample] | This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignment.json | +| [policyAssignmentsDeleteByIdSample.ts][policyassignmentsdeletebyidsample] | This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicyAssignmentById.json | +| [policyAssignmentsDeleteSample.ts][policyassignmentsdeletesample] | This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicyAssignment.json | +| [policyAssignmentsGetByIdSample.ts][policyassignmentsgetbyidsample] | The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyAssignmentById.json | +| [policyAssignmentsGetSample.ts][policyassignmentsgetsample] | This operation retrieves a single policy assignment, given its name and the scope it was created at. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyAssignment.json | +| [policyAssignmentsListForManagementGroupSample.ts][policyassignmentslistformanagementgroupsample] | This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyAssignmentsForManagementGroup.json | +| [policyAssignmentsListForResourceGroupSample.ts][policyassignmentslistforresourcegroupsample] | This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyAssignmentsForResourceGroup.json | +| [policyAssignmentsListForResourceSample.ts][policyassignmentslistforresourcesample] | This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyAssignmentsForResource.json | +| [policyAssignmentsListSample.ts][policyassignmentslistsample] | This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyAssignments.json | +| [policyAssignmentsUpdateByIdSample.ts][policyassignmentsupdatebyidsample] | This operation updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/updatePolicyAssignmentWithIdentityById.json | +| [policyAssignmentsUpdateSample.ts][policyassignmentsupdatesample] | This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/updatePolicyAssignmentWithIdentity.json | +| [policyDefinitionsCreateOrUpdateAtManagementGroupSample.ts][policydefinitionscreateorupdateatmanagementgroupsample] | This operation creates or updates a policy definition in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicyDefinitionAtManagementGroup.json | +| [policyDefinitionsCreateOrUpdateSample.ts][policydefinitionscreateorupdatesample] | This operation creates or updates a policy definition in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicyDefinition.json | +| [policyDefinitionsDeleteAtManagementGroupSample.ts][policydefinitionsdeleteatmanagementgroupsample] | This operation deletes the policy definition in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicyDefinitionAtManagementGroup.json | +| [policyDefinitionsDeleteSample.ts][policydefinitionsdeletesample] | This operation deletes the policy definition in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicyDefinition.json | +| [policyDefinitionsGetAtManagementGroupSample.ts][policydefinitionsgetatmanagementgroupsample] | This operation retrieves the policy definition in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinitionAtManagementGroup.json | +| [policyDefinitionsGetBuiltInSample.ts][policydefinitionsgetbuiltinsample] | This operation retrieves the built-in policy definition with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getBuiltinPolicyDefinition.json | +| [policyDefinitionsGetSample.ts][policydefinitionsgetsample] | This operation retrieves the policy definition in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinition.json | +| [policyDefinitionsListBuiltInSample.ts][policydefinitionslistbuiltinsample] | This operation retrieves a list of all the built-in policy definitions that match the optional given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose category match the {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listBuiltInPolicyDefinitions.json | +| [policyDefinitionsListByManagementGroupSample.ts][policydefinitionslistbymanagementgroupsample] | This operation retrieves a list of all the policy definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyDefinitionsByManagementGroup.json | +| [policyDefinitionsListSample.ts][policydefinitionslistsample] | This operation retrieves a list of all the policy definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyDefinitions.json | +| [policyExemptionsCreateOrUpdateSample.ts][policyexemptionscreateorupdatesample] | This operation creates or updates a policy exemption with the given scope and name. Policy exemptions apply to all resources contained within their scope. For example, when you create a policy exemption at resource group scope for a policy assignment at the same or above level, the exemption exempts to all applicable resources in the resource group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/createOrUpdatePolicyExemption.json | +| [policyExemptionsDeleteSample.ts][policyexemptionsdeletesample] | This operation deletes a policy exemption, given its name and the scope it was created in. The scope of a policy exemption is the part of its ID preceding '/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/deletePolicyExemption.json | +| [policyExemptionsGetSample.ts][policyexemptionsgetsample] | This operation retrieves a single policy exemption, given its name and the scope it was created at. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/getPolicyExemption.json | +| [policyExemptionsListForManagementGroupSample.ts][policyexemptionslistformanagementgroupsample] | This operation retrieves the list of all policy exemptions applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy exemptions that are assigned to the management group or the management group's ancestors. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/listPolicyExemptionsForManagementGroup.json | +| [policyExemptionsListForResourceGroupSample.ts][policyexemptionslistforresourcegroupsample] | This operation retrieves the list of all policy exemptions associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/listPolicyExemptionsForResourceGroup.json | +| [policyExemptionsListForResourceSample.ts][policyexemptionslistforresourcesample] | This operation retrieves the list of all policy exemptions associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/listPolicyExemptionsForResource.json | +| [policyExemptionsListSample.ts][policyexemptionslistsample] | This operation retrieves the list of all policy exemptions associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/listPolicyExemptionsForSubscription.json | +| [policySetDefinitionsCreateOrUpdateAtManagementGroupSample.ts][policysetdefinitionscreateorupdateatmanagementgroupsample] | This operation creates or updates a policy set definition in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinitionAtManagementGroup.json | +| [policySetDefinitionsCreateOrUpdateSample.ts][policysetdefinitionscreateorupdatesample] | This operation creates or updates a policy set definition in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinition.json | +| [policySetDefinitionsDeleteAtManagementGroupSample.ts][policysetdefinitionsdeleteatmanagementgroupsample] | This operation deletes the policy set definition in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicySetDefinitionAtManagementGroup.json | +| [policySetDefinitionsDeleteSample.ts][policysetdefinitionsdeletesample] | This operation deletes the policy set definition in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicySetDefinition.json | +| [policySetDefinitionsGetAtManagementGroupSample.ts][policysetdefinitionsgetatmanagementgroupsample] | This operation retrieves the policy set definition in the given management group with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinitionAtManagementGroup.json | +| [policySetDefinitionsGetBuiltInSample.ts][policysetdefinitionsgetbuiltinsample] | This operation retrieves the built-in policy set definition with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getBuiltInPolicySetDefinition.json | +| [policySetDefinitionsGetSample.ts][policysetdefinitionsgetsample] | This operation retrieves the policy set definition in the given subscription with the given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinition.json | +| [policySetDefinitionsListBuiltInSample.ts][policysetdefinitionslistbuiltinsample] | This operation retrieves a list of all the built-in policy set definitions that match the optional given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy set definitions whose category match the {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listBuiltInPolicySetDefinitions.json | +| [policySetDefinitionsListByManagementGroupSample.ts][policysetdefinitionslistbymanagementgroupsample] | This operation retrieves a list of all the policy set definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicySetDefinitionsByManagementGroup.json | +| [policySetDefinitionsListSample.ts][policysetdefinitionslistsample] | This operation retrieves a list of all the policy set definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicySetDefinitions.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +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/dataPolicyManifestsGetByPolicyModeSample.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 node dist/dataPolicyManifestsGetByPolicyModeSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[datapolicymanifestsgetbypolicymodesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/dataPolicyManifestsGetByPolicyModeSample.ts +[datapolicymanifestslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/dataPolicyManifestsListSample.ts +[policyassignmentscreatebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsCreateByIdSample.ts +[policyassignmentscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsCreateSample.ts +[policyassignmentsdeletebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsDeleteByIdSample.ts +[policyassignmentsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsDeleteSample.ts +[policyassignmentsgetbyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsGetByIdSample.ts +[policyassignmentsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsGetSample.ts +[policyassignmentslistformanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsListForManagementGroupSample.ts +[policyassignmentslistforresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsListForResourceGroupSample.ts +[policyassignmentslistforresourcesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsListForResourceSample.ts +[policyassignmentslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsListSample.ts +[policyassignmentsupdatebyidsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsUpdateByIdSample.ts +[policyassignmentsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsUpdateSample.ts +[policydefinitionscreateorupdateatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsCreateOrUpdateAtManagementGroupSample.ts +[policydefinitionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsCreateOrUpdateSample.ts +[policydefinitionsdeleteatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsDeleteAtManagementGroupSample.ts +[policydefinitionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsDeleteSample.ts +[policydefinitionsgetatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsGetAtManagementGroupSample.ts +[policydefinitionsgetbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsGetBuiltInSample.ts +[policydefinitionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsGetSample.ts +[policydefinitionslistbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsListBuiltInSample.ts +[policydefinitionslistbymanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsListByManagementGroupSample.ts +[policydefinitionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsListSample.ts +[policyexemptionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsCreateOrUpdateSample.ts +[policyexemptionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsDeleteSample.ts +[policyexemptionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsGetSample.ts +[policyexemptionslistformanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsListForManagementGroupSample.ts +[policyexemptionslistforresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsListForResourceGroupSample.ts +[policyexemptionslistforresourcesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsListForResourceSample.ts +[policyexemptionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsListSample.ts +[policysetdefinitionscreateorupdateatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.ts +[policysetdefinitionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsCreateOrUpdateSample.ts +[policysetdefinitionsdeleteatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsDeleteAtManagementGroupSample.ts +[policysetdefinitionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsDeleteSample.ts +[policysetdefinitionsgetatmanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsGetAtManagementGroupSample.ts +[policysetdefinitionsgetbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsGetBuiltInSample.ts +[policysetdefinitionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsGetSample.ts +[policysetdefinitionslistbuiltinsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsListBuiltInSample.ts +[policysetdefinitionslistbymanagementgroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsListByManagementGroupSample.ts +[policysetdefinitionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsListSample.ts +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-policy?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/policy/arm-policy/README.md +[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/policy/arm-policy/samples/v5/typescript/package.json b/sdk/policy/arm-policy/samples/v5/typescript/package.json new file mode 100644 index 000000000000..3cf9067e3d05 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/package.json @@ -0,0 +1,41 @@ +{ + "name": "@azure-samples/arm-policy-ts", + "private": true, + "version": "1.0.0", + "description": " client library samples for TypeScript", + "engines": { + "node": ">=12.0.0" + }, + "scripts": { + "build": "tsc", + "prebuild": "rimraf dist/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/policy/arm-policy" + }, + "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/policy/arm-policy", + "dependencies": { + "@azure/arm-policy": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + }, + "devDependencies": { + "@types/node": "^12.0.0", + "typescript": "~4.4.0", + "rimraf": "latest" + } +} diff --git a/sdk/policy/arm-policy/samples/v5/typescript/sample.env b/sdk/policy/arm-policy/samples/v5/typescript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/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/policy/arm-policy/samples/v5/typescript/src/dataPolicyManifestsGetByPolicyModeSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/dataPolicyManifestsGetByPolicyModeSample.ts new file mode 100644 index 000000000000..956226d4552c --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/dataPolicyManifestsGetByPolicyModeSample.ts @@ -0,0 +1,29 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the data policy manifest with the given policy mode. + * + * @summary This operation retrieves the data policy manifest with the given policy mode. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/getDataPolicyManifest.json + */ +async function retrieveADataPolicyManifestByPolicyMode() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyMode = "Microsoft.KeyVault.Data"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.dataPolicyManifests.getByPolicyMode(policyMode); + console.log(result); +} + +retrieveADataPolicyManifestByPolicyMode().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/dataPolicyManifestsListSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/dataPolicyManifestsListSample.ts new file mode 100644 index 000000000000..b9a1e68ed467 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/dataPolicyManifestsListSample.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 { + DataPolicyManifestsListOptionalParams, + PolicyClient +} from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves a list of all the data policy manifests that match the optional given $filter. Valid values for $filter are: "$filter=namespace eq '{0}'". If $filter is not provided, the unfiltered list includes all data policy manifests for data resource types. If $filter=namespace is provided, the returned list only includes all data policy manifests that have a namespace matching the provided value. + * + * @summary This operation retrieves a list of all the data policy manifests that match the optional given $filter. Valid values for $filter are: "$filter=namespace eq '{0}'". If $filter is not provided, the unfiltered list includes all data policy manifests for data resource types. If $filter=namespace is provided, the returned list only includes all data policy manifests that have a namespace matching the provided value. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/listDataPolicyManifests.json + */ +async function listDataPolicyManifests() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.dataPolicyManifests.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listDataPolicyManifests().catch(console.error); + +/** + * This sample demonstrates how to This operation retrieves a list of all the data policy manifests that match the optional given $filter. Valid values for $filter are: "$filter=namespace eq '{0}'". If $filter is not provided, the unfiltered list includes all data policy manifests for data resource types. If $filter=namespace is provided, the returned list only includes all data policy manifests that have a namespace matching the provided value. + * + * @summary This operation retrieves a list of all the data policy manifests that match the optional given $filter. Valid values for $filter are: "$filter=namespace eq '{0}'". If $filter is not provided, the unfiltered list includes all data policy manifests for data resource types. If $filter=namespace is provided, the returned list only includes all data policy manifests that have a namespace matching the provided value. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/listDataPolicyManifestsNamespaceFilter.json + */ +async function listDataPolicyManifestsWithNamespaceFilter() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const filter = "namespace eq 'Microsoft.KeyVault'"; + const options: DataPolicyManifestsListOptionalParams = { filter }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.dataPolicyManifests.list(options)) { + resArray.push(item); + } + console.log(resArray); +} + +listDataPolicyManifestsWithNamespaceFilter().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsCreateByIdSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsCreateByIdSample.ts new file mode 100644 index 000000000000..c4cf52a4165d --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsCreateByIdSample.ts @@ -0,0 +1,80 @@ +/* + * 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 { PolicyAssignment, PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * + * @summary This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignmentById.json + */ +async function createOrUpdatePolicyAssignmentById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyAssignmentId = + "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; + const parameters: PolicyAssignment = { + description: + "Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created", + displayName: "Enforce storage account SKU", + enforcementMode: "Default", + metadata: { assignedBy: "Cheapskate Boss" }, + parameters: { + listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] } + }, + policyDefinitionId: + "/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1" + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.createById( + policyAssignmentId, + parameters + ); + console.log(result); +} + +createOrUpdatePolicyAssignmentById().catch(console.error); + +/** + * This sample demonstrates how to This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * + * @summary This operation creates or updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignmentWithIdentityById.json + */ +async function createOrUpdatePolicyAssignmentWithAManagedIdentityById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyAssignmentId = + "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; + const parameters: PolicyAssignment = { + description: + "Allow only storage accounts of SKU Standard_GRS or Standard_LRS to be created", + displayName: "Enforce storage account SKU", + enforcementMode: "Default", + identity: { type: "SystemAssigned" }, + location: "eastus", + metadata: { assignedBy: "Cheapskate Boss" }, + parameters: { + listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] } + }, + policyDefinitionId: + "/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1" + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.createById( + policyAssignmentId, + parameters + ); + console.log(result); +} + +createOrUpdatePolicyAssignmentWithAManagedIdentityById().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsCreateSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsCreateSample.ts new file mode 100644 index 000000000000..133bde87b7fb --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsCreateSample.ts @@ -0,0 +1,198 @@ +/* + * 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 { PolicyAssignment, PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignment.json + */ +async function createOrUpdateAPolicyAssignment() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const parameters: PolicyAssignment = { + description: + "Force resource names to begin with given DeptA and end with -LC", + displayName: "Enforce resource naming rules", + metadata: { assignedBy: "Special Someone" }, + nonComplianceMessages: [ + { message: "Resource names must start with 'DeptA' and end with '-LC'." } + ], + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming" + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.create( + scope, + policyAssignmentName, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicyAssignment().catch(console.error); + +/** + * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignmentWithIdentity.json + */ +async function createOrUpdateAPolicyAssignmentWithASystemAssignedIdentity() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const parameters: PolicyAssignment = { + description: + "Force resource names to begin with given DeptA and end with -LC", + displayName: "Enforce resource naming rules", + enforcementMode: "Default", + identity: { type: "SystemAssigned" }, + location: "eastus", + metadata: { assignedBy: "Foo Bar" }, + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming" + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.create( + scope, + policyAssignmentName, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicyAssignmentWithASystemAssignedIdentity().catch( + console.error +); + +/** + * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignmentWithUserAssignedIdentity.json + */ +async function createOrUpdateAPolicyAssignmentWithAUserAssignedIdentity() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const parameters: PolicyAssignment = { + description: + "Force resource names to begin with given DeptA and end with -LC", + displayName: "Enforce resource naming rules", + enforcementMode: "Default", + identity: { + type: "UserAssigned", + userAssignedIdentities: { + "/subscriptions/ae640e6bBa3e42569d622993eecfa6f2/resourceGroups/testResourceGroup/providers/MicrosoftManagedIdentity/userAssignedIdentities/testIdentity": {} + } + }, + location: "eastus", + metadata: { assignedBy: "Foo Bar" }, + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming" + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.create( + scope, + policyAssignmentName, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicyAssignmentWithAUserAssignedIdentity().catch(console.error); + +/** + * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignmentNonComplianceMessages.json + */ +async function createOrUpdateAPolicyAssignmentWithMultipleNonComplianceMessages() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "securityInitAssignment"; + const parameters: PolicyAssignment = { + displayName: "Enforce security policies", + nonComplianceMessages: [ + { + message: + "Resources must comply with all internal security policies. See for more info." + }, + { + message: "Resource names must start with 'DeptA' and end with '-LC'.", + policyDefinitionReferenceId: "10420126870854049575" + }, + { + message: "Storage accounts must have firewall rules configured.", + policyDefinitionReferenceId: "8572513655450389710" + } + ], + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/securityInitiative" + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.create( + scope, + policyAssignmentName, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicyAssignmentWithMultipleNonComplianceMessages().catch( + console.error +); + +/** + * This sample demonstrates how to This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary This operation creates or updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createPolicyAssignmentWithoutEnforcement.json + */ +async function createOrUpdateAPolicyAssignmentWithoutEnforcingPolicyEffectDuringResourceCreationOrUpdate() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const parameters: PolicyAssignment = { + description: + "Force resource names to begin with given DeptA and end with -LC", + displayName: "Enforce resource naming rules", + enforcementMode: "DoNotEnforce", + metadata: { assignedBy: "Special Someone" }, + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming" + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.create( + scope, + policyAssignmentName, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicyAssignmentWithoutEnforcingPolicyEffectDuringResourceCreationOrUpdate().catch( + console.error +); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsDeleteByIdSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsDeleteByIdSample.ts new file mode 100644 index 000000000000..d35b62115dc8 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsDeleteByIdSample.ts @@ -0,0 +1,30 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). + * + * @summary This operation deletes the policy with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid formats for {scope} are: '/providers/Microsoft.Management/managementGroups/{managementGroup}' (management group), '/subscriptions/{subscriptionId}' (subscription), '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' (resource group), or '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}' (resource). + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicyAssignmentById.json + */ +async function deleteAPolicyAssignmentById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyAssignmentId = + "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.deleteById(policyAssignmentId); + console.log(result); +} + +deleteAPolicyAssignmentById().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsDeleteSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsDeleteSample.ts new file mode 100644 index 000000000000..e2976b8ac214 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsDeleteSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * + * @summary This operation deletes a policy assignment, given its name and the scope it was created in. The scope of a policy assignment is the part of its ID preceding '/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicyAssignment.json + */ +async function deleteAPolicyAssignment() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.delete( + scope, + policyAssignmentName + ); + console.log(result); +} + +deleteAPolicyAssignment().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsGetByIdSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsGetByIdSample.ts new file mode 100644 index 000000000000..1733f93e2cd9 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsGetByIdSample.ts @@ -0,0 +1,48 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * + * @summary The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyAssignmentById.json + */ +async function retrieveAPolicyAssignmentById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyAssignmentId = + "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.getById(policyAssignmentId); + console.log(result); +} + +retrieveAPolicyAssignmentById().catch(console.error); + +/** + * This sample demonstrates how to The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * + * @summary The operation retrieves the policy assignment with the given ID. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyAssignmentWithIdentityById.json + */ +async function retrieveAPolicyAssignmentWithAManagedIdentityById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyAssignmentId = + "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.getById(policyAssignmentId); + console.log(result); +} + +retrieveAPolicyAssignmentWithAManagedIdentityById().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsGetSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsGetSample.ts new file mode 100644 index 000000000000..0b98df70f83a --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsGetSample.ts @@ -0,0 +1,75 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at. + * + * @summary This operation retrieves a single policy assignment, given its name and the scope it was created at. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyAssignment.json + */ +async function retrieveAPolicyAssignment() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.get( + scope, + policyAssignmentName + ); + console.log(result); +} + +retrieveAPolicyAssignment().catch(console.error); + +/** + * This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at. + * + * @summary This operation retrieves a single policy assignment, given its name and the scope it was created at. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyAssignmentWithIdentity.json + */ +async function retrieveAPolicyAssignmentWithASystemAssignedIdentity() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.get( + scope, + policyAssignmentName + ); + console.log(result); +} + +retrieveAPolicyAssignmentWithASystemAssignedIdentity().catch(console.error); + +/** + * This sample demonstrates how to This operation retrieves a single policy assignment, given its name and the scope it was created at. + * + * @summary This operation retrieves a single policy assignment, given its name and the scope it was created at. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyAssignmentWithUserAssignedIdentity.json + */ +async function retrieveAPolicyAssignmentWithAUserAssignedIdentity() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.get( + scope, + policyAssignmentName + ); + console.log(result); +} + +retrieveAPolicyAssignmentWithAUserAssignedIdentity().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsListForManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsListForManagementGroupSample.ts new file mode 100644 index 000000000000..dacf306881b2 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsListForManagementGroupSample.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 { + PolicyAssignmentsListForManagementGroupOptionalParams, + PolicyClient +} from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. + * + * @summary This operation retrieves the list of all policy assignments applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy assignments that are assigned to the management group or the management group's ancestors. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the management group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the management group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyAssignmentsForManagementGroup.json + */ +async function listPolicyAssignmentsThatApplyToAManagementGroup() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const managementGroupId = "TestManagementGroup"; + const filter = "atScope()"; + const options: PolicyAssignmentsListForManagementGroupOptionalParams = { + filter + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyAssignments.listForManagementGroup( + managementGroupId, + options + )) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicyAssignmentsThatApplyToAManagementGroup().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsListForResourceGroupSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsListForResourceGroupSample.ts new file mode 100644 index 000000000000..43679b8ae4c8 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsListForResourceGroupSample.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 { + PolicyAssignmentsListForResourceGroupOptionalParams, + PolicyClient +} from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + * + * @summary This operation retrieves the list of all policy assignments associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource group, which is everything in the unfiltered list except those applied to resources contained within the resource group. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource group. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyAssignmentsForResourceGroup.json + */ +async function listPolicyAssignmentsThatApplyToAResourceGroup() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const resourceGroupName = "TestResourceGroup"; + const filter = "atScope()"; + const options: PolicyAssignmentsListForResourceGroupOptionalParams = { + filter + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyAssignments.listForResourceGroup( + resourceGroupName, + options + )) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicyAssignmentsThatApplyToAResourceGroup().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsListForResourceSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsListForResourceSample.ts new file mode 100644 index 000000000000..0d43e41446b9 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsListForResourceSample.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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * + * @summary This operation retrieves the list of all policy assignments associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the resource, which is everything in the unfiltered list except those applied to resources contained within the resource. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the resource level. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value} that apply to the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyAssignmentsForResource.json + */ +async function listAllPolicyAssignmentsThatApplyToAResource() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const resourceGroupName = "TestResourceGroup"; + const resourceProviderNamespace = "Microsoft.Compute"; + const parentResourcePath = "virtualMachines/MyTestVm"; + const resourceType = "domainNames"; + const resourceName = "MyTestComputer.cloudapp.net"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyAssignments.listForResource( + resourceGroupName, + resourceProviderNamespace, + parentResourcePath, + resourceType, + resourceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listAllPolicyAssignmentsThatApplyToAResource().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsListSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsListSample.ts new file mode 100644 index 000000000000..c3e9575f594c --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsListSample.ts @@ -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. +import { + PolicyAssignmentsListOptionalParams, + PolicyClient +} from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + * + * @summary This operation retrieves the list of all policy assignments associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()' or 'policyDefinitionId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy assignments associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. If $filter=atScope() is provided, the returned list includes all policy assignments that apply to the subscription, which is everything in the unfiltered list except those applied to objects contained within the subscription. If $filter=atExactScope() is provided, the returned list only includes all policy assignments that at the subscription. If $filter=policyDefinitionId eq '{value}' is provided, the returned list includes all policy assignments of the policy definition whose id is {value}. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyAssignments.json + */ +async function listPolicyAssignmentsThatApplyToASubscription() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const filter = "atScope()"; + const options: PolicyAssignmentsListOptionalParams = { filter }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyAssignments.list(options)) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicyAssignmentsThatApplyToASubscription().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsUpdateByIdSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsUpdateByIdSample.ts new file mode 100644 index 000000000000..3f654336a500 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsUpdateByIdSample.ts @@ -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. +import { PolicyAssignmentUpdate, PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * + * @summary This operation updates the policy assignment with the given ID. Policy assignments made on a scope apply to all resources contained in that scope. For example, when you assign a policy to a resource group that policy applies to all resources in the group. Policy assignment IDs have this format: '{scope}/providers/Microsoft.Authorization/policyAssignments/{policyAssignmentName}'. Valid scopes are: management group (format: '/providers/Microsoft.Management/managementGroups/{managementGroup}'), subscription (format: '/subscriptions/{subscriptionId}'), resource group (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}', or resource (format: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/[{parentResourcePath}/]{resourceType}/{resourceName}'. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/updatePolicyAssignmentWithIdentityById.json + */ +async function updatePolicyAssignmentWithAManagedIdentityById() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyAssignmentId = + "providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyAssignments/LowCostStorage"; + const parameters: PolicyAssignmentUpdate = { + identity: { type: "SystemAssigned" }, + location: "eastus" + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.updateById( + policyAssignmentId, + parameters + ); + console.log(result); +} + +updatePolicyAssignmentWithAManagedIdentityById().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsUpdateSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsUpdateSample.ts new file mode 100644 index 000000000000..2c5ad77e13d0 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyAssignmentsUpdateSample.ts @@ -0,0 +1,69 @@ +/* + * 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 { PolicyAssignmentUpdate, PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/updatePolicyAssignmentWithIdentity.json + */ +async function updateAPolicyAssignmentWithASystemAssignedIdentity() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const parameters: PolicyAssignmentUpdate = { + identity: { type: "SystemAssigned" }, + location: "eastus" + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.update( + scope, + policyAssignmentName, + parameters + ); + console.log(result); +} + +updateAPolicyAssignmentWithASystemAssignedIdentity().catch(console.error); + +/** + * This sample demonstrates how to This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * + * @summary This operation updates a policy assignment with the given scope and name. Policy assignments apply to all resources contained within their scope. For example, when you assign a policy at resource group scope, that policy applies to all resources in the group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/updatePolicyAssignmentWithUserAssignedIdentity.json + */ +async function updateAPolicyAssignmentWithAUserAssignedIdentity() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyAssignmentName = "EnforceNaming"; + const parameters: PolicyAssignmentUpdate = { + identity: { + type: "UserAssigned", + userAssignedIdentities: { + "/subscriptions/ae640e6bBa3e42569d622993eecfa6f2/resourceGroups/testResourceGroup/providers/MicrosoftManagedIdentity/userAssignedIdentities/testIdentity": {} + } + }, + location: "eastus" + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyAssignments.update( + scope, + policyAssignmentName, + parameters + ); + console.log(result); +} + +updateAPolicyAssignmentWithAUserAssignedIdentity().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsCreateOrUpdateAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsCreateOrUpdateAtManagementGroupSample.ts new file mode 100644 index 000000000000..eb6f78d43180 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsCreateOrUpdateAtManagementGroupSample.ts @@ -0,0 +1,60 @@ +/* + * 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 { PolicyDefinition, PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation creates or updates a policy definition in the given management group with the given name. + * + * @summary This operation creates or updates a policy definition in the given management group with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicyDefinitionAtManagementGroup.json + */ +async function createOrUpdateAPolicyDefinitionAtManagementGroupLevel() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyDefinitionName = "ResourceNaming"; + const managementGroupId = "MyManagementGroup"; + const parameters: PolicyDefinition = { + description: + "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", + displayName: "Enforce resource naming convention", + metadata: { category: "Naming" }, + mode: "All", + parameters: { + prefix: { + type: "String", + metadata: { description: "Resource name prefix", displayName: "Prefix" } + }, + suffix: { + type: "String", + metadata: { description: "Resource name suffix", displayName: "Suffix" } + } + }, + policyRule: { + if: { + not: { + field: "name", + like: "[concat(parameters('prefix'), '*', parameters('suffix'))]" + } + }, + then: { effect: "deny" } + } + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.createOrUpdateAtManagementGroup( + policyDefinitionName, + managementGroupId, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicyDefinitionAtManagementGroupLevel().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsCreateOrUpdateSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..73945549810e --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsCreateOrUpdateSample.ts @@ -0,0 +1,119 @@ +/* + * 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 { PolicyDefinition, PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation creates or updates a policy definition in the given subscription with the given name. + * + * @summary This operation creates or updates a policy definition in the given subscription with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicyDefinition.json + */ +async function createOrUpdateAPolicyDefinition() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyDefinitionName = "ResourceNaming"; + const parameters: PolicyDefinition = { + description: + "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", + displayName: "Enforce resource naming convention", + metadata: { category: "Naming" }, + mode: "All", + parameters: { + prefix: { + type: "String", + metadata: { description: "Resource name prefix", displayName: "Prefix" } + }, + suffix: { + type: "String", + metadata: { description: "Resource name suffix", displayName: "Suffix" } + } + }, + policyRule: { + if: { + not: { + field: "name", + like: "[concat(parameters('prefix'), '*', parameters('suffix'))]" + } + }, + then: { effect: "deny" } + } + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.createOrUpdate( + policyDefinitionName, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicyDefinition().catch(console.error); + +/** + * This sample demonstrates how to This operation creates or updates a policy definition in the given subscription with the given name. + * + * @summary This operation creates or updates a policy definition in the given subscription with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicyDefinitionAdvancedParams.json + */ +async function createOrUpdateAPolicyDefinitionWithAdvancedParameters() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyDefinitionName = "EventHubDiagnosticLogs"; + const parameters: PolicyDefinition = { + description: + "Audit enabling of logs and retain them up to a year. This enables recreation of activity trails for investigation purposes when a security incident occurs or your network is compromised", + displayName: "Event Hubs should have diagnostic logging enabled", + metadata: { category: "Event Hub" }, + mode: "Indexed", + parameters: { + requiredRetentionDays: { + type: "Integer", + allowedValues: [0, 30, 90, 180, 365], + defaultValue: 365, + metadata: { + description: "The required diagnostic logs retention in days", + displayName: "Required retention (days)" + } + } + }, + policyRule: { + if: { equals: "Microsoft.EventHub/namespaces", field: "type" }, + then: { + effect: "AuditIfNotExists", + details: { + type: "Microsoft.Insights/diagnosticSettings", + existenceCondition: { + allOf: [ + { + equals: "true", + field: + "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.enabled" + }, + { + equals: "[parameters('requiredRetentionDays')]", + field: + "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.days" + } + ] + } + } + } + } + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.createOrUpdate( + policyDefinitionName, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicyDefinitionWithAdvancedParameters().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsDeleteAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsDeleteAtManagementGroupSample.ts new file mode 100644 index 000000000000..f21e0b672e3c --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsDeleteAtManagementGroupSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation deletes the policy definition in the given management group with the given name. + * + * @summary This operation deletes the policy definition in the given management group with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicyDefinitionAtManagementGroup.json + */ +async function deleteAPolicyDefinitionAtManagementGroupLevel() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyDefinitionName = "ResourceNaming"; + const managementGroupId = "MyManagementGroup"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.deleteAtManagementGroup( + policyDefinitionName, + managementGroupId + ); + console.log(result); +} + +deleteAPolicyDefinitionAtManagementGroupLevel().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsDeleteSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsDeleteSample.ts new file mode 100644 index 000000000000..ba4d5422c2ae --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsDeleteSample.ts @@ -0,0 +1,29 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation deletes the policy definition in the given subscription with the given name. + * + * @summary This operation deletes the policy definition in the given subscription with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicyDefinition.json + */ +async function deleteAPolicyDefinition() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyDefinitionName = "ResourceNaming"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.delete(policyDefinitionName); + console.log(result); +} + +deleteAPolicyDefinition().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsGetAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsGetAtManagementGroupSample.ts new file mode 100644 index 000000000000..27fcab9e3087 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsGetAtManagementGroupSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the policy definition in the given management group with the given name. + * + * @summary This operation retrieves the policy definition in the given management group with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinitionAtManagementGroup.json + */ +async function retrieveAPolicyDefinitionAtManagementGroupLevel() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyDefinitionName = "ResourceNaming"; + const managementGroupId = "MyManagementGroup"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.getAtManagementGroup( + policyDefinitionName, + managementGroupId + ); + console.log(result); +} + +retrieveAPolicyDefinitionAtManagementGroupLevel().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsGetBuiltInSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsGetBuiltInSample.ts new file mode 100644 index 000000000000..f719a34a23bf --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsGetBuiltInSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the built-in policy definition with the given name. + * + * @summary This operation retrieves the built-in policy definition with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getBuiltinPolicyDefinition.json + */ +async function retrieveABuiltInPolicyDefinition() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policyDefinitionName = "7433c107-6db4-4ad1-b57a-a76dce0154a1"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.getBuiltIn( + policyDefinitionName + ); + console.log(result); +} + +retrieveABuiltInPolicyDefinition().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsGetSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsGetSample.ts new file mode 100644 index 000000000000..ce61f8060856 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsGetSample.ts @@ -0,0 +1,29 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the policy definition in the given subscription with the given name. + * + * @summary This operation retrieves the policy definition in the given subscription with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinition.json + */ +async function retrieveAPolicyDefinition() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policyDefinitionName = "ResourceNaming"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyDefinitions.get(policyDefinitionName); + console.log(result); +} + +retrieveAPolicyDefinition().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsListBuiltInSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsListBuiltInSample.ts new file mode 100644 index 000000000000..b565261b76cf --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsListBuiltInSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves a list of all the built-in policy definitions that match the optional given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose category match the {value}. + * + * @summary This operation retrieves a list of all the built-in policy definitions that match the optional given $filter. If $filter='policyType -eq {value}' is provided, the returned list only includes all built-in policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy definitions whose category match the {value}. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listBuiltInPolicyDefinitions.json + */ +async function listBuiltInPolicyDefinitions() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyDefinitions.listBuiltIn()) { + resArray.push(item); + } + console.log(resArray); +} + +listBuiltInPolicyDefinitions().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsListByManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsListByManagementGroupSample.ts new file mode 100644 index 000000000000..0d588d20df2b --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsListByManagementGroupSample.ts @@ -0,0 +1,34 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves a list of all the policy definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. + * + * @summary This operation retrieves a list of all the policy definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyDefinitionsByManagementGroup.json + */ +async function listPolicyDefinitionsByManagementGroup() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const managementGroupId = "MyManagementGroup"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyDefinitions.listByManagementGroup( + managementGroupId + )) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicyDefinitionsByManagementGroup().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsListSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsListSample.ts new file mode 100644 index 000000000000..b98016d43e38 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyDefinitionsListSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves a list of all the policy definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. + * + * @summary This operation retrieves a list of all the policy definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn, Custom, and Static. If $filter='category -eq {value}' is provided, the returned list only includes all policy definitions whose category match the {value}. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyDefinitions.json + */ +async function listPolicyDefinitionsBySubscription() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyDefinitions.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicyDefinitionsBySubscription().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsCreateOrUpdateSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..d8baa98d0f63 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsCreateOrUpdateSample.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 { PolicyExemption, PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation creates or updates a policy exemption with the given scope and name. Policy exemptions apply to all resources contained within their scope. For example, when you create a policy exemption at resource group scope for a policy assignment at the same or above level, the exemption exempts to all applicable resources in the resource group. + * + * @summary This operation creates or updates a policy exemption with the given scope and name. Policy exemptions apply to all resources contained within their scope. For example, when you create a policy exemption at resource group scope for a policy assignment at the same or above level, the exemption exempts to all applicable resources in the resource group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/createOrUpdatePolicyExemption.json + */ +async function createOrUpdateAPolicyExemption() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster"; + const policyExemptionName = "DemoExpensiveVM"; + const parameters: PolicyExemption = { + description: "Exempt demo cluster from limit sku", + displayName: "Exempt demo cluster", + exemptionCategory: "Waiver", + metadata: { reason: "Temporary exemption for a expensive VM demo" }, + policyAssignmentId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyAssignments/CostManagement", + policyDefinitionReferenceIds: ["Limit_Skus"] + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyExemptions.createOrUpdate( + scope, + policyExemptionName, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicyExemption().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsDeleteSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsDeleteSample.ts new file mode 100644 index 000000000000..333235e2aff4 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsDeleteSample.ts @@ -0,0 +1,34 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation deletes a policy exemption, given its name and the scope it was created in. The scope of a policy exemption is the part of its ID preceding '/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'. + * + * @summary This operation deletes a policy exemption, given its name and the scope it was created in. The scope of a policy exemption is the part of its ID preceding '/providers/Microsoft.Authorization/policyExemptions/{policyExemptionName}'. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/deletePolicyExemption.json + */ +async function deleteAPolicyExemption() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster"; + const policyExemptionName = "DemoExpensiveVM"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyExemptions.delete( + scope, + policyExemptionName + ); + console.log(result); +} + +deleteAPolicyExemption().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsGetSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsGetSample.ts new file mode 100644 index 000000000000..04416e7965c0 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsGetSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves a single policy exemption, given its name and the scope it was created at. + * + * @summary This operation retrieves a single policy exemption, given its name and the scope it was created at. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/getPolicyExemption.json + */ +async function retrieveAPolicyExemption() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = + "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/demoCluster"; + const policyExemptionName = "DemoExpensiveVM"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policyExemptions.get(scope, policyExemptionName); + console.log(result); +} + +retrieveAPolicyExemption().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsListForManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsListForManagementGroupSample.ts new file mode 100644 index 000000000000..7efc527ef9a4 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsListForManagementGroupSample.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 { + PolicyExemptionsListForManagementGroupOptionalParams, + PolicyClient +} from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the list of all policy exemptions applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy exemptions that are assigned to the management group or the management group's ancestors. + * + * @summary This operation retrieves the list of all policy exemptions applicable to the management group that match the given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter=atScope() is provided, the returned list includes all policy exemptions that are assigned to the management group or the management group's ancestors. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/listPolicyExemptionsForManagementGroup.json + */ +async function listPolicyExemptionsThatApplyToAManagementGroup() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const managementGroupId = "DevOrg"; + const filter = "atScope()"; + const options: PolicyExemptionsListForManagementGroupOptionalParams = { + filter + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyExemptions.listForManagementGroup( + managementGroupId, + options + )) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicyExemptionsThatApplyToAManagementGroup().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsListForResourceGroupSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsListForResourceGroupSample.ts new file mode 100644 index 000000000000..71b11bd79266 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsListForResourceGroupSample.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 { + PolicyExemptionsListForResourceGroupOptionalParams, + PolicyClient +} from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the list of all policy exemptions associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. + * + * @summary This operation retrieves the list of all policy exemptions associated with the given resource group in the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the resource group, including those that apply directly or apply from containing scopes, as well as any applied to resources contained within the resource group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/listPolicyExemptionsForResourceGroup.json + */ +async function listPolicyExemptionsThatApplyToAResourceGroup() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const resourceGroupName = "TestResourceGroup"; + const filter = "atScope()"; + const options: PolicyExemptionsListForResourceGroupOptionalParams = { + filter + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyExemptions.listForResourceGroup( + resourceGroupName, + options + )) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicyExemptionsThatApplyToAResourceGroup().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsListForResourceSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsListForResourceSample.ts new file mode 100644 index 000000000000..d244bccee220 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsListForResourceSample.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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the list of all policy exemptions associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * + * @summary This operation retrieves the list of all policy exemptions associated with the specified resource in the given resource group and subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the resource, including those that apply directly or from all containing scopes, as well as any applied to resources contained within the resource. Three parameters plus the resource name are used to identify a specific resource. If the resource is not part of a parent resource (the more common case), the parent resource path should not be provided (or provided as ''). For example a web app could be specified as ({resourceProviderNamespace} == 'Microsoft.Web', {parentResourcePath} == '', {resourceType} == 'sites', {resourceName} == 'MyWebApp'). If the resource is part of a parent resource, then all parameters should be provided. For example a virtual machine DNS name could be specified as ({resourceProviderNamespace} == 'Microsoft.Compute', {parentResourcePath} == 'virtualMachines/MyVirtualMachine', {resourceType} == 'domainNames', {resourceName} == 'MyComputerName'). A convenient alternative to providing the namespace and type name separately is to provide both in the {resourceType} parameter, format: ({resourceProviderNamespace} == '', {parentResourcePath} == '', {resourceType} == 'Microsoft.Web/sites', {resourceName} == 'MyWebApp'). + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/listPolicyExemptionsForResource.json + */ +async function listAllPolicyExemptionsThatApplyToAResource() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const resourceGroupName = "TestResourceGroup"; + const resourceProviderNamespace = "Microsoft.Compute"; + const parentResourcePath = "virtualMachines/MyTestVm"; + const resourceType = "domainNames"; + const resourceName = "MyTestComputer.cloudapp.net"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyExemptions.listForResource( + resourceGroupName, + resourceProviderNamespace, + parentResourcePath, + resourceType, + resourceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +listAllPolicyExemptionsThatApplyToAResource().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsListSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsListSample.ts new file mode 100644 index 000000000000..60c1219dbbf3 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policyExemptionsListSample.ts @@ -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. +import { + PolicyExemptionsListOptionalParams, + PolicyClient +} from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the list of all policy exemptions associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. + * + * @summary This operation retrieves the list of all policy exemptions associated with the given subscription that match the optional given $filter. Valid values for $filter are: 'atScope()', 'atExactScope()', 'excludeExpired()' or 'policyAssignmentId eq '{value}''. If $filter is not provided, the unfiltered list includes all policy exemptions associated with the subscription, including those that apply directly or from management groups that contain the given subscription, as well as any applied to objects contained within the subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/preview/2020-07-01-preview/examples/listPolicyExemptionsForSubscription.json + */ +async function listPolicyExemptionsThatApplyToASubscription() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const filter = "atScope()"; + const options: PolicyExemptionsListOptionalParams = { filter }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policyExemptions.list(options)) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicyExemptionsThatApplyToASubscription().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.ts new file mode 100644 index 000000000000..e0d324f27db8 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsCreateOrUpdateAtManagementGroupSample.ts @@ -0,0 +1,116 @@ +/* + * 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 { PolicySetDefinition, PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation creates or updates a policy set definition in the given management group with the given name. + * + * @summary This operation creates or updates a policy set definition in the given management group with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinitionAtManagementGroup.json + */ +async function createOrUpdateAPolicySetDefinitionAtManagementGroupLevel() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policySetDefinitionName = "CostManagement"; + const managementGroupId = "MyManagementGroup"; + const parameters: PolicySetDefinition = { + description: "Policies to enforce low cost storage SKUs", + displayName: "Cost Management", + metadata: { category: "Cost Management" }, + policyDefinitions: [ + { + parameters: { + listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] } + }, + policyDefinitionId: + "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + policyDefinitionReferenceId: "Limit_Skus" + }, + { + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + policyDefinitionReferenceId: "Resource_Naming" + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.createOrUpdateAtManagementGroup( + policySetDefinitionName, + managementGroupId, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicySetDefinitionAtManagementGroupLevel().catch(console.error); + +/** + * This sample demonstrates how to This operation creates or updates a policy set definition in the given management group with the given name. + * + * @summary This operation creates or updates a policy set definition in the given management group with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinitionWithGroupsAtManagementGroup.json + */ +async function createOrUpdateAPolicySetDefinitionWithGroupsAtManagementGroupLevel() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policySetDefinitionName = "CostManagement"; + const managementGroupId = "MyManagementGroup"; + const parameters: PolicySetDefinition = { + description: "Policies to enforce low cost storage SKUs", + displayName: "Cost Management", + metadata: { category: "Cost Management" }, + policyDefinitionGroups: [ + { + name: "CostSaving", + description: + "Policies designed to control spend within a subscription.", + displayName: "Cost Management Policies" + }, + { + name: "Organizational", + description: + "Policies that help enforce resource organization standards within a subscription.", + displayName: "Organizational Policies" + } + ], + policyDefinitions: [ + { + groupNames: ["CostSaving"], + parameters: { + listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] } + }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + policyDefinitionReferenceId: "Limit_Skus" + }, + { + groupNames: ["Organizational"], + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + policyDefinitionReferenceId: "Resource_Naming" + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.createOrUpdateAtManagementGroup( + policySetDefinitionName, + managementGroupId, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicySetDefinitionWithGroupsAtManagementGroupLevel().catch( + console.error +); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsCreateOrUpdateSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..8b66d516f5f0 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsCreateOrUpdateSample.ts @@ -0,0 +1,120 @@ +/* + * 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 { PolicySetDefinition, PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation creates or updates a policy set definition in the given subscription with the given name. + * + * @summary This operation creates or updates a policy set definition in the given subscription with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinition.json + */ +async function createOrUpdateAPolicySetDefinition() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policySetDefinitionName = "CostManagement"; + const parameters: PolicySetDefinition = { + description: "Policies to enforce low cost storage SKUs", + displayName: "Cost Management", + metadata: { category: "Cost Management" }, + parameters: { + namePrefix: { + type: "String", + defaultValue: "myPrefix", + metadata: { displayName: "Prefix to enforce on resource names" } + } + }, + policyDefinitions: [ + { + parameters: { + listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] } + }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + policyDefinitionReferenceId: "Limit_Skus" + }, + { + parameters: { + prefix: { value: "[parameters('namePrefix')]" }, + suffix: { value: "-LC" } + }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + policyDefinitionReferenceId: "Resource_Naming" + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.createOrUpdate( + policySetDefinitionName, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicySetDefinition().catch(console.error); + +/** + * This sample demonstrates how to This operation creates or updates a policy set definition in the given subscription with the given name. + * + * @summary This operation creates or updates a policy set definition in the given subscription with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicySetDefinitionWithGroups.json + */ +async function createOrUpdateAPolicySetDefinitionWithGroups() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policySetDefinitionName = "CostManagement"; + const parameters: PolicySetDefinition = { + description: "Policies to enforce low cost storage SKUs", + displayName: "Cost Management", + metadata: { category: "Cost Management" }, + policyDefinitionGroups: [ + { + name: "CostSaving", + description: + "Policies designed to control spend within a subscription.", + displayName: "Cost Management Policies" + }, + { + name: "Organizational", + description: + "Policies that help enforce resource organization standards within a subscription.", + displayName: "Organizational Policies" + } + ], + policyDefinitions: [ + { + groupNames: ["CostSaving"], + parameters: { + listOfAllowedSKUs: { value: ["Standard_GRS", "Standard_LRS"] } + }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1", + policyDefinitionReferenceId: "Limit_Skus" + }, + { + groupNames: ["Organizational"], + parameters: { prefix: { value: "DeptA" }, suffix: { value: "-LC" } }, + policyDefinitionId: + "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", + policyDefinitionReferenceId: "Resource_Naming" + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.createOrUpdate( + policySetDefinitionName, + parameters + ); + console.log(result); +} + +createOrUpdateAPolicySetDefinitionWithGroups().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsDeleteAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsDeleteAtManagementGroupSample.ts new file mode 100644 index 000000000000..049650909401 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsDeleteAtManagementGroupSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation deletes the policy set definition in the given management group with the given name. + * + * @summary This operation deletes the policy set definition in the given management group with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicySetDefinitionAtManagementGroup.json + */ +async function deleteAPolicySetDefinitionAtManagementGroupLevel() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policySetDefinitionName = "CostManagement"; + const managementGroupId = "MyManagementGroup"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.deleteAtManagementGroup( + policySetDefinitionName, + managementGroupId + ); + console.log(result); +} + +deleteAPolicySetDefinitionAtManagementGroupLevel().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsDeleteSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsDeleteSample.ts new file mode 100644 index 000000000000..f677be46c467 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsDeleteSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation deletes the policy set definition in the given subscription with the given name. + * + * @summary This operation deletes the policy set definition in the given subscription with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicySetDefinition.json + */ +async function deleteAPolicySetDefinition() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policySetDefinitionName = "CostManagement"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.delete( + policySetDefinitionName + ); + console.log(result); +} + +deleteAPolicySetDefinition().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsGetAtManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsGetAtManagementGroupSample.ts new file mode 100644 index 000000000000..5bc3ae6bc005 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsGetAtManagementGroupSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the policy set definition in the given management group with the given name. + * + * @summary This operation retrieves the policy set definition in the given management group with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinitionAtManagementGroup.json + */ +async function retrieveAPolicySetDefinitionAtManagementGroupLevel() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policySetDefinitionName = "CostManagement"; + const managementGroupId = "MyManagementGroup"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.getAtManagementGroup( + policySetDefinitionName, + managementGroupId + ); + console.log(result); +} + +retrieveAPolicySetDefinitionAtManagementGroupLevel().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsGetBuiltInSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsGetBuiltInSample.ts new file mode 100644 index 000000000000..eaa2ab035acc --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsGetBuiltInSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the built-in policy set definition with the given name. + * + * @summary This operation retrieves the built-in policy set definition with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getBuiltInPolicySetDefinition.json + */ +async function retrieveABuiltInPolicySetDefinition() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const policySetDefinitionName = "1f3afdf9-d0c9-4c3d-847f-89da613e70a8"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.getBuiltIn( + policySetDefinitionName + ); + console.log(result); +} + +retrieveABuiltInPolicySetDefinition().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsGetSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsGetSample.ts new file mode 100644 index 000000000000..f157eb34c168 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsGetSample.ts @@ -0,0 +1,29 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves the policy set definition in the given subscription with the given name. + * + * @summary This operation retrieves the policy set definition in the given subscription with the given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinition.json + */ +async function retrieveAPolicySetDefinition() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const policySetDefinitionName = "CostManagement"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const result = await client.policySetDefinitions.get(policySetDefinitionName); + console.log(result); +} + +retrieveAPolicySetDefinition().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsListBuiltInSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsListBuiltInSample.ts new file mode 100644 index 000000000000..39c0fa42c3b7 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsListBuiltInSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves a list of all the built-in policy set definitions that match the optional given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy set definitions whose category match the {value}. + * + * @summary This operation retrieves a list of all the built-in policy set definitions that match the optional given $filter. If $filter='category -eq {value}' is provided, the returned list only includes all built-in policy set definitions whose category match the {value}. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listBuiltInPolicySetDefinitions.json + */ +async function listBuiltInPolicySetDefinitions() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policySetDefinitions.listBuiltIn()) { + resArray.push(item); + } + console.log(resArray); +} + +listBuiltInPolicySetDefinitions().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsListByManagementGroupSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsListByManagementGroupSample.ts new file mode 100644 index 000000000000..7ad9f07b3d79 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsListByManagementGroupSample.ts @@ -0,0 +1,34 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves a list of all the policy set definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. + * + * @summary This operation retrieves a list of all the policy set definitions in a given management group that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the management group, including those that apply directly or from management groups that contain the given management group. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given management group. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicySetDefinitionsByManagementGroup.json + */ +async function listPolicySetDefinitionsAtManagementGroupLevel() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const managementGroupId = "MyManagementGroup"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policySetDefinitions.listByManagementGroup( + managementGroupId + )) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicySetDefinitionsAtManagementGroupLevel().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsListSample.ts b/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsListSample.ts new file mode 100644 index 000000000000..9f7ffe53961a --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/src/policySetDefinitionsListSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { PolicyClient } from "@azure/arm-policy"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation retrieves a list of all the policy set definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. + * + * @summary This operation retrieves a list of all the policy set definitions in a given subscription that match the optional given $filter. Valid values for $filter are: 'atExactScope()', 'policyType -eq {value}' or 'category eq '{value}''. If $filter is not provided, the unfiltered list includes all policy set definitions associated with the subscription, including those that apply directly or from management groups that contain the given subscription. If $filter=atExactScope() is provided, the returned list only includes all policy set definitions that at the given subscription. If $filter='policyType -eq {value}' is provided, the returned list only includes all policy set definitions whose type match the {value}. Possible policyType values are NotSpecified, BuiltIn and Custom. If $filter='category -eq {value}' is provided, the returned list only includes all policy set definitions whose category match the {value}. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicySetDefinitions.json + */ +async function listPolicySetDefinitions() { + const subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + const credential = new DefaultAzureCredential(); + const client = new PolicyClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.policySetDefinitions.list()) { + resArray.push(item); + } + console.log(resArray); +} + +listPolicySetDefinitions().catch(console.error); diff --git a/sdk/policy/arm-policy/samples/v5/typescript/tsconfig.json b/sdk/policy/arm-policy/samples/v5/typescript/tsconfig.json new file mode 100644 index 000000000000..416c2dd82e00 --- /dev/null +++ b/sdk/policy/arm-policy/samples/v5/typescript/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2018", + "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/policy/arm-policy/src/policyClient.ts b/sdk/policy/arm-policy/src/policyClient.ts index df8f68c3339f..2c71d0401974 100644 --- a/sdk/policy/arm-policy/src/policyClient.ts +++ b/sdk/policy/arm-policy/src/policyClient.ts @@ -7,6 +7,7 @@ */ import * as coreClient from "@azure/core-client"; +import * as coreRestPipeline from "@azure/core-rest-pipeline"; import * as coreAuth from "@azure/core-auth"; import { DataPolicyManifestsImpl, @@ -55,7 +56,7 @@ export class PolicyClient extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-policy/5.0.0`; + const packageDetails = `azsdk-js-arm-policy/5.0.1`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` @@ -70,9 +71,33 @@ export class PolicyClient extends coreClient.ServiceClient { userAgentOptions: { userAgentPrefix }, - baseUri: options.endpoint || "https://management.azure.com" + baseUri: + options.endpoint ?? options.baseUri ?? "https://management.azure.com" }; super(optionsWithDefaults); + + if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { + const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies(); + const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( + (pipelinePolicy) => + pipelinePolicy.name === + coreRestPipeline.bearerTokenAuthenticationPolicyName + ); + if (!bearerTokenAuthenticationPolicyFound) { + this.pipeline.removePolicy({ + name: coreRestPipeline.bearerTokenAuthenticationPolicyName + }); + this.pipeline.addPolicy( + coreRestPipeline.bearerTokenAuthenticationPolicy({ + scopes: `${optionsWithDefaults.baseUri}/.default`, + challengeCallbacks: { + authorizeRequestOnChallenge: + coreClient.authorizeRequestOnClaimChallenge + } + }) + ); + } + } // Parameter assignments this.subscriptionId = subscriptionId; diff --git a/sdk/policy/arm-policy/test/policy_examples.ts b/sdk/policy/arm-policy/test/policy_examples.ts index f09a21711283..013697f871e2 100644 --- a/sdk/policy/arm-policy/test/policy_examples.ts +++ b/sdk/policy/arm-policy/test/policy_examples.ts @@ -50,7 +50,7 @@ describe("Policy test", () => { let scope: string; let policyAssignmentName: string; - beforeEach(async function() { + beforeEach(async function () { recorder = record(this, recorderEnvSetup); subscriptionId = env.SUBSCRIPTION_ID; // This is an example of how the environment variables are used @@ -68,79 +68,79 @@ describe("Policy test", () => { policyAssignmentName = "passigment"; }); - afterEach(async function() { + afterEach(async function () { await recorder.stop(); }); - it("policyDefinitions create test", async function() { - const res = await client.policyDefinitions.createOrUpdateAtManagementGroup(policyName,groupId,{ + it("policyDefinitions create test", async function () { + const res = await client.policyDefinitions.createOrUpdateAtManagementGroup(policyName, groupId, { policyType: "Custom", - description: "Don't create a VM anywhere", - policyRule: { - if: { - allof: [ - { - source: "action", - equals: "Microsoft.Compute/virtualMachines/write", - }, - { - field: "location", - in: ["eastus", "eastus2", "centralus"], - }, - ], - }, - then: { - effect: "deny", - }, - } + description: "Don't create a VM anywhere", + policyRule: { + if: { + allof: [ + { + source: "action", + equals: "Microsoft.Compute/virtualMachines/write", + }, + { + field: "location", + in: ["eastus", "eastus2", "centralus"], + }, + ], + }, + then: { + effect: "deny", + }, + } }) - assert.equal(res.name,policyName); + assert.equal(res.name, policyName); }); - it("policyDefinitions get test", async function() { - const res = await client.policyDefinitions.getAtManagementGroup(policyName,groupId); - assert.equal(res.name,policyName); + it("policyDefinitions get test", async function () { + const res = await client.policyDefinitions.getAtManagementGroup(policyName, groupId); + assert.equal(res.name, policyName); }); - it("policyDefinitions list test", async function() { + it("policyDefinitions list test", async function () { const resArray = new Array(); - for await (let item of client.policyDefinitions.listByManagementGroup(groupId)){ + for await (let item of client.policyDefinitions.listByManagementGroup(groupId)) { resArray.push(item); } - assert.notEqual(resArray.length,0); + assert.notEqual(resArray.length, 0); }); - it("policyAssignments create test", async function() { - const definition = await client.policyDefinitions.getAtManagementGroup(policyName,groupId); - const res = await client.policyAssignments.create(scope,policyAssignmentName,{ + it("policyAssignments create test", async function () { + const definition = await client.policyDefinitions.getAtManagementGroup(policyName, groupId); + const res = await client.policyAssignments.create(scope, policyAssignmentName, { policyDefinitionId: definition.id }) - assert.equal(res.name,policyAssignmentName); + assert.equal(res.name, policyAssignmentName); }); - it("policyAssignments get test", async function() { - const res = await client.policyAssignments.get(scope,policyAssignmentName); - assert.equal(res.name,policyAssignmentName); + it("policyAssignments get test", async function () { + const res = await client.policyAssignments.get(scope, policyAssignmentName); + assert.equal(res.name, policyAssignmentName); }); - it("policyAssignments list test", async function() { + it("policyAssignments list test", async function () { const resArray = new Array(); - for await (let item of client.policyAssignments.list()){ + for await (let item of client.policyAssignments.list()) { resArray.push(item); } - assert.notEqual(resArray.length,0); + assert.notEqual(resArray.length, 0); }); - it("policyAssignments delete test", async function() { - const res = await client.policyAssignments.delete(scope,policyAssignmentName); + it("policyAssignments delete test", async function () { + const res = await client.policyAssignments.delete(scope, policyAssignmentName); const resArray = new Array(); - for await (let item of client.policyAssignments.list()){ + for await (let item of client.policyAssignments.list()) { resArray.push(item); } - assert.notEqual(resArray.length,0); + assert.notEqual(resArray.length, 0); }); - it("policyDefinitions delete test", async function() { - const res = await client.policyDefinitions.deleteAtManagementGroup(policyName,groupId); + it("policyDefinitions delete test", async function () { + const res = await client.policyDefinitions.deleteAtManagementGroup(policyName, groupId); }); }); diff --git a/sdk/policy/arm-policy/tsconfig.json b/sdk/policy/arm-policy/tsconfig.json index 6e3251194117..6a98d34a03ed 100644 --- a/sdk/policy/arm-policy/tsconfig.json +++ b/sdk/policy/arm-policy/tsconfig.json @@ -9,11 +9,31 @@ "esModuleInterop": true, "allowSyntheticDefaultImports": true, "forceConsistentCasingInFileNames": true, - "lib": ["es6", "dom"], + "lib": [ + "es6", + "dom" + ], "declaration": true, "outDir": "./dist-esm", - "importHelpers": true + "importHelpers": true, + "paths": { + "@azure/arm-policy": [ + "./src/index" + ] + } }, - "include": ["./src/**/*.ts", "./test/**/*.ts"], - "exclude": ["node_modules"] -} + "include": [ + "./src/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts" + ], + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/sdk/policy/ci.mgmt.yml b/sdk/policy/ci.mgmt.yml index c436db498f2c..f625b32e10bc 100644 --- a/sdk/policy/ci.mgmt.yml +++ b/sdk/policy/ci.mgmt.yml @@ -11,6 +11,7 @@ trigger: - sdk/policy/ci.mgmt.yml - sdk/policy/arm-policy/ - sdk/policy/arm-policy-profile-2020-09-01-hybrid + - sdk/policy/arm-policy pr: branches: include: @@ -25,6 +26,7 @@ pr: - sdk/policy/ci.mgmt.yml - sdk/policy/arm-policy/ - sdk/policy/arm-policy-profile-2020-09-01-hybrid + - sdk/policy/arm-policy extends: template: /eng/pipelines/templates/stages/archetype-sdk-client.yml parameters: diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/CHANGELOG.md b/sdk/resources-subscriptions/arm-resources-subscriptions/CHANGELOG.md index 8ce89dbbad49..09638996a453 100644 --- a/sdk/resources-subscriptions/arm-resources-subscriptions/CHANGELOG.md +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/CHANGELOG.md @@ -1,14 +1,10 @@ # Release History -## 2.0.1 (Unreleased) +## 2.0.1 (2022-04-18) -### Features Added +**features** -### Breaking Changes - -### Bugs Fixed - -### Other Changes + - Bug fix ## 2.0.0 (2021-12-16) diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/LICENSE b/sdk/resources-subscriptions/arm-resources-subscriptions/LICENSE index ccb63b166732..5d1d36e0af80 100644 --- a/sdk/resources-subscriptions/arm-resources-subscriptions/LICENSE +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2021 Microsoft +Copyright (c) 2022 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/resources-subscriptions/arm-resources-subscriptions/README.md b/sdk/resources-subscriptions/arm-resources-subscriptions/README.md index 4b70c812c97d..d29d253f7476 100644 --- a/sdk/resources-subscriptions/arm-resources-subscriptions/README.md +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/README.md @@ -16,6 +16,8 @@ All resource groups and resources exist within subscriptions. These operation en - [LTS versions of Node.js](https://nodejs.org/about/releases/) - 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]. @@ -49,7 +51,17 @@ For more information about how to create an Azure AD Application check out [this ```javascript const { SubscriptionClient } = require("@azure/arm-resources-subscriptions"); const { DefaultAzureCredential } = require("@azure/identity"); -const client = new SubscriptionClient(new DefaultAzureCredential()); +// 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 SubscriptionClient(new DefaultAzureCredential(), subscriptionId); + +// For client-side applications running in the browser, use this code instead: +// const credential = new InteractiveBrowserCredential({ +// tenantId: "", +// clientId: "" +// }); +// const client = new SubscriptionClient(credential, subscriptionId); ``` diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/_meta.json b/sdk/resources-subscriptions/arm-resources-subscriptions/_meta.json index 44e0b401977a..c6765ba542bb 100644 --- a/sdk/resources-subscriptions/arm-resources-subscriptions/_meta.json +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/_meta.json @@ -1,7 +1,8 @@ { - "commit": "ea0f7b072ad3aaff203ea9003246b9e584b819ff", - "readme": "specification/resources/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 --generate-test --typescript-sdks-folder=D:\\mydev\\azure-sdk-for-js ../azure-rest-api-specs/specification/resources/resource-manager/readme.md --use=@autorest/typescript@6.0.0-alpha.16.20211207.1", + "commit": "a42f1b58607091c4f255ead152a8ef323fa0b280", + "readme": "specification\\resources\\resource-manager\\readme.md", + "autorest_command": "autorest --version=3.7.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\work\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\resources\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-alpha.19.20220408.1 --generate-sample=true", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "use": "@autorest/typescript@6.0.0-alpha.16.20211207.1" + "release_tool": "@azure-tools/js-sdk-release-tools@2.2.6", + "use": "@autorest/typescript@6.0.0-alpha.19.20220408.1" } \ No newline at end of file diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/api-extractor.json b/sdk/resources-subscriptions/arm-resources-subscriptions/api-extractor.json index c8418c03f72e..e6ee8b9d231c 100644 --- a/sdk/resources-subscriptions/arm-resources-subscriptions/api-extractor.json +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/api-extractor.json @@ -1,18 +1,31 @@ { "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", "mainEntryPointFilePath": "./dist-esm/src/index.d.ts", - "docModel": { "enabled": true }, - "apiReport": { "enabled": true, "reportFolder": "./review" }, + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, "dtsRollup": { "enabled": true, "untrimmedFilePath": "", "publicTrimmedFilePath": "./types/arm-resources-subscriptions.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/resources-subscriptions/arm-resources-subscriptions/package.json b/sdk/resources-subscriptions/arm-resources-subscriptions/package.json index 4ec0b028e816..fa31e679a675 100644 --- a/sdk/resources-subscriptions/arm-resources-subscriptions/package.json +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/package.json @@ -9,9 +9,9 @@ }, "dependencies": { "@azure/core-paging": "^1.2.0", - "@azure/core-client": "^1.0.0", + "@azure/core-client": "^1.5.0", "@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": [ @@ -28,12 +28,12 @@ "devDependencies": { "@microsoft/api-extractor": "^7.18.11", "@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-plugin-sourcemaps": "^0.4.2", + "rollup": "^2.66.1", + "rollup-plugin-sourcemaps": "^0.6.3", "typescript": "~4.2.0", "uglify-js": "^3.4.9", "rimraf": "^3.0.0", @@ -96,5 +96,21 @@ "docs": "echo skipped" }, "sideEffects": false, - "autoPublish": true + "//metadata": { + "constantPaths": [ + { + "path": "src/subscriptionClient.ts", + "prefix": "packageDetails" + } + ] + }, + "autoPublish": true, + "//sampleConfiguration": { + "productName": "", + "productSlugs": [ + "azure" + ], + "disableDocsMs": true, + "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-resources-subscriptions?view=azure-node-preview" + } } diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/rollup.config.js b/sdk/resources-subscriptions/arm-resources-subscriptions/rollup.config.js index 9be1955eb7f1..3f89d7309da5 100644 --- a/sdk/resources-subscriptions/arm-resources-subscriptions/rollup.config.js +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/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/resources-subscriptions/arm-resources-subscriptions/sample.env b/sdk/resources-subscriptions/arm-resources-subscriptions/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/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/resources-subscriptions/arm-resources-subscriptions/samples-dev/checkResourceNameSample.ts b/sdk/resources-subscriptions/arm-resources-subscriptions/samples-dev/checkResourceNameSample.ts new file mode 100644 index 000000000000..122651ad1707 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/samples-dev/checkResourceNameSample.ts @@ -0,0 +1,27 @@ +/* + * 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 { SubscriptionClient } from "@azure/arm-resources-subscriptions"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to A resource name is valid if it is not a reserved word, does not contains a reserved word and does not start with a reserved word + * + * @summary A resource name is valid if it is not a reserved word, does not contains a reserved word and does not start with a reserved word + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/CheckResourceName.json + */ +async function checkValidityForAResourceName() { + const credential = new DefaultAzureCredential(); + const client = new SubscriptionClient(credential); + const result = await client.checkResourceName(); + console.log(result); +} + +checkValidityForAResourceName().catch(console.error); diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/samples-dev/subscriptionsGetSample.ts b/sdk/resources-subscriptions/arm-resources-subscriptions/samples-dev/subscriptionsGetSample.ts new file mode 100644 index 000000000000..0e569720616d --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/samples-dev/subscriptionsGetSample.ts @@ -0,0 +1,28 @@ +/* + * 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 { SubscriptionClient } from "@azure/arm-resources-subscriptions"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets details about a specified subscription. + * + * @summary Gets details about a specified subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetSubscription.json + */ +async function getASingleSubscription() { + const subscriptionId = "291bba3f-e0a5-47bc-a099-3bdcb2a50a05"; + const credential = new DefaultAzureCredential(); + const client = new SubscriptionClient(credential); + const result = await client.subscriptions.get(subscriptionId); + console.log(result); +} + +getASingleSubscription().catch(console.error); diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/samples-dev/subscriptionsListLocationsSample.ts b/sdk/resources-subscriptions/arm-resources-subscriptions/samples-dev/subscriptionsListLocationsSample.ts new file mode 100644 index 000000000000..b62c8e593805 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/samples-dev/subscriptionsListLocationsSample.ts @@ -0,0 +1,60 @@ +/* + * 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 { + SubscriptionsListLocationsOptionalParams, + SubscriptionClient +} from "@azure/arm-resources-subscriptions"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. + * + * @summary This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetLocations.json + */ +async function getLocationsWithASubscriptionId() { + const subscriptionId = "291bba3f-e0a5-47bc-a099-3bdcb2a50a05"; + const credential = new DefaultAzureCredential(); + const client = new SubscriptionClient(credential); + const resArray = new Array(); + for await (let item of client.subscriptions.listLocations(subscriptionId)) { + resArray.push(item); + } + console.log(resArray); +} + +getLocationsWithASubscriptionId().catch(console.error); + +/** + * This sample demonstrates how to This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. + * + * @summary This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetLocationsWithExtendedLocations.json + */ +async function getLocationsWithExtendedLocations() { + const subscriptionId = "291bba3f-e0a5-47bc-a099-3bdcb2a50a05"; + const includeExtendedLocations = true; + const options: SubscriptionsListLocationsOptionalParams = { + includeExtendedLocations + }; + const credential = new DefaultAzureCredential(); + const client = new SubscriptionClient(credential); + const resArray = new Array(); + for await (let item of client.subscriptions.listLocations( + subscriptionId, + options + )) { + resArray.push(item); + } + console.log(resArray); +} + +getLocationsWithExtendedLocations().catch(console.error); diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/samples-dev/subscriptionsListSample.ts b/sdk/resources-subscriptions/arm-resources-subscriptions/samples-dev/subscriptionsListSample.ts new file mode 100644 index 000000000000..674735994a89 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/samples-dev/subscriptionsListSample.ts @@ -0,0 +1,30 @@ +/* + * 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 { SubscriptionClient } from "@azure/arm-resources-subscriptions"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all subscriptions for a tenant. + * + * @summary Gets all subscriptions for a tenant. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetSubscriptions.json + */ +async function getAllSubscriptions() { + const credential = new DefaultAzureCredential(); + const client = new SubscriptionClient(credential); + const resArray = new Array(); + for await (let item of client.subscriptions.list()) { + resArray.push(item); + } + console.log(resArray); +} + +getAllSubscriptions().catch(console.error); diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/samples-dev/tenantsListSample.ts b/sdk/resources-subscriptions/arm-resources-subscriptions/samples-dev/tenantsListSample.ts new file mode 100644 index 000000000000..43f6e7ad2e8a --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/samples-dev/tenantsListSample.ts @@ -0,0 +1,30 @@ +/* + * 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 { SubscriptionClient } from "@azure/arm-resources-subscriptions"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the tenants for your account. + * + * @summary Gets the tenants for your account. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetTenants.json + */ +async function getAllTenants() { + const credential = new DefaultAzureCredential(); + const client = new SubscriptionClient(credential); + const resArray = new Array(); + for await (let item of client.tenants.list()) { + resArray.push(item); + } + console.log(resArray); +} + +getAllTenants().catch(console.error); diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/README.md b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/README.md new file mode 100644 index 000000000000..fd1a252f9d41 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/README.md @@ -0,0 +1,58 @@ +# client library samples for JavaScript + +These sample programs show how to use the JavaScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [checkResourceNameSample.js][checkresourcenamesample] | A resource name is valid if it is not a reserved word, does not contains a reserved word and does not start with a reserved word x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/CheckResourceName.json | +| [subscriptionsGetSample.js][subscriptionsgetsample] | Gets details about a specified subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetSubscription.json | +| [subscriptionsListLocationsSample.js][subscriptionslistlocationssample] | This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetLocations.json | +| [subscriptionsListSample.js][subscriptionslistsample] | Gets all subscriptions for a tenant. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetSubscriptions.json | +| [tenantsListSample.js][tenantslistsample] | Gets the tenants for your account. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetTenants.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +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 checkResourceNameSample.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 node checkResourceNameSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[checkresourcenamesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/checkResourceNameSample.js +[subscriptionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/subscriptionsGetSample.js +[subscriptionslistlocationssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/subscriptionsListLocationsSample.js +[subscriptionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/subscriptionsListSample.js +[tenantslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/tenantsListSample.js +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-resources-subscriptions?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/resources-subscriptions/arm-resources-subscriptions/README.md diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/checkResourceNameSample.js b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/checkResourceNameSample.js new file mode 100644 index 000000000000..1d5182e21be7 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/checkResourceNameSample.js @@ -0,0 +1,27 @@ +/* + * 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 { SubscriptionClient } = require("@azure/arm-resources-subscriptions"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to A resource name is valid if it is not a reserved word, does not contains a reserved word and does not start with a reserved word + * + * @summary A resource name is valid if it is not a reserved word, does not contains a reserved word and does not start with a reserved word + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/CheckResourceName.json + */ +async function checkValidityForAResourceName() { + const credential = new DefaultAzureCredential(); + const client = new SubscriptionClient(credential); + const result = await client.checkResourceName(); + console.log(result); +} + +checkValidityForAResourceName().catch(console.error); diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/package.json b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/package.json new file mode 100644 index 000000000000..60bd2680eab5 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/package.json @@ -0,0 +1,32 @@ +{ + "name": "@azure-samples/arm-resources-subscriptions-js", + "private": true, + "version": "1.0.0", + "description": " client library samples for JavaScript", + "engines": { + "node": ">=12.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/resources-subscriptions/arm-resources-subscriptions" + }, + "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/resources-subscriptions/arm-resources-subscriptions", + "dependencies": { + "@azure/arm-resources-subscriptions": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + } +} diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/sample.env b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/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/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/subscriptionsGetSample.js b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/subscriptionsGetSample.js new file mode 100644 index 000000000000..4f234581e8f3 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/subscriptionsGetSample.js @@ -0,0 +1,28 @@ +/* + * 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 { SubscriptionClient } = require("@azure/arm-resources-subscriptions"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets details about a specified subscription. + * + * @summary Gets details about a specified subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetSubscription.json + */ +async function getASingleSubscription() { + const subscriptionId = "291bba3f-e0a5-47bc-a099-3bdcb2a50a05"; + const credential = new DefaultAzureCredential(); + const client = new SubscriptionClient(credential); + const result = await client.subscriptions.get(subscriptionId); + console.log(result); +} + +getASingleSubscription().catch(console.error); diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/subscriptionsListLocationsSample.js b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/subscriptionsListLocationsSample.js new file mode 100644 index 000000000000..a61127ff9b2f --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/subscriptionsListLocationsSample.js @@ -0,0 +1,54 @@ +/* + * 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 { SubscriptionClient } = require("@azure/arm-resources-subscriptions"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. + * + * @summary This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetLocations.json + */ +async function getLocationsWithASubscriptionId() { + const subscriptionId = "291bba3f-e0a5-47bc-a099-3bdcb2a50a05"; + const credential = new DefaultAzureCredential(); + const client = new SubscriptionClient(credential); + const resArray = new Array(); + for await (let item of client.subscriptions.listLocations(subscriptionId)) { + resArray.push(item); + } + console.log(resArray); +} + +getLocationsWithASubscriptionId().catch(console.error); + +/** + * This sample demonstrates how to This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. + * + * @summary This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetLocationsWithExtendedLocations.json + */ +async function getLocationsWithExtendedLocations() { + const subscriptionId = "291bba3f-e0a5-47bc-a099-3bdcb2a50a05"; + const includeExtendedLocations = true; + const options = { + includeExtendedLocations, + }; + const credential = new DefaultAzureCredential(); + const client = new SubscriptionClient(credential); + const resArray = new Array(); + for await (let item of client.subscriptions.listLocations(subscriptionId, options)) { + resArray.push(item); + } + console.log(resArray); +} + +getLocationsWithExtendedLocations().catch(console.error); diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/subscriptionsListSample.js b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/subscriptionsListSample.js new file mode 100644 index 000000000000..897894412fc3 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/subscriptionsListSample.js @@ -0,0 +1,30 @@ +/* + * 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 { SubscriptionClient } = require("@azure/arm-resources-subscriptions"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets all subscriptions for a tenant. + * + * @summary Gets all subscriptions for a tenant. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetSubscriptions.json + */ +async function getAllSubscriptions() { + const credential = new DefaultAzureCredential(); + const client = new SubscriptionClient(credential); + const resArray = new Array(); + for await (let item of client.subscriptions.list()) { + resArray.push(item); + } + console.log(resArray); +} + +getAllSubscriptions().catch(console.error); diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/tenantsListSample.js b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/tenantsListSample.js new file mode 100644 index 000000000000..7e3909ade514 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/javascript/tenantsListSample.js @@ -0,0 +1,30 @@ +/* + * 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 { SubscriptionClient } = require("@azure/arm-resources-subscriptions"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets the tenants for your account. + * + * @summary Gets the tenants for your account. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetTenants.json + */ +async function getAllTenants() { + const credential = new DefaultAzureCredential(); + const client = new SubscriptionClient(credential); + const resArray = new Array(); + for await (let item of client.tenants.list()) { + resArray.push(item); + } + console.log(resArray); +} + +getAllTenants().catch(console.error); diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/README.md b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/README.md new file mode 100644 index 000000000000..916745f5d8c2 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/README.md @@ -0,0 +1,71 @@ +# client library samples for TypeScript + +These sample programs show how to use the TypeScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [checkResourceNameSample.ts][checkresourcenamesample] | A resource name is valid if it is not a reserved word, does not contains a reserved word and does not start with a reserved word x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/CheckResourceName.json | +| [subscriptionsGetSample.ts][subscriptionsgetsample] | Gets details about a specified subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetSubscription.json | +| [subscriptionsListLocationsSample.ts][subscriptionslistlocationssample] | This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetLocations.json | +| [subscriptionsListSample.ts][subscriptionslistsample] | Gets all subscriptions for a tenant. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetSubscriptions.json | +| [tenantsListSample.ts][tenantslistsample] | Gets the tenants for your account. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetTenants.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +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/checkResourceNameSample.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 node dist/checkResourceNameSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[checkresourcenamesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/src/checkResourceNameSample.ts +[subscriptionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/src/subscriptionsGetSample.ts +[subscriptionslistlocationssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/src/subscriptionsListLocationsSample.ts +[subscriptionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/src/subscriptionsListSample.ts +[tenantslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/src/tenantsListSample.ts +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-resources-subscriptions?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/resources-subscriptions/arm-resources-subscriptions/README.md +[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/package.json b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/package.json new file mode 100644 index 000000000000..b8583fdbce44 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/package.json @@ -0,0 +1,41 @@ +{ + "name": "@azure-samples/arm-resources-subscriptions-ts", + "private": true, + "version": "1.0.0", + "description": " client library samples for TypeScript", + "engines": { + "node": ">=12.0.0" + }, + "scripts": { + "build": "tsc", + "prebuild": "rimraf dist/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/resources-subscriptions/arm-resources-subscriptions" + }, + "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/resources-subscriptions/arm-resources-subscriptions", + "dependencies": { + "@azure/arm-resources-subscriptions": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + }, + "devDependencies": { + "@types/node": "^12.0.0", + "typescript": "~4.4.0", + "rimraf": "latest" + } +} diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/sample.env b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/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/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/src/checkResourceNameSample.ts b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/src/checkResourceNameSample.ts new file mode 100644 index 000000000000..122651ad1707 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/src/checkResourceNameSample.ts @@ -0,0 +1,27 @@ +/* + * 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 { SubscriptionClient } from "@azure/arm-resources-subscriptions"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to A resource name is valid if it is not a reserved word, does not contains a reserved word and does not start with a reserved word + * + * @summary A resource name is valid if it is not a reserved word, does not contains a reserved word and does not start with a reserved word + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/CheckResourceName.json + */ +async function checkValidityForAResourceName() { + const credential = new DefaultAzureCredential(); + const client = new SubscriptionClient(credential); + const result = await client.checkResourceName(); + console.log(result); +} + +checkValidityForAResourceName().catch(console.error); diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/src/subscriptionsGetSample.ts b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/src/subscriptionsGetSample.ts new file mode 100644 index 000000000000..0e569720616d --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/src/subscriptionsGetSample.ts @@ -0,0 +1,28 @@ +/* + * 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 { SubscriptionClient } from "@azure/arm-resources-subscriptions"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets details about a specified subscription. + * + * @summary Gets details about a specified subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetSubscription.json + */ +async function getASingleSubscription() { + const subscriptionId = "291bba3f-e0a5-47bc-a099-3bdcb2a50a05"; + const credential = new DefaultAzureCredential(); + const client = new SubscriptionClient(credential); + const result = await client.subscriptions.get(subscriptionId); + console.log(result); +} + +getASingleSubscription().catch(console.error); diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/src/subscriptionsListLocationsSample.ts b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/src/subscriptionsListLocationsSample.ts new file mode 100644 index 000000000000..b62c8e593805 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/src/subscriptionsListLocationsSample.ts @@ -0,0 +1,60 @@ +/* + * 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 { + SubscriptionsListLocationsOptionalParams, + SubscriptionClient +} from "@azure/arm-resources-subscriptions"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. + * + * @summary This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetLocations.json + */ +async function getLocationsWithASubscriptionId() { + const subscriptionId = "291bba3f-e0a5-47bc-a099-3bdcb2a50a05"; + const credential = new DefaultAzureCredential(); + const client = new SubscriptionClient(credential); + const resArray = new Array(); + for await (let item of client.subscriptions.listLocations(subscriptionId)) { + resArray.push(item); + } + console.log(resArray); +} + +getLocationsWithASubscriptionId().catch(console.error); + +/** + * This sample demonstrates how to This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. + * + * @summary This operation provides all the locations that are available for resource providers; however, each resource provider may support a subset of this list. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetLocationsWithExtendedLocations.json + */ +async function getLocationsWithExtendedLocations() { + const subscriptionId = "291bba3f-e0a5-47bc-a099-3bdcb2a50a05"; + const includeExtendedLocations = true; + const options: SubscriptionsListLocationsOptionalParams = { + includeExtendedLocations + }; + const credential = new DefaultAzureCredential(); + const client = new SubscriptionClient(credential); + const resArray = new Array(); + for await (let item of client.subscriptions.listLocations( + subscriptionId, + options + )) { + resArray.push(item); + } + console.log(resArray); +} + +getLocationsWithExtendedLocations().catch(console.error); diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/src/subscriptionsListSample.ts b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/src/subscriptionsListSample.ts new file mode 100644 index 000000000000..674735994a89 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/src/subscriptionsListSample.ts @@ -0,0 +1,30 @@ +/* + * 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 { SubscriptionClient } from "@azure/arm-resources-subscriptions"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all subscriptions for a tenant. + * + * @summary Gets all subscriptions for a tenant. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetSubscriptions.json + */ +async function getAllSubscriptions() { + const credential = new DefaultAzureCredential(); + const client = new SubscriptionClient(credential); + const resArray = new Array(); + for await (let item of client.subscriptions.list()) { + resArray.push(item); + } + console.log(resArray); +} + +getAllSubscriptions().catch(console.error); diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/src/tenantsListSample.ts b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/src/tenantsListSample.ts new file mode 100644 index 000000000000..43f6e7ad2e8a --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/src/tenantsListSample.ts @@ -0,0 +1,30 @@ +/* + * 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 { SubscriptionClient } from "@azure/arm-resources-subscriptions"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the tenants for your account. + * + * @summary Gets the tenants for your account. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-01-01/examples/GetTenants.json + */ +async function getAllTenants() { + const credential = new DefaultAzureCredential(); + const client = new SubscriptionClient(credential); + const resArray = new Array(); + for await (let item of client.tenants.list()) { + resArray.push(item); + } + console.log(resArray); +} + +getAllTenants().catch(console.error); diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/tsconfig.json b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/tsconfig.json new file mode 100644 index 000000000000..416c2dd82e00 --- /dev/null +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/samples/v2/typescript/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2018", + "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/resources-subscriptions/arm-resources-subscriptions/src/subscriptionClient.ts b/sdk/resources-subscriptions/arm-resources-subscriptions/src/subscriptionClient.ts index 62f638d02aac..0ebb0bf1d304 100644 --- a/sdk/resources-subscriptions/arm-resources-subscriptions/src/subscriptionClient.ts +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/src/subscriptionClient.ts @@ -7,6 +7,7 @@ */ import * as coreClient from "@azure/core-client"; +import * as coreRestPipeline from "@azure/core-rest-pipeline"; import * as coreAuth from "@azure/core-auth"; import { SubscriptionsImpl, TenantsImpl } from "./operations"; import { Subscriptions, Tenants } from "./operationsInterfaces"; @@ -44,7 +45,7 @@ export class SubscriptionClient extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-resources-subscriptions/2.0.0`; + const packageDetails = `azsdk-js-arm-resources-subscriptions/2.0.1`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` @@ -59,10 +60,34 @@ export class SubscriptionClient extends coreClient.ServiceClient { userAgentOptions: { userAgentPrefix }, - baseUri: options.endpoint || "https://management.azure.com" + baseUri: + options.endpoint ?? options.baseUri ?? "https://management.azure.com" }; super(optionsWithDefaults); + if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { + const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies(); + const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( + (pipelinePolicy) => + pipelinePolicy.name === + coreRestPipeline.bearerTokenAuthenticationPolicyName + ); + if (!bearerTokenAuthenticationPolicyFound) { + this.pipeline.removePolicy({ + name: coreRestPipeline.bearerTokenAuthenticationPolicyName + }); + this.pipeline.addPolicy( + coreRestPipeline.bearerTokenAuthenticationPolicy({ + scopes: `${optionsWithDefaults.baseUri}/.default`, + challengeCallbacks: { + authorizeRequestOnChallenge: + coreClient.authorizeRequestOnClaimChallenge + } + }) + ); + } + } + // Assigning values to Constant parameters this.$host = options.$host || "https://management.azure.com"; this.apiVersion = options.apiVersion || "2021-01-01"; diff --git a/sdk/resources-subscriptions/arm-resources-subscriptions/tsconfig.json b/sdk/resources-subscriptions/arm-resources-subscriptions/tsconfig.json index 6e3251194117..a3108459456b 100644 --- a/sdk/resources-subscriptions/arm-resources-subscriptions/tsconfig.json +++ b/sdk/resources-subscriptions/arm-resources-subscriptions/tsconfig.json @@ -9,11 +9,39 @@ "esModuleInterop": true, "allowSyntheticDefaultImports": true, "forceConsistentCasingInFileNames": true, - "lib": ["es6", "dom"], + "lib": [ + "es6", + "dom" + ], "declaration": true, "outDir": "./dist-esm", - "importHelpers": true + "importHelpers": true, + "paths": { + "@azure/arm-resources-subscriptions": [ + "./src/index" + ] + } }, - "include": ["./src/**/*.ts", "./test/**/*.ts"], - "exclude": ["node_modules"] -} + "include": [ + "./src/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts" + ], + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/sdk/resources-subscriptions/ci.mgmt.yml b/sdk/resources-subscriptions/ci.mgmt.yml index f03381b60be3..1e18fb43f1d9 100644 --- a/sdk/resources-subscriptions/ci.mgmt.yml +++ b/sdk/resources-subscriptions/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,7 +9,7 @@ trigger: paths: include: - sdk/resources-subscriptions/ci.mgmt.yml - - sdk/resources-subscriptions/arm-resources-subscriptions/ + - sdk/resources-subscriptions/arm-resources-subscriptions pr: branches: include: @@ -22,12 +22,11 @@ pr: paths: include: - sdk/resources-subscriptions/ci.mgmt.yml - - sdk/resources-subscriptions/arm-resources-subscriptions/ - + - sdk/resources-subscriptions/arm-resources-subscriptions extends: template: /eng/pipelines/templates/stages/archetype-sdk-client.yml parameters: ServiceDirectory: resources-subscriptions Artifacts: - name: azure-arm-resources-subscriptions - safeName: azurearmresourcessubscriptions \ No newline at end of file + safeName: azurearmresourcessubscriptions diff --git a/sdk/resources/arm-resources/CHANGELOG.md b/sdk/resources/arm-resources/CHANGELOG.md index 90feb450b39d..3d3c82735202 100644 --- a/sdk/resources/arm-resources/CHANGELOG.md +++ b/sdk/resources/arm-resources/CHANGELOG.md @@ -1,14 +1,10 @@ # Release History -## 5.0.1 (Unreleased) +## 5.0.1 (2022-04-18) -### Features Added +**features** -### Breaking Changes - -### Bugs Fixed - -### Other Changes + - Bug fix ## 5.0.0 (2021-12-06) diff --git a/sdk/resources/arm-resources/LICENSE b/sdk/resources/arm-resources/LICENSE index ccb63b166732..5d1d36e0af80 100644 --- a/sdk/resources/arm-resources/LICENSE +++ b/sdk/resources/arm-resources/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2021 Microsoft +Copyright (c) 2022 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/resources/arm-resources/README.md b/sdk/resources/arm-resources/README.md index 5fe029b8e1ce..1b8cbb6728f6 100644 --- a/sdk/resources/arm-resources/README.md +++ b/sdk/resources/arm-resources/README.md @@ -16,6 +16,8 @@ Provides operations for working with resources and resource groups. - [LTS versions of Node.js](https://nodejs.org/about/releases/) - 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]. @@ -49,8 +51,17 @@ For more information about how to create an Azure AD Application check out [this ```javascript const { ResourceManagementClient } = require("@azure/arm-resources"); 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 ResourceManagementClient(new DefaultAzureCredential(), subscriptionId); + +// For client-side applications running in the browser, use this code instead: +// const credential = new InteractiveBrowserCredential({ +// tenantId: "", +// clientId: "" +// }); +// const client = new ResourceManagementClient(credential, subscriptionId); ``` diff --git a/sdk/resources/arm-resources/_meta.json b/sdk/resources/arm-resources/_meta.json index 5d7ef963d992..c6765ba542bb 100644 --- a/sdk/resources/arm-resources/_meta.json +++ b/sdk/resources/arm-resources/_meta.json @@ -1,7 +1,8 @@ { - "commit": "3b2f85d320fac5b282bc80240f9e5c2c57753bad", - "readme": "specification/resources/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 --generate-test --typescript-sdks-folder=D:\\mydev\\azure-sdk-for-js ../azure-rest-api-specs/specification/resources/resource-manager/readme.md --use=@autorest/typescript@6.0.0-alpha.16.20211130.1", + "commit": "a42f1b58607091c4f255ead152a8ef323fa0b280", + "readme": "specification\\resources\\resource-manager\\readme.md", + "autorest_command": "autorest --version=3.7.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\work\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\resources\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-alpha.19.20220408.1 --generate-sample=true", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "use": "@autorest/typescript@6.0.0-alpha.16.20211130.1" + "release_tool": "@azure-tools/js-sdk-release-tools@2.2.6", + "use": "@autorest/typescript@6.0.0-alpha.19.20220408.1" } \ No newline at end of file diff --git a/sdk/resources/arm-resources/api-extractor.json b/sdk/resources/arm-resources/api-extractor.json index f15a9f7765b6..20477a758ec1 100644 --- a/sdk/resources/arm-resources/api-extractor.json +++ b/sdk/resources/arm-resources/api-extractor.json @@ -1,18 +1,31 @@ { "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", "mainEntryPointFilePath": "./dist-esm/src/index.d.ts", - "docModel": { "enabled": true }, - "apiReport": { "enabled": true, "reportFolder": "./review" }, + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, "dtsRollup": { "enabled": true, "untrimmedFilePath": "", "publicTrimmedFilePath": "./types/arm-resources.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/resources/arm-resources/package.json b/sdk/resources/arm-resources/package.json index 6243b25e1867..1aa3d4dbddc3 100644 --- a/sdk/resources/arm-resources/package.json +++ b/sdk/resources/arm-resources/package.json @@ -11,9 +11,9 @@ "@azure/core-lro": "^2.2.0", "@azure/abort-controller": "^1.0.0", "@azure/core-paging": "^1.2.0", - "@azure/core-client": "^1.0.0", + "@azure/core-client": "^1.5.0", "@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": [ @@ -30,12 +30,12 @@ "devDependencies": { "@microsoft/api-extractor": "^7.18.11", "@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-plugin-sourcemaps": "^0.4.2", + "rollup": "^2.66.1", + "rollup-plugin-sourcemaps": "^0.6.3", "typescript": "~4.2.0", "uglify-js": "^3.4.9", "rimraf": "^3.0.0", @@ -98,5 +98,21 @@ "docs": "echo skipped" }, "sideEffects": false, - "autoPublish": true + "//metadata": { + "constantPaths": [ + { + "path": "src/resourceManagementClient.ts", + "prefix": "packageDetails" + } + ] + }, + "autoPublish": true, + "//sampleConfiguration": { + "productName": "", + "productSlugs": [ + "azure" + ], + "disableDocsMs": true, + "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-resources?view=azure-node-preview" + } } diff --git a/sdk/resources/arm-resources/rollup.config.js b/sdk/resources/arm-resources/rollup.config.js index 9be1955eb7f1..3f89d7309da5 100644 --- a/sdk/resources/arm-resources/rollup.config.js +++ b/sdk/resources/arm-resources/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/resources/arm-resources/sample.env b/sdk/resources/arm-resources/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/resources/arm-resources/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/resources/arm-resources/samples-dev/deploymentsCalculateTemplateHashSample.ts b/sdk/resources/arm-resources/samples-dev/deploymentsCalculateTemplateHashSample.ts new file mode 100644 index 000000000000..ef98d9c46a68 --- /dev/null +++ b/sdk/resources/arm-resources/samples-dev/deploymentsCalculateTemplateHashSample.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 { ResourceManagementClient } from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Calculate the hash of the given template. + * + * @summary Calculate the hash of the given template. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/CalculateTemplateHash.json + */ +async function calculateTemplateHash() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const template: Record = { + $schema: + "http://schemas.management.azure.com/deploymentTemplate?api-version=2014-04-01-preview", + contentVersion: "1.0.0.0", + outputs: { string: { type: "string", value: "myvalue" } }, + parameters: { string: { type: "string" } }, + resources: [], + variables: { + array: [1, 2, 3, 4], + bool: true, + int: 42, + object: { object: { location: "West US", vmSize: "Large" } }, + string: "string" + } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.calculateTemplateHash(template); + console.log(result); +} + +calculateTemplateHash().catch(console.error); diff --git a/sdk/resources/arm-resources/samples-dev/deploymentsCreateOrUpdateAtManagementGroupScopeSample.ts b/sdk/resources/arm-resources/samples-dev/deploymentsCreateOrUpdateAtManagementGroupScopeSample.ts new file mode 100644 index 000000000000..67139e55ae43 --- /dev/null +++ b/sdk/resources/arm-resources/samples-dev/deploymentsCreateOrUpdateAtManagementGroupScopeSample.ts @@ -0,0 +1,45 @@ +/* + * 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 { + ScopedDeployment, + ResourceManagementClient +} from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to You can provide the template and parameters directly in the request or link to JSON files. + * + * @summary You can provide the template and parameters directly in the request or link to JSON files. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentAtManagementGroup.json + */ +async function createDeploymentAtManagementGroupScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const groupId = "my-management-group-id"; + const deploymentName = "my-deployment"; + const parameters: ScopedDeployment = { + location: "eastus", + properties: { + mode: "Incremental", + parameters: {}, + templateLink: { uri: "https://example.com/exampleTemplate.json" } + } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAtManagementGroupScopeAndWait( + groupId, + deploymentName, + parameters + ); + console.log(result); +} + +createDeploymentAtManagementGroupScope().catch(console.error); diff --git a/sdk/resources/arm-resources/samples-dev/deploymentsCreateOrUpdateAtScopeSample.ts b/sdk/resources/arm-resources/samples-dev/deploymentsCreateOrUpdateAtScopeSample.ts new file mode 100644 index 000000000000..b0efcc3ad039 --- /dev/null +++ b/sdk/resources/arm-resources/samples-dev/deploymentsCreateOrUpdateAtScopeSample.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 { Deployment, ResourceManagementClient } from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to You can provide the template and parameters directly in the request or link to JSON files. + * + * @summary You can provide the template and parameters directly in the request or link to JSON files. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentAtScope.json + */ +async function createDeploymentAtAGivenScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Management/managementGroups/my-management-group-id"; + const deploymentName = "my-deployment"; + const parameters: Deployment = { + location: "eastus", + properties: { + mode: "Incremental", + parameters: {}, + templateLink: { uri: "https://example.com/exampleTemplate.json" } + }, + tags: { tagKey1: "tag-value-1", tagKey2: "tag-value-2" } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAtScopeAndWait( + scope, + deploymentName, + parameters + ); + console.log(result); +} + +createDeploymentAtAGivenScope().catch(console.error); diff --git a/sdk/resources/arm-resources/samples-dev/deploymentsCreateOrUpdateAtSubscriptionScopeSample.ts b/sdk/resources/arm-resources/samples-dev/deploymentsCreateOrUpdateAtSubscriptionScopeSample.ts new file mode 100644 index 000000000000..2c7ba97b349c --- /dev/null +++ b/sdk/resources/arm-resources/samples-dev/deploymentsCreateOrUpdateAtSubscriptionScopeSample.ts @@ -0,0 +1,45 @@ +/* + * 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 { Deployment, ResourceManagementClient } from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to You can provide the template and parameters directly in the request or link to JSON files. + * + * @summary You can provide the template and parameters directly in the request or link to JSON files. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentSubscriptionTemplateSpecsWithId.json + */ +async function createADeploymentThatWillDeployATemplateSpecWithTheGivenResourceId() { + const subscriptionId = "00000000-0000-0000-0000-000000000001"; + const deploymentName = "my-deployment"; + const parameters: Deployment = { + location: "eastus", + properties: { + mode: "Incremental", + parameters: {}, + templateLink: { + id: + "/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Resources/TemplateSpecs/TemplateSpec-Name/versions/v1" + } + } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAtSubscriptionScopeAndWait( + deploymentName, + parameters + ); + console.log(result); +} + +createADeploymentThatWillDeployATemplateSpecWithTheGivenResourceId().catch( + console.error +); diff --git a/sdk/resources/arm-resources/samples-dev/deploymentsCreateOrUpdateAtTenantScopeSample.ts b/sdk/resources/arm-resources/samples-dev/deploymentsCreateOrUpdateAtTenantScopeSample.ts new file mode 100644 index 000000000000..2a7a2b607b1b --- /dev/null +++ b/sdk/resources/arm-resources/samples-dev/deploymentsCreateOrUpdateAtTenantScopeSample.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 { + ScopedDeployment, + ResourceManagementClient +} from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to You can provide the template and parameters directly in the request or link to JSON files. + * + * @summary You can provide the template and parameters directly in the request or link to JSON files. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentAtTenant.json + */ +async function createDeploymentAtTenantScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const deploymentName = "tenant-dep01"; + const parameters: ScopedDeployment = { + location: "eastus", + properties: { + mode: "Incremental", + parameters: {}, + templateLink: { uri: "https://example.com/exampleTemplate.json" } + }, + tags: { tagKey1: "tag-value-1", tagKey2: "tag-value-2" } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAtTenantScopeAndWait( + deploymentName, + parameters + ); + console.log(result); +} + +createDeploymentAtTenantScope().catch(console.error); diff --git a/sdk/resources/arm-resources/samples-dev/deploymentsCreateOrUpdateSample.ts b/sdk/resources/arm-resources/samples-dev/deploymentsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..fa6712c0b5cb --- /dev/null +++ b/sdk/resources/arm-resources/samples-dev/deploymentsCreateOrUpdateSample.ts @@ -0,0 +1,148 @@ +/* + * 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 { Deployment, ResourceManagementClient } from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to You can provide the template and parameters directly in the request or link to JSON files. + * + * @summary You can provide the template and parameters directly in the request or link to JSON files. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentResourceGroup.json + */ +async function createADeploymentThatWillDeployATemplateWithAUriAndQueryString() { + const subscriptionId = "00000000-0000-0000-0000-000000000001"; + const resourceGroupName = "my-resource-group"; + const deploymentName = "my-deployment"; + const parameters: Deployment = { + properties: { + mode: "Incremental", + parameters: {}, + templateLink: { + queryString: + "sv=2019-02-02&st=2019-04-29T22%3A18%3A26Z&se=2019-04-30T02%3A23%3A26Z&sr=b&sp=rw&sip=168.1.5.60-168.1.5.70&spr=https&sig=xxxxxxxx0xxxxxxxxxxxxx%2bxxxxxxxxxxxxxxxxxxxx%3d", + uri: "https://example.com/exampleTemplate.json" + } + } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAndWait( + resourceGroupName, + deploymentName, + parameters + ); + console.log(result); +} + +createADeploymentThatWillDeployATemplateWithAUriAndQueryString().catch( + console.error +); + +/** + * This sample demonstrates how to You can provide the template and parameters directly in the request or link to JSON files. + * + * @summary You can provide the template and parameters directly in the request or link to JSON files. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentResourceGroupTemplateSpecsWithId.json + */ +async function createADeploymentThatWillDeployATemplateSpecWithTheGivenResourceId() { + const subscriptionId = "00000000-0000-0000-0000-000000000001"; + const resourceGroupName = "my-resource-group"; + const deploymentName = "my-deployment"; + const parameters: Deployment = { + properties: { + mode: "Incremental", + parameters: {}, + templateLink: { + id: + "/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Resources/TemplateSpecs/TemplateSpec-Name/versions/v1" + } + } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAndWait( + resourceGroupName, + deploymentName, + parameters + ); + console.log(result); +} + +createADeploymentThatWillDeployATemplateSpecWithTheGivenResourceId().catch( + console.error +); + +/** + * This sample demonstrates how to You can provide the template and parameters directly in the request or link to JSON files. + * + * @summary You can provide the template and parameters directly in the request or link to JSON files. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentWithOnErrorDeploymentSpecificDeployment.json + */ +async function createADeploymentThatWillRedeployAnotherDeploymentOnFailure() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "my-resource-group"; + const deploymentName = "my-deployment"; + const parameters: Deployment = { + properties: { + mode: "Complete", + onErrorDeployment: { + type: "SpecificDeployment", + deploymentName: "name-of-deployment-to-use" + }, + parameters: {}, + templateLink: { uri: "https://example.com/exampleTemplate.json" } + } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAndWait( + resourceGroupName, + deploymentName, + parameters + ); + console.log(result); +} + +createADeploymentThatWillRedeployAnotherDeploymentOnFailure().catch( + console.error +); + +/** + * This sample demonstrates how to You can provide the template and parameters directly in the request or link to JSON files. + * + * @summary You can provide the template and parameters directly in the request or link to JSON files. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentWithOnErrorDeploymentLastSuccessful.json + */ +async function createADeploymentThatWillRedeployTheLastSuccessfulDeploymentOnFailure() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "my-resource-group"; + const deploymentName = "my-deployment"; + const parameters: Deployment = { + properties: { + mode: "Complete", + onErrorDeployment: { type: "LastSuccessful" }, + parameters: {}, + templateLink: { uri: "https://example.com/exampleTemplate.json" } + } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAndWait( + resourceGroupName, + deploymentName, + parameters + ); + console.log(result); +} + +createADeploymentThatWillRedeployTheLastSuccessfulDeploymentOnFailure().catch( + console.error +); diff --git a/sdk/resources/arm-resources/samples-dev/deploymentsWhatIfAtManagementGroupScopeSample.ts b/sdk/resources/arm-resources/samples-dev/deploymentsWhatIfAtManagementGroupScopeSample.ts new file mode 100644 index 000000000000..11ae8b873957 --- /dev/null +++ b/sdk/resources/arm-resources/samples-dev/deploymentsWhatIfAtManagementGroupScopeSample.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 { + ScopedDeploymentWhatIf, + ResourceManagementClient +} from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Returns changes that will be made by the deployment if executed at the scope of the management group. + * + * @summary Returns changes that will be made by the deployment if executed at the scope of the management group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PostDeploymentWhatIfOnManagementGroup.json + */ +async function predictTemplateChangesAtManagementGroupScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const groupId = "myManagementGruop"; + const deploymentName = "exampleDeploymentName"; + const parameters: ScopedDeploymentWhatIf = { + location: "eastus", + properties: { mode: "Incremental", parameters: {}, templateLink: {} } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginWhatIfAtManagementGroupScopeAndWait( + groupId, + deploymentName, + parameters + ); + console.log(result); +} + +predictTemplateChangesAtManagementGroupScope().catch(console.error); diff --git a/sdk/resources/arm-resources/samples-dev/deploymentsWhatIfAtSubscriptionScopeSample.ts b/sdk/resources/arm-resources/samples-dev/deploymentsWhatIfAtSubscriptionScopeSample.ts new file mode 100644 index 000000000000..7b4e19af94a4 --- /dev/null +++ b/sdk/resources/arm-resources/samples-dev/deploymentsWhatIfAtSubscriptionScopeSample.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 { + DeploymentWhatIf, + ResourceManagementClient +} from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Returns changes that will be made by the deployment if executed at the scope of the subscription. + * + * @summary Returns changes that will be made by the deployment if executed at the scope of the subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PostDeploymentWhatIfOnSubscription.json + */ +async function predictTemplateChangesAtSubscriptionScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000001"; + const deploymentName = "my-deployment"; + const parameters: DeploymentWhatIf = { + location: "westus", + properties: { mode: "Incremental", parameters: {}, templateLink: {} } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginWhatIfAtSubscriptionScopeAndWait( + deploymentName, + parameters + ); + console.log(result); +} + +predictTemplateChangesAtSubscriptionScope().catch(console.error); diff --git a/sdk/resources/arm-resources/samples-dev/deploymentsWhatIfAtTenantScopeSample.ts b/sdk/resources/arm-resources/samples-dev/deploymentsWhatIfAtTenantScopeSample.ts new file mode 100644 index 000000000000..e6dfcf7c6aab --- /dev/null +++ b/sdk/resources/arm-resources/samples-dev/deploymentsWhatIfAtTenantScopeSample.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 { + ScopedDeploymentWhatIf, + ResourceManagementClient +} from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Returns changes that will be made by the deployment if executed at the scope of the tenant group. + * + * @summary Returns changes that will be made by the deployment if executed at the scope of the tenant group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PostDeploymentWhatIfOnTenant.json + */ +async function predictTemplateChangesAtManagementGroupScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const deploymentName = "exampleDeploymentName"; + const parameters: ScopedDeploymentWhatIf = { + location: "eastus", + properties: { mode: "Incremental", parameters: {}, templateLink: {} } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginWhatIfAtTenantScopeAndWait( + deploymentName, + parameters + ); + console.log(result); +} + +predictTemplateChangesAtManagementGroupScope().catch(console.error); diff --git a/sdk/resources/arm-resources/samples-dev/deploymentsWhatIfSample.ts b/sdk/resources/arm-resources/samples-dev/deploymentsWhatIfSample.ts new file mode 100644 index 000000000000..65bfa94d74da --- /dev/null +++ b/sdk/resources/arm-resources/samples-dev/deploymentsWhatIfSample.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 { + DeploymentWhatIf, + ResourceManagementClient +} from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Returns changes that will be made by the deployment if executed at the scope of the resource group. + * + * @summary Returns changes that will be made by the deployment if executed at the scope of the resource group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PostDeploymentWhatIfOnResourceGroup.json + */ +async function predictTemplateChangesAtResourceGroupScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000001"; + const resourceGroupName = "my-resource-group"; + const deploymentName = "my-deployment"; + const parameters: DeploymentWhatIf = { + properties: { mode: "Incremental", parameters: {}, templateLink: {} } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginWhatIfAndWait( + resourceGroupName, + deploymentName, + parameters + ); + console.log(result); +} + +predictTemplateChangesAtResourceGroupScope().catch(console.error); diff --git a/sdk/resources/arm-resources/samples-dev/providerResourceTypesListSample.ts b/sdk/resources/arm-resources/samples-dev/providerResourceTypesListSample.ts new file mode 100644 index 000000000000..b090f7f94330 --- /dev/null +++ b/sdk/resources/arm-resources/samples-dev/providerResourceTypesListSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { ResourceManagementClient } from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to List the resource types for a specified resource provider. + * + * @summary List the resource types for a specified resource provider. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetProviderResourceTypes.json + */ +async function getProviderResourceTypes() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceProviderNamespace = "Microsoft.TestRP"; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.providerResourceTypes.list( + resourceProviderNamespace + ); + console.log(result); +} + +getProviderResourceTypes().catch(console.error); diff --git a/sdk/resources/arm-resources/samples-dev/providersGetAtTenantScopeSample.ts b/sdk/resources/arm-resources/samples-dev/providersGetAtTenantScopeSample.ts new file mode 100644 index 000000000000..e15e706b5352 --- /dev/null +++ b/sdk/resources/arm-resources/samples-dev/providersGetAtTenantScopeSample.ts @@ -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. +import { + ProvidersGetAtTenantScopeOptionalParams, + ResourceManagementClient +} from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the specified resource provider at the tenant level. + * + * @summary Gets the specified resource provider at the tenant level. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetNamedProviderAtTenant.json + */ +async function getAResourceProviderAtTenantScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const expand = "resourceTypes/aliases"; + const resourceProviderNamespace = "Microsoft.Storage"; + const options: ProvidersGetAtTenantScopeOptionalParams = { expand }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.providers.getAtTenantScope( + resourceProviderNamespace, + options + ); + console.log(result); +} + +getAResourceProviderAtTenantScope().catch(console.error); diff --git a/sdk/resources/arm-resources/samples-dev/providersGetSample.ts b/sdk/resources/arm-resources/samples-dev/providersGetSample.ts new file mode 100644 index 000000000000..bc749dab5de5 --- /dev/null +++ b/sdk/resources/arm-resources/samples-dev/providersGetSample.ts @@ -0,0 +1,29 @@ +/* + * 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 { ResourceManagementClient } from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the specified resource provider. + * + * @summary Gets the specified resource provider. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetProvider.json + */ +async function getProvider() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceProviderNamespace = "Microsoft.TestRP1"; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.providers.get(resourceProviderNamespace); + console.log(result); +} + +getProvider().catch(console.error); diff --git a/sdk/resources/arm-resources/samples-dev/providersListSample.ts b/sdk/resources/arm-resources/samples-dev/providersListSample.ts new file mode 100644 index 000000000000..bcd76e00734a --- /dev/null +++ b/sdk/resources/arm-resources/samples-dev/providersListSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { ResourceManagementClient } from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all resource providers for a subscription. + * + * @summary Gets all resource providers for a subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetProviders.json + */ +async function getProviders() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.providers.list()) { + resArray.push(item); + } + console.log(resArray); +} + +getProviders().catch(console.error); diff --git a/sdk/resources/arm-resources/samples-dev/providersProviderPermissionsSample.ts b/sdk/resources/arm-resources/samples-dev/providersProviderPermissionsSample.ts new file mode 100644 index 000000000000..819377488db7 --- /dev/null +++ b/sdk/resources/arm-resources/samples-dev/providersProviderPermissionsSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { ResourceManagementClient } from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Get the provider permissions. + * + * @summary Get the provider permissions. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetProviderPermissions.json + */ +async function getProviderResourceTypes() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceProviderNamespace = "Microsoft.TestRP"; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.providers.providerPermissions( + resourceProviderNamespace + ); + console.log(result); +} + +getProviderResourceTypes().catch(console.error); diff --git a/sdk/resources/arm-resources/samples-dev/resourceGroupsCreateOrUpdateSample.ts b/sdk/resources/arm-resources/samples-dev/resourceGroupsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..05d744c91c8a --- /dev/null +++ b/sdk/resources/arm-resources/samples-dev/resourceGroupsCreateOrUpdateSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { ResourceGroup, ResourceManagementClient } from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates a resource group. + * + * @summary Creates or updates a resource group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/CreateResourceGroup.json + */ +async function createOrUpdateAResourceGroup() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "my-resource-group"; + const parameters: ResourceGroup = { location: "eastus" }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.resourceGroups.createOrUpdate( + resourceGroupName, + parameters + ); + console.log(result); +} + +createOrUpdateAResourceGroup().catch(console.error); diff --git a/sdk/resources/arm-resources/samples-dev/resourceGroupsDeleteSample.ts b/sdk/resources/arm-resources/samples-dev/resourceGroupsDeleteSample.ts new file mode 100644 index 000000000000..b01fb3eebf0c --- /dev/null +++ b/sdk/resources/arm-resources/samples-dev/resourceGroupsDeleteSample.ts @@ -0,0 +1,62 @@ +/* + * 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 { + ResourceGroupsDeleteOptionalParams, + ResourceManagementClient +} from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. + * + * @summary When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/ForceDeleteVMsAndVMSSInResourceGroup.json + */ +async function forceDeleteAllTheVirtualMachinesAndVirtualMachineScaleSetsInAResourceGroup() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "my-resource-group"; + const forceDeletionTypes = + "Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachineScaleSets"; + const options: ResourceGroupsDeleteOptionalParams = { forceDeletionTypes }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.resourceGroups.beginDeleteAndWait( + resourceGroupName, + options + ); + console.log(result); +} + +forceDeleteAllTheVirtualMachinesAndVirtualMachineScaleSetsInAResourceGroup().catch( + console.error +); + +/** + * This sample demonstrates how to When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. + * + * @summary When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/ForceDeleteVMsInResourceGroup.json + */ +async function forceDeleteAllTheVirtualMachinesInAResourceGroup() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "my-resource-group"; + const forceDeletionTypes = "Microsoft.Compute/virtualMachines"; + const options: ResourceGroupsDeleteOptionalParams = { forceDeletionTypes }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.resourceGroups.beginDeleteAndWait( + resourceGroupName, + options + ); + console.log(result); +} + +forceDeleteAllTheVirtualMachinesInAResourceGroup().catch(console.error); diff --git a/sdk/resources/arm-resources/samples-dev/resourceGroupsExportTemplateSample.ts b/sdk/resources/arm-resources/samples-dev/resourceGroupsExportTemplateSample.ts new file mode 100644 index 000000000000..9775c5733f95 --- /dev/null +++ b/sdk/resources/arm-resources/samples-dev/resourceGroupsExportTemplateSample.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 { + ExportTemplateRequest, + ResourceManagementClient +} from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Captures the specified resource group as a template. + * + * @summary Captures the specified resource group as a template. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/ExportResourceGroup.json + */ +async function exportAResourceGroup() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "my-resource-group"; + const parameters: ExportTemplateRequest = { + options: "IncludeParameterDefaultValue,IncludeComments", + resources: ["*"] + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.resourceGroups.beginExportTemplateAndWait( + resourceGroupName, + parameters + ); + console.log(result); +} + +exportAResourceGroup().catch(console.error); + +/** + * This sample demonstrates how to Captures the specified resource group as a template. + * + * @summary Captures the specified resource group as a template. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/ExportResourceGroupWithFiltering.json + */ +async function exportAResourceGroupWithFiltering() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "my-resource-group"; + const parameters: ExportTemplateRequest = { + options: "SkipResourceNameParameterization", + resources: [ + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/My.RP/myResourceType/myFirstResource" + ] + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.resourceGroups.beginExportTemplateAndWait( + resourceGroupName, + parameters + ); + console.log(result); +} + +exportAResourceGroupWithFiltering().catch(console.error); diff --git a/sdk/resources/arm-resources/samples-dev/tagsCreateOrUpdateAtScopeSample.ts b/sdk/resources/arm-resources/samples-dev/tagsCreateOrUpdateAtScopeSample.ts new file mode 100644 index 000000000000..ad99eea1a194 --- /dev/null +++ b/sdk/resources/arm-resources/samples-dev/tagsCreateOrUpdateAtScopeSample.ts @@ -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. +import { TagsResource, ResourceManagementClient } from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags. + * + * @summary This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutTagsResource.json + */ +async function updateTagsOnAResource() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = + "subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/myPRNameSpace/VM/myVm"; + const parameters: TagsResource = { + properties: { tags: { tagKey1: "tag-value-1", tagKey2: "tag-value-2" } } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.tagsOperations.createOrUpdateAtScope( + scope, + parameters + ); + console.log(result); +} + +updateTagsOnAResource().catch(console.error); + +/** + * This sample demonstrates how to This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags. + * + * @summary This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutTagsSubscription.json + */ +async function updateTagsOnASubscription() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/00000000-0000-0000-0000-000000000000"; + const parameters: TagsResource = { + properties: { tags: { tagKey1: "tag-value-1", tagKey2: "tag-value-2" } } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.tagsOperations.createOrUpdateAtScope( + scope, + parameters + ); + console.log(result); +} + +updateTagsOnASubscription().catch(console.error); diff --git a/sdk/resources/arm-resources/samples-dev/tagsGetAtScopeSample.ts b/sdk/resources/arm-resources/samples-dev/tagsGetAtScopeSample.ts new file mode 100644 index 000000000000..d43b397344ee --- /dev/null +++ b/sdk/resources/arm-resources/samples-dev/tagsGetAtScopeSample.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 { ResourceManagementClient } from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the entire set of tags on a resource or subscription. + * + * @summary Gets the entire set of tags on a resource or subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetTagsResource.json + */ +async function getTagsOnAResource() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = + "subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/myPRNameSpace/VM/myVm"; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.tagsOperations.getAtScope(scope); + console.log(result); +} + +getTagsOnAResource().catch(console.error); + +/** + * This sample demonstrates how to Gets the entire set of tags on a resource or subscription. + * + * @summary Gets the entire set of tags on a resource or subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetTagsSubscription.json + */ +async function getTagsOnASubscription() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.tagsOperations.getAtScope(scope); + console.log(result); +} + +getTagsOnASubscription().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/javascript/README.md b/sdk/resources/arm-resources/samples/v5/javascript/README.md new file mode 100644 index 000000000000..9aa2db1a29ae --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/javascript/README.md @@ -0,0 +1,88 @@ +# client library samples for JavaScript + +These sample programs show how to use the JavaScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| ----------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [deploymentsCalculateTemplateHashSample.js][deploymentscalculatetemplatehashsample] | Calculate the hash of the given template. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/CalculateTemplateHash.json | +| [deploymentsCreateOrUpdateAtManagementGroupScopeSample.js][deploymentscreateorupdateatmanagementgroupscopesample] | You can provide the template and parameters directly in the request or link to JSON files. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentAtManagementGroup.json | +| [deploymentsCreateOrUpdateAtScopeSample.js][deploymentscreateorupdateatscopesample] | You can provide the template and parameters directly in the request or link to JSON files. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentAtScope.json | +| [deploymentsCreateOrUpdateAtSubscriptionScopeSample.js][deploymentscreateorupdateatsubscriptionscopesample] | You can provide the template and parameters directly in the request or link to JSON files. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentSubscriptionTemplateSpecsWithId.json | +| [deploymentsCreateOrUpdateAtTenantScopeSample.js][deploymentscreateorupdateattenantscopesample] | You can provide the template and parameters directly in the request or link to JSON files. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentAtTenant.json | +| [deploymentsCreateOrUpdateSample.js][deploymentscreateorupdatesample] | You can provide the template and parameters directly in the request or link to JSON files. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentResourceGroup.json | +| [deploymentsWhatIfAtManagementGroupScopeSample.js][deploymentswhatifatmanagementgroupscopesample] | Returns changes that will be made by the deployment if executed at the scope of the management group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PostDeploymentWhatIfOnManagementGroup.json | +| [deploymentsWhatIfAtSubscriptionScopeSample.js][deploymentswhatifatsubscriptionscopesample] | Returns changes that will be made by the deployment if executed at the scope of the subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PostDeploymentWhatIfOnSubscription.json | +| [deploymentsWhatIfAtTenantScopeSample.js][deploymentswhatifattenantscopesample] | Returns changes that will be made by the deployment if executed at the scope of the tenant group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PostDeploymentWhatIfOnTenant.json | +| [deploymentsWhatIfSample.js][deploymentswhatifsample] | Returns changes that will be made by the deployment if executed at the scope of the resource group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PostDeploymentWhatIfOnResourceGroup.json | +| [providerResourceTypesListSample.js][providerresourcetypeslistsample] | List the resource types for a specified resource provider. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetProviderResourceTypes.json | +| [providersGetAtTenantScopeSample.js][providersgetattenantscopesample] | Gets the specified resource provider at the tenant level. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetNamedProviderAtTenant.json | +| [providersGetSample.js][providersgetsample] | Gets the specified resource provider. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetProvider.json | +| [providersListSample.js][providerslistsample] | Gets all resource providers for a subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetProviders.json | +| [providersProviderPermissionsSample.js][providersproviderpermissionssample] | Get the provider permissions. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetProviderPermissions.json | +| [resourceGroupsCreateOrUpdateSample.js][resourcegroupscreateorupdatesample] | Creates or updates a resource group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/CreateResourceGroup.json | +| [resourceGroupsDeleteSample.js][resourcegroupsdeletesample] | When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/ForceDeleteVMsAndVMSSInResourceGroup.json | +| [resourceGroupsExportTemplateSample.js][resourcegroupsexporttemplatesample] | Captures the specified resource group as a template. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/ExportResourceGroup.json | +| [tagsCreateOrUpdateAtScopeSample.js][tagscreateorupdateatscopesample] | This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutTagsResource.json | +| [tagsGetAtScopeSample.js][tagsgetatscopesample] | Gets the entire set of tags on a resource or subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetTagsResource.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +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 deploymentsCalculateTemplateHashSample.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 node deploymentsCalculateTemplateHashSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[deploymentscalculatetemplatehashsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/javascript/deploymentsCalculateTemplateHashSample.js +[deploymentscreateorupdateatmanagementgroupscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/javascript/deploymentsCreateOrUpdateAtManagementGroupScopeSample.js +[deploymentscreateorupdateatscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/javascript/deploymentsCreateOrUpdateAtScopeSample.js +[deploymentscreateorupdateatsubscriptionscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/javascript/deploymentsCreateOrUpdateAtSubscriptionScopeSample.js +[deploymentscreateorupdateattenantscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/javascript/deploymentsCreateOrUpdateAtTenantScopeSample.js +[deploymentscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/javascript/deploymentsCreateOrUpdateSample.js +[deploymentswhatifatmanagementgroupscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/javascript/deploymentsWhatIfAtManagementGroupScopeSample.js +[deploymentswhatifatsubscriptionscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/javascript/deploymentsWhatIfAtSubscriptionScopeSample.js +[deploymentswhatifattenantscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/javascript/deploymentsWhatIfAtTenantScopeSample.js +[deploymentswhatifsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/javascript/deploymentsWhatIfSample.js +[providerresourcetypeslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/javascript/providerResourceTypesListSample.js +[providersgetattenantscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/javascript/providersGetAtTenantScopeSample.js +[providersgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/javascript/providersGetSample.js +[providerslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/javascript/providersListSample.js +[providersproviderpermissionssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/javascript/providersProviderPermissionsSample.js +[resourcegroupscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/javascript/resourceGroupsCreateOrUpdateSample.js +[resourcegroupsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/javascript/resourceGroupsDeleteSample.js +[resourcegroupsexporttemplatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/javascript/resourceGroupsExportTemplateSample.js +[tagscreateorupdateatscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/javascript/tagsCreateOrUpdateAtScopeSample.js +[tagsgetatscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/javascript/tagsGetAtScopeSample.js +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-resources?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/resources/arm-resources/README.md diff --git a/sdk/resources/arm-resources/samples/v5/javascript/deploymentsCalculateTemplateHashSample.js b/sdk/resources/arm-resources/samples/v5/javascript/deploymentsCalculateTemplateHashSample.js new file mode 100644 index 000000000000..85a819234b88 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/javascript/deploymentsCalculateTemplateHashSample.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 { ResourceManagementClient } = require("@azure/arm-resources"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Calculate the hash of the given template. + * + * @summary Calculate the hash of the given template. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/CalculateTemplateHash.json + */ +async function calculateTemplateHash() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const template = { + $schema: + "http://schemas.management.azure.com/deploymentTemplate?api-version=2014-04-01-preview", + contentVersion: "1.0.0.0", + outputs: { string: { type: "string", value: "myvalue" } }, + parameters: { string: { type: "string" } }, + resources: [], + variables: { + array: [1, 2, 3, 4], + bool: true, + int: 42, + object: { object: { location: "West US", vmSize: "Large" } }, + string: "string", + }, + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.calculateTemplateHash(template); + console.log(result); +} + +calculateTemplateHash().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/javascript/deploymentsCreateOrUpdateAtManagementGroupScopeSample.js b/sdk/resources/arm-resources/samples/v5/javascript/deploymentsCreateOrUpdateAtManagementGroupScopeSample.js new file mode 100644 index 000000000000..c20ce8677c71 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/javascript/deploymentsCreateOrUpdateAtManagementGroupScopeSample.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 { ResourceManagementClient } = require("@azure/arm-resources"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to You can provide the template and parameters directly in the request or link to JSON files. + * + * @summary You can provide the template and parameters directly in the request or link to JSON files. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentAtManagementGroup.json + */ +async function createDeploymentAtManagementGroupScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const groupId = "my-management-group-id"; + const deploymentName = "my-deployment"; + const parameters = { + location: "eastus", + properties: { + mode: "Incremental", + parameters: {}, + templateLink: { uri: "https://example.com/exampleTemplate.json" }, + }, + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAtManagementGroupScopeAndWait( + groupId, + deploymentName, + parameters + ); + console.log(result); +} + +createDeploymentAtManagementGroupScope().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/javascript/deploymentsCreateOrUpdateAtScopeSample.js b/sdk/resources/arm-resources/samples/v5/javascript/deploymentsCreateOrUpdateAtScopeSample.js new file mode 100644 index 000000000000..cc4c06703491 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/javascript/deploymentsCreateOrUpdateAtScopeSample.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 { ResourceManagementClient } = require("@azure/arm-resources"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to You can provide the template and parameters directly in the request or link to JSON files. + * + * @summary You can provide the template and parameters directly in the request or link to JSON files. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentAtScope.json + */ +async function createDeploymentAtAGivenScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "providers/Microsoft.Management/managementGroups/my-management-group-id"; + const deploymentName = "my-deployment"; + const parameters = { + location: "eastus", + properties: { + mode: "Incremental", + parameters: {}, + templateLink: { uri: "https://example.com/exampleTemplate.json" }, + }, + tags: { tagKey1: "tag-value-1", tagKey2: "tag-value-2" }, + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAtScopeAndWait( + scope, + deploymentName, + parameters + ); + console.log(result); +} + +createDeploymentAtAGivenScope().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/javascript/deploymentsCreateOrUpdateAtSubscriptionScopeSample.js b/sdk/resources/arm-resources/samples/v5/javascript/deploymentsCreateOrUpdateAtSubscriptionScopeSample.js new file mode 100644 index 000000000000..e631da187b4c --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/javascript/deploymentsCreateOrUpdateAtSubscriptionScopeSample.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 { ResourceManagementClient } = require("@azure/arm-resources"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to You can provide the template and parameters directly in the request or link to JSON files. + * + * @summary You can provide the template and parameters directly in the request or link to JSON files. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentSubscriptionTemplateSpecsWithId.json + */ +async function createADeploymentThatWillDeployATemplateSpecWithTheGivenResourceId() { + const subscriptionId = "00000000-0000-0000-0000-000000000001"; + const deploymentName = "my-deployment"; + const parameters = { + location: "eastus", + properties: { + mode: "Incremental", + parameters: {}, + templateLink: { + id: "/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Resources/TemplateSpecs/TemplateSpec-Name/versions/v1", + }, + }, + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAtSubscriptionScopeAndWait( + deploymentName, + parameters + ); + console.log(result); +} + +createADeploymentThatWillDeployATemplateSpecWithTheGivenResourceId().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/javascript/deploymentsCreateOrUpdateAtTenantScopeSample.js b/sdk/resources/arm-resources/samples/v5/javascript/deploymentsCreateOrUpdateAtTenantScopeSample.js new file mode 100644 index 000000000000..379ee8a5553c --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/javascript/deploymentsCreateOrUpdateAtTenantScopeSample.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 { ResourceManagementClient } = require("@azure/arm-resources"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to You can provide the template and parameters directly in the request or link to JSON files. + * + * @summary You can provide the template and parameters directly in the request or link to JSON files. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentAtTenant.json + */ +async function createDeploymentAtTenantScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const deploymentName = "tenant-dep01"; + const parameters = { + location: "eastus", + properties: { + mode: "Incremental", + parameters: {}, + templateLink: { uri: "https://example.com/exampleTemplate.json" }, + }, + tags: { tagKey1: "tag-value-1", tagKey2: "tag-value-2" }, + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAtTenantScopeAndWait( + deploymentName, + parameters + ); + console.log(result); +} + +createDeploymentAtTenantScope().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/javascript/deploymentsCreateOrUpdateSample.js b/sdk/resources/arm-resources/samples/v5/javascript/deploymentsCreateOrUpdateSample.js new file mode 100644 index 000000000000..d9e19783fefb --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/javascript/deploymentsCreateOrUpdateSample.js @@ -0,0 +1,139 @@ +/* + * 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 { ResourceManagementClient } = require("@azure/arm-resources"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to You can provide the template and parameters directly in the request or link to JSON files. + * + * @summary You can provide the template and parameters directly in the request or link to JSON files. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentResourceGroup.json + */ +async function createADeploymentThatWillDeployATemplateWithAUriAndQueryString() { + const subscriptionId = "00000000-0000-0000-0000-000000000001"; + const resourceGroupName = "my-resource-group"; + const deploymentName = "my-deployment"; + const parameters = { + properties: { + mode: "Incremental", + parameters: {}, + templateLink: { + queryString: + "sv=2019-02-02&st=2019-04-29T22%3A18%3A26Z&se=2019-04-30T02%3A23%3A26Z&sr=b&sp=rw&sip=168.1.5.60-168.1.5.70&spr=https&sig=xxxxxxxx0xxxxxxxxxxxxx%2bxxxxxxxxxxxxxxxxxxxx%3d", + uri: "https://example.com/exampleTemplate.json", + }, + }, + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAndWait( + resourceGroupName, + deploymentName, + parameters + ); + console.log(result); +} + +createADeploymentThatWillDeployATemplateWithAUriAndQueryString().catch(console.error); + +/** + * This sample demonstrates how to You can provide the template and parameters directly in the request or link to JSON files. + * + * @summary You can provide the template and parameters directly in the request or link to JSON files. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentResourceGroupTemplateSpecsWithId.json + */ +async function createADeploymentThatWillDeployATemplateSpecWithTheGivenResourceId() { + const subscriptionId = "00000000-0000-0000-0000-000000000001"; + const resourceGroupName = "my-resource-group"; + const deploymentName = "my-deployment"; + const parameters = { + properties: { + mode: "Incremental", + parameters: {}, + templateLink: { + id: "/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Resources/TemplateSpecs/TemplateSpec-Name/versions/v1", + }, + }, + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAndWait( + resourceGroupName, + deploymentName, + parameters + ); + console.log(result); +} + +createADeploymentThatWillDeployATemplateSpecWithTheGivenResourceId().catch(console.error); + +/** + * This sample demonstrates how to You can provide the template and parameters directly in the request or link to JSON files. + * + * @summary You can provide the template and parameters directly in the request or link to JSON files. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentWithOnErrorDeploymentSpecificDeployment.json + */ +async function createADeploymentThatWillRedeployAnotherDeploymentOnFailure() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "my-resource-group"; + const deploymentName = "my-deployment"; + const parameters = { + properties: { + mode: "Complete", + onErrorDeployment: { + type: "SpecificDeployment", + deploymentName: "name-of-deployment-to-use", + }, + parameters: {}, + templateLink: { uri: "https://example.com/exampleTemplate.json" }, + }, + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAndWait( + resourceGroupName, + deploymentName, + parameters + ); + console.log(result); +} + +createADeploymentThatWillRedeployAnotherDeploymentOnFailure().catch(console.error); + +/** + * This sample demonstrates how to You can provide the template and parameters directly in the request or link to JSON files. + * + * @summary You can provide the template and parameters directly in the request or link to JSON files. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentWithOnErrorDeploymentLastSuccessful.json + */ +async function createADeploymentThatWillRedeployTheLastSuccessfulDeploymentOnFailure() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "my-resource-group"; + const deploymentName = "my-deployment"; + const parameters = { + properties: { + mode: "Complete", + onErrorDeployment: { type: "LastSuccessful" }, + parameters: {}, + templateLink: { uri: "https://example.com/exampleTemplate.json" }, + }, + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAndWait( + resourceGroupName, + deploymentName, + parameters + ); + console.log(result); +} + +createADeploymentThatWillRedeployTheLastSuccessfulDeploymentOnFailure().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/javascript/deploymentsWhatIfAtManagementGroupScopeSample.js b/sdk/resources/arm-resources/samples/v5/javascript/deploymentsWhatIfAtManagementGroupScopeSample.js new file mode 100644 index 000000000000..3c34db0d3932 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/javascript/deploymentsWhatIfAtManagementGroupScopeSample.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 { ResourceManagementClient } = require("@azure/arm-resources"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Returns changes that will be made by the deployment if executed at the scope of the management group. + * + * @summary Returns changes that will be made by the deployment if executed at the scope of the management group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PostDeploymentWhatIfOnManagementGroup.json + */ +async function predictTemplateChangesAtManagementGroupScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const groupId = "myManagementGruop"; + const deploymentName = "exampleDeploymentName"; + const parameters = { + location: "eastus", + properties: { mode: "Incremental", parameters: {}, templateLink: {} }, + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginWhatIfAtManagementGroupScopeAndWait( + groupId, + deploymentName, + parameters + ); + console.log(result); +} + +predictTemplateChangesAtManagementGroupScope().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/javascript/deploymentsWhatIfAtSubscriptionScopeSample.js b/sdk/resources/arm-resources/samples/v5/javascript/deploymentsWhatIfAtSubscriptionScopeSample.js new file mode 100644 index 000000000000..2359c33b209b --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/javascript/deploymentsWhatIfAtSubscriptionScopeSample.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 { ResourceManagementClient } = require("@azure/arm-resources"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Returns changes that will be made by the deployment if executed at the scope of the subscription. + * + * @summary Returns changes that will be made by the deployment if executed at the scope of the subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PostDeploymentWhatIfOnSubscription.json + */ +async function predictTemplateChangesAtSubscriptionScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000001"; + const deploymentName = "my-deployment"; + const parameters = { + location: "westus", + properties: { mode: "Incremental", parameters: {}, templateLink: {} }, + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginWhatIfAtSubscriptionScopeAndWait( + deploymentName, + parameters + ); + console.log(result); +} + +predictTemplateChangesAtSubscriptionScope().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/javascript/deploymentsWhatIfAtTenantScopeSample.js b/sdk/resources/arm-resources/samples/v5/javascript/deploymentsWhatIfAtTenantScopeSample.js new file mode 100644 index 000000000000..11d40683b268 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/javascript/deploymentsWhatIfAtTenantScopeSample.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 { ResourceManagementClient } = require("@azure/arm-resources"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Returns changes that will be made by the deployment if executed at the scope of the tenant group. + * + * @summary Returns changes that will be made by the deployment if executed at the scope of the tenant group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PostDeploymentWhatIfOnTenant.json + */ +async function predictTemplateChangesAtManagementGroupScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const deploymentName = "exampleDeploymentName"; + const parameters = { + location: "eastus", + properties: { mode: "Incremental", parameters: {}, templateLink: {} }, + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginWhatIfAtTenantScopeAndWait( + deploymentName, + parameters + ); + console.log(result); +} + +predictTemplateChangesAtManagementGroupScope().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/javascript/deploymentsWhatIfSample.js b/sdk/resources/arm-resources/samples/v5/javascript/deploymentsWhatIfSample.js new file mode 100644 index 000000000000..e5f9473f19a3 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/javascript/deploymentsWhatIfSample.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 { ResourceManagementClient } = require("@azure/arm-resources"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Returns changes that will be made by the deployment if executed at the scope of the resource group. + * + * @summary Returns changes that will be made by the deployment if executed at the scope of the resource group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PostDeploymentWhatIfOnResourceGroup.json + */ +async function predictTemplateChangesAtResourceGroupScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000001"; + const resourceGroupName = "my-resource-group"; + const deploymentName = "my-deployment"; + const parameters = { + properties: { mode: "Incremental", parameters: {}, templateLink: {} }, + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginWhatIfAndWait( + resourceGroupName, + deploymentName, + parameters + ); + console.log(result); +} + +predictTemplateChangesAtResourceGroupScope().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/javascript/package.json b/sdk/resources/arm-resources/samples/v5/javascript/package.json new file mode 100644 index 000000000000..12bba49263e8 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/javascript/package.json @@ -0,0 +1,32 @@ +{ + "name": "@azure-samples/arm-resources-js", + "private": true, + "version": "1.0.0", + "description": " client library samples for JavaScript", + "engines": { + "node": ">=12.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/resources/arm-resources" + }, + "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/resources/arm-resources", + "dependencies": { + "@azure/arm-resources": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + } +} diff --git a/sdk/resources/arm-resources/samples/v5/javascript/providerResourceTypesListSample.js b/sdk/resources/arm-resources/samples/v5/javascript/providerResourceTypesListSample.js new file mode 100644 index 000000000000..fb97a3cdcf2c --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/javascript/providerResourceTypesListSample.js @@ -0,0 +1,29 @@ +/* + * 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 { ResourceManagementClient } = require("@azure/arm-resources"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to List the resource types for a specified resource provider. + * + * @summary List the resource types for a specified resource provider. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetProviderResourceTypes.json + */ +async function getProviderResourceTypes() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceProviderNamespace = "Microsoft.TestRP"; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.providerResourceTypes.list(resourceProviderNamespace); + console.log(result); +} + +getProviderResourceTypes().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/javascript/providersGetAtTenantScopeSample.js b/sdk/resources/arm-resources/samples/v5/javascript/providersGetAtTenantScopeSample.js new file mode 100644 index 000000000000..445e2a249eba --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/javascript/providersGetAtTenantScopeSample.js @@ -0,0 +1,31 @@ +/* + * 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 { ResourceManagementClient } = require("@azure/arm-resources"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets the specified resource provider at the tenant level. + * + * @summary Gets the specified resource provider at the tenant level. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetNamedProviderAtTenant.json + */ +async function getAResourceProviderAtTenantScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const expand = "resourceTypes/aliases"; + const resourceProviderNamespace = "Microsoft.Storage"; + const options = { expand }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.providers.getAtTenantScope(resourceProviderNamespace, options); + console.log(result); +} + +getAResourceProviderAtTenantScope().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/javascript/providersGetSample.js b/sdk/resources/arm-resources/samples/v5/javascript/providersGetSample.js new file mode 100644 index 000000000000..b6fe20b65918 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/javascript/providersGetSample.js @@ -0,0 +1,29 @@ +/* + * 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 { ResourceManagementClient } = require("@azure/arm-resources"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets the specified resource provider. + * + * @summary Gets the specified resource provider. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetProvider.json + */ +async function getProvider() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceProviderNamespace = "Microsoft.TestRP1"; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.providers.get(resourceProviderNamespace); + console.log(result); +} + +getProvider().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/javascript/providersListSample.js b/sdk/resources/arm-resources/samples/v5/javascript/providersListSample.js new file mode 100644 index 000000000000..ccc70914ee6e --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/javascript/providersListSample.js @@ -0,0 +1,31 @@ +/* + * 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 { ResourceManagementClient } = require("@azure/arm-resources"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets all resource providers for a subscription. + * + * @summary Gets all resource providers for a subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetProviders.json + */ +async function getProviders() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.providers.list()) { + resArray.push(item); + } + console.log(resArray); +} + +getProviders().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/javascript/providersProviderPermissionsSample.js b/sdk/resources/arm-resources/samples/v5/javascript/providersProviderPermissionsSample.js new file mode 100644 index 000000000000..59829087b401 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/javascript/providersProviderPermissionsSample.js @@ -0,0 +1,29 @@ +/* + * 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 { ResourceManagementClient } = require("@azure/arm-resources"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Get the provider permissions. + * + * @summary Get the provider permissions. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetProviderPermissions.json + */ +async function getProviderResourceTypes() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceProviderNamespace = "Microsoft.TestRP"; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.providers.providerPermissions(resourceProviderNamespace); + console.log(result); +} + +getProviderResourceTypes().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/javascript/resourceGroupsCreateOrUpdateSample.js b/sdk/resources/arm-resources/samples/v5/javascript/resourceGroupsCreateOrUpdateSample.js new file mode 100644 index 000000000000..92cd414ad069 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/javascript/resourceGroupsCreateOrUpdateSample.js @@ -0,0 +1,30 @@ +/* + * 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 { ResourceManagementClient } = require("@azure/arm-resources"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Creates or updates a resource group. + * + * @summary Creates or updates a resource group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/CreateResourceGroup.json + */ +async function createOrUpdateAResourceGroup() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "my-resource-group"; + const parameters = { location: "eastus" }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.resourceGroups.createOrUpdate(resourceGroupName, parameters); + console.log(result); +} + +createOrUpdateAResourceGroup().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/javascript/resourceGroupsDeleteSample.js b/sdk/resources/arm-resources/samples/v5/javascript/resourceGroupsDeleteSample.js new file mode 100644 index 000000000000..e9bc48901916 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/javascript/resourceGroupsDeleteSample.js @@ -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. +const { ResourceManagementClient } = require("@azure/arm-resources"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. + * + * @summary When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/ForceDeleteVMsAndVMSSInResourceGroup.json + */ +async function forceDeleteAllTheVirtualMachinesAndVirtualMachineScaleSetsInAResourceGroup() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "my-resource-group"; + const forceDeletionTypes = + "Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachineScaleSets"; + const options = { forceDeletionTypes }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.resourceGroups.beginDeleteAndWait(resourceGroupName, options); + console.log(result); +} + +forceDeleteAllTheVirtualMachinesAndVirtualMachineScaleSetsInAResourceGroup().catch(console.error); + +/** + * This sample demonstrates how to When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. + * + * @summary When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/ForceDeleteVMsInResourceGroup.json + */ +async function forceDeleteAllTheVirtualMachinesInAResourceGroup() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "my-resource-group"; + const forceDeletionTypes = "Microsoft.Compute/virtualMachines"; + const options = { forceDeletionTypes }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.resourceGroups.beginDeleteAndWait(resourceGroupName, options); + console.log(result); +} + +forceDeleteAllTheVirtualMachinesInAResourceGroup().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/javascript/resourceGroupsExportTemplateSample.js b/sdk/resources/arm-resources/samples/v5/javascript/resourceGroupsExportTemplateSample.js new file mode 100644 index 000000000000..804fc2096199 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/javascript/resourceGroupsExportTemplateSample.js @@ -0,0 +1,62 @@ +/* + * 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 { ResourceManagementClient } = require("@azure/arm-resources"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Captures the specified resource group as a template. + * + * @summary Captures the specified resource group as a template. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/ExportResourceGroup.json + */ +async function exportAResourceGroup() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "my-resource-group"; + const parameters = { + options: "IncludeParameterDefaultValue,IncludeComments", + resources: ["*"], + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.resourceGroups.beginExportTemplateAndWait( + resourceGroupName, + parameters + ); + console.log(result); +} + +exportAResourceGroup().catch(console.error); + +/** + * This sample demonstrates how to Captures the specified resource group as a template. + * + * @summary Captures the specified resource group as a template. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/ExportResourceGroupWithFiltering.json + */ +async function exportAResourceGroupWithFiltering() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "my-resource-group"; + const parameters = { + options: "SkipResourceNameParameterization", + resources: [ + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/My.RP/myResourceType/myFirstResource", + ], + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.resourceGroups.beginExportTemplateAndWait( + resourceGroupName, + parameters + ); + console.log(result); +} + +exportAResourceGroupWithFiltering().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/javascript/sample.env b/sdk/resources/arm-resources/samples/v5/javascript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/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/resources/arm-resources/samples/v5/javascript/tagsCreateOrUpdateAtScopeSample.js b/sdk/resources/arm-resources/samples/v5/javascript/tagsCreateOrUpdateAtScopeSample.js new file mode 100644 index 000000000000..b870cdb54584 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/javascript/tagsCreateOrUpdateAtScopeSample.js @@ -0,0 +1,53 @@ +/* + * 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 { ResourceManagementClient } = require("@azure/arm-resources"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags. + * + * @summary This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutTagsResource.json + */ +async function updateTagsOnAResource() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = + "subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/myPRNameSpace/VM/myVm"; + const parameters = { + properties: { tags: { tagKey1: "tag-value-1", tagKey2: "tag-value-2" } }, + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.tagsOperations.createOrUpdateAtScope(scope, parameters); + console.log(result); +} + +updateTagsOnAResource().catch(console.error); + +/** + * This sample demonstrates how to This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags. + * + * @summary This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutTagsSubscription.json + */ +async function updateTagsOnASubscription() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/00000000-0000-0000-0000-000000000000"; + const parameters = { + properties: { tags: { tagKey1: "tag-value-1", tagKey2: "tag-value-2" } }, + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.tagsOperations.createOrUpdateAtScope(scope, parameters); + console.log(result); +} + +updateTagsOnASubscription().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/javascript/tagsGetAtScopeSample.js b/sdk/resources/arm-resources/samples/v5/javascript/tagsGetAtScopeSample.js new file mode 100644 index 000000000000..c878c2c92d51 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/javascript/tagsGetAtScopeSample.js @@ -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. +const { ResourceManagementClient } = require("@azure/arm-resources"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets the entire set of tags on a resource or subscription. + * + * @summary Gets the entire set of tags on a resource or subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetTagsResource.json + */ +async function getTagsOnAResource() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = + "subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/myPRNameSpace/VM/myVm"; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.tagsOperations.getAtScope(scope); + console.log(result); +} + +getTagsOnAResource().catch(console.error); + +/** + * This sample demonstrates how to Gets the entire set of tags on a resource or subscription. + * + * @summary Gets the entire set of tags on a resource or subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetTagsSubscription.json + */ +async function getTagsOnASubscription() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.tagsOperations.getAtScope(scope); + console.log(result); +} + +getTagsOnASubscription().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/typescript/README.md b/sdk/resources/arm-resources/samples/v5/typescript/README.md new file mode 100644 index 000000000000..b8ecc3961f1c --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/typescript/README.md @@ -0,0 +1,101 @@ +# client library samples for TypeScript + +These sample programs show how to use the TypeScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| ----------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [deploymentsCalculateTemplateHashSample.ts][deploymentscalculatetemplatehashsample] | Calculate the hash of the given template. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/CalculateTemplateHash.json | +| [deploymentsCreateOrUpdateAtManagementGroupScopeSample.ts][deploymentscreateorupdateatmanagementgroupscopesample] | You can provide the template and parameters directly in the request or link to JSON files. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentAtManagementGroup.json | +| [deploymentsCreateOrUpdateAtScopeSample.ts][deploymentscreateorupdateatscopesample] | You can provide the template and parameters directly in the request or link to JSON files. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentAtScope.json | +| [deploymentsCreateOrUpdateAtSubscriptionScopeSample.ts][deploymentscreateorupdateatsubscriptionscopesample] | You can provide the template and parameters directly in the request or link to JSON files. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentSubscriptionTemplateSpecsWithId.json | +| [deploymentsCreateOrUpdateAtTenantScopeSample.ts][deploymentscreateorupdateattenantscopesample] | You can provide the template and parameters directly in the request or link to JSON files. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentAtTenant.json | +| [deploymentsCreateOrUpdateSample.ts][deploymentscreateorupdatesample] | You can provide the template and parameters directly in the request or link to JSON files. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentResourceGroup.json | +| [deploymentsWhatIfAtManagementGroupScopeSample.ts][deploymentswhatifatmanagementgroupscopesample] | Returns changes that will be made by the deployment if executed at the scope of the management group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PostDeploymentWhatIfOnManagementGroup.json | +| [deploymentsWhatIfAtSubscriptionScopeSample.ts][deploymentswhatifatsubscriptionscopesample] | Returns changes that will be made by the deployment if executed at the scope of the subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PostDeploymentWhatIfOnSubscription.json | +| [deploymentsWhatIfAtTenantScopeSample.ts][deploymentswhatifattenantscopesample] | Returns changes that will be made by the deployment if executed at the scope of the tenant group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PostDeploymentWhatIfOnTenant.json | +| [deploymentsWhatIfSample.ts][deploymentswhatifsample] | Returns changes that will be made by the deployment if executed at the scope of the resource group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PostDeploymentWhatIfOnResourceGroup.json | +| [providerResourceTypesListSample.ts][providerresourcetypeslistsample] | List the resource types for a specified resource provider. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetProviderResourceTypes.json | +| [providersGetAtTenantScopeSample.ts][providersgetattenantscopesample] | Gets the specified resource provider at the tenant level. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetNamedProviderAtTenant.json | +| [providersGetSample.ts][providersgetsample] | Gets the specified resource provider. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetProvider.json | +| [providersListSample.ts][providerslistsample] | Gets all resource providers for a subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetProviders.json | +| [providersProviderPermissionsSample.ts][providersproviderpermissionssample] | Get the provider permissions. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetProviderPermissions.json | +| [resourceGroupsCreateOrUpdateSample.ts][resourcegroupscreateorupdatesample] | Creates or updates a resource group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/CreateResourceGroup.json | +| [resourceGroupsDeleteSample.ts][resourcegroupsdeletesample] | When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/ForceDeleteVMsAndVMSSInResourceGroup.json | +| [resourceGroupsExportTemplateSample.ts][resourcegroupsexporttemplatesample] | Captures the specified resource group as a template. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/ExportResourceGroup.json | +| [tagsCreateOrUpdateAtScopeSample.ts][tagscreateorupdateatscopesample] | This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutTagsResource.json | +| [tagsGetAtScopeSample.ts][tagsgetatscopesample] | Gets the entire set of tags on a resource or subscription. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetTagsResource.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +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/deploymentsCalculateTemplateHashSample.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 node dist/deploymentsCalculateTemplateHashSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[deploymentscalculatetemplatehashsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsCalculateTemplateHashSample.ts +[deploymentscreateorupdateatmanagementgroupscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsCreateOrUpdateAtManagementGroupScopeSample.ts +[deploymentscreateorupdateatscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsCreateOrUpdateAtScopeSample.ts +[deploymentscreateorupdateatsubscriptionscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsCreateOrUpdateAtSubscriptionScopeSample.ts +[deploymentscreateorupdateattenantscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsCreateOrUpdateAtTenantScopeSample.ts +[deploymentscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsCreateOrUpdateSample.ts +[deploymentswhatifatmanagementgroupscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsWhatIfAtManagementGroupScopeSample.ts +[deploymentswhatifatsubscriptionscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsWhatIfAtSubscriptionScopeSample.ts +[deploymentswhatifattenantscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsWhatIfAtTenantScopeSample.ts +[deploymentswhatifsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsWhatIfSample.ts +[providerresourcetypeslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/typescript/src/providerResourceTypesListSample.ts +[providersgetattenantscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/typescript/src/providersGetAtTenantScopeSample.ts +[providersgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/typescript/src/providersGetSample.ts +[providerslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/typescript/src/providersListSample.ts +[providersproviderpermissionssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/typescript/src/providersProviderPermissionsSample.ts +[resourcegroupscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/typescript/src/resourceGroupsCreateOrUpdateSample.ts +[resourcegroupsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/typescript/src/resourceGroupsDeleteSample.ts +[resourcegroupsexporttemplatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/typescript/src/resourceGroupsExportTemplateSample.ts +[tagscreateorupdateatscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/typescript/src/tagsCreateOrUpdateAtScopeSample.ts +[tagsgetatscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources/samples/v5/typescript/src/tagsGetAtScopeSample.ts +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-resources?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/resources/arm-resources/README.md +[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/resources/arm-resources/samples/v5/typescript/package.json b/sdk/resources/arm-resources/samples/v5/typescript/package.json new file mode 100644 index 000000000000..d797f919c9ab --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/typescript/package.json @@ -0,0 +1,41 @@ +{ + "name": "@azure-samples/arm-resources-ts", + "private": true, + "version": "1.0.0", + "description": " client library samples for TypeScript", + "engines": { + "node": ">=12.0.0" + }, + "scripts": { + "build": "tsc", + "prebuild": "rimraf dist/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/resources/arm-resources" + }, + "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/resources/arm-resources", + "dependencies": { + "@azure/arm-resources": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + }, + "devDependencies": { + "@types/node": "^12.0.0", + "typescript": "~4.4.0", + "rimraf": "latest" + } +} diff --git a/sdk/resources/arm-resources/samples/v5/typescript/sample.env b/sdk/resources/arm-resources/samples/v5/typescript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/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/resources/arm-resources/samples/v5/typescript/src/deploymentsCalculateTemplateHashSample.ts b/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsCalculateTemplateHashSample.ts new file mode 100644 index 000000000000..ef98d9c46a68 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsCalculateTemplateHashSample.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 { ResourceManagementClient } from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Calculate the hash of the given template. + * + * @summary Calculate the hash of the given template. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/CalculateTemplateHash.json + */ +async function calculateTemplateHash() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const template: Record = { + $schema: + "http://schemas.management.azure.com/deploymentTemplate?api-version=2014-04-01-preview", + contentVersion: "1.0.0.0", + outputs: { string: { type: "string", value: "myvalue" } }, + parameters: { string: { type: "string" } }, + resources: [], + variables: { + array: [1, 2, 3, 4], + bool: true, + int: 42, + object: { object: { location: "West US", vmSize: "Large" } }, + string: "string" + } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.calculateTemplateHash(template); + console.log(result); +} + +calculateTemplateHash().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsCreateOrUpdateAtManagementGroupScopeSample.ts b/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsCreateOrUpdateAtManagementGroupScopeSample.ts new file mode 100644 index 000000000000..67139e55ae43 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsCreateOrUpdateAtManagementGroupScopeSample.ts @@ -0,0 +1,45 @@ +/* + * 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 { + ScopedDeployment, + ResourceManagementClient +} from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to You can provide the template and parameters directly in the request or link to JSON files. + * + * @summary You can provide the template and parameters directly in the request or link to JSON files. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentAtManagementGroup.json + */ +async function createDeploymentAtManagementGroupScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const groupId = "my-management-group-id"; + const deploymentName = "my-deployment"; + const parameters: ScopedDeployment = { + location: "eastus", + properties: { + mode: "Incremental", + parameters: {}, + templateLink: { uri: "https://example.com/exampleTemplate.json" } + } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAtManagementGroupScopeAndWait( + groupId, + deploymentName, + parameters + ); + console.log(result); +} + +createDeploymentAtManagementGroupScope().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsCreateOrUpdateAtScopeSample.ts b/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsCreateOrUpdateAtScopeSample.ts new file mode 100644 index 000000000000..b0efcc3ad039 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsCreateOrUpdateAtScopeSample.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 { Deployment, ResourceManagementClient } from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to You can provide the template and parameters directly in the request or link to JSON files. + * + * @summary You can provide the template and parameters directly in the request or link to JSON files. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentAtScope.json + */ +async function createDeploymentAtAGivenScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = + "providers/Microsoft.Management/managementGroups/my-management-group-id"; + const deploymentName = "my-deployment"; + const parameters: Deployment = { + location: "eastus", + properties: { + mode: "Incremental", + parameters: {}, + templateLink: { uri: "https://example.com/exampleTemplate.json" } + }, + tags: { tagKey1: "tag-value-1", tagKey2: "tag-value-2" } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAtScopeAndWait( + scope, + deploymentName, + parameters + ); + console.log(result); +} + +createDeploymentAtAGivenScope().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsCreateOrUpdateAtSubscriptionScopeSample.ts b/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsCreateOrUpdateAtSubscriptionScopeSample.ts new file mode 100644 index 000000000000..2c7ba97b349c --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsCreateOrUpdateAtSubscriptionScopeSample.ts @@ -0,0 +1,45 @@ +/* + * 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 { Deployment, ResourceManagementClient } from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to You can provide the template and parameters directly in the request or link to JSON files. + * + * @summary You can provide the template and parameters directly in the request or link to JSON files. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentSubscriptionTemplateSpecsWithId.json + */ +async function createADeploymentThatWillDeployATemplateSpecWithTheGivenResourceId() { + const subscriptionId = "00000000-0000-0000-0000-000000000001"; + const deploymentName = "my-deployment"; + const parameters: Deployment = { + location: "eastus", + properties: { + mode: "Incremental", + parameters: {}, + templateLink: { + id: + "/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Resources/TemplateSpecs/TemplateSpec-Name/versions/v1" + } + } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAtSubscriptionScopeAndWait( + deploymentName, + parameters + ); + console.log(result); +} + +createADeploymentThatWillDeployATemplateSpecWithTheGivenResourceId().catch( + console.error +); diff --git a/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsCreateOrUpdateAtTenantScopeSample.ts b/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsCreateOrUpdateAtTenantScopeSample.ts new file mode 100644 index 000000000000..2a7a2b607b1b --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsCreateOrUpdateAtTenantScopeSample.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 { + ScopedDeployment, + ResourceManagementClient +} from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to You can provide the template and parameters directly in the request or link to JSON files. + * + * @summary You can provide the template and parameters directly in the request or link to JSON files. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentAtTenant.json + */ +async function createDeploymentAtTenantScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const deploymentName = "tenant-dep01"; + const parameters: ScopedDeployment = { + location: "eastus", + properties: { + mode: "Incremental", + parameters: {}, + templateLink: { uri: "https://example.com/exampleTemplate.json" } + }, + tags: { tagKey1: "tag-value-1", tagKey2: "tag-value-2" } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAtTenantScopeAndWait( + deploymentName, + parameters + ); + console.log(result); +} + +createDeploymentAtTenantScope().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsCreateOrUpdateSample.ts b/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..fa6712c0b5cb --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsCreateOrUpdateSample.ts @@ -0,0 +1,148 @@ +/* + * 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 { Deployment, ResourceManagementClient } from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to You can provide the template and parameters directly in the request or link to JSON files. + * + * @summary You can provide the template and parameters directly in the request or link to JSON files. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentResourceGroup.json + */ +async function createADeploymentThatWillDeployATemplateWithAUriAndQueryString() { + const subscriptionId = "00000000-0000-0000-0000-000000000001"; + const resourceGroupName = "my-resource-group"; + const deploymentName = "my-deployment"; + const parameters: Deployment = { + properties: { + mode: "Incremental", + parameters: {}, + templateLink: { + queryString: + "sv=2019-02-02&st=2019-04-29T22%3A18%3A26Z&se=2019-04-30T02%3A23%3A26Z&sr=b&sp=rw&sip=168.1.5.60-168.1.5.70&spr=https&sig=xxxxxxxx0xxxxxxxxxxxxx%2bxxxxxxxxxxxxxxxxxxxx%3d", + uri: "https://example.com/exampleTemplate.json" + } + } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAndWait( + resourceGroupName, + deploymentName, + parameters + ); + console.log(result); +} + +createADeploymentThatWillDeployATemplateWithAUriAndQueryString().catch( + console.error +); + +/** + * This sample demonstrates how to You can provide the template and parameters directly in the request or link to JSON files. + * + * @summary You can provide the template and parameters directly in the request or link to JSON files. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentResourceGroupTemplateSpecsWithId.json + */ +async function createADeploymentThatWillDeployATemplateSpecWithTheGivenResourceId() { + const subscriptionId = "00000000-0000-0000-0000-000000000001"; + const resourceGroupName = "my-resource-group"; + const deploymentName = "my-deployment"; + const parameters: Deployment = { + properties: { + mode: "Incremental", + parameters: {}, + templateLink: { + id: + "/subscriptions/00000000-0000-0000-0000-000000000001/resourceGroups/my-resource-group/providers/Microsoft.Resources/TemplateSpecs/TemplateSpec-Name/versions/v1" + } + } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAndWait( + resourceGroupName, + deploymentName, + parameters + ); + console.log(result); +} + +createADeploymentThatWillDeployATemplateSpecWithTheGivenResourceId().catch( + console.error +); + +/** + * This sample demonstrates how to You can provide the template and parameters directly in the request or link to JSON files. + * + * @summary You can provide the template and parameters directly in the request or link to JSON files. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentWithOnErrorDeploymentSpecificDeployment.json + */ +async function createADeploymentThatWillRedeployAnotherDeploymentOnFailure() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "my-resource-group"; + const deploymentName = "my-deployment"; + const parameters: Deployment = { + properties: { + mode: "Complete", + onErrorDeployment: { + type: "SpecificDeployment", + deploymentName: "name-of-deployment-to-use" + }, + parameters: {}, + templateLink: { uri: "https://example.com/exampleTemplate.json" } + } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAndWait( + resourceGroupName, + deploymentName, + parameters + ); + console.log(result); +} + +createADeploymentThatWillRedeployAnotherDeploymentOnFailure().catch( + console.error +); + +/** + * This sample demonstrates how to You can provide the template and parameters directly in the request or link to JSON files. + * + * @summary You can provide the template and parameters directly in the request or link to JSON files. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutDeploymentWithOnErrorDeploymentLastSuccessful.json + */ +async function createADeploymentThatWillRedeployTheLastSuccessfulDeploymentOnFailure() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "my-resource-group"; + const deploymentName = "my-deployment"; + const parameters: Deployment = { + properties: { + mode: "Complete", + onErrorDeployment: { type: "LastSuccessful" }, + parameters: {}, + templateLink: { uri: "https://example.com/exampleTemplate.json" } + } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAndWait( + resourceGroupName, + deploymentName, + parameters + ); + console.log(result); +} + +createADeploymentThatWillRedeployTheLastSuccessfulDeploymentOnFailure().catch( + console.error +); diff --git a/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsWhatIfAtManagementGroupScopeSample.ts b/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsWhatIfAtManagementGroupScopeSample.ts new file mode 100644 index 000000000000..11ae8b873957 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsWhatIfAtManagementGroupScopeSample.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 { + ScopedDeploymentWhatIf, + ResourceManagementClient +} from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Returns changes that will be made by the deployment if executed at the scope of the management group. + * + * @summary Returns changes that will be made by the deployment if executed at the scope of the management group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PostDeploymentWhatIfOnManagementGroup.json + */ +async function predictTemplateChangesAtManagementGroupScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const groupId = "myManagementGruop"; + const deploymentName = "exampleDeploymentName"; + const parameters: ScopedDeploymentWhatIf = { + location: "eastus", + properties: { mode: "Incremental", parameters: {}, templateLink: {} } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginWhatIfAtManagementGroupScopeAndWait( + groupId, + deploymentName, + parameters + ); + console.log(result); +} + +predictTemplateChangesAtManagementGroupScope().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsWhatIfAtSubscriptionScopeSample.ts b/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsWhatIfAtSubscriptionScopeSample.ts new file mode 100644 index 000000000000..7b4e19af94a4 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsWhatIfAtSubscriptionScopeSample.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 { + DeploymentWhatIf, + ResourceManagementClient +} from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Returns changes that will be made by the deployment if executed at the scope of the subscription. + * + * @summary Returns changes that will be made by the deployment if executed at the scope of the subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PostDeploymentWhatIfOnSubscription.json + */ +async function predictTemplateChangesAtSubscriptionScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000001"; + const deploymentName = "my-deployment"; + const parameters: DeploymentWhatIf = { + location: "westus", + properties: { mode: "Incremental", parameters: {}, templateLink: {} } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginWhatIfAtSubscriptionScopeAndWait( + deploymentName, + parameters + ); + console.log(result); +} + +predictTemplateChangesAtSubscriptionScope().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsWhatIfAtTenantScopeSample.ts b/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsWhatIfAtTenantScopeSample.ts new file mode 100644 index 000000000000..e6dfcf7c6aab --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsWhatIfAtTenantScopeSample.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 { + ScopedDeploymentWhatIf, + ResourceManagementClient +} from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Returns changes that will be made by the deployment if executed at the scope of the tenant group. + * + * @summary Returns changes that will be made by the deployment if executed at the scope of the tenant group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PostDeploymentWhatIfOnTenant.json + */ +async function predictTemplateChangesAtManagementGroupScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const deploymentName = "exampleDeploymentName"; + const parameters: ScopedDeploymentWhatIf = { + location: "eastus", + properties: { mode: "Incremental", parameters: {}, templateLink: {} } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginWhatIfAtTenantScopeAndWait( + deploymentName, + parameters + ); + console.log(result); +} + +predictTemplateChangesAtManagementGroupScope().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsWhatIfSample.ts b/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsWhatIfSample.ts new file mode 100644 index 000000000000..65bfa94d74da --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/typescript/src/deploymentsWhatIfSample.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 { + DeploymentWhatIf, + ResourceManagementClient +} from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Returns changes that will be made by the deployment if executed at the scope of the resource group. + * + * @summary Returns changes that will be made by the deployment if executed at the scope of the resource group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PostDeploymentWhatIfOnResourceGroup.json + */ +async function predictTemplateChangesAtResourceGroupScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000001"; + const resourceGroupName = "my-resource-group"; + const deploymentName = "my-deployment"; + const parameters: DeploymentWhatIf = { + properties: { mode: "Incremental", parameters: {}, templateLink: {} } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginWhatIfAndWait( + resourceGroupName, + deploymentName, + parameters + ); + console.log(result); +} + +predictTemplateChangesAtResourceGroupScope().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/typescript/src/providerResourceTypesListSample.ts b/sdk/resources/arm-resources/samples/v5/typescript/src/providerResourceTypesListSample.ts new file mode 100644 index 000000000000..b090f7f94330 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/typescript/src/providerResourceTypesListSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { ResourceManagementClient } from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to List the resource types for a specified resource provider. + * + * @summary List the resource types for a specified resource provider. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetProviderResourceTypes.json + */ +async function getProviderResourceTypes() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceProviderNamespace = "Microsoft.TestRP"; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.providerResourceTypes.list( + resourceProviderNamespace + ); + console.log(result); +} + +getProviderResourceTypes().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/typescript/src/providersGetAtTenantScopeSample.ts b/sdk/resources/arm-resources/samples/v5/typescript/src/providersGetAtTenantScopeSample.ts new file mode 100644 index 000000000000..e15e706b5352 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/typescript/src/providersGetAtTenantScopeSample.ts @@ -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. +import { + ProvidersGetAtTenantScopeOptionalParams, + ResourceManagementClient +} from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the specified resource provider at the tenant level. + * + * @summary Gets the specified resource provider at the tenant level. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetNamedProviderAtTenant.json + */ +async function getAResourceProviderAtTenantScope() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const expand = "resourceTypes/aliases"; + const resourceProviderNamespace = "Microsoft.Storage"; + const options: ProvidersGetAtTenantScopeOptionalParams = { expand }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.providers.getAtTenantScope( + resourceProviderNamespace, + options + ); + console.log(result); +} + +getAResourceProviderAtTenantScope().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/typescript/src/providersGetSample.ts b/sdk/resources/arm-resources/samples/v5/typescript/src/providersGetSample.ts new file mode 100644 index 000000000000..bc749dab5de5 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/typescript/src/providersGetSample.ts @@ -0,0 +1,29 @@ +/* + * 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 { ResourceManagementClient } from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the specified resource provider. + * + * @summary Gets the specified resource provider. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetProvider.json + */ +async function getProvider() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceProviderNamespace = "Microsoft.TestRP1"; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.providers.get(resourceProviderNamespace); + console.log(result); +} + +getProvider().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/typescript/src/providersListSample.ts b/sdk/resources/arm-resources/samples/v5/typescript/src/providersListSample.ts new file mode 100644 index 000000000000..bcd76e00734a --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/typescript/src/providersListSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { ResourceManagementClient } from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets all resource providers for a subscription. + * + * @summary Gets all resource providers for a subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetProviders.json + */ +async function getProviders() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.providers.list()) { + resArray.push(item); + } + console.log(resArray); +} + +getProviders().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/typescript/src/providersProviderPermissionsSample.ts b/sdk/resources/arm-resources/samples/v5/typescript/src/providersProviderPermissionsSample.ts new file mode 100644 index 000000000000..819377488db7 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/typescript/src/providersProviderPermissionsSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { ResourceManagementClient } from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Get the provider permissions. + * + * @summary Get the provider permissions. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetProviderPermissions.json + */ +async function getProviderResourceTypes() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceProviderNamespace = "Microsoft.TestRP"; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.providers.providerPermissions( + resourceProviderNamespace + ); + console.log(result); +} + +getProviderResourceTypes().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/typescript/src/resourceGroupsCreateOrUpdateSample.ts b/sdk/resources/arm-resources/samples/v5/typescript/src/resourceGroupsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..05d744c91c8a --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/typescript/src/resourceGroupsCreateOrUpdateSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { ResourceGroup, ResourceManagementClient } from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates a resource group. + * + * @summary Creates or updates a resource group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/CreateResourceGroup.json + */ +async function createOrUpdateAResourceGroup() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "my-resource-group"; + const parameters: ResourceGroup = { location: "eastus" }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.resourceGroups.createOrUpdate( + resourceGroupName, + parameters + ); + console.log(result); +} + +createOrUpdateAResourceGroup().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/typescript/src/resourceGroupsDeleteSample.ts b/sdk/resources/arm-resources/samples/v5/typescript/src/resourceGroupsDeleteSample.ts new file mode 100644 index 000000000000..b01fb3eebf0c --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/typescript/src/resourceGroupsDeleteSample.ts @@ -0,0 +1,62 @@ +/* + * 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 { + ResourceGroupsDeleteOptionalParams, + ResourceManagementClient +} from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. + * + * @summary When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/ForceDeleteVMsAndVMSSInResourceGroup.json + */ +async function forceDeleteAllTheVirtualMachinesAndVirtualMachineScaleSetsInAResourceGroup() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "my-resource-group"; + const forceDeletionTypes = + "Microsoft.Compute/virtualMachines,Microsoft.Compute/virtualMachineScaleSets"; + const options: ResourceGroupsDeleteOptionalParams = { forceDeletionTypes }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.resourceGroups.beginDeleteAndWait( + resourceGroupName, + options + ); + console.log(result); +} + +forceDeleteAllTheVirtualMachinesAndVirtualMachineScaleSetsInAResourceGroup().catch( + console.error +); + +/** + * This sample demonstrates how to When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. + * + * @summary When you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes all of its template deployments and currently stored operations. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/ForceDeleteVMsInResourceGroup.json + */ +async function forceDeleteAllTheVirtualMachinesInAResourceGroup() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "my-resource-group"; + const forceDeletionTypes = "Microsoft.Compute/virtualMachines"; + const options: ResourceGroupsDeleteOptionalParams = { forceDeletionTypes }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.resourceGroups.beginDeleteAndWait( + resourceGroupName, + options + ); + console.log(result); +} + +forceDeleteAllTheVirtualMachinesInAResourceGroup().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/typescript/src/resourceGroupsExportTemplateSample.ts b/sdk/resources/arm-resources/samples/v5/typescript/src/resourceGroupsExportTemplateSample.ts new file mode 100644 index 000000000000..9775c5733f95 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/typescript/src/resourceGroupsExportTemplateSample.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 { + ExportTemplateRequest, + ResourceManagementClient +} from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Captures the specified resource group as a template. + * + * @summary Captures the specified resource group as a template. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/ExportResourceGroup.json + */ +async function exportAResourceGroup() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "my-resource-group"; + const parameters: ExportTemplateRequest = { + options: "IncludeParameterDefaultValue,IncludeComments", + resources: ["*"] + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.resourceGroups.beginExportTemplateAndWait( + resourceGroupName, + parameters + ); + console.log(result); +} + +exportAResourceGroup().catch(console.error); + +/** + * This sample demonstrates how to Captures the specified resource group as a template. + * + * @summary Captures the specified resource group as a template. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/ExportResourceGroupWithFiltering.json + */ +async function exportAResourceGroupWithFiltering() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "my-resource-group"; + const parameters: ExportTemplateRequest = { + options: "SkipResourceNameParameterization", + resources: [ + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/My.RP/myResourceType/myFirstResource" + ] + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.resourceGroups.beginExportTemplateAndWait( + resourceGroupName, + parameters + ); + console.log(result); +} + +exportAResourceGroupWithFiltering().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/typescript/src/tagsCreateOrUpdateAtScopeSample.ts b/sdk/resources/arm-resources/samples/v5/typescript/src/tagsCreateOrUpdateAtScopeSample.ts new file mode 100644 index 000000000000..ad99eea1a194 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/typescript/src/tagsCreateOrUpdateAtScopeSample.ts @@ -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. +import { TagsResource, ResourceManagementClient } from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags. + * + * @summary This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutTagsResource.json + */ +async function updateTagsOnAResource() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = + "subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/myPRNameSpace/VM/myVm"; + const parameters: TagsResource = { + properties: { tags: { tagKey1: "tag-value-1", tagKey2: "tag-value-2" } } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.tagsOperations.createOrUpdateAtScope( + scope, + parameters + ); + console.log(result); +} + +updateTagsOnAResource().catch(console.error); + +/** + * This sample demonstrates how to This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags. + * + * @summary This operation allows adding or replacing the entire set of tags on the specified resource or subscription. The specified entity can have a maximum of 50 tags. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/PutTagsSubscription.json + */ +async function updateTagsOnASubscription() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/00000000-0000-0000-0000-000000000000"; + const parameters: TagsResource = { + properties: { tags: { tagKey1: "tag-value-1", tagKey2: "tag-value-2" } } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.tagsOperations.createOrUpdateAtScope( + scope, + parameters + ); + console.log(result); +} + +updateTagsOnASubscription().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/typescript/src/tagsGetAtScopeSample.ts b/sdk/resources/arm-resources/samples/v5/typescript/src/tagsGetAtScopeSample.ts new file mode 100644 index 000000000000..d43b397344ee --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/typescript/src/tagsGetAtScopeSample.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 { ResourceManagementClient } from "@azure/arm-resources"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets the entire set of tags on a resource or subscription. + * + * @summary Gets the entire set of tags on a resource or subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetTagsResource.json + */ +async function getTagsOnAResource() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = + "subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/my-resource-group/providers/myPRNameSpace/VM/myVm"; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.tagsOperations.getAtScope(scope); + console.log(result); +} + +getTagsOnAResource().catch(console.error); + +/** + * This sample demonstrates how to Gets the entire set of tags on a resource or subscription. + * + * @summary Gets the entire set of tags on a resource or subscription. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-04-01/examples/GetTagsSubscription.json + */ +async function getTagsOnASubscription() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.tagsOperations.getAtScope(scope); + console.log(result); +} + +getTagsOnASubscription().catch(console.error); diff --git a/sdk/resources/arm-resources/samples/v5/typescript/tsconfig.json b/sdk/resources/arm-resources/samples/v5/typescript/tsconfig.json new file mode 100644 index 000000000000..416c2dd82e00 --- /dev/null +++ b/sdk/resources/arm-resources/samples/v5/typescript/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2018", + "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/resources/arm-resources/src/operations/deployments.ts b/sdk/resources/arm-resources/src/operations/deployments.ts index a4d92e6a9e98..97634950b406 100644 --- a/sdk/resources/arm-resources/src/operations/deployments.ts +++ b/sdk/resources/arm-resources/src/operations/deployments.ts @@ -426,10 +426,12 @@ export class DeploymentsImpl implements Deployments { { scope, deploymentName, options }, deleteAtScopeOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -536,10 +538,12 @@ export class DeploymentsImpl implements Deployments { { scope, deploymentName, parameters, options }, createOrUpdateAtScopeOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -663,10 +667,12 @@ export class DeploymentsImpl implements Deployments { { scope, deploymentName, parameters, options }, validateAtScopeOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -783,10 +789,12 @@ export class DeploymentsImpl implements Deployments { { deploymentName, options }, deleteAtTenantScopeOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -883,10 +891,12 @@ export class DeploymentsImpl implements Deployments { { deploymentName, parameters, options }, createOrUpdateAtTenantScopeOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -1001,10 +1011,12 @@ export class DeploymentsImpl implements Deployments { { deploymentName, parameters, options }, validateAtTenantScopeOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -1087,11 +1099,13 @@ export class DeploymentsImpl implements Deployments { { deploymentName, parameters, options }, whatIfAtTenantScopeOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, lroResourceLocationConfig: "location" }); + await poller.poll(); + return poller; } /** @@ -1202,10 +1216,12 @@ export class DeploymentsImpl implements Deployments { { groupId, deploymentName, options }, deleteAtManagementGroupScopeOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -1314,10 +1330,12 @@ export class DeploymentsImpl implements Deployments { { groupId, deploymentName, parameters, options }, createOrUpdateAtManagementGroupScopeOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -1441,10 +1459,12 @@ export class DeploymentsImpl implements Deployments { { groupId, deploymentName, parameters, options }, validateAtManagementGroupScopeOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -1533,11 +1553,13 @@ export class DeploymentsImpl implements Deployments { { groupId, deploymentName, parameters, options }, whatIfAtManagementGroupScopeOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, lroResourceLocationConfig: "location" }); + await poller.poll(); + return poller; } /** @@ -1654,10 +1676,12 @@ export class DeploymentsImpl implements Deployments { { deploymentName, options }, deleteAtSubscriptionScopeOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -1757,10 +1781,12 @@ export class DeploymentsImpl implements Deployments { { deploymentName, parameters, options }, createOrUpdateAtSubscriptionScopeOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -1875,10 +1901,12 @@ export class DeploymentsImpl implements Deployments { { deploymentName, parameters, options }, validateAtSubscriptionScopeOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -1961,11 +1989,13 @@ export class DeploymentsImpl implements Deployments { { deploymentName, parameters, options }, whatIfAtSubscriptionScopeOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, lroResourceLocationConfig: "location" }); + await poller.poll(); + return poller; } /** @@ -2078,10 +2108,12 @@ export class DeploymentsImpl implements Deployments { { resourceGroupName, deploymentName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -2192,10 +2224,12 @@ export class DeploymentsImpl implements Deployments { { resourceGroupName, deploymentName, parameters, options }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -2321,10 +2355,12 @@ export class DeploymentsImpl implements Deployments { { resourceGroupName, deploymentName, parameters, options }, validateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -2414,11 +2450,13 @@ export class DeploymentsImpl implements Deployments { { resourceGroupName, deploymentName, parameters, options }, whatIfOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, lroResourceLocationConfig: "location" }); + await poller.poll(); + return poller; } /** diff --git a/sdk/resources/arm-resources/src/operations/resourceGroups.ts b/sdk/resources/arm-resources/src/operations/resourceGroups.ts index 230e17766800..8a07b3adfc70 100644 --- a/sdk/resources/arm-resources/src/operations/resourceGroups.ts +++ b/sdk/resources/arm-resources/src/operations/resourceGroups.ts @@ -178,10 +178,12 @@ export class ResourceGroupsImpl implements ResourceGroups { { resourceGroupName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -292,11 +294,13 @@ export class ResourceGroupsImpl implements ResourceGroups { { resourceGroupName, parameters, options }, exportTemplateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, lroResourceLocationConfig: "location" }); + await poller.poll(); + return poller; } /** diff --git a/sdk/resources/arm-resources/src/operations/resources.ts b/sdk/resources/arm-resources/src/operations/resources.ts index 88740016d4bd..780c455e8515 100644 --- a/sdk/resources/arm-resources/src/operations/resources.ts +++ b/sdk/resources/arm-resources/src/operations/resources.ts @@ -230,10 +230,12 @@ export class ResourcesImpl implements Resources { { sourceResourceGroupName, parameters, options }, moveResourcesOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -320,10 +322,12 @@ export class ResourcesImpl implements Resources { { sourceResourceGroupName, parameters, options }, validateMoveResourcesOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -467,10 +471,12 @@ export class ResourcesImpl implements Resources { }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -585,10 +591,12 @@ export class ResourcesImpl implements Resources { }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -706,10 +714,12 @@ export class ResourcesImpl implements Resources { }, updateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -857,10 +867,12 @@ export class ResourcesImpl implements Resources { { resourceId, apiVersion, options }, deleteByIdOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -944,10 +956,12 @@ export class ResourcesImpl implements Resources { { resourceId, apiVersion, parameters, options }, createOrUpdateByIdOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -1038,10 +1052,12 @@ export class ResourcesImpl implements Resources { { resourceId, apiVersion, parameters, options }, updateByIdOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** diff --git a/sdk/resources/arm-resources/src/resourceManagementClient.ts b/sdk/resources/arm-resources/src/resourceManagementClient.ts index 79a57585c866..ef6854e51748 100644 --- a/sdk/resources/arm-resources/src/resourceManagementClient.ts +++ b/sdk/resources/arm-resources/src/resourceManagementClient.ts @@ -7,6 +7,7 @@ */ import * as coreClient from "@azure/core-client"; +import * as coreRestPipeline from "@azure/core-rest-pipeline"; import * as coreAuth from "@azure/core-auth"; import { OperationsImpl, @@ -62,7 +63,7 @@ export class ResourceManagementClient extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-resources/5.0.0`; + const packageDetails = `azsdk-js-arm-resources/5.0.1`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` @@ -77,9 +78,33 @@ export class ResourceManagementClient extends coreClient.ServiceClient { userAgentOptions: { userAgentPrefix }, - baseUri: options.endpoint || "https://management.azure.com" + baseUri: + options.endpoint ?? options.baseUri ?? "https://management.azure.com" }; super(optionsWithDefaults); + + if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { + const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies(); + const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( + (pipelinePolicy) => + pipelinePolicy.name === + coreRestPipeline.bearerTokenAuthenticationPolicyName + ); + if (!bearerTokenAuthenticationPolicyFound) { + this.pipeline.removePolicy({ + name: coreRestPipeline.bearerTokenAuthenticationPolicyName + }); + this.pipeline.addPolicy( + coreRestPipeline.bearerTokenAuthenticationPolicy({ + scopes: `${optionsWithDefaults.baseUri}/.default`, + challengeCallbacks: { + authorizeRequestOnChallenge: + coreClient.authorizeRequestOnClaimChallenge + } + }) + ); + } + } // Parameter assignments this.subscriptionId = subscriptionId; diff --git a/sdk/resources/arm-resources/tsconfig.json b/sdk/resources/arm-resources/tsconfig.json index 6e3251194117..b26efa5c66ab 100644 --- a/sdk/resources/arm-resources/tsconfig.json +++ b/sdk/resources/arm-resources/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-resources": [ + "./src/index" + ] + } }, - "include": ["./src/**/*.ts", "./test/**/*.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/resources/ci.mgmt.yml b/sdk/resources/ci.mgmt.yml index a454db923ccb..867f13116ea1 100644 --- a/sdk/resources/ci.mgmt.yml +++ b/sdk/resources/ci.mgmt.yml @@ -9,8 +9,8 @@ trigger: paths: include: - sdk/resources/ci.mgmt.yml - - sdk/resources/arm-resources/ - sdk/resources/arm-resources-profile-2020-09-01-hybrid + - sdk/resources/arm-resources pr: branches: include: @@ -23,8 +23,8 @@ pr: paths: include: - sdk/resources/ci.mgmt.yml - - sdk/resources/arm-resources/ - sdk/resources/arm-resources-profile-2020-09-01-hybrid + - sdk/resources/arm-resources extends: template: /eng/pipelines/templates/stages/archetype-sdk-client.yml parameters: diff --git a/sdk/templatespecs/arm-templatespecs/CHANGELOG.md b/sdk/templatespecs/arm-templatespecs/CHANGELOG.md index 83cc6a6a2b3d..b9151f7ae3c7 100644 --- a/sdk/templatespecs/arm-templatespecs/CHANGELOG.md +++ b/sdk/templatespecs/arm-templatespecs/CHANGELOG.md @@ -1,15 +1,11 @@ # Release History -## 2.0.1 (Unreleased) +## 2.0.1 (2022-04-18) -### Features Added +**features** -### Breaking Changes - -### Bugs Fixed - -### Other Changes + - Bug fix ## 2.0.0 (2021-12-16) -- The package of @azure/arm-webpubsub is using our next generation design principles. To learn more, please refer to our documentation [Quick Start](https://aka.ms/js-track2-quickstart). +- The package of @azure/arm-templatespecs is using our next generation design principles. To learn more, please refer to our documentation [Quick Start](https://aka.ms/js-track2-quickstart). diff --git a/sdk/templatespecs/arm-templatespecs/LICENSE b/sdk/templatespecs/arm-templatespecs/LICENSE index ccb63b166732..5d1d36e0af80 100644 --- a/sdk/templatespecs/arm-templatespecs/LICENSE +++ b/sdk/templatespecs/arm-templatespecs/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2021 Microsoft +Copyright (c) 2022 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/templatespecs/arm-templatespecs/README.md b/sdk/templatespecs/arm-templatespecs/README.md index 610bdbc8c557..7abfe7b7edbb 100644 --- a/sdk/templatespecs/arm-templatespecs/README.md +++ b/sdk/templatespecs/arm-templatespecs/README.md @@ -16,6 +16,8 @@ The APIs listed in this specification can be used to manage Template Spec resour - [LTS versions of Node.js](https://nodejs.org/about/releases/) - 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]. @@ -49,8 +51,17 @@ For more information about how to create an Azure AD Application check out [this ```javascript const { TemplateSpecsClient } = require("@azure/arm-templatespecs"); 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 TemplateSpecsClient(new DefaultAzureCredential(), subscriptionId); + +// For client-side applications running in the browser, use this code instead: +// const credential = new InteractiveBrowserCredential({ +// tenantId: "", +// clientId: "" +// }); +// const client = new TemplateSpecsClient(credential, subscriptionId); ``` diff --git a/sdk/templatespecs/arm-templatespecs/_meta.json b/sdk/templatespecs/arm-templatespecs/_meta.json index 44e0b401977a..c6765ba542bb 100644 --- a/sdk/templatespecs/arm-templatespecs/_meta.json +++ b/sdk/templatespecs/arm-templatespecs/_meta.json @@ -1,7 +1,8 @@ { - "commit": "ea0f7b072ad3aaff203ea9003246b9e584b819ff", - "readme": "specification/resources/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 --generate-test --typescript-sdks-folder=D:\\mydev\\azure-sdk-for-js ../azure-rest-api-specs/specification/resources/resource-manager/readme.md --use=@autorest/typescript@6.0.0-alpha.16.20211207.1", + "commit": "a42f1b58607091c4f255ead152a8ef323fa0b280", + "readme": "specification\\resources\\resource-manager\\readme.md", + "autorest_command": "autorest --version=3.7.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\work\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\resources\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-alpha.19.20220408.1 --generate-sample=true", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "use": "@autorest/typescript@6.0.0-alpha.16.20211207.1" + "release_tool": "@azure-tools/js-sdk-release-tools@2.2.6", + "use": "@autorest/typescript@6.0.0-alpha.19.20220408.1" } \ No newline at end of file diff --git a/sdk/templatespecs/arm-templatespecs/api-extractor.json b/sdk/templatespecs/arm-templatespecs/api-extractor.json index 384f0e25c009..933b7f47abcd 100644 --- a/sdk/templatespecs/arm-templatespecs/api-extractor.json +++ b/sdk/templatespecs/arm-templatespecs/api-extractor.json @@ -1,18 +1,31 @@ { "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", "mainEntryPointFilePath": "./dist-esm/src/index.d.ts", - "docModel": { "enabled": true }, - "apiReport": { "enabled": true, "reportFolder": "./review" }, + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, "dtsRollup": { "enabled": true, "untrimmedFilePath": "", "publicTrimmedFilePath": "./types/arm-templatespecs.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/templatespecs/arm-templatespecs/package.json b/sdk/templatespecs/arm-templatespecs/package.json index 3bbb11a0d8e5..188a070d22da 100644 --- a/sdk/templatespecs/arm-templatespecs/package.json +++ b/sdk/templatespecs/arm-templatespecs/package.json @@ -9,9 +9,9 @@ }, "dependencies": { "@azure/core-paging": "^1.2.0", - "@azure/core-client": "^1.0.0", + "@azure/core-client": "^1.5.0", "@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": [ @@ -28,12 +28,12 @@ "devDependencies": { "@microsoft/api-extractor": "^7.18.11", "@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-plugin-sourcemaps": "^0.4.2", + "rollup": "^2.66.1", + "rollup-plugin-sourcemaps": "^0.6.3", "typescript": "~4.2.0", "uglify-js": "^3.4.9", "rimraf": "^3.0.0", @@ -96,5 +96,21 @@ "docs": "echo skipped" }, "sideEffects": false, - "autoPublish": true + "//metadata": { + "constantPaths": [ + { + "path": "src/templateSpecsClient.ts", + "prefix": "packageDetails" + } + ] + }, + "autoPublish": true, + "//sampleConfiguration": { + "productName": "", + "productSlugs": [ + "azure" + ], + "disableDocsMs": true, + "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-templatespecs?view=azure-node-preview" + } } diff --git a/sdk/templatespecs/arm-templatespecs/rollup.config.js b/sdk/templatespecs/arm-templatespecs/rollup.config.js index 9be1955eb7f1..3f89d7309da5 100644 --- a/sdk/templatespecs/arm-templatespecs/rollup.config.js +++ b/sdk/templatespecs/arm-templatespecs/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/templatespecs/arm-templatespecs/sample.env b/sdk/templatespecs/arm-templatespecs/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/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/templatespecs/arm-templatespecs/samples-dev/templateSpecVersionsCreateOrUpdateSample.ts b/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecVersionsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..198aa0eeb688 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecVersionsCreateOrUpdateSample.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 { + TemplateSpecVersion, + TemplateSpecsClient +} from "@azure/arm-templatespecs"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates a Template Spec version. + * + * @summary Creates or updates a Template Spec version. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsCreate.json + */ +async function templateSpecVersionsCreateUpdate() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const templateSpecName = "simpleTemplateSpec"; + const templateSpecVersion = "v1.0"; + const templateSpecVersionModel: TemplateSpecVersion = { + description: "This is version v1.0 of our template content", + location: "eastus", + mainTemplate: { + $schema: + "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + contentVersion: "1.0.0.0", + parameters: {}, + resources: [] + } + }; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const result = await client.templateSpecVersions.createOrUpdate( + resourceGroupName, + templateSpecName, + templateSpecVersion, + templateSpecVersionModel + ); + console.log(result); +} + +templateSpecVersionsCreateUpdate().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecVersionsDeleteSample.ts b/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecVersionsDeleteSample.ts new file mode 100644 index 000000000000..d5ed9459e5e9 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecVersionsDeleteSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { TemplateSpecsClient } from "@azure/arm-templatespecs"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes a specific version from a Template Spec. When operation completes, status code 200 returned without content. + * + * @summary Deletes a specific version from a Template Spec. When operation completes, status code 200 returned without content. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsDelete.json + */ +async function templateSpecVersionsDelete() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const templateSpecName = "simpleTemplateSpec"; + const templateSpecVersion = "v1.0"; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const result = await client.templateSpecVersions.delete( + resourceGroupName, + templateSpecName, + templateSpecVersion + ); + console.log(result); +} + +templateSpecVersionsDelete().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecVersionsGetSample.ts b/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecVersionsGetSample.ts new file mode 100644 index 000000000000..c0edaf567c18 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecVersionsGetSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { TemplateSpecsClient } from "@azure/arm-templatespecs"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets a Template Spec version from a specific Template Spec. + * + * @summary Gets a Template Spec version from a specific Template Spec. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsGet.json + */ +async function templateSpecVersionsGet() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const templateSpecName = "simpleTemplateSpec"; + const templateSpecVersion = "v1.0"; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const result = await client.templateSpecVersions.get( + resourceGroupName, + templateSpecName, + templateSpecVersion + ); + console.log(result); +} + +templateSpecVersionsGet().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecVersionsListSample.ts b/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecVersionsListSample.ts new file mode 100644 index 000000000000..21e4828073f6 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecVersionsListSample.ts @@ -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. +import { TemplateSpecsClient } from "@azure/arm-templatespecs"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists all the Template Spec versions in the specified Template Spec. + * + * @summary Lists all the Template Spec versions in the specified Template Spec. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsList.json + */ +async function templateSpecVersionsList() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const templateSpecName = "simpleTemplateSpec"; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.templateSpecVersions.list( + resourceGroupName, + templateSpecName + )) { + resArray.push(item); + } + console.log(resArray); +} + +templateSpecVersionsList().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecVersionsUpdateSample.ts b/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecVersionsUpdateSample.ts new file mode 100644 index 000000000000..6fcfba655f91 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecVersionsUpdateSample.ts @@ -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. +import { + TemplateSpecVersionUpdateModel, + TemplateSpecVersionsUpdateOptionalParams, + TemplateSpecsClient +} from "@azure/arm-templatespecs"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Updates Template Spec Version tags with specified values. + * + * @summary Updates Template Spec Version tags with specified values. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsPatch.json + */ +async function templateSpecsPatch() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const templateSpecName = "simpleTemplateSpec"; + const templateSpecVersion = "v1.0"; + const templateSpecVersionUpdateModel: TemplateSpecVersionUpdateModel = { + tags: { myTag: "My Value" } + }; + const options: TemplateSpecVersionsUpdateOptionalParams = { + templateSpecVersionUpdateModel + }; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const result = await client.templateSpecVersions.update( + resourceGroupName, + templateSpecName, + templateSpecVersion, + options + ); + console.log(result); +} + +templateSpecsPatch().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecsCreateOrUpdateSample.ts b/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..a6c11c0d6fe6 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecsCreateOrUpdateSample.ts @@ -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. +import { TemplateSpec, TemplateSpecsClient } from "@azure/arm-templatespecs"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates a Template Spec. + * + * @summary Creates or updates a Template Spec. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsCreate.json + */ +async function templateSpecsCreateUpdate() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const templateSpecName = "simpleTemplateSpec"; + const templateSpec: TemplateSpec = { + description: "A very simple Template Spec", + location: "eastus" + }; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const result = await client.templateSpecs.createOrUpdate( + resourceGroupName, + templateSpecName, + templateSpec + ); + console.log(result); +} + +templateSpecsCreateUpdate().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecsDeleteSample.ts b/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecsDeleteSample.ts new file mode 100644 index 000000000000..6371ae865565 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecsDeleteSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { TemplateSpecsClient } from "@azure/arm-templatespecs"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes a Template Spec by name. When operation completes, status code 200 returned without content. + * + * @summary Deletes a Template Spec by name. When operation completes, status code 200 returned without content. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsDelete.json + */ +async function templateSpecsDelete() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const templateSpecName = "simpleTemplateSpec"; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const result = await client.templateSpecs.delete( + resourceGroupName, + templateSpecName + ); + console.log(result); +} + +templateSpecsDelete().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecsGetSample.ts b/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecsGetSample.ts new file mode 100644 index 000000000000..86adc1e41adc --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecsGetSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { TemplateSpecsClient } from "@azure/arm-templatespecs"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets a Template Spec with a given name. + * + * @summary Gets a Template Spec with a given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsGet.json + */ +async function templateSpecsGet() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const templateSpecName = "simpleTemplateSpec"; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const result = await client.templateSpecs.get( + resourceGroupName, + templateSpecName + ); + console.log(result); +} + +templateSpecsGet().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecsListByResourceGroupSample.ts b/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecsListByResourceGroupSample.ts new file mode 100644 index 000000000000..b1b4f867f196 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecsListByResourceGroupSample.ts @@ -0,0 +1,34 @@ +/* + * 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 { TemplateSpecsClient } from "@azure/arm-templatespecs"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists all the Template Specs within the specified resource group. + * + * @summary Lists all the Template Specs within the specified resource group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsListByResourceGroup.json + */ +async function templateSpecsListByResourceGroup() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.templateSpecs.listByResourceGroup( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +templateSpecsListByResourceGroup().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecsListBySubscriptionSample.ts b/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecsListBySubscriptionSample.ts new file mode 100644 index 000000000000..8c180802ae26 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecsListBySubscriptionSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { TemplateSpecsClient } from "@azure/arm-templatespecs"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists all the Template Specs within the specified subscriptions. + * + * @summary Lists all the Template Specs within the specified subscriptions. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsListBySubscription.json + */ +async function templatesSpecsListBySubscription() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.templateSpecs.listBySubscription()) { + resArray.push(item); + } + console.log(resArray); +} + +templatesSpecsListBySubscription().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecsUpdateSample.ts b/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecsUpdateSample.ts new file mode 100644 index 000000000000..98102d1dd7e4 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples-dev/templateSpecsUpdateSample.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 { + TemplateSpecUpdateModel, + TemplateSpecsUpdateOptionalParams, + TemplateSpecsClient +} from "@azure/arm-templatespecs"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Updates Template Spec tags with specified values. + * + * @summary Updates Template Spec tags with specified values. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsPatch.json + */ +async function templateSpecsPatch() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const templateSpecName = "simpleTemplateSpec"; + const templateSpec: TemplateSpecUpdateModel = { tags: { myTag: "My Value" } }; + const options: TemplateSpecsUpdateOptionalParams = { templateSpec }; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const result = await client.templateSpecs.update( + resourceGroupName, + templateSpecName, + options + ); + console.log(result); +} + +templateSpecsPatch().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/README.md b/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/README.md new file mode 100644 index 000000000000..a330b929e1b4 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/README.md @@ -0,0 +1,70 @@ +# client library samples for JavaScript + +These sample programs show how to use the JavaScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| --------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [templateSpecVersionsCreateOrUpdateSample.js][templatespecversionscreateorupdatesample] | Creates or updates a Template Spec version. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsCreate.json | +| [templateSpecVersionsDeleteSample.js][templatespecversionsdeletesample] | Deletes a specific version from a Template Spec. When operation completes, status code 200 returned without content. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsDelete.json | +| [templateSpecVersionsGetSample.js][templatespecversionsgetsample] | Gets a Template Spec version from a specific Template Spec. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsGet.json | +| [templateSpecVersionsListSample.js][templatespecversionslistsample] | Lists all the Template Spec versions in the specified Template Spec. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsList.json | +| [templateSpecVersionsUpdateSample.js][templatespecversionsupdatesample] | Updates Template Spec Version tags with specified values. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsPatch.json | +| [templateSpecsCreateOrUpdateSample.js][templatespecscreateorupdatesample] | Creates or updates a Template Spec. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsCreate.json | +| [templateSpecsDeleteSample.js][templatespecsdeletesample] | Deletes a Template Spec by name. When operation completes, status code 200 returned without content. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsDelete.json | +| [templateSpecsGetSample.js][templatespecsgetsample] | Gets a Template Spec with a given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsGet.json | +| [templateSpecsListByResourceGroupSample.js][templatespecslistbyresourcegroupsample] | Lists all the Template Specs within the specified resource group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsListByResourceGroup.json | +| [templateSpecsListBySubscriptionSample.js][templatespecslistbysubscriptionsample] | Lists all the Template Specs within the specified subscriptions. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsListBySubscription.json | +| [templateSpecsUpdateSample.js][templatespecsupdatesample] | Updates Template Spec tags with specified values. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsPatch.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +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 templateSpecVersionsCreateOrUpdateSample.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 node templateSpecVersionsCreateOrUpdateSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[templatespecversionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecVersionsCreateOrUpdateSample.js +[templatespecversionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecVersionsDeleteSample.js +[templatespecversionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecVersionsGetSample.js +[templatespecversionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecVersionsListSample.js +[templatespecversionsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecVersionsUpdateSample.js +[templatespecscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecsCreateOrUpdateSample.js +[templatespecsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecsDeleteSample.js +[templatespecsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecsGetSample.js +[templatespecslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecsListByResourceGroupSample.js +[templatespecslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecsListBySubscriptionSample.js +[templatespecsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecsUpdateSample.js +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-templatespecs?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/templatespecs/arm-templatespecs/README.md diff --git a/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/package.json b/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/package.json new file mode 100644 index 000000000000..7c0c3d85f973 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/package.json @@ -0,0 +1,32 @@ +{ + "name": "@azure-samples/arm-templatespecs-js", + "private": true, + "version": "1.0.0", + "description": " client library samples for JavaScript", + "engines": { + "node": ">=12.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/templatespecs/arm-templatespecs" + }, + "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/templatespecs/arm-templatespecs", + "dependencies": { + "@azure/arm-templatespecs": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + } +} diff --git a/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/sample.env b/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/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/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecVersionsCreateOrUpdateSample.js b/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecVersionsCreateOrUpdateSample.js new file mode 100644 index 000000000000..0d38c0b4d6b4 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecVersionsCreateOrUpdateSample.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 { TemplateSpecsClient } = require("@azure/arm-templatespecs"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Creates or updates a Template Spec version. + * + * @summary Creates or updates a Template Spec version. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsCreate.json + */ +async function templateSpecVersionsCreateUpdate() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const templateSpecName = "simpleTemplateSpec"; + const templateSpecVersion = "v1.0"; + const templateSpecVersionModel = { + description: "This is version v1.0 of our template content", + location: "eastus", + mainTemplate: { + $schema: "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + contentVersion: "1.0.0.0", + parameters: {}, + resources: [], + }, + }; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const result = await client.templateSpecVersions.createOrUpdate( + resourceGroupName, + templateSpecName, + templateSpecVersion, + templateSpecVersionModel + ); + console.log(result); +} + +templateSpecVersionsCreateUpdate().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecVersionsDeleteSample.js b/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecVersionsDeleteSample.js new file mode 100644 index 000000000000..8b61c3e0cde2 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecVersionsDeleteSample.js @@ -0,0 +1,35 @@ +/* + * 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 { TemplateSpecsClient } = require("@azure/arm-templatespecs"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes a specific version from a Template Spec. When operation completes, status code 200 returned without content. + * + * @summary Deletes a specific version from a Template Spec. When operation completes, status code 200 returned without content. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsDelete.json + */ +async function templateSpecVersionsDelete() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const templateSpecName = "simpleTemplateSpec"; + const templateSpecVersion = "v1.0"; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const result = await client.templateSpecVersions.delete( + resourceGroupName, + templateSpecName, + templateSpecVersion + ); + console.log(result); +} + +templateSpecVersionsDelete().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecVersionsGetSample.js b/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecVersionsGetSample.js new file mode 100644 index 000000000000..0f39a2facaa0 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecVersionsGetSample.js @@ -0,0 +1,35 @@ +/* + * 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 { TemplateSpecsClient } = require("@azure/arm-templatespecs"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets a Template Spec version from a specific Template Spec. + * + * @summary Gets a Template Spec version from a specific Template Spec. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsGet.json + */ +async function templateSpecVersionsGet() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const templateSpecName = "simpleTemplateSpec"; + const templateSpecVersion = "v1.0"; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const result = await client.templateSpecVersions.get( + resourceGroupName, + templateSpecName, + templateSpecVersion + ); + console.log(result); +} + +templateSpecVersionsGet().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecVersionsListSample.js b/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecVersionsListSample.js new file mode 100644 index 000000000000..a83defd5c403 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecVersionsListSample.js @@ -0,0 +1,33 @@ +/* + * 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 { TemplateSpecsClient } = require("@azure/arm-templatespecs"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists all the Template Spec versions in the specified Template Spec. + * + * @summary Lists all the Template Spec versions in the specified Template Spec. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsList.json + */ +async function templateSpecVersionsList() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const templateSpecName = "simpleTemplateSpec"; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.templateSpecVersions.list(resourceGroupName, templateSpecName)) { + resArray.push(item); + } + console.log(resArray); +} + +templateSpecVersionsList().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecVersionsUpdateSample.js b/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecVersionsUpdateSample.js new file mode 100644 index 000000000000..d257b953ed32 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecVersionsUpdateSample.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 { TemplateSpecsClient } = require("@azure/arm-templatespecs"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Updates Template Spec Version tags with specified values. + * + * @summary Updates Template Spec Version tags with specified values. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsPatch.json + */ +async function templateSpecsPatch() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const templateSpecName = "simpleTemplateSpec"; + const templateSpecVersion = "v1.0"; + const templateSpecVersionUpdateModel = { + tags: { myTag: "My Value" }, + }; + const options = { + templateSpecVersionUpdateModel, + }; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const result = await client.templateSpecVersions.update( + resourceGroupName, + templateSpecName, + templateSpecVersion, + options + ); + console.log(result); +} + +templateSpecsPatch().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecsCreateOrUpdateSample.js b/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecsCreateOrUpdateSample.js new file mode 100644 index 000000000000..c73dfab861e2 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecsCreateOrUpdateSample.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 { TemplateSpecsClient } = require("@azure/arm-templatespecs"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Creates or updates a Template Spec. + * + * @summary Creates or updates a Template Spec. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsCreate.json + */ +async function templateSpecsCreateUpdate() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const templateSpecName = "simpleTemplateSpec"; + const templateSpec = { + description: "A very simple Template Spec", + location: "eastus", + }; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const result = await client.templateSpecs.createOrUpdate( + resourceGroupName, + templateSpecName, + templateSpec + ); + console.log(result); +} + +templateSpecsCreateUpdate().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecsDeleteSample.js b/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecsDeleteSample.js new file mode 100644 index 000000000000..7daf065a837d --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecsDeleteSample.js @@ -0,0 +1,30 @@ +/* + * 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 { TemplateSpecsClient } = require("@azure/arm-templatespecs"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Deletes a Template Spec by name. When operation completes, status code 200 returned without content. + * + * @summary Deletes a Template Spec by name. When operation completes, status code 200 returned without content. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsDelete.json + */ +async function templateSpecsDelete() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const templateSpecName = "simpleTemplateSpec"; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const result = await client.templateSpecs.delete(resourceGroupName, templateSpecName); + console.log(result); +} + +templateSpecsDelete().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecsGetSample.js b/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecsGetSample.js new file mode 100644 index 000000000000..95d7f9749c2f --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecsGetSample.js @@ -0,0 +1,30 @@ +/* + * 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 { TemplateSpecsClient } = require("@azure/arm-templatespecs"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Gets a Template Spec with a given name. + * + * @summary Gets a Template Spec with a given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsGet.json + */ +async function templateSpecsGet() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const templateSpecName = "simpleTemplateSpec"; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const result = await client.templateSpecs.get(resourceGroupName, templateSpecName); + console.log(result); +} + +templateSpecsGet().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecsListByResourceGroupSample.js b/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecsListByResourceGroupSample.js new file mode 100644 index 000000000000..ca580f768a00 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecsListByResourceGroupSample.js @@ -0,0 +1,32 @@ +/* + * 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 { TemplateSpecsClient } = require("@azure/arm-templatespecs"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists all the Template Specs within the specified resource group. + * + * @summary Lists all the Template Specs within the specified resource group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsListByResourceGroup.json + */ +async function templateSpecsListByResourceGroup() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.templateSpecs.listByResourceGroup(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +templateSpecsListByResourceGroup().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecsListBySubscriptionSample.js b/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecsListBySubscriptionSample.js new file mode 100644 index 000000000000..3c8df22608e6 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecsListBySubscriptionSample.js @@ -0,0 +1,31 @@ +/* + * 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 { TemplateSpecsClient } = require("@azure/arm-templatespecs"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Lists all the Template Specs within the specified subscriptions. + * + * @summary Lists all the Template Specs within the specified subscriptions. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsListBySubscription.json + */ +async function templatesSpecsListBySubscription() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.templateSpecs.listBySubscription()) { + resArray.push(item); + } + console.log(resArray); +} + +templatesSpecsListBySubscription().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecsUpdateSample.js b/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecsUpdateSample.js new file mode 100644 index 000000000000..abe7b1f0ce55 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/javascript/templateSpecsUpdateSample.js @@ -0,0 +1,32 @@ +/* + * 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 { TemplateSpecsClient } = require("@azure/arm-templatespecs"); +const { DefaultAzureCredential } = require("@azure/identity"); + +/** + * This sample demonstrates how to Updates Template Spec tags with specified values. + * + * @summary Updates Template Spec tags with specified values. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsPatch.json + */ +async function templateSpecsPatch() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const templateSpecName = "simpleTemplateSpec"; + const templateSpec = { tags: { myTag: "My Value" } }; + const options = { templateSpec }; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const result = await client.templateSpecs.update(resourceGroupName, templateSpecName, options); + console.log(result); +} + +templateSpecsPatch().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/README.md b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/README.md new file mode 100644 index 000000000000..968dd45c5d07 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/README.md @@ -0,0 +1,83 @@ +# client library samples for TypeScript + +These sample programs show how to use the TypeScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| --------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [templateSpecVersionsCreateOrUpdateSample.ts][templatespecversionscreateorupdatesample] | Creates or updates a Template Spec version. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsCreate.json | +| [templateSpecVersionsDeleteSample.ts][templatespecversionsdeletesample] | Deletes a specific version from a Template Spec. When operation completes, status code 200 returned without content. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsDelete.json | +| [templateSpecVersionsGetSample.ts][templatespecversionsgetsample] | Gets a Template Spec version from a specific Template Spec. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsGet.json | +| [templateSpecVersionsListSample.ts][templatespecversionslistsample] | Lists all the Template Spec versions in the specified Template Spec. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsList.json | +| [templateSpecVersionsUpdateSample.ts][templatespecversionsupdatesample] | Updates Template Spec Version tags with specified values. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsPatch.json | +| [templateSpecsCreateOrUpdateSample.ts][templatespecscreateorupdatesample] | Creates or updates a Template Spec. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsCreate.json | +| [templateSpecsDeleteSample.ts][templatespecsdeletesample] | Deletes a Template Spec by name. When operation completes, status code 200 returned without content. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsDelete.json | +| [templateSpecsGetSample.ts][templatespecsgetsample] | Gets a Template Spec with a given name. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsGet.json | +| [templateSpecsListByResourceGroupSample.ts][templatespecslistbyresourcegroupsample] | Lists all the Template Specs within the specified resource group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsListByResourceGroup.json | +| [templateSpecsListBySubscriptionSample.ts][templatespecslistbysubscriptionsample] | Lists all the Template Specs within the specified subscriptions. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsListBySubscription.json | +| [templateSpecsUpdateSample.ts][templatespecsupdatesample] | Updates Template Spec tags with specified values. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsPatch.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://nodejs.org/about/releases/). + +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/templateSpecVersionsCreateOrUpdateSample.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 node dist/templateSpecVersionsCreateOrUpdateSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[templatespecversionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecVersionsCreateOrUpdateSample.ts +[templatespecversionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecVersionsDeleteSample.ts +[templatespecversionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecVersionsGetSample.ts +[templatespecversionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecVersionsListSample.ts +[templatespecversionsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecVersionsUpdateSample.ts +[templatespecscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecsCreateOrUpdateSample.ts +[templatespecsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecsDeleteSample.ts +[templatespecsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecsGetSample.ts +[templatespecslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecsListByResourceGroupSample.ts +[templatespecslistbysubscriptionsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecsListBySubscriptionSample.ts +[templatespecsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecsUpdateSample.ts +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-templatespecs?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/templatespecs/arm-templatespecs/README.md +[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/package.json b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/package.json new file mode 100644 index 000000000000..34953351c904 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/package.json @@ -0,0 +1,41 @@ +{ + "name": "@azure-samples/arm-templatespecs-ts", + "private": true, + "version": "1.0.0", + "description": " client library samples for TypeScript", + "engines": { + "node": ">=12.0.0" + }, + "scripts": { + "build": "tsc", + "prebuild": "rimraf dist/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/templatespecs/arm-templatespecs" + }, + "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/templatespecs/arm-templatespecs", + "dependencies": { + "@azure/arm-templatespecs": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + }, + "devDependencies": { + "@types/node": "^12.0.0", + "typescript": "~4.4.0", + "rimraf": "latest" + } +} diff --git a/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/sample.env b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/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/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecVersionsCreateOrUpdateSample.ts b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecVersionsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..198aa0eeb688 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecVersionsCreateOrUpdateSample.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 { + TemplateSpecVersion, + TemplateSpecsClient +} from "@azure/arm-templatespecs"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates a Template Spec version. + * + * @summary Creates or updates a Template Spec version. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsCreate.json + */ +async function templateSpecVersionsCreateUpdate() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const templateSpecName = "simpleTemplateSpec"; + const templateSpecVersion = "v1.0"; + const templateSpecVersionModel: TemplateSpecVersion = { + description: "This is version v1.0 of our template content", + location: "eastus", + mainTemplate: { + $schema: + "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + contentVersion: "1.0.0.0", + parameters: {}, + resources: [] + } + }; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const result = await client.templateSpecVersions.createOrUpdate( + resourceGroupName, + templateSpecName, + templateSpecVersion, + templateSpecVersionModel + ); + console.log(result); +} + +templateSpecVersionsCreateUpdate().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecVersionsDeleteSample.ts b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecVersionsDeleteSample.ts new file mode 100644 index 000000000000..d5ed9459e5e9 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecVersionsDeleteSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { TemplateSpecsClient } from "@azure/arm-templatespecs"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes a specific version from a Template Spec. When operation completes, status code 200 returned without content. + * + * @summary Deletes a specific version from a Template Spec. When operation completes, status code 200 returned without content. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsDelete.json + */ +async function templateSpecVersionsDelete() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const templateSpecName = "simpleTemplateSpec"; + const templateSpecVersion = "v1.0"; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const result = await client.templateSpecVersions.delete( + resourceGroupName, + templateSpecName, + templateSpecVersion + ); + console.log(result); +} + +templateSpecVersionsDelete().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecVersionsGetSample.ts b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecVersionsGetSample.ts new file mode 100644 index 000000000000..c0edaf567c18 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecVersionsGetSample.ts @@ -0,0 +1,35 @@ +/* + * 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 { TemplateSpecsClient } from "@azure/arm-templatespecs"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets a Template Spec version from a specific Template Spec. + * + * @summary Gets a Template Spec version from a specific Template Spec. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsGet.json + */ +async function templateSpecVersionsGet() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const templateSpecName = "simpleTemplateSpec"; + const templateSpecVersion = "v1.0"; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const result = await client.templateSpecVersions.get( + resourceGroupName, + templateSpecName, + templateSpecVersion + ); + console.log(result); +} + +templateSpecVersionsGet().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecVersionsListSample.ts b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecVersionsListSample.ts new file mode 100644 index 000000000000..21e4828073f6 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecVersionsListSample.ts @@ -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. +import { TemplateSpecsClient } from "@azure/arm-templatespecs"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists all the Template Spec versions in the specified Template Spec. + * + * @summary Lists all the Template Spec versions in the specified Template Spec. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsList.json + */ +async function templateSpecVersionsList() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const templateSpecName = "simpleTemplateSpec"; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.templateSpecVersions.list( + resourceGroupName, + templateSpecName + )) { + resArray.push(item); + } + console.log(resArray); +} + +templateSpecVersionsList().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecVersionsUpdateSample.ts b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecVersionsUpdateSample.ts new file mode 100644 index 000000000000..6fcfba655f91 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecVersionsUpdateSample.ts @@ -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. +import { + TemplateSpecVersionUpdateModel, + TemplateSpecVersionsUpdateOptionalParams, + TemplateSpecsClient +} from "@azure/arm-templatespecs"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Updates Template Spec Version tags with specified values. + * + * @summary Updates Template Spec Version tags with specified values. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsPatch.json + */ +async function templateSpecsPatch() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const templateSpecName = "simpleTemplateSpec"; + const templateSpecVersion = "v1.0"; + const templateSpecVersionUpdateModel: TemplateSpecVersionUpdateModel = { + tags: { myTag: "My Value" } + }; + const options: TemplateSpecVersionsUpdateOptionalParams = { + templateSpecVersionUpdateModel + }; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const result = await client.templateSpecVersions.update( + resourceGroupName, + templateSpecName, + templateSpecVersion, + options + ); + console.log(result); +} + +templateSpecsPatch().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecsCreateOrUpdateSample.ts b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..a6c11c0d6fe6 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecsCreateOrUpdateSample.ts @@ -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. +import { TemplateSpec, TemplateSpecsClient } from "@azure/arm-templatespecs"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Creates or updates a Template Spec. + * + * @summary Creates or updates a Template Spec. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsCreate.json + */ +async function templateSpecsCreateUpdate() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const templateSpecName = "simpleTemplateSpec"; + const templateSpec: TemplateSpec = { + description: "A very simple Template Spec", + location: "eastus" + }; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const result = await client.templateSpecs.createOrUpdate( + resourceGroupName, + templateSpecName, + templateSpec + ); + console.log(result); +} + +templateSpecsCreateUpdate().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecsDeleteSample.ts b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecsDeleteSample.ts new file mode 100644 index 000000000000..6371ae865565 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecsDeleteSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { TemplateSpecsClient } from "@azure/arm-templatespecs"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Deletes a Template Spec by name. When operation completes, status code 200 returned without content. + * + * @summary Deletes a Template Spec by name. When operation completes, status code 200 returned without content. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsDelete.json + */ +async function templateSpecsDelete() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const templateSpecName = "simpleTemplateSpec"; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const result = await client.templateSpecs.delete( + resourceGroupName, + templateSpecName + ); + console.log(result); +} + +templateSpecsDelete().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecsGetSample.ts b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecsGetSample.ts new file mode 100644 index 000000000000..86adc1e41adc --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecsGetSample.ts @@ -0,0 +1,33 @@ +/* + * 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 { TemplateSpecsClient } from "@azure/arm-templatespecs"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Gets a Template Spec with a given name. + * + * @summary Gets a Template Spec with a given name. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsGet.json + */ +async function templateSpecsGet() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const templateSpecName = "simpleTemplateSpec"; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const result = await client.templateSpecs.get( + resourceGroupName, + templateSpecName + ); + console.log(result); +} + +templateSpecsGet().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecsListByResourceGroupSample.ts b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecsListByResourceGroupSample.ts new file mode 100644 index 000000000000..b1b4f867f196 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecsListByResourceGroupSample.ts @@ -0,0 +1,34 @@ +/* + * 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 { TemplateSpecsClient } from "@azure/arm-templatespecs"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists all the Template Specs within the specified resource group. + * + * @summary Lists all the Template Specs within the specified resource group. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsListByResourceGroup.json + */ +async function templateSpecsListByResourceGroup() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.templateSpecs.listByResourceGroup( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +templateSpecsListByResourceGroup().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecsListBySubscriptionSample.ts b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecsListBySubscriptionSample.ts new file mode 100644 index 000000000000..8c180802ae26 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecsListBySubscriptionSample.ts @@ -0,0 +1,31 @@ +/* + * 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 { TemplateSpecsClient } from "@azure/arm-templatespecs"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Lists all the Template Specs within the specified subscriptions. + * + * @summary Lists all the Template Specs within the specified subscriptions. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsListBySubscription.json + */ +async function templatesSpecsListBySubscription() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.templateSpecs.listBySubscription()) { + resArray.push(item); + } + console.log(resArray); +} + +templatesSpecsListBySubscription().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecsUpdateSample.ts b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecsUpdateSample.ts new file mode 100644 index 000000000000..98102d1dd7e4 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/src/templateSpecsUpdateSample.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 { + TemplateSpecUpdateModel, + TemplateSpecsUpdateOptionalParams, + TemplateSpecsClient +} from "@azure/arm-templatespecs"; +import { DefaultAzureCredential } from "@azure/identity"; + +/** + * This sample demonstrates how to Updates Template Spec tags with specified values. + * + * @summary Updates Template Spec tags with specified values. + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsPatch.json + */ +async function templateSpecsPatch() { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const resourceGroupName = "templateSpecRG"; + const templateSpecName = "simpleTemplateSpec"; + const templateSpec: TemplateSpecUpdateModel = { tags: { myTag: "My Value" } }; + const options: TemplateSpecsUpdateOptionalParams = { templateSpec }; + const credential = new DefaultAzureCredential(); + const client = new TemplateSpecsClient(credential, subscriptionId); + const result = await client.templateSpecs.update( + resourceGroupName, + templateSpecName, + options + ); + console.log(result); +} + +templateSpecsPatch().catch(console.error); diff --git a/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/tsconfig.json b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/tsconfig.json new file mode 100644 index 000000000000..416c2dd82e00 --- /dev/null +++ b/sdk/templatespecs/arm-templatespecs/samples/v2/typescript/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2018", + "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/templatespecs/arm-templatespecs/src/templateSpecsClient.ts b/sdk/templatespecs/arm-templatespecs/src/templateSpecsClient.ts index bc1a81ad6ae4..aecc75d946df 100644 --- a/sdk/templatespecs/arm-templatespecs/src/templateSpecsClient.ts +++ b/sdk/templatespecs/arm-templatespecs/src/templateSpecsClient.ts @@ -7,6 +7,7 @@ */ import * as coreClient from "@azure/core-client"; +import * as coreRestPipeline from "@azure/core-rest-pipeline"; import * as coreAuth from "@azure/core-auth"; import { TemplateSpecsImpl, TemplateSpecVersionsImpl } from "./operations"; import { TemplateSpecs, TemplateSpecVersions } from "./operationsInterfaces"; @@ -44,7 +45,7 @@ export class TemplateSpecsClient extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-templatespecs/2.0.0`; + const packageDetails = `azsdk-js-arm-templatespecs/2.0.1`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` @@ -59,9 +60,33 @@ export class TemplateSpecsClient extends coreClient.ServiceClient { userAgentOptions: { userAgentPrefix }, - baseUri: options.endpoint || "https://management.azure.com" + baseUri: + options.endpoint ?? options.baseUri ?? "https://management.azure.com" }; super(optionsWithDefaults); + + if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { + const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies(); + const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( + (pipelinePolicy) => + pipelinePolicy.name === + coreRestPipeline.bearerTokenAuthenticationPolicyName + ); + if (!bearerTokenAuthenticationPolicyFound) { + this.pipeline.removePolicy({ + name: coreRestPipeline.bearerTokenAuthenticationPolicyName + }); + this.pipeline.addPolicy( + coreRestPipeline.bearerTokenAuthenticationPolicy({ + scopes: `${optionsWithDefaults.baseUri}/.default`, + challengeCallbacks: { + authorizeRequestOnChallenge: + coreClient.authorizeRequestOnClaimChallenge + } + }) + ); + } + } // Parameter assignments this.subscriptionId = subscriptionId; diff --git a/sdk/templatespecs/arm-templatespecs/tsconfig.json b/sdk/templatespecs/arm-templatespecs/tsconfig.json index 6e3251194117..825c435cdd51 100644 --- a/sdk/templatespecs/arm-templatespecs/tsconfig.json +++ b/sdk/templatespecs/arm-templatespecs/tsconfig.json @@ -9,11 +9,37 @@ "esModuleInterop": true, "allowSyntheticDefaultImports": true, "forceConsistentCasingInFileNames": true, - "lib": ["es6", "dom"], + "lib": [ + "es6", + "dom" + ], "declaration": true, "outDir": "./dist-esm", - "importHelpers": true + "importHelpers": true, + "paths": { + "@azure/arm-templatespecs": [ + "./src/index" + ] + } }, - "include": ["./src/**/*.ts", "./test/**/*.ts"], - "exclude": ["node_modules"] -} + "include": [ + "./src/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts", + "./test/**/*.ts", + "samples-dev/**/*.ts" + ], + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/sdk/templatespecs/ci.mgmt.yml b/sdk/templatespecs/ci.mgmt.yml index 06a43f7d5730..6719e7d35715 100644 --- a/sdk/templatespecs/ci.mgmt.yml +++ b/sdk/templatespecs/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,7 +9,7 @@ trigger: paths: include: - sdk/templatespecs/ci.mgmt.yml - - sdk/templatespecs/arm-templatespecs/ + - sdk/templatespecs/arm-templatespecs pr: branches: include: @@ -22,12 +22,12 @@ pr: paths: include: - sdk/synapse/ci.mgmt.yml - - sdk/synapse/arm-synapse/ - + - sdk/templatespecs/arm-templatespecs + - sdk/templatespecs/ci.mgmt.yml extends: template: /eng/pipelines/templates/stages/archetype-sdk-client.yml parameters: ServiceDirectory: templatespecs Artifacts: - name: azure-arm-templatespecs - safeName: azurearmtemplatespecs \ No newline at end of file + safeName: azurearmtemplatespecs