diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 05b730f2babc..651f926ddf38 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -3784,7 +3784,7 @@ packages: dependencies: semver: 7.3.8 shelljs: 0.8.5 - typescript: 5.0.0-dev.20221221 + typescript: 5.0.0-dev.20221222 dev: false /downlevel-dts/0.7.0: @@ -8488,8 +8488,8 @@ packages: hasBin: true dev: false - /typescript/5.0.0-dev.20221221: - resolution: {integrity: sha512-QpKFAtn9fFixtDNPVmOYlpmSGh1N/YP5vJq5xX5yVUiPOUrsAsEQFJxqBkGiiKrZAI132fVyM32GrhUXorp2gQ==} + /typescript/5.0.0-dev.20221222: + resolution: {integrity: sha512-9YjbBpzM8BrO3WcbFEE63qQtipPlBP+WFmQDpI/j1W1DInACLJESbWsVAeYBC6PUvIBMzKIVO33cJUUv2l/pmw==} engines: {node: '>=4.2.0'} hasBin: true dev: false @@ -13044,7 +13044,7 @@ packages: dev: false file:projects/arm-network-profile-2020-09-01-hybrid.tgz: - resolution: {integrity: sha512-Hz8Gz41MPZy2UY8vsAxEt/bVG0f0EKSrd5GNpY+rHh5fm7D9/+tSGJLFAJyHgViY8WoX9zFcEI9pDiskQzHfEg==, tarball: file:projects/arm-network-profile-2020-09-01-hybrid.tgz} + resolution: {integrity: sha512-PkBFe9t5oHar5Spgj62KlYy3/fxxVqkF3ZJuEPfGWu9mIFLRbfh4uQ81Ng0f1BE7PjGcE6h3p0XO6vkpSqjdRw==, tarball: file:projects/arm-network-profile-2020-09-01-hybrid.tgz} name: '@rush-temp/arm-network-profile-2020-09-01-hybrid' version: 0.0.0 dependencies: @@ -13055,18 +13055,20 @@ packages: '@rollup/plugin-json': 4.1.0_rollup@2.79.1 '@rollup/plugin-multi-entry': 4.1.0_rollup@2.79.1 '@rollup/plugin-node-resolve': 13.3.0_rollup@2.79.1 + '@types/chai': 4.3.4 + '@types/node': 14.18.33 + chai: 4.3.7 cross-env: 7.0.3 + dotenv: 8.6.0 mkdirp: 1.0.4 mocha: 7.2.0 rimraf: 3.0.2 rollup: 2.79.1 - rollup-plugin-sourcemaps: 0.6.3_rollup@2.79.1 + rollup-plugin-sourcemaps: 0.6.3_1225c068d0546e507df7db46196a6444 tslib: 2.4.1 - typescript: 4.2.4 + typescript: 4.8.4 uglify-js: 3.17.4 transitivePeerDependencies: - - '@types/node' - - encoding - supports-color dev: false @@ -13334,7 +13336,7 @@ packages: dev: false file:projects/arm-policy-profile-2020-09-01-hybrid.tgz: - resolution: {integrity: sha512-42k6NgBkqVa0Fp7nu86aKxAiSWInf6jcfDw/M6o43aNAjtFllryStccIPMOoNGghDyFo353wV/ukHzKV14yEGg==, tarball: file:projects/arm-policy-profile-2020-09-01-hybrid.tgz} + resolution: {integrity: sha512-X0tPE22aV5Azuo0eVPDWnSpITM/HsGOOlaIT7GFg//mZA7D9Yg7PGy9cu88W/i9Xk+Jx9gGruK+2hNaB2ZFFbg==, tarball: file:projects/arm-policy-profile-2020-09-01-hybrid.tgz} name: '@rush-temp/arm-policy-profile-2020-09-01-hybrid' version: 0.0.0 dependencies: @@ -13345,18 +13347,20 @@ packages: '@rollup/plugin-json': 4.1.0_rollup@2.79.1 '@rollup/plugin-multi-entry': 4.1.0_rollup@2.79.1 '@rollup/plugin-node-resolve': 13.3.0_rollup@2.79.1 + '@types/chai': 4.3.4 + '@types/node': 14.18.33 + chai: 4.3.7 cross-env: 7.0.3 + dotenv: 8.6.0 mkdirp: 1.0.4 mocha: 7.2.0 rimraf: 3.0.2 rollup: 2.79.1 - rollup-plugin-sourcemaps: 0.6.3_rollup@2.79.1 + rollup-plugin-sourcemaps: 0.6.3_1225c068d0546e507df7db46196a6444 tslib: 2.4.1 - typescript: 4.2.4 + typescript: 4.8.4 uglify-js: 3.17.4 transitivePeerDependencies: - - '@types/node' - - encoding - supports-color dev: false @@ -13442,7 +13446,7 @@ packages: dev: false file:projects/arm-postgresql-flexible.tgz: - resolution: {integrity: sha512-+4ZsSAlzBc9H+Lb/drKyoyIPW1xp/5ijxaTokvtS0e20AZdoEvZfJ3sLq/Aoa68x69wo9dUx/+xNvOPlGcLogg==, tarball: file:projects/arm-postgresql-flexible.tgz} + resolution: {integrity: sha512-jdFQE2aDxnLQq2q6peHgplVa0kp4gJ0xoRb2ajCDuA0vJR5oxN7o/3vgWYW9Hg+B/A7bCpxQIoQji4mXzcn++g==, tarball: file:projects/arm-postgresql-flexible.tgz} name: '@rush-temp/arm-postgresql-flexible' version: 0.0.0 dependencies: @@ -13453,18 +13457,20 @@ packages: '@rollup/plugin-json': 4.1.0_rollup@2.79.1 '@rollup/plugin-multi-entry': 4.1.0_rollup@2.79.1 '@rollup/plugin-node-resolve': 13.3.0_rollup@2.79.1 + '@types/chai': 4.3.4 + '@types/node': 14.18.33 + chai: 4.3.7 cross-env: 7.0.3 + dotenv: 8.6.0 mkdirp: 1.0.4 mocha: 7.2.0 rimraf: 3.0.2 rollup: 2.79.1 - rollup-plugin-sourcemaps: 0.6.3_rollup@2.79.1 + rollup-plugin-sourcemaps: 0.6.3_1225c068d0546e507df7db46196a6444 tslib: 2.4.1 - typescript: 4.2.4 + typescript: 4.8.4 uglify-js: 3.17.4 transitivePeerDependencies: - - '@types/node' - - encoding - supports-color dev: false @@ -13939,7 +13945,7 @@ packages: dev: false file:projects/arm-resources-profile-2020-09-01-hybrid.tgz: - resolution: {integrity: sha512-ATsKeGfQUHgY7etJoB+1DsxFh2s3PEMr+RLFYD/kGga1oui7pP2+kMAV2CBUKs7mzihgwMiMCsb+fhBF/ATNVA==, tarball: file:projects/arm-resources-profile-2020-09-01-hybrid.tgz} + resolution: {integrity: sha512-JVwy8SQBeyPyGZvruzbJXk55mgUgZcoVBxDXxiSkb/jxkM4dZu4mPNojX67sBgRJTSW5HrLp1CT8vufec+WJcg==, tarball: file:projects/arm-resources-profile-2020-09-01-hybrid.tgz} name: '@rush-temp/arm-resources-profile-2020-09-01-hybrid' version: 0.0.0 dependencies: @@ -13950,18 +13956,20 @@ packages: '@rollup/plugin-json': 4.1.0_rollup@2.79.1 '@rollup/plugin-multi-entry': 4.1.0_rollup@2.79.1 '@rollup/plugin-node-resolve': 13.3.0_rollup@2.79.1 + '@types/chai': 4.3.4 + '@types/node': 14.18.33 + chai: 4.3.7 cross-env: 7.0.3 + dotenv: 8.6.0 mkdirp: 1.0.4 mocha: 7.2.0 rimraf: 3.0.2 rollup: 2.79.1 - rollup-plugin-sourcemaps: 0.6.3_rollup@2.79.1 + rollup-plugin-sourcemaps: 0.6.3_1225c068d0546e507df7db46196a6444 tslib: 2.4.1 - typescript: 4.2.4 + typescript: 4.8.4 uglify-js: 3.17.4 transitivePeerDependencies: - - '@types/node' - - encoding - supports-color dev: false @@ -14448,7 +14456,7 @@ packages: dev: false file:projects/arm-storage-profile-2020-09-01-hybrid.tgz: - resolution: {integrity: sha512-10YDqx9GnCIctv7snNDXH54ftm1Cl0JO1BBkXtqGkv3swyDVECVNs7VfvQ5uyQsH7RcyiuYvwXQjR4rXMy5zbg==, tarball: file:projects/arm-storage-profile-2020-09-01-hybrid.tgz} + resolution: {integrity: sha512-oEh8oRzA6fyKBQsQIkAGhDK85UZgfRZaxGgIo9X873vLNdUqPjwGr2OZ/z48oLTkJA4iTM1GBag7QEsEGDqPoA==, tarball: file:projects/arm-storage-profile-2020-09-01-hybrid.tgz} name: '@rush-temp/arm-storage-profile-2020-09-01-hybrid' version: 0.0.0 dependencies: @@ -14459,18 +14467,20 @@ packages: '@rollup/plugin-json': 4.1.0_rollup@2.79.1 '@rollup/plugin-multi-entry': 4.1.0_rollup@2.79.1 '@rollup/plugin-node-resolve': 13.3.0_rollup@2.79.1 + '@types/chai': 4.3.4 + '@types/node': 14.18.33 + chai: 4.3.7 cross-env: 7.0.3 + dotenv: 8.6.0 mkdirp: 1.0.4 mocha: 7.2.0 rimraf: 3.0.2 rollup: 2.79.1 - rollup-plugin-sourcemaps: 0.6.3_rollup@2.79.1 + rollup-plugin-sourcemaps: 0.6.3_1225c068d0546e507df7db46196a6444 tslib: 2.4.1 - typescript: 4.2.4 + typescript: 4.8.4 uglify-js: 3.17.4 transitivePeerDependencies: - - '@types/node' - - encoding - supports-color dev: false @@ -14668,7 +14678,7 @@ packages: dev: false file:projects/arm-subscriptions-profile-2020-09-01-hybrid.tgz: - resolution: {integrity: sha512-1jdYKXu7XxtKu1uVkx92KftB4vh8u9AygXH2URq5dJVNdiEvHwG8uELXljUCJbwJ9z749mls489s1qwV9gr3Cw==, tarball: file:projects/arm-subscriptions-profile-2020-09-01-hybrid.tgz} + resolution: {integrity: sha512-cIzQus770G3+CG561lmmuapHMUUgqA9q0v/aizUGA62bfEyehOVTg0VHgoiWf7ioa/TC5YcM3AcrQLcK/1rXsg==, tarball: file:projects/arm-subscriptions-profile-2020-09-01-hybrid.tgz} name: '@rush-temp/arm-subscriptions-profile-2020-09-01-hybrid' version: 0.0.0 dependencies: @@ -14679,18 +14689,20 @@ packages: '@rollup/plugin-json': 4.1.0_rollup@2.79.1 '@rollup/plugin-multi-entry': 4.1.0_rollup@2.79.1 '@rollup/plugin-node-resolve': 13.3.0_rollup@2.79.1 + '@types/chai': 4.3.4 + '@types/node': 14.18.33 + chai: 4.3.7 cross-env: 7.0.3 + dotenv: 8.6.0 mkdirp: 1.0.4 mocha: 7.2.0 rimraf: 3.0.2 rollup: 2.79.1 - rollup-plugin-sourcemaps: 0.6.3_rollup@2.79.1 + rollup-plugin-sourcemaps: 0.6.3_1225c068d0546e507df7db46196a6444 tslib: 2.4.1 - typescript: 4.2.4 + typescript: 4.8.4 uglify-js: 3.17.4 transitivePeerDependencies: - - '@types/node' - - encoding - supports-color dev: false diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/CHANGELOG.md b/sdk/network/arm-network-profile-2020-09-01-hybrid/CHANGELOG.md index 5741659a9903..23c437eae1f2 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/CHANGELOG.md +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/CHANGELOG.md @@ -1,15 +1,50 @@ # Release History - -## 2.0.1 (Unreleased) - -### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes - + +## 2.1.0 (2022-12-22) + +**Features** + + - Added Interface ApplicationGatewayBackendAddressPool + - Added Interface ApplicationSecurityGroup + - Added Interface BackendAddressPool + - Added Interface ConnectionSharedKey + - Added Interface Delegation + - Added Interface FrontendIPConfiguration + - Added Interface InboundNatPool + - Added Interface InboundNatRule + - Added Interface InterfaceEndpoint + - Added Interface IPConfiguration + - Added Interface IPConfigurationProfile + - Added Interface LoadBalancer + - Added Interface LoadBalancingRule + - Added Interface LocalNetworkGateway + - Added Interface NetworkInterface + - Added Interface NetworkInterfaceIPConfiguration + - Added Interface NetworkInterfaceTapConfiguration + - Added Interface NetworkSecurityGroup + - Added Interface OutboundRule + - Added Interface Probe + - Added Interface PublicIPAddress + - Added Interface ResourceNavigationLink + - Added Interface Route + - Added Interface RouteTable + - Added Interface SecurityRule + - Added Interface ServiceAssociationLink + - Added Interface ServiceEndpointPolicy + - Added Interface ServiceEndpointPolicyDefinition + - Added Interface Subnet + - Added Interface VirtualNetwork + - Added Interface VirtualNetworkGateway + - Added Interface VirtualNetworkGatewayConnection + - Added Interface VirtualNetworkGatewayConnectionListEntity + - Added Interface VirtualNetworkGatewayIPConfiguration + - Added Interface VirtualNetworkPeering + - Added Interface VirtualNetworkTap + - Added Interface VpnClientRevokedCertificate + - Added Interface VpnClientRootCertificate + - Added function getContinuationToken + + ## 2.0.0 (2022-03-09) The package of @azure/arm-network-profile-2020-09-01-hybrid is using our next generation design principles since version 2.0.0, which contains breaking changes. diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/_meta.json b/sdk/network/arm-network-profile-2020-09-01-hybrid/_meta.json index 9fde56f55fa7..9539401fe4f3 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/_meta.json +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/_meta.json @@ -1,8 +1,8 @@ { "commit": "1067b78669466324a1a2666adf053433c61e7f77", "readme": "specification/network/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\\network\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-beta.16 --tag=profile-hybrid-2020-09-01 --profile-content=profile-hybrid-2020-09-01", + "autorest_command": "autorest --version=3.9.3 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=F:\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\network\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-rc.5.20221215.1 --generate-sample=true --profile-content=profile-hybrid-2020-09-01", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "release_tool": "@azure-tools/js-sdk-release-tools@2.1.1", - "use": "@autorest/typescript@6.0.0-beta.16" + "release_tool": "@azure-tools/js-sdk-release-tools@2.5.4", + "use": "@autorest/typescript@6.0.0-rc.5.20221215.1" } \ No newline at end of file diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/package.json b/sdk/network/arm-network-profile-2020-09-01-hybrid/package.json index 5b6eceb2b431..f57c2b46959c 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/package.json +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/package.json @@ -3,7 +3,7 @@ "sdk-type": "mgmt", "author": "Microsoft Corporation", "description": "A generated SDK for NetworkManagementClient.", - "version": "2.0.1", + "version": "2.1.0", "engines": { "node": ">=14.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.6.1", "@azure/core-auth": "^1.3.0", - "@azure/core-rest-pipeline": "^1.1.0", + "@azure/core-rest-pipeline": "^1.8.0", "tslib": "^2.2.0" }, "keywords": [ @@ -36,15 +36,20 @@ "mkdirp": "^1.0.4", "rollup": "^2.66.1", "rollup-plugin-sourcemaps": "^0.6.3", - "typescript": "~4.2.0", + "typescript": "~4.8.0", "uglify-js": "^3.4.9", "rimraf": "^3.0.0", + "dotenv": "^8.2.0", "@azure/identity": "^2.0.1", - "@azure-tools/test-recorder": "^1.0.0", + "@azure-tools/test-recorder": "^2.0.0", + "@azure-tools/test-credential": "^1.0.0", "mocha": "^7.1.1", - "cross-env": "^7.0.2" + "@types/chai": "^4.2.8", + "chai": "^4.2.0", + "cross-env": "^7.0.2", + "@types/node": "^14.0.0", + "@azure/dev-tool": "^1.0.0" }, - "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/network/arm-network-profile-2020-09-01-hybrid", "repository": { "type": "git", "url": "https://github.com/Azure/azure-sdk-for-js.git" @@ -93,9 +98,8 @@ "unit-test:node": "cross-env TEST_MODE=playback npm run integration-test:node", "unit-test:browser": "echo skipped", "integration-test": "npm run integration-test:node && npm run integration-test:browser", - "integration-test:node": "mocha -r esm --require ts-node/register --timeout 1200000 --full-trace test/*.ts --reporter ../../../common/tools/mocha-multi-reporter.js", - "integration-test:browser": "echo skipped", - "docs": "echo skipped" + "integration-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 'test/*.ts'", + "integration-test:browser": "echo skipped" }, "sideEffects": false, "//metadata": { @@ -106,5 +110,14 @@ } ] }, - "autoPublish": true -} + "autoPublish": true, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/network/arm-network-profile-2020-09-01-hybrid", + "//sampleConfiguration": { + "productName": "", + "productSlugs": [ + "azure" + ], + "disableDocsMs": true, + "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-network-profile-2020-09-01-hybrid?view=azure-node-preview" + } +} \ No newline at end of file diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/recordings/node/my_test/recording_sample_test.json b/sdk/network/arm-network-profile-2020-09-01-hybrid/recordings/node/my_test/recording_sample_test.json new file mode 100644 index 000000000000..f721723386d8 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/recordings/node/my_test/recording_sample_test.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/review/arm-network-profile-2020-09-01-hybrid.api.md b/sdk/network/arm-network-profile-2020-09-01-hybrid/review/arm-network-profile-2020-09-01-hybrid.api.md index 8514ab2b86a5..42b1f0b5cb61 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/review/arm-network-profile-2020-09-01-hybrid.api.md +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/review/arm-network-profile-2020-09-01-hybrid.api.md @@ -22,21 +22,21 @@ export interface ApplicationGatewayBackendAddress { } // @public -export type ApplicationGatewayBackendAddressPool = SubResource & { - name?: string; - etag?: string; - type?: string; - backendIPConfigurations?: NetworkInterfaceIPConfiguration[]; +export interface ApplicationGatewayBackendAddressPool extends SubResource { backendAddresses?: ApplicationGatewayBackendAddress[]; + backendIPConfigurations?: NetworkInterfaceIPConfiguration[]; + etag?: string; + name?: string; provisioningState?: string; -}; + type?: string; +} // @public -export type ApplicationSecurityGroup = Resource & { +export interface ApplicationSecurityGroup extends Resource { readonly etag?: string; - readonly resourceGuid?: string; readonly provisioningState?: string; -}; + readonly resourceGuid?: string; +} // @public export type AuthenticationMethod = string; @@ -56,15 +56,15 @@ export interface AzureAsyncOperationResult { } // @public -export type BackendAddressPool = SubResource & { - name?: string; - etag?: string; +export interface BackendAddressPool extends SubResource { readonly backendIPConfigurations?: NetworkInterfaceIPConfiguration[]; + etag?: string; readonly loadBalancingRules?: SubResource[]; + name?: string; readonly outboundRule?: SubResource; readonly outboundRules?: SubResource[]; provisioningState?: string; -}; +} // @public export type BgpPeerState = string; @@ -105,9 +105,9 @@ export interface ConnectionResetSharedKey { } // @public -export type ConnectionSharedKey = SubResource & { +export interface ConnectionSharedKey extends SubResource { value: string; -}; +} // @public export interface DdosSettings { @@ -146,13 +146,13 @@ export interface DefaultSecurityRulesListOptionalParams extends coreClient.Opera export type DefaultSecurityRulesListResponse = SecurityRuleListResult; // @public -export type Delegation = SubResource & { - name?: string; - etag?: string; - serviceName?: string; +export interface Delegation extends SubResource { actions?: string[]; + etag?: string; + name?: string; readonly provisioningState?: string; -}; + serviceName?: string; +} // @public export interface DhcpOptions { @@ -263,21 +263,21 @@ export interface ErrorModel { } // @public -export type FrontendIPConfiguration = SubResource & { - name?: string; +export interface FrontendIPConfiguration extends SubResource { etag?: string; - zones?: string[]; - readonly inboundNatRules?: SubResource[]; readonly inboundNatPools?: SubResource[]; - readonly outboundRules?: SubResource[]; + readonly inboundNatRules?: SubResource[]; readonly loadBalancingRules?: SubResource[]; + name?: string; + readonly outboundRules?: SubResource[]; privateIPAddress?: string; privateIPAllocationMethod?: IPAllocationMethod; - subnet?: Subnet; + provisioningState?: string; publicIPAddress?: PublicIPAddress; publicIPPrefix?: SubResource; - provisioningState?: string; -}; + subnet?: Subnet; + zones?: string[]; +} // @public export interface GatewayRoute { @@ -295,6 +295,9 @@ export interface GatewayRouteListResult { value?: GatewayRoute[]; } +// @public +export function getContinuationToken(page: unknown): string | undefined; + // @public export type IkeEncryption = string; @@ -302,34 +305,34 @@ export type IkeEncryption = string; export type IkeIntegrity = string; // @public -export type InboundNatPool = SubResource & { - name?: string; +export interface InboundNatPool extends SubResource { + backendPort?: number; + enableFloatingIP?: boolean; + enableTcpReset?: boolean; etag?: string; frontendIPConfiguration?: SubResource; - protocol?: TransportProtocol; - frontendPortRangeStart?: number; frontendPortRangeEnd?: number; - backendPort?: number; + frontendPortRangeStart?: number; idleTimeoutInMinutes?: number; - enableFloatingIP?: boolean; - enableTcpReset?: boolean; + name?: string; + protocol?: TransportProtocol; provisioningState?: string; -}; +} // @public -export type InboundNatRule = SubResource & { - name?: string; - etag?: string; - frontendIPConfiguration?: SubResource; +export interface InboundNatRule extends SubResource { readonly backendIPConfiguration?: NetworkInterfaceIPConfiguration; - protocol?: TransportProtocol; - frontendPort?: number; backendPort?: number; - idleTimeoutInMinutes?: number; enableFloatingIP?: boolean; enableTcpReset?: boolean; + etag?: string; + frontendIPConfiguration?: SubResource; + frontendPort?: number; + idleTimeoutInMinutes?: number; + name?: string; + protocol?: TransportProtocol; provisioningState?: string; -}; +} // @public export interface InboundNatRuleListResult { @@ -385,15 +388,15 @@ export interface InboundNatRulesListOptionalParams extends coreClient.OperationO export type InboundNatRulesListResponse = InboundNatRuleListResult; // @public -export type InterfaceEndpoint = Resource & { +export interface InterfaceEndpoint extends Resource { + endpointService?: EndpointService; etag?: string; fqdn?: string; - endpointService?: EndpointService; - subnet?: Subnet; readonly networkInterfaces?: NetworkInterface[]; readonly owner?: string; readonly provisioningState?: string; -}; + subnet?: Subnet; +} // @public export interface IPAddressAvailabilityResult { @@ -405,24 +408,24 @@ export interface IPAddressAvailabilityResult { export type IPAllocationMethod = string; // @public -export type IPConfiguration = SubResource & { - name?: string; +export interface IPConfiguration extends SubResource { etag?: string; + name?: string; privateIPAddress?: string; privateIPAllocationMethod?: IPAllocationMethod; - subnet?: Subnet; - publicIPAddress?: PublicIPAddress; provisioningState?: string; -}; + publicIPAddress?: PublicIPAddress; + subnet?: Subnet; +} // @public -export type IPConfigurationProfile = SubResource & { - name?: string; - readonly type?: string; +export interface IPConfigurationProfile extends SubResource { etag?: string; - subnet?: Subnet; + name?: string; readonly provisioningState?: string; -}; + subnet?: Subnet; + readonly type?: string; +} // @public export type IpsecEncryption = string; @@ -453,450 +456,304 @@ export type IPVersion = string; // @public export enum KnownAuthenticationMethod { - // (undocumented) EapmschaPv2 = "EAPMSCHAPv2", - // (undocumented) Eaptls = "EAPTLS" } // @public export enum KnownBgpPeerState { - // (undocumented) Connected = "Connected", - // (undocumented) Connecting = "Connecting", - // (undocumented) Idle = "Idle", - // (undocumented) Stopped = "Stopped", - // (undocumented) Unknown = "Unknown" } // @public export enum KnownDdosSettingsProtectionCoverage { - // (undocumented) Basic = "Basic", - // (undocumented) Standard = "Standard" } // @public export enum KnownDhGroup { - // (undocumented) DHGroup1 = "DHGroup1", - // (undocumented) DHGroup14 = "DHGroup14", - // (undocumented) DHGroup2 = "DHGroup2", - // (undocumented) DHGroup2048 = "DHGroup2048", - // (undocumented) DHGroup24 = "DHGroup24", - // (undocumented) ECP256 = "ECP256", - // (undocumented) ECP384 = "ECP384", - // (undocumented) None = "None" } // @public export enum KnownEffectiveRouteSource { - // (undocumented) Default = "Default", - // (undocumented) Unknown = "Unknown", - // (undocumented) User = "User", - // (undocumented) VirtualNetworkGateway = "VirtualNetworkGateway" } // @public export enum KnownEffectiveRouteState { - // (undocumented) Active = "Active", - // (undocumented) Invalid = "Invalid" } // @public export enum KnownEffectiveSecurityRuleProtocol { - // (undocumented) All = "All", - // (undocumented) Tcp = "Tcp", - // (undocumented) Udp = "Udp" } // @public export enum KnownIkeEncryption { - // (undocumented) AES128 = "AES128", - // (undocumented) AES192 = "AES192", - // (undocumented) AES256 = "AES256", - // (undocumented) DES = "DES", - // (undocumented) DES3 = "DES3", - // (undocumented) Gcmaes128 = "GCMAES128", - // (undocumented) Gcmaes256 = "GCMAES256" } // @public export enum KnownIkeIntegrity { - // (undocumented) Gcmaes128 = "GCMAES128", - // (undocumented) Gcmaes256 = "GCMAES256", - // (undocumented) MD5 = "MD5", - // (undocumented) SHA1 = "SHA1", - // (undocumented) SHA256 = "SHA256", - // (undocumented) SHA384 = "SHA384" } // @public export enum KnownIPAllocationMethod { - // (undocumented) Dynamic = "Dynamic", - // (undocumented) Static = "Static" } // @public export enum KnownIpsecEncryption { - // (undocumented) AES128 = "AES128", - // (undocumented) AES192 = "AES192", - // (undocumented) AES256 = "AES256", - // (undocumented) DES = "DES", - // (undocumented) DES3 = "DES3", - // (undocumented) Gcmaes128 = "GCMAES128", - // (undocumented) Gcmaes192 = "GCMAES192", - // (undocumented) Gcmaes256 = "GCMAES256", - // (undocumented) None = "None" } // @public export enum KnownIpsecIntegrity { - // (undocumented) Gcmaes128 = "GCMAES128", - // (undocumented) Gcmaes192 = "GCMAES192", - // (undocumented) Gcmaes256 = "GCMAES256", - // (undocumented) MD5 = "MD5", - // (undocumented) SHA1 = "SHA1", - // (undocumented) SHA256 = "SHA256" } // @public export enum KnownIPVersion { - // (undocumented) IPv4 = "IPv4", - // (undocumented) IPv6 = "IPv6" } // @public export enum KnownLoadBalancerSkuName { - // (undocumented) Basic = "Basic", - // (undocumented) Standard = "Standard" } // @public export enum KnownLoadDistribution { - // (undocumented) Default = "Default", - // (undocumented) SourceIP = "SourceIP", - // (undocumented) SourceIPProtocol = "SourceIPProtocol" } // @public export enum KnownNetworkOperationStatus { - // (undocumented) Failed = "Failed", - // (undocumented) InProgress = "InProgress", - // (undocumented) Succeeded = "Succeeded" } // @public export enum KnownOutboundRulePropertiesFormatProtocol { - // (undocumented) All = "All", - // (undocumented) Tcp = "Tcp", - // (undocumented) Udp = "Udp" } // @public export enum KnownPfsGroup { - // (undocumented) ECP256 = "ECP256", - // (undocumented) ECP384 = "ECP384", - // (undocumented) None = "None", - // (undocumented) PFS1 = "PFS1", - // (undocumented) PFS14 = "PFS14", - // (undocumented) PFS2 = "PFS2", - // (undocumented) PFS2048 = "PFS2048", - // (undocumented) PFS24 = "PFS24", - // (undocumented) Pfsmm = "PFSMM" } // @public export enum KnownProbeProtocol { - // (undocumented) Http = "Http", - // (undocumented) Https = "Https", - // (undocumented) Tcp = "Tcp" } // @public export enum KnownProcessorArchitecture { - // (undocumented) Amd64 = "Amd64", - // (undocumented) X86 = "X86" } // @public export enum KnownPublicIPAddressSkuName { - // (undocumented) Basic = "Basic", - // (undocumented) Standard = "Standard" } // @public export enum KnownRouteNextHopType { - // (undocumented) Internet = "Internet", - // (undocumented) None = "None", - // (undocumented) VirtualAppliance = "VirtualAppliance", - // (undocumented) VirtualNetworkGateway = "VirtualNetworkGateway", - // (undocumented) VnetLocal = "VnetLocal" } // @public export enum KnownSecurityRuleAccess { - // (undocumented) Allow = "Allow", - // (undocumented) Deny = "Deny" } // @public export enum KnownSecurityRuleDirection { - // (undocumented) Inbound = "Inbound", - // (undocumented) Outbound = "Outbound" } // @public export enum KnownSecurityRuleProtocol { - // (undocumented) Asterisk = "*", - // (undocumented) Tcp = "Tcp", - // (undocumented) Udp = "Udp" } // @public export enum KnownTransportProtocol { - // (undocumented) All = "All", - // (undocumented) Tcp = "Tcp", - // (undocumented) Udp = "Udp" } // @public export enum KnownVirtualNetworkGatewayConnectionProtocol { - // (undocumented) IKEv1 = "IKEv1", - // (undocumented) IKEv2 = "IKEv2" } // @public export enum KnownVirtualNetworkGatewayConnectionStatus { - // (undocumented) Connected = "Connected", - // (undocumented) Connecting = "Connecting", - // (undocumented) NotConnected = "NotConnected", - // (undocumented) Unknown = "Unknown" } // @public export enum KnownVirtualNetworkGatewayConnectionType { - // (undocumented) ExpressRoute = "ExpressRoute", - // (undocumented) IPsec = "IPsec", - // (undocumented) Vnet2Vnet = "Vnet2Vnet", - // (undocumented) VPNClient = "VPNClient" } // @public export enum KnownVirtualNetworkGatewaySkuName { - // (undocumented) Basic = "Basic", - // (undocumented) ErGw1AZ = "ErGw1AZ", - // (undocumented) ErGw2AZ = "ErGw2AZ", - // (undocumented) ErGw3AZ = "ErGw3AZ", - // (undocumented) HighPerformance = "HighPerformance", - // (undocumented) Standard = "Standard", - // (undocumented) UltraPerformance = "UltraPerformance", - // (undocumented) VpnGw1 = "VpnGw1", - // (undocumented) VpnGw1AZ = "VpnGw1AZ", - // (undocumented) VpnGw2 = "VpnGw2", - // (undocumented) VpnGw2AZ = "VpnGw2AZ", - // (undocumented) VpnGw3 = "VpnGw3", - // (undocumented) VpnGw3AZ = "VpnGw3AZ" } // @public export enum KnownVirtualNetworkGatewaySkuTier { - // (undocumented) Basic = "Basic", - // (undocumented) ErGw1AZ = "ErGw1AZ", - // (undocumented) ErGw2AZ = "ErGw2AZ", - // (undocumented) ErGw3AZ = "ErGw3AZ", - // (undocumented) HighPerformance = "HighPerformance", - // (undocumented) Standard = "Standard", - // (undocumented) UltraPerformance = "UltraPerformance", - // (undocumented) VpnGw1 = "VpnGw1", - // (undocumented) VpnGw1AZ = "VpnGw1AZ", - // (undocumented) VpnGw2 = "VpnGw2", - // (undocumented) VpnGw2AZ = "VpnGw2AZ", - // (undocumented) VpnGw3 = "VpnGw3", - // (undocumented) VpnGw3AZ = "VpnGw3AZ" } // @public export enum KnownVirtualNetworkGatewayType { - // (undocumented) ExpressRoute = "ExpressRoute", - // (undocumented) Vpn = "Vpn" } // @public export enum KnownVirtualNetworkPeeringState { - // (undocumented) Connected = "Connected", - // (undocumented) Disconnected = "Disconnected", - // (undocumented) Initiated = "Initiated" } // @public export enum KnownVpnClientProtocol { - // (undocumented) IkeV2 = "IkeV2", - // (undocumented) OpenVPN = "OpenVPN", - // (undocumented) Sstp = "SSTP" } // @public export enum KnownVpnType { - // (undocumented) PolicyBased = "PolicyBased", - // (undocumented) RouteBased = "RouteBased" } // @public -export type LoadBalancer = Resource & { - sku?: LoadBalancerSku; +export interface LoadBalancer extends Resource { + backendAddressPools?: BackendAddressPool[]; etag?: string; frontendIPConfigurations?: FrontendIPConfiguration[]; - backendAddressPools?: BackendAddressPool[]; - loadBalancingRules?: LoadBalancingRule[]; - probes?: Probe[]; - inboundNatRules?: InboundNatRule[]; inboundNatPools?: InboundNatPool[]; + inboundNatRules?: InboundNatRule[]; + loadBalancingRules?: LoadBalancingRule[]; outboundRules?: OutboundRule[]; - resourceGuid?: string; + probes?: Probe[]; provisioningState?: string; -}; + resourceGuid?: string; + sku?: LoadBalancerSku; +} // @public export interface LoadBalancerBackendAddressPoolListResult { @@ -1170,35 +1027,35 @@ export interface LoadBalancersUpdateTagsOptionalParams extends coreClient.Operat export type LoadBalancersUpdateTagsResponse = LoadBalancer; // @public -export type LoadBalancingRule = SubResource & { - name?: string; - etag?: string; - frontendIPConfiguration?: SubResource; +export interface LoadBalancingRule extends SubResource { backendAddressPool?: SubResource; - probe?: SubResource; - protocol?: TransportProtocol; - loadDistribution?: LoadDistribution; - frontendPort?: number; backendPort?: number; - idleTimeoutInMinutes?: number; + disableOutboundSnat?: boolean; enableFloatingIP?: boolean; enableTcpReset?: boolean; - disableOutboundSnat?: boolean; + etag?: string; + frontendIPConfiguration?: SubResource; + frontendPort?: number; + idleTimeoutInMinutes?: number; + loadDistribution?: LoadDistribution; + name?: string; + probe?: SubResource; + protocol?: TransportProtocol; provisioningState?: string; -}; +} // @public export type LoadDistribution = string; // @public -export type LocalNetworkGateway = Resource & { +export interface LocalNetworkGateway extends Resource { + bgpSettings?: BgpSettings; etag?: string; - localNetworkAddressSpace?: AddressSpace; gatewayIpAddress?: string; - bgpSettings?: BgpSettings; - resourceGuid?: string; + localNetworkAddressSpace?: AddressSpace; readonly provisioningState?: string; -}; + resourceGuid?: string; +} // @public export interface LocalNetworkGatewayListResult { @@ -1299,22 +1156,22 @@ export interface MetricSpecification { } // @public -export type NetworkInterface = Resource & { +export interface NetworkInterface extends Resource { + dnsSettings?: NetworkInterfaceDnsSettings; + enableAcceleratedNetworking?: boolean; + enableIPForwarding?: boolean; etag?: string; - readonly virtualMachine?: SubResource; - networkSecurityGroup?: NetworkSecurityGroup; + readonly hostedWorkloads?: string[]; readonly interfaceEndpoint?: InterfaceEndpoint; ipConfigurations?: NetworkInterfaceIPConfiguration[]; - tapConfigurations?: NetworkInterfaceTapConfiguration[]; - dnsSettings?: NetworkInterfaceDnsSettings; macAddress?: string; + networkSecurityGroup?: NetworkSecurityGroup; primary?: boolean; - enableAcceleratedNetworking?: boolean; - enableIPForwarding?: boolean; - readonly hostedWorkloads?: string[]; - resourceGuid?: string; provisioningState?: string; -}; + resourceGuid?: string; + tapConfigurations?: NetworkInterfaceTapConfiguration[]; + readonly virtualMachine?: SubResource; +} // @public export interface NetworkInterfaceDnsSettings { @@ -1326,22 +1183,22 @@ export interface NetworkInterfaceDnsSettings { } // @public -export type NetworkInterfaceIPConfiguration = SubResource & { - name?: string; - etag?: string; - virtualNetworkTaps?: VirtualNetworkTap[]; +export interface NetworkInterfaceIPConfiguration extends SubResource { applicationGatewayBackendAddressPools?: ApplicationGatewayBackendAddressPool[]; + applicationSecurityGroups?: ApplicationSecurityGroup[]; + etag?: string; loadBalancerBackendAddressPools?: BackendAddressPool[]; loadBalancerInboundNatRules?: InboundNatRule[]; + name?: string; + primary?: boolean; privateIPAddress?: string; - privateIPAllocationMethod?: IPAllocationMethod; privateIPAddressVersion?: IPVersion; - subnet?: Subnet; - primary?: boolean; - publicIPAddress?: PublicIPAddress; - applicationSecurityGroups?: ApplicationSecurityGroup[]; + privateIPAllocationMethod?: IPAllocationMethod; provisioningState?: string; -}; + publicIPAddress?: PublicIPAddress; + subnet?: Subnet; + virtualNetworkTaps?: VirtualNetworkTap[]; +} // @public export interface NetworkInterfaceIPConfigurationListResult { @@ -1503,13 +1360,13 @@ export interface NetworkInterfacesUpdateTagsOptionalParams extends coreClient.Op export type NetworkInterfacesUpdateTagsResponse = NetworkInterface; // @public -export type NetworkInterfaceTapConfiguration = SubResource & { - name?: string; +export interface NetworkInterfaceTapConfiguration extends SubResource { etag?: string; + name?: string; + readonly provisioningState?: string; readonly type?: string; virtualNetworkTap?: VirtualNetworkTap; - readonly provisioningState?: string; -}; +} // @public export interface NetworkInterfaceTapConfigurationListResult { @@ -1635,15 +1492,15 @@ export interface NetworkManagementClientOptionalParams extends coreClient.Servic export type NetworkOperationStatus = string; // @public -export type NetworkSecurityGroup = Resource & { - etag?: string; - securityRules?: SecurityRule[]; +export interface NetworkSecurityGroup extends Resource { defaultSecurityRules?: SecurityRule[]; + etag?: string; readonly networkInterfaces?: NetworkInterface[]; - readonly subnets?: Subnet[]; - resourceGuid?: string; provisioningState?: string; -}; + resourceGuid?: string; + securityRules?: SecurityRule[]; + readonly subnets?: Subnet[]; +} // @public export interface NetworkSecurityGroupListResult { @@ -1772,17 +1629,17 @@ export interface OperationsListOptionalParams extends coreClient.OperationOption export type OperationsListResponse = OperationListResult; // @public -export type OutboundRule = SubResource & { - name?: string; - etag?: string; +export interface OutboundRule extends SubResource { allocatedOutboundPorts?: number; - frontendIPConfigurations?: SubResource[]; backendAddressPool?: SubResource; - provisioningState?: string; - protocol?: OutboundRulePropertiesFormatProtocol; enableTcpReset?: boolean; + etag?: string; + frontendIPConfigurations?: SubResource[]; idleTimeoutInMinutes?: number; -}; + name?: string; + protocol?: OutboundRulePropertiesFormatProtocol; + provisioningState?: string; +} // @public export type OutboundRulePropertiesFormatProtocol = string; @@ -1791,17 +1648,17 @@ export type OutboundRulePropertiesFormatProtocol = string; export type PfsGroup = string; // @public -export type Probe = SubResource & { - name?: string; +export interface Probe extends SubResource { etag?: string; - readonly loadBalancingRules?: SubResource[]; - protocol?: ProbeProtocol; - port?: number; intervalInSeconds?: number; + readonly loadBalancingRules?: SubResource[]; + name?: string; numberOfProbes?: number; - requestPath?: string; + port?: number; + protocol?: ProbeProtocol; provisioningState?: string; -}; + requestPath?: string; +} // @public export type ProbeProtocol = string; @@ -1810,22 +1667,22 @@ export type ProbeProtocol = string; export type ProcessorArchitecture = string; // @public -export type PublicIPAddress = Resource & { - sku?: PublicIPAddressSku; +export interface PublicIPAddress extends Resource { + ddosSettings?: DdosSettings; + dnsSettings?: PublicIPAddressDnsSettings; etag?: string; - zones?: string[]; - publicIPAllocationMethod?: IPAllocationMethod; - publicIPAddressVersion?: IPVersion; + idleTimeoutInMinutes?: number; + ipAddress?: string; readonly ipConfiguration?: IPConfiguration; - dnsSettings?: PublicIPAddressDnsSettings; - ddosSettings?: DdosSettings; ipTags?: IpTag[]; - ipAddress?: string; + provisioningState?: string; + publicIPAddressVersion?: IPVersion; + publicIPAllocationMethod?: IPAllocationMethod; publicIPPrefix?: SubResource; - idleTimeoutInMinutes?: number; resourceGuid?: string; - provisioningState?: string; -}; + sku?: PublicIPAddressSku; + zones?: string[]; +} // @public export interface PublicIPAddressDnsSettings { @@ -1936,23 +1793,23 @@ export interface Resource { export type ResourceIdentityType = "SystemAssigned" | "UserAssigned" | "SystemAssigned, UserAssigned" | "None"; // @public -export type ResourceNavigationLink = SubResource & { - name?: string; +export interface ResourceNavigationLink extends SubResource { readonly etag?: string; - linkedResourceType?: string; link?: string; + linkedResourceType?: string; + name?: string; readonly provisioningState?: string; -}; +} // @public -export type Route = SubResource & { - name?: string; - etag?: string; +export interface Route extends SubResource { addressPrefix?: string; - nextHopType?: RouteNextHopType; + etag?: string; + name?: string; nextHopIpAddress?: string; + nextHopType?: RouteNextHopType; provisioningState?: string; -}; +} // @public export interface RouteListResult { @@ -2010,13 +1867,13 @@ export interface RoutesListOptionalParams extends coreClient.OperationOptions { export type RoutesListResponse = RouteListResult; // @public -export type RouteTable = Resource & { +export interface RouteTable extends Resource { + disableBgpRoutePropagation?: boolean; etag?: string; + provisioningState?: string; routes?: Route[]; readonly subnets?: Subnet[]; - disableBgpRoutePropagation?: boolean; - provisioningState?: string; -}; +} // @public export interface RouteTableListResult { @@ -2098,26 +1955,26 @@ export interface RouteTablesUpdateTagsOptionalParams extends coreClient.Operatio export type RouteTablesUpdateTagsResponse = RouteTable; // @public -export type SecurityRule = SubResource & { - name?: string; - etag?: string; +export interface SecurityRule extends SubResource { + access?: SecurityRuleAccess; description?: string; - protocol?: SecurityRuleProtocol; - sourcePortRange?: string; - destinationPortRange?: string; - sourceAddressPrefix?: string; - sourceAddressPrefixes?: string[]; - sourceApplicationSecurityGroups?: ApplicationSecurityGroup[]; destinationAddressPrefix?: string; destinationAddressPrefixes?: string[]; destinationApplicationSecurityGroups?: ApplicationSecurityGroup[]; - sourcePortRanges?: string[]; + destinationPortRange?: string; destinationPortRanges?: string[]; - access?: SecurityRuleAccess; - priority?: number; direction?: SecurityRuleDirection; + etag?: string; + name?: string; + priority?: number; + protocol?: SecurityRuleProtocol; provisioningState?: string; -}; + sourceAddressPrefix?: string; + sourceAddressPrefixes?: string[]; + sourceApplicationSecurityGroups?: ApplicationSecurityGroup[]; + sourcePortRange?: string; + sourcePortRanges?: string[]; +} // @public export type SecurityRuleAccess = string; @@ -2181,32 +2038,32 @@ export interface SecurityRulesListOptionalParams extends coreClient.OperationOpt export type SecurityRulesListResponse = SecurityRuleListResult; // @public -export type ServiceAssociationLink = SubResource & { - name?: string; +export interface ServiceAssociationLink extends SubResource { readonly etag?: string; - linkedResourceType?: string; link?: string; + linkedResourceType?: string; + name?: string; readonly provisioningState?: string; -}; +} // @public -export type ServiceEndpointPolicy = Resource & { +export interface ServiceEndpointPolicy extends Resource { etag?: string; + readonly provisioningState?: string; + readonly resourceGuid?: string; serviceEndpointPolicyDefinitions?: ServiceEndpointPolicyDefinition[]; readonly subnets?: Subnet[]; - readonly resourceGuid?: string; - readonly provisioningState?: string; -}; +} // @public -export type ServiceEndpointPolicyDefinition = SubResource & { - name?: string; - etag?: string; +export interface ServiceEndpointPolicyDefinition extends SubResource { description?: string; + etag?: string; + name?: string; + readonly provisioningState?: string; service?: string; serviceResources?: string[]; - readonly provisioningState?: string; -}; +} // @public export interface ServiceEndpointPropertiesFormat { @@ -2216,24 +2073,24 @@ export interface ServiceEndpointPropertiesFormat { } // @public -export type Subnet = SubResource & { - name?: string; - etag?: string; +export interface Subnet extends SubResource { addressPrefix?: string; addressPrefixes?: string[]; - networkSecurityGroup?: NetworkSecurityGroup; - routeTable?: RouteTable; - serviceEndpoints?: ServiceEndpointPropertiesFormat[]; - serviceEndpointPolicies?: ServiceEndpointPolicy[]; + delegations?: Delegation[]; + etag?: string; readonly interfaceEndpoints?: InterfaceEndpoint[]; - readonly ipConfigurations?: IPConfiguration[]; readonly ipConfigurationProfiles?: IPConfigurationProfile[]; + readonly ipConfigurations?: IPConfiguration[]; + name?: string; + networkSecurityGroup?: NetworkSecurityGroup; + provisioningState?: string; + readonly purpose?: string; resourceNavigationLinks?: ResourceNavigationLink[]; + routeTable?: RouteTable; serviceAssociationLinks?: ServiceAssociationLink[]; - delegations?: Delegation[]; - readonly purpose?: string; - provisioningState?: string; -}; + serviceEndpointPolicies?: ServiceEndpointPolicy[]; + serviceEndpoints?: ServiceEndpointPropertiesFormat[]; +} // @public export interface SubnetListResult { @@ -2313,18 +2170,18 @@ export interface TunnelConnectionHealth { } // @public -export type VirtualNetwork = Resource & { - etag?: string; +export interface VirtualNetwork extends Resource { addressSpace?: AddressSpace; + ddosProtectionPlan?: SubResource; dhcpOptions?: DhcpOptions; - subnets?: Subnet[]; - virtualNetworkPeerings?: VirtualNetworkPeering[]; - resourceGuid?: string; - provisioningState?: string; enableDdosProtection?: boolean; enableVmProtection?: boolean; - ddosProtectionPlan?: SubResource; -}; + etag?: string; + provisioningState?: string; + resourceGuid?: string; + subnets?: Subnet[]; + virtualNetworkPeerings?: VirtualNetworkPeering[]; +} // @public export interface VirtualNetworkConnectionGatewayReference { @@ -2332,68 +2189,68 @@ export interface VirtualNetworkConnectionGatewayReference { } // @public -export type VirtualNetworkGateway = Resource & { - etag?: string; - ipConfigurations?: VirtualNetworkGatewayIPConfiguration[]; - gatewayType?: VirtualNetworkGatewayType; - vpnType?: VpnType; - enableBgp?: boolean; +export interface VirtualNetworkGateway extends Resource { active?: boolean; + bgpSettings?: BgpSettings; + enableBgp?: boolean; + etag?: string; gatewayDefaultSite?: SubResource; + gatewayType?: VirtualNetworkGatewayType; + ipConfigurations?: VirtualNetworkGatewayIPConfiguration[]; + readonly provisioningState?: string; + resourceGuid?: string; sku?: VirtualNetworkGatewaySku; vpnClientConfiguration?: VpnClientConfiguration; - bgpSettings?: BgpSettings; - resourceGuid?: string; - readonly provisioningState?: string; -}; + vpnType?: VpnType; +} // @public -export type VirtualNetworkGatewayConnection = Resource & { - etag?: string; +export interface VirtualNetworkGatewayConnection extends Resource { authorizationKey?: string; - virtualNetworkGateway1: VirtualNetworkGateway; - virtualNetworkGateway2?: VirtualNetworkGateway; - localNetworkGateway2?: LocalNetworkGateway; - connectionType: VirtualNetworkGatewayConnectionType; connectionProtocol?: VirtualNetworkGatewayConnectionProtocol; - routingWeight?: number; - sharedKey?: string; readonly connectionStatus?: VirtualNetworkGatewayConnectionStatus; - readonly tunnelConnectionStatus?: TunnelConnectionHealth[]; + connectionType: VirtualNetworkGatewayConnectionType; readonly egressBytesTransferred?: number; - readonly ingressBytesTransferred?: number; - peer?: SubResource; enableBgp?: boolean; - usePolicyBasedTrafficSelectors?: boolean; + etag?: string; + expressRouteGatewayBypass?: boolean; + readonly ingressBytesTransferred?: number; ipsecPolicies?: IpsecPolicy[]; - resourceGuid?: string; + localNetworkGateway2?: LocalNetworkGateway; + peer?: SubResource; readonly provisioningState?: string; - expressRouteGatewayBypass?: boolean; -}; + resourceGuid?: string; + routingWeight?: number; + sharedKey?: string; + readonly tunnelConnectionStatus?: TunnelConnectionHealth[]; + usePolicyBasedTrafficSelectors?: boolean; + virtualNetworkGateway1: VirtualNetworkGateway; + virtualNetworkGateway2?: VirtualNetworkGateway; +} // @public -export type VirtualNetworkGatewayConnectionListEntity = Resource & { - etag?: string; +export interface VirtualNetworkGatewayConnectionListEntity extends Resource { authorizationKey?: string; - virtualNetworkGateway1: VirtualNetworkConnectionGatewayReference; - virtualNetworkGateway2?: VirtualNetworkConnectionGatewayReference; - localNetworkGateway2?: VirtualNetworkConnectionGatewayReference; - connectionType: VirtualNetworkGatewayConnectionType; connectionProtocol?: VirtualNetworkGatewayConnectionProtocol; - routingWeight?: number; - sharedKey?: string; readonly connectionStatus?: VirtualNetworkGatewayConnectionStatus; - readonly tunnelConnectionStatus?: TunnelConnectionHealth[]; + connectionType: VirtualNetworkGatewayConnectionType; readonly egressBytesTransferred?: number; - readonly ingressBytesTransferred?: number; - peer?: SubResource; enableBgp?: boolean; - usePolicyBasedTrafficSelectors?: boolean; + etag?: string; + expressRouteGatewayBypass?: boolean; + readonly ingressBytesTransferred?: number; ipsecPolicies?: IpsecPolicy[]; - resourceGuid?: string; + localNetworkGateway2?: VirtualNetworkConnectionGatewayReference; + peer?: SubResource; readonly provisioningState?: string; - expressRouteGatewayBypass?: boolean; -}; + resourceGuid?: string; + routingWeight?: number; + sharedKey?: string; + readonly tunnelConnectionStatus?: TunnelConnectionHealth[]; + usePolicyBasedTrafficSelectors?: boolean; + virtualNetworkGateway1: VirtualNetworkConnectionGatewayReference; + virtualNetworkGateway2?: VirtualNetworkConnectionGatewayReference; +} // @public export interface VirtualNetworkGatewayConnectionListResult { @@ -2498,14 +2355,14 @@ export type VirtualNetworkGatewayConnectionsUpdateTagsResponse = VirtualNetworkG export type VirtualNetworkGatewayConnectionType = string; // @public -export type VirtualNetworkGatewayIPConfiguration = SubResource & { - name?: string; +export interface VirtualNetworkGatewayIPConfiguration extends SubResource { etag?: string; + name?: string; privateIPAllocationMethod?: IPAllocationMethod; - subnet?: SubResource; - publicIPAddress?: SubResource; readonly provisioningState?: string; -}; + publicIPAddress?: SubResource; + subnet?: SubResource; +} // @public export interface VirtualNetworkGatewayListConnectionsResult { @@ -2755,18 +2612,18 @@ export interface VirtualNetworkListUsageResult { } // @public -export type VirtualNetworkPeering = SubResource & { - name?: string; - etag?: string; - allowVirtualNetworkAccess?: boolean; +export interface VirtualNetworkPeering extends SubResource { allowForwardedTraffic?: boolean; allowGatewayTransit?: boolean; - useRemoteGateways?: boolean; - remoteVirtualNetwork?: SubResource; - remoteAddressSpace?: AddressSpace; + allowVirtualNetworkAccess?: boolean; + etag?: string; + name?: string; peeringState?: VirtualNetworkPeeringState; provisioningState?: string; -}; + remoteAddressSpace?: AddressSpace; + remoteVirtualNetwork?: SubResource; + useRemoteGateways?: boolean; +} // @public export interface VirtualNetworkPeeringListResult { @@ -2920,15 +2777,15 @@ export interface VirtualNetworksUpdateTagsOptionalParams extends coreClient.Oper export type VirtualNetworksUpdateTagsResponse = VirtualNetwork; // @public -export type VirtualNetworkTap = Resource & { +export interface VirtualNetworkTap extends Resource { + destinationLoadBalancerFrontEndIPConfiguration?: FrontendIPConfiguration; + destinationNetworkInterfaceIPConfiguration?: NetworkInterfaceIPConfiguration; + destinationPort?: number; etag?: string; readonly networkInterfaceTapConfigurations?: NetworkInterfaceTapConfiguration[]; - readonly resourceGuid?: string; readonly provisioningState?: string; - destinationNetworkInterfaceIPConfiguration?: NetworkInterfaceIPConfiguration; - destinationLoadBalancerFrontEndIPConfiguration?: FrontendIPConfiguration; - destinationPort?: number; -}; + readonly resourceGuid?: string; +} // @public export interface VirtualNetworkUsage { @@ -2980,20 +2837,20 @@ export interface VpnClientParameters { export type VpnClientProtocol = string; // @public -export type VpnClientRevokedCertificate = SubResource & { - name?: string; +export interface VpnClientRevokedCertificate extends SubResource { etag?: string; - thumbprint?: string; + name?: string; readonly provisioningState?: string; -}; + thumbprint?: string; +} // @public -export type VpnClientRootCertificate = SubResource & { - name?: string; +export interface VpnClientRootCertificate extends SubResource { etag?: string; - publicCertData: string; + name?: string; readonly provisioningState?: string; -}; + publicCertData: string; +} // @public export interface VpnDeviceScriptParameters { diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/sample.env b/sdk/network/arm-network-profile-2020-09-01-hybrid/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/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/network/arm-network-profile-2020-09-01-hybrid/samples-dev/defaultSecurityRulesGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/defaultSecurityRulesGetSample.ts new file mode 100644 index 000000000000..ff59d9ce97b5 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/defaultSecurityRulesGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get the specified default network security rule. + * + * @summary Get the specified default network security rule. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/DefaultSecurityRuleGet.json + */ +async function defaultSecurityRuleGet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const networkSecurityGroupName = "nsg1"; + const defaultSecurityRuleName = "AllowVnetInBound"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.defaultSecurityRules.get( + resourceGroupName, + networkSecurityGroupName, + defaultSecurityRuleName + ); + console.log(result); +} + +async function main() { + defaultSecurityRuleGet(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/defaultSecurityRulesListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/defaultSecurityRulesListSample.ts new file mode 100644 index 000000000000..a66bcfc71a9a --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/defaultSecurityRulesListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all default security rules in a network security group. + * + * @summary Gets all default security rules in a network security group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/DefaultSecurityRuleList.json + */ +async function defaultSecurityRuleList() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const networkSecurityGroupName = "nsg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.defaultSecurityRules.list( + resourceGroupName, + networkSecurityGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + defaultSecurityRuleList(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/inboundNatRulesCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/inboundNatRulesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..b2ce30545481 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/inboundNatRulesCreateOrUpdateSample.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + InboundNatRule, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a load balancer inbound nat rule. + * + * @summary Creates or updates a load balancer inbound nat rule. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/InboundNatRuleCreate.json + */ +async function inboundNatRuleCreate() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb1"; + const inboundNatRuleName = "natRule1.1"; + const inboundNatRuleParameters: InboundNatRule = { + backendPort: 3389, + enableFloatingIP: false, + enableTcpReset: true, + frontendIPConfiguration: { + id: + "/subscriptions/subid/resourceGroups/testrg/providers/Microsoft.Network/loadBalancers/lb1/frontendIPConfigurations/ip1" + }, + frontendPort: 3390, + idleTimeoutInMinutes: 4, + protocol: "Tcp" + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.inboundNatRules.beginCreateOrUpdateAndWait( + resourceGroupName, + loadBalancerName, + inboundNatRuleName, + inboundNatRuleParameters + ); + console.log(result); +} + +async function main() { + inboundNatRuleCreate(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/inboundNatRulesDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/inboundNatRulesDeleteSample.ts new file mode 100644 index 000000000000..128b2850f35b --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/inboundNatRulesDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified load balancer inbound nat rule. + * + * @summary Deletes the specified load balancer inbound nat rule. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/InboundNatRuleDelete.json + */ +async function inboundNatRuleDelete() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb1"; + const inboundNatRuleName = "natRule1.1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.inboundNatRules.beginDeleteAndWait( + resourceGroupName, + loadBalancerName, + inboundNatRuleName + ); + console.log(result); +} + +async function main() { + inboundNatRuleDelete(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/inboundNatRulesGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/inboundNatRulesGetSample.ts new file mode 100644 index 000000000000..0b903dd70b3b --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/inboundNatRulesGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified load balancer inbound nat rule. + * + * @summary Gets the specified load balancer inbound nat rule. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/InboundNatRuleGet.json + */ +async function inboundNatRuleGet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb1"; + const inboundNatRuleName = "natRule1.1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.inboundNatRules.get( + resourceGroupName, + loadBalancerName, + inboundNatRuleName + ); + console.log(result); +} + +async function main() { + inboundNatRuleGet(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/inboundNatRulesListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/inboundNatRulesListSample.ts new file mode 100644 index 000000000000..318477df357b --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/inboundNatRulesListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all the inbound nat rules in a load balancer. + * + * @summary Gets all the inbound nat rules in a load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/InboundNatRuleList.json + */ +async function inboundNatRuleList() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.inboundNatRules.list( + resourceGroupName, + loadBalancerName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + inboundNatRuleList(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerBackendAddressPoolsGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerBackendAddressPoolsGetSample.ts new file mode 100644 index 000000000000..eaef1c62ebc2 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerBackendAddressPoolsGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets load balancer backend address pool. + * + * @summary Gets load balancer backend address pool. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerBackendAddressPoolGet.json + */ +async function loadBalancerBackendAddressPoolGet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb"; + const backendAddressPoolName = "backend"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancerBackendAddressPools.get( + resourceGroupName, + loadBalancerName, + backendAddressPoolName + ); + console.log(result); +} + +async function main() { + loadBalancerBackendAddressPoolGet(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerBackendAddressPoolsListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerBackendAddressPoolsListSample.ts new file mode 100644 index 000000000000..5415ce4e703d --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerBackendAddressPoolsListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all the load balancer backed address pools. + * + * @summary Gets all the load balancer backed address pools. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerBackendAddressPoolList.json + */ +async function loadBalancerBackendAddressPoolList() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.loadBalancerBackendAddressPools.list( + resourceGroupName, + loadBalancerName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + loadBalancerBackendAddressPoolList(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerFrontendIPConfigurationsGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerFrontendIPConfigurationsGetSample.ts new file mode 100644 index 000000000000..86ac76580a7c --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerFrontendIPConfigurationsGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets load balancer frontend IP configuration. + * + * @summary Gets load balancer frontend IP configuration. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerFrontendIPConfigurationGet.json + */ +async function loadBalancerFrontendIPConfigurationGet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb"; + const frontendIPConfigurationName = "frontend"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancerFrontendIPConfigurations.get( + resourceGroupName, + loadBalancerName, + frontendIPConfigurationName + ); + console.log(result); +} + +async function main() { + loadBalancerFrontendIPConfigurationGet(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerFrontendIPConfigurationsListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerFrontendIPConfigurationsListSample.ts new file mode 100644 index 000000000000..64972b28ca26 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerFrontendIPConfigurationsListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all the load balancer frontend IP configurations. + * + * @summary Gets all the load balancer frontend IP configurations. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerFrontendIPConfigurationList.json + */ +async function loadBalancerFrontendIPConfigurationList() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.loadBalancerFrontendIPConfigurations.list( + resourceGroupName, + loadBalancerName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + loadBalancerFrontendIPConfigurationList(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerLoadBalancingRulesGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerLoadBalancingRulesGetSample.ts new file mode 100644 index 000000000000..169adf0055c2 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerLoadBalancingRulesGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified load balancer load balancing rule. + * + * @summary Gets the specified load balancer load balancing rule. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerLoadBalancingRuleGet.json + */ +async function loadBalancerLoadBalancingRuleGet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb1"; + const loadBalancingRuleName = "rule1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancerLoadBalancingRules.get( + resourceGroupName, + loadBalancerName, + loadBalancingRuleName + ); + console.log(result); +} + +async function main() { + loadBalancerLoadBalancingRuleGet(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerLoadBalancingRulesListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerLoadBalancingRulesListSample.ts new file mode 100644 index 000000000000..685ea4d9466c --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerLoadBalancingRulesListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all the load balancing rules in a load balancer. + * + * @summary Gets all the load balancing rules in a load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerLoadBalancingRuleList.json + */ +async function loadBalancerLoadBalancingRuleList() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.loadBalancerLoadBalancingRules.list( + resourceGroupName, + loadBalancerName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + loadBalancerLoadBalancingRuleList(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerNetworkInterfacesListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerNetworkInterfacesListSample.ts new file mode 100644 index 000000000000..554f347b2be5 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerNetworkInterfacesListSample.ts @@ -0,0 +1,66 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets associated load balancer network interfaces. + * + * @summary Gets associated load balancer network interfaces. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerNetworkInterfaceListSimple.json + */ +async function loadBalancerNetworkInterfaceListSimple() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.loadBalancerNetworkInterfaces.list( + resourceGroupName, + loadBalancerName + )) { + resArray.push(item); + } + console.log(resArray); +} + +/** + * This sample demonstrates how to Gets associated load balancer network interfaces. + * + * @summary Gets associated load balancer network interfaces. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerNetworkInterfaceListVmss.json + */ +async function loadBalancerNetworkInterfaceListVmss() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.loadBalancerNetworkInterfaces.list( + resourceGroupName, + loadBalancerName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + loadBalancerNetworkInterfaceListSimple(); + loadBalancerNetworkInterfaceListVmss(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerOutboundRulesGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerOutboundRulesGetSample.ts new file mode 100644 index 000000000000..698b52cab4c2 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerOutboundRulesGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified load balancer outbound rule. + * + * @summary Gets the specified load balancer outbound rule. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerOutboundRuleGet.json + */ +async function loadBalancerOutboundRuleGet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb1"; + const outboundRuleName = "rule1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancerOutboundRules.get( + resourceGroupName, + loadBalancerName, + outboundRuleName + ); + console.log(result); +} + +async function main() { + loadBalancerOutboundRuleGet(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerOutboundRulesListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerOutboundRulesListSample.ts new file mode 100644 index 000000000000..edcbb14fc436 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerOutboundRulesListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all the outbound rules in a load balancer. + * + * @summary Gets all the outbound rules in a load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerOutboundRuleList.json + */ +async function loadBalancerOutboundRuleList() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.loadBalancerOutboundRules.list( + resourceGroupName, + loadBalancerName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + loadBalancerOutboundRuleList(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerProbesGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerProbesGetSample.ts new file mode 100644 index 000000000000..893e6251d43d --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerProbesGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets load balancer probe. + * + * @summary Gets load balancer probe. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerProbeGet.json + */ +async function loadBalancerProbeGet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb"; + const probeName = "probe1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancerProbes.get( + resourceGroupName, + loadBalancerName, + probeName + ); + console.log(result); +} + +async function main() { + loadBalancerProbeGet(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerProbesListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerProbesListSample.ts new file mode 100644 index 000000000000..1a6aa24824bf --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancerProbesListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all the load balancer probes. + * + * @summary Gets all the load balancer probes. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerProbeList.json + */ +async function loadBalancerProbeList() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.loadBalancerProbes.list( + resourceGroupName, + loadBalancerName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + loadBalancerProbeList(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancersCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancersCreateOrUpdateSample.ts new file mode 100644 index 000000000000..b89de9395fa1 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancersCreateOrUpdateSample.ts @@ -0,0 +1,435 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + LoadBalancer, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a load balancer. + * + * @summary Creates or updates a load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerCreate.json + */ +async function createLoadBalancer() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const loadBalancerName = "lb"; + const parameters: LoadBalancer = { + backendAddressPools: [{ name: "be-lb" }], + frontendIPConfigurations: [ + { + name: "fe-lb", + subnet: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb/subnets/subnetlb" + } + } + ], + inboundNatPools: [], + inboundNatRules: [ + { + name: "in-nat-rule", + backendPort: 3389, + enableFloatingIP: true, + enableTcpReset: true, + frontendIPConfiguration: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb" + }, + frontendPort: 3389, + idleTimeoutInMinutes: 15, + protocol: "Tcp" + } + ], + loadBalancingRules: [ + { + name: "rulelb", + backendAddressPool: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/be-lb" + }, + backendPort: 80, + enableFloatingIP: true, + enableTcpReset: true, + frontendIPConfiguration: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb" + }, + frontendPort: 80, + idleTimeoutInMinutes: 15, + loadDistribution: "Default", + probe: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/probes/probe-lb" + }, + protocol: "Tcp" + } + ], + probes: [ + { + name: "probe-lb", + intervalInSeconds: 15, + numberOfProbes: 2, + port: 80, + requestPath: "healthcheck.aspx", + protocol: "Http" + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancers.beginCreateOrUpdateAndWait( + resourceGroupName, + loadBalancerName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a load balancer. + * + * @summary Creates or updates a load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerCreateWithZones.json + */ +async function createLoadBalancerWithFrontendIPInZone1() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const loadBalancerName = "lb"; + const parameters: LoadBalancer = { + backendAddressPools: [{ name: "be-lb" }], + frontendIPConfigurations: [ + { + name: "fe-lb", + subnet: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb/subnets/subnetlb" + }, + zones: ["1"] + } + ], + inboundNatPools: [], + inboundNatRules: [ + { + name: "in-nat-rule", + backendPort: 3389, + enableFloatingIP: true, + frontendIPConfiguration: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb" + }, + frontendPort: 3389, + idleTimeoutInMinutes: 15, + protocol: "Tcp" + } + ], + loadBalancingRules: [ + { + name: "rulelb", + backendAddressPool: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/be-lb" + }, + backendPort: 80, + enableFloatingIP: true, + frontendIPConfiguration: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb" + }, + frontendPort: 80, + idleTimeoutInMinutes: 15, + loadDistribution: "Default", + probe: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/probes/probe-lb" + }, + protocol: "Tcp" + } + ], + outboundRules: [], + probes: [ + { + name: "probe-lb", + intervalInSeconds: 15, + numberOfProbes: 2, + port: 80, + requestPath: "healthcheck.aspx", + protocol: "Http" + } + ], + sku: { name: "Standard" } + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancers.beginCreateOrUpdateAndWait( + resourceGroupName, + loadBalancerName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a load balancer. + * + * @summary Creates or updates a load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerCreateStandardSku.json + */ +async function createLoadBalancerWithStandardSku() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const loadBalancerName = "lb"; + const parameters: LoadBalancer = { + backendAddressPools: [{ name: "be-lb" }], + frontendIPConfigurations: [ + { + name: "fe-lb", + subnet: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb/subnets/subnetlb" + } + } + ], + inboundNatPools: [], + inboundNatRules: [ + { + name: "in-nat-rule", + backendPort: 3389, + enableFloatingIP: true, + frontendIPConfiguration: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb" + }, + frontendPort: 3389, + idleTimeoutInMinutes: 15, + protocol: "Tcp" + } + ], + loadBalancingRules: [ + { + name: "rulelb", + backendAddressPool: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/be-lb" + }, + backendPort: 80, + enableFloatingIP: true, + frontendIPConfiguration: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb" + }, + frontendPort: 80, + idleTimeoutInMinutes: 15, + loadDistribution: "Default", + probe: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/probes/probe-lb" + }, + protocol: "Tcp" + } + ], + outboundRules: [], + probes: [ + { + name: "probe-lb", + intervalInSeconds: 15, + numberOfProbes: 2, + port: 80, + requestPath: "healthcheck.aspx", + protocol: "Http" + } + ], + sku: { name: "Standard" } + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancers.beginCreateOrUpdateAndWait( + resourceGroupName, + loadBalancerName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a load balancer. + * + * @summary Creates or updates a load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerCreateWithInboundNatPool.json + */ +async function createLoadBalancerWithInboundNatPool() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const loadBalancerName = "lb"; + const parameters: LoadBalancer = { + backendAddressPools: [], + frontendIPConfigurations: [ + { + name: "test", + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/test", + privateIPAllocationMethod: "Dynamic", + subnet: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/lbvnet/subnets/lbsubnet", + resourceNavigationLinks: [], + serviceEndpoints: [] + }, + zones: [] + } + ], + inboundNatPools: [ + { + name: "test", + backendPort: 8888, + enableFloatingIP: true, + enableTcpReset: true, + frontendIPConfiguration: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/test" + }, + frontendPortRangeEnd: 8085, + frontendPortRangeStart: 8080, + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/inboundNatPools/test", + idleTimeoutInMinutes: 10, + protocol: "Tcp" + } + ], + inboundNatRules: [], + loadBalancingRules: [], + outboundRules: [], + probes: [], + sku: { name: "Standard" } + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancers.beginCreateOrUpdateAndWait( + resourceGroupName, + loadBalancerName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a load balancer. + * + * @summary Creates or updates a load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerCreateWithOutboundRules.json + */ +async function createLoadBalancerWithOutboundRules() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const loadBalancerName = "lb"; + const parameters: LoadBalancer = { + backendAddressPools: [{ name: "be-lb" }], + frontendIPConfigurations: [ + { + name: "fe-lb", + publicIPAddress: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/pip" + } + } + ], + inboundNatPools: [], + inboundNatRules: [ + { + name: "in-nat-rule", + backendPort: 3389, + enableFloatingIP: true, + frontendIPConfiguration: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb" + }, + frontendPort: 3389, + idleTimeoutInMinutes: 15, + protocol: "Tcp" + } + ], + loadBalancingRules: [ + { + name: "rulelb", + backendAddressPool: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/be-lb" + }, + backendPort: 80, + disableOutboundSnat: true, + enableFloatingIP: true, + frontendIPConfiguration: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb" + }, + frontendPort: 80, + idleTimeoutInMinutes: 15, + loadDistribution: "Default", + probe: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/probes/probe-lb" + }, + protocol: "Tcp" + } + ], + location: "eastus", + outboundRules: [ + { + name: "rule1", + backendAddressPool: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/be-lb" + }, + frontendIPConfigurations: [ + { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb" + } + ], + protocol: "All" + } + ], + probes: [ + { + name: "probe-lb", + intervalInSeconds: 15, + numberOfProbes: 2, + port: 80, + requestPath: "healthcheck.aspx", + protocol: "Http" + } + ], + sku: { name: "Standard" } + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancers.beginCreateOrUpdateAndWait( + resourceGroupName, + loadBalancerName, + parameters + ); + console.log(result); +} + +async function main() { + createLoadBalancer(); + createLoadBalancerWithFrontendIPInZone1(); + createLoadBalancerWithStandardSku(); + createLoadBalancerWithInboundNatPool(); + createLoadBalancerWithOutboundRules(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancersDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancersDeleteSample.ts new file mode 100644 index 000000000000..e837f3284210 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancersDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified load balancer. + * + * @summary Deletes the specified load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerDelete.json + */ +async function deleteLoadBalancer() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const loadBalancerName = "lb"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancers.beginDeleteAndWait( + resourceGroupName, + loadBalancerName + ); + console.log(result); +} + +async function main() { + deleteLoadBalancer(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancersGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancersGetSample.ts new file mode 100644 index 000000000000..788563a98cac --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancersGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified load balancer. + * + * @summary Gets the specified load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerGet.json + */ +async function getLoadBalancer() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const loadBalancerName = "lb"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancers.get( + resourceGroupName, + loadBalancerName + ); + console.log(result); +} + +async function main() { + getLoadBalancer(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancersListAllSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancersListAllSample.ts new file mode 100644 index 000000000000..fdac0824edaf --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancersListAllSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all the load balancers in a subscription. + * + * @summary Gets all the load balancers in a subscription. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerListAll.json + */ +async function listAllLoadBalancers() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.loadBalancers.listAll()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAllLoadBalancers(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancersListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancersListSample.ts new file mode 100644 index 000000000000..3cb16a2c278a --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancersListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all the load balancers in a resource group. + * + * @summary Gets all the load balancers in a resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerList.json + */ +async function listLoadBalancersInResourceGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.loadBalancers.list(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listLoadBalancersInResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancersUpdateTagsSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancersUpdateTagsSample.ts new file mode 100644 index 000000000000..68aa086e7032 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/loadBalancersUpdateTagsSample.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 { + TagsObject, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Updates a load balancer tags. + * + * @summary Updates a load balancer tags. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerUpdateTags.json + */ +async function updateLoadBalancerTags() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const loadBalancerName = "lb"; + const parameters: TagsObject = { tags: { tag1: "value1", tag2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancers.beginUpdateTagsAndWait( + resourceGroupName, + loadBalancerName, + parameters + ); + console.log(result); +} + +async function main() { + updateLoadBalancerTags(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/localNetworkGatewaysCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/localNetworkGatewaysCreateOrUpdateSample.ts new file mode 100644 index 000000000000..40690c895536 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/localNetworkGatewaysCreateOrUpdateSample.ts @@ -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. +import { + LocalNetworkGateway, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a local network gateway in the specified resource group. + * + * @summary Creates or updates a local network gateway in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LocalNetworkGatewayCreate.json + */ +async function createLocalNetworkGateway() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const localNetworkGatewayName = "localgw"; + const parameters: LocalNetworkGateway = { + gatewayIpAddress: "x.x.x.x", + localNetworkAddressSpace: { addressPrefixes: ["10.1.0.0/16"] }, + location: "Central US" + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.localNetworkGateways.beginCreateOrUpdateAndWait( + resourceGroupName, + localNetworkGatewayName, + parameters + ); + console.log(result); +} + +async function main() { + createLocalNetworkGateway(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/localNetworkGatewaysDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/localNetworkGatewaysDeleteSample.ts new file mode 100644 index 000000000000..aa49bd1984bd --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/localNetworkGatewaysDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified local network gateway. + * + * @summary Deletes the specified local network gateway. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LocalNetworkGatewayDelete.json + */ +async function deleteLocalNetworkGateway() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const localNetworkGatewayName = "localgw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.localNetworkGateways.beginDeleteAndWait( + resourceGroupName, + localNetworkGatewayName + ); + console.log(result); +} + +async function main() { + deleteLocalNetworkGateway(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/localNetworkGatewaysGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/localNetworkGatewaysGetSample.ts new file mode 100644 index 000000000000..54b700ec3661 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/localNetworkGatewaysGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified local network gateway in a resource group. + * + * @summary Gets the specified local network gateway in a resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LocalNetworkGatewayGet.json + */ +async function getLocalNetworkGateway() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const localNetworkGatewayName = "localgw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.localNetworkGateways.get( + resourceGroupName, + localNetworkGatewayName + ); + console.log(result); +} + +async function main() { + getLocalNetworkGateway(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/localNetworkGatewaysListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/localNetworkGatewaysListSample.ts new file mode 100644 index 000000000000..798efd0e9c5d --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/localNetworkGatewaysListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all the local network gateways in a resource group. + * + * @summary Gets all the local network gateways in a resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LocalNetworkGatewayList.json + */ +async function listLocalNetworkGateways() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.localNetworkGateways.list(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listLocalNetworkGateways(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/localNetworkGatewaysUpdateTagsSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/localNetworkGatewaysUpdateTagsSample.ts new file mode 100644 index 000000000000..2bf34ecc51d1 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/localNetworkGatewaysUpdateTagsSample.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 { + TagsObject, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Updates a local network gateway tags. + * + * @summary Updates a local network gateway tags. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LocalNetworkGatewayUpdateTags.json + */ +async function updateLocalNetworkGatewayTags() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const localNetworkGatewayName = "lgw"; + const parameters: TagsObject = { tags: { tag1: "value1", tag2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.localNetworkGateways.beginUpdateTagsAndWait( + resourceGroupName, + localNetworkGatewayName, + parameters + ); + console.log(result); +} + +async function main() { + updateLocalNetworkGatewayTags(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfaceIPConfigurationsGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfaceIPConfigurationsGetSample.ts new file mode 100644 index 000000000000..b5bdd5840b04 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfaceIPConfigurationsGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified network interface ip configuration. + * + * @summary Gets the specified network interface ip configuration. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceIPConfigurationGet.json + */ +async function networkInterfaceIPConfigurationGet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const networkInterfaceName = "mynic"; + const ipConfigurationName = "ipconfig1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaceIPConfigurations.get( + resourceGroupName, + networkInterfaceName, + ipConfigurationName + ); + console.log(result); +} + +async function main() { + networkInterfaceIPConfigurationGet(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfaceIPConfigurationsListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfaceIPConfigurationsListSample.ts new file mode 100644 index 000000000000..36e785391151 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfaceIPConfigurationsListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get all ip configurations in a network interface + * + * @summary Get all ip configurations in a network interface + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceIPConfigurationList.json + */ +async function networkInterfaceIPConfigurationList() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const networkInterfaceName = "nic1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.networkInterfaceIPConfigurations.list( + resourceGroupName, + networkInterfaceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + networkInterfaceIPConfigurationList(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfaceLoadBalancersListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfaceLoadBalancersListSample.ts new file mode 100644 index 000000000000..356cf0731884 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfaceLoadBalancersListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List all load balancers in a network interface. + * + * @summary List all load balancers in a network interface. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceLoadBalancerList.json + */ +async function networkInterfaceLoadBalancerList() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const networkInterfaceName = "nic1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.networkInterfaceLoadBalancers.list( + resourceGroupName, + networkInterfaceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + networkInterfaceLoadBalancerList(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfaceTapConfigurationsCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfaceTapConfigurationsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..724027dc1c67 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfaceTapConfigurationsCreateOrUpdateSample.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + NetworkInterfaceTapConfiguration, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a Tap configuration in the specified NetworkInterface. + * + * @summary Creates or updates a Tap configuration in the specified NetworkInterface. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceTapConfigurationCreate.json + */ +async function createNetworkInterfaceTapConfigurations() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const networkInterfaceName = "mynic"; + const tapConfigurationName = "tapconfiguration1"; + const tapConfigurationParameters: NetworkInterfaceTapConfiguration = { + virtualNetworkTap: { + id: + "/subscriptions/subid/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworkTaps/testvtap" + } + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaceTapConfigurations.beginCreateOrUpdateAndWait( + resourceGroupName, + networkInterfaceName, + tapConfigurationName, + tapConfigurationParameters + ); + console.log(result); +} + +async function main() { + createNetworkInterfaceTapConfigurations(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfaceTapConfigurationsDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfaceTapConfigurationsDeleteSample.ts new file mode 100644 index 000000000000..be01a69b9c84 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfaceTapConfigurationsDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified tap configuration from the NetworkInterface. + * + * @summary Deletes the specified tap configuration from the NetworkInterface. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceTapConfigurationDelete.json + */ +async function deleteTapConfiguration() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkInterfaceName = "test-networkinterface"; + const tapConfigurationName = "test-tapconfiguration"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaceTapConfigurations.beginDeleteAndWait( + resourceGroupName, + networkInterfaceName, + tapConfigurationName + ); + console.log(result); +} + +async function main() { + deleteTapConfiguration(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfaceTapConfigurationsGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfaceTapConfigurationsGetSample.ts new file mode 100644 index 000000000000..f0c79f385fb6 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfaceTapConfigurationsGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get the specified tap configuration on a network interface. + * + * @summary Get the specified tap configuration on a network interface. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceTapConfigurationGet.json + */ +async function getNetworkInterfaceTapConfigurations() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const networkInterfaceName = "mynic"; + const tapConfigurationName = "tapconfiguration1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaceTapConfigurations.get( + resourceGroupName, + networkInterfaceName, + tapConfigurationName + ); + console.log(result); +} + +async function main() { + getNetworkInterfaceTapConfigurations(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfaceTapConfigurationsListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfaceTapConfigurationsListSample.ts new file mode 100644 index 000000000000..7285d70b794e --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfaceTapConfigurationsListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get all Tap configurations in a network interface + * + * @summary Get all Tap configurations in a network interface + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceTapConfigurationList.json + */ +async function listVirtualNetworkTapConfigurations() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkInterfaceName = "mynic"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.networkInterfaceTapConfigurations.list( + resourceGroupName, + networkInterfaceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listVirtualNetworkTapConfigurations(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfacesCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfacesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..17c86b96dd00 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfacesCreateOrUpdateSample.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 { + NetworkInterface, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a network interface. + * + * @summary Creates or updates a network interface. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceCreate.json + */ +async function createNetworkInterface() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkInterfaceName = "test-nic"; + const parameters: NetworkInterface = { + enableAcceleratedNetworking: true, + ipConfigurations: [ + { + name: "ipconfig1", + publicIPAddress: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/test-ip" + }, + subnet: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/rg1-vnet/subnets/default" + } + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaces.beginCreateOrUpdateAndWait( + resourceGroupName, + networkInterfaceName, + parameters + ); + console.log(result); +} + +async function main() { + createNetworkInterface(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfacesDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfacesDeleteSample.ts new file mode 100644 index 000000000000..bbc4889537ec --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfacesDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified network interface. + * + * @summary Deletes the specified network interface. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceDelete.json + */ +async function deleteNetworkInterface() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkInterfaceName = "test-nic"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaces.beginDeleteAndWait( + resourceGroupName, + networkInterfaceName + ); + console.log(result); +} + +async function main() { + deleteNetworkInterface(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfacesGetEffectiveRouteTableSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfacesGetEffectiveRouteTableSample.ts new file mode 100644 index 000000000000..56637d3a94a3 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfacesGetEffectiveRouteTableSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all route tables applied to a network interface. + * + * @summary Gets all route tables applied to a network interface. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceEffectiveRouteTableList.json + */ +async function showNetworkInterfaceEffectiveRouteTables() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkInterfaceName = "nic1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaces.beginGetEffectiveRouteTableAndWait( + resourceGroupName, + networkInterfaceName + ); + console.log(result); +} + +async function main() { + showNetworkInterfaceEffectiveRouteTables(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfacesGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfacesGetSample.ts new file mode 100644 index 000000000000..c8ffeb31e9c3 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfacesGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets information about the specified network interface. + * + * @summary Gets information about the specified network interface. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceGet.json + */ +async function getNetworkInterface() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkInterfaceName = "test-nic"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaces.get( + resourceGroupName, + networkInterfaceName + ); + console.log(result); +} + +async function main() { + getNetworkInterface(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfacesListAllSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfacesListAllSample.ts new file mode 100644 index 000000000000..471ec3cd8a9c --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfacesListAllSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all network interfaces in a subscription. + * + * @summary Gets all network interfaces in a subscription. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceListAll.json + */ +async function listAllNetworkInterfaces() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.networkInterfaces.listAll()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAllNetworkInterfaces(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfacesListEffectiveNetworkSecurityGroupsSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfacesListEffectiveNetworkSecurityGroupsSample.ts new file mode 100644 index 000000000000..0590cd6b2f39 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfacesListEffectiveNetworkSecurityGroupsSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all network security groups applied to a network interface. + * + * @summary Gets all network security groups applied to a network interface. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceEffectiveNSGList.json + */ +async function listNetworkInterfaceEffectiveNetworkSecurityGroups() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkInterfaceName = "nic1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaces.beginListEffectiveNetworkSecurityGroupsAndWait( + resourceGroupName, + networkInterfaceName + ); + console.log(result); +} + +async function main() { + listNetworkInterfaceEffectiveNetworkSecurityGroups(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfacesListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfacesListSample.ts new file mode 100644 index 000000000000..5fad48780ee1 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfacesListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all network interfaces in a resource group. + * + * @summary Gets all network interfaces in a resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceList.json + */ +async function listNetworkInterfacesInResourceGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.networkInterfaces.list(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listNetworkInterfacesInResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfacesUpdateTagsSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfacesUpdateTagsSample.ts new file mode 100644 index 000000000000..d26718d128c2 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkInterfacesUpdateTagsSample.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 { + TagsObject, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Updates a network interface tags. + * + * @summary Updates a network interface tags. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceUpdateTags.json + */ +async function updateNetworkInterfaceTags() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkInterfaceName = "test-nic"; + const parameters: TagsObject = { tags: { tag1: "value1", tag2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaces.beginUpdateTagsAndWait( + resourceGroupName, + networkInterfaceName, + parameters + ); + console.log(result); +} + +async function main() { + updateNetworkInterfaceTags(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkSecurityGroupsCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkSecurityGroupsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..e9de37d80152 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkSecurityGroupsCreateOrUpdateSample.ts @@ -0,0 +1,81 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + NetworkSecurityGroup, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a network security group in the specified resource group. + * + * @summary Creates or updates a network security group in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupCreate.json + */ +async function createNetworkSecurityGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkSecurityGroupName = "testnsg"; + const parameters: NetworkSecurityGroup = {}; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkSecurityGroups.beginCreateOrUpdateAndWait( + resourceGroupName, + networkSecurityGroupName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a network security group in the specified resource group. + * + * @summary Creates or updates a network security group in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupCreateWithRule.json + */ +async function createNetworkSecurityGroupWithRule() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkSecurityGroupName = "testnsg"; + const parameters: NetworkSecurityGroup = { + securityRules: [ + { + name: "rule1", + access: "Allow", + destinationAddressPrefix: "*", + destinationPortRange: "80", + direction: "Inbound", + priority: 130, + sourceAddressPrefix: "*", + sourcePortRange: "*", + protocol: "*" + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkSecurityGroups.beginCreateOrUpdateAndWait( + resourceGroupName, + networkSecurityGroupName, + parameters + ); + console.log(result); +} + +async function main() { + createNetworkSecurityGroup(); + createNetworkSecurityGroupWithRule(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkSecurityGroupsDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkSecurityGroupsDeleteSample.ts new file mode 100644 index 000000000000..32bf62ce02c5 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkSecurityGroupsDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified network security group. + * + * @summary Deletes the specified network security group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupDelete.json + */ +async function deleteNetworkSecurityGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkSecurityGroupName = "testnsg"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkSecurityGroups.beginDeleteAndWait( + resourceGroupName, + networkSecurityGroupName + ); + console.log(result); +} + +async function main() { + deleteNetworkSecurityGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkSecurityGroupsGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkSecurityGroupsGetSample.ts new file mode 100644 index 000000000000..f05464ca69d3 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkSecurityGroupsGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified network security group. + * + * @summary Gets the specified network security group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupGet.json + */ +async function getNetworkSecurityGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkSecurityGroupName = "testnsg"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkSecurityGroups.get( + resourceGroupName, + networkSecurityGroupName + ); + console.log(result); +} + +async function main() { + getNetworkSecurityGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkSecurityGroupsListAllSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkSecurityGroupsListAllSample.ts new file mode 100644 index 000000000000..81e6c6cb0fdf --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkSecurityGroupsListAllSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all network security groups in a subscription. + * + * @summary Gets all network security groups in a subscription. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupListAll.json + */ +async function listAllNetworkSecurityGroups() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.networkSecurityGroups.listAll()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAllNetworkSecurityGroups(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkSecurityGroupsListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkSecurityGroupsListSample.ts new file mode 100644 index 000000000000..c2b4e025b89b --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkSecurityGroupsListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all network security groups in a resource group. + * + * @summary Gets all network security groups in a resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupList.json + */ +async function listNetworkSecurityGroupsInResourceGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.networkSecurityGroups.list(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listNetworkSecurityGroupsInResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkSecurityGroupsUpdateTagsSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkSecurityGroupsUpdateTagsSample.ts new file mode 100644 index 000000000000..b0afb89975ef --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/networkSecurityGroupsUpdateTagsSample.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 { + TagsObject, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Updates a network security group tags. + * + * @summary Updates a network security group tags. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupUpdateTags.json + */ +async function updateNetworkSecurityGroupTags() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkSecurityGroupName = "testnsg"; + const parameters: TagsObject = { tags: { tag1: "value1", tag2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkSecurityGroups.beginUpdateTagsAndWait( + resourceGroupName, + networkSecurityGroupName, + parameters + ); + console.log(result); +} + +async function main() { + updateNetworkSecurityGroupTags(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/operationsListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/operationsListSample.ts new file mode 100644 index 000000000000..939bad352ea7 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/operationsListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Lists all of the available Network Rest API operations. + * + * @summary Lists all of the available Network Rest API operations. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/OperationList.json + */ +async function getAListOfOperationsForAResourceProvider() { + const subscriptionId = + process.env["NETWORK_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getAListOfOperationsForAResourceProvider(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/publicIPAddressesCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/publicIPAddressesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..df333efefc7e --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/publicIPAddressesCreateOrUpdateSample.ts @@ -0,0 +1,96 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + PublicIPAddress, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a static or dynamic public IP address. + * + * @summary Creates or updates a static or dynamic public IP address. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressCreateDns.json + */ +async function createPublicIPAddressDns() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const publicIpAddressName = "test-ip"; + const parameters: PublicIPAddress = { + dnsSettings: { domainNameLabel: "dnslbl" } + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.publicIPAddresses.beginCreateOrUpdateAndWait( + resourceGroupName, + publicIpAddressName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a static or dynamic public IP address. + * + * @summary Creates or updates a static or dynamic public IP address. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressCreateCustomizedValues.json + */ +async function createPublicIPAddressAllocationMethod() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const publicIpAddressName = "test-ip"; + const parameters: PublicIPAddress = { + idleTimeoutInMinutes: 10, + publicIPAddressVersion: "IPv4", + publicIPAllocationMethod: "Static", + sku: { name: "Standard" } + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.publicIPAddresses.beginCreateOrUpdateAndWait( + resourceGroupName, + publicIpAddressName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a static or dynamic public IP address. + * + * @summary Creates or updates a static or dynamic public IP address. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressCreateDefaults.json + */ +async function createPublicIPAddressDefaults() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const publicIpAddressName = "test-ip"; + const parameters: PublicIPAddress = {}; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.publicIPAddresses.beginCreateOrUpdateAndWait( + resourceGroupName, + publicIpAddressName, + parameters + ); + console.log(result); +} + +async function main() { + createPublicIPAddressDns(); + createPublicIPAddressAllocationMethod(); + createPublicIPAddressDefaults(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/publicIPAddressesDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/publicIPAddressesDeleteSample.ts new file mode 100644 index 000000000000..6e7c0d6dc519 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/publicIPAddressesDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified public IP address. + * + * @summary Deletes the specified public IP address. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressDelete.json + */ +async function deletePublicIPAddress() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const publicIpAddressName = "test-ip"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.publicIPAddresses.beginDeleteAndWait( + resourceGroupName, + publicIpAddressName + ); + console.log(result); +} + +async function main() { + deletePublicIPAddress(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/publicIPAddressesGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/publicIPAddressesGetSample.ts new file mode 100644 index 000000000000..450428f16f8c --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/publicIPAddressesGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified public IP address in a specified resource group. + * + * @summary Gets the specified public IP address in a specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressGet.json + */ +async function getPublicIPAddress() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const publicIpAddressName = "testDNS-ip"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.publicIPAddresses.get( + resourceGroupName, + publicIpAddressName + ); + console.log(result); +} + +async function main() { + getPublicIPAddress(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/publicIPAddressesListAllSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/publicIPAddressesListAllSample.ts new file mode 100644 index 000000000000..be3867944bf9 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/publicIPAddressesListAllSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all the public IP addresses in a subscription. + * + * @summary Gets all the public IP addresses in a subscription. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressListAll.json + */ +async function listAllPublicIPAddresses() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.publicIPAddresses.listAll()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAllPublicIPAddresses(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/publicIPAddressesListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/publicIPAddressesListSample.ts new file mode 100644 index 000000000000..35c93fab9890 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/publicIPAddressesListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all public IP addresses in a resource group. + * + * @summary Gets all public IP addresses in a resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressList.json + */ +async function listResourceGroupPublicIPAddresses() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.publicIPAddresses.list(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listResourceGroupPublicIPAddresses(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/publicIPAddressesUpdateTagsSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/publicIPAddressesUpdateTagsSample.ts new file mode 100644 index 000000000000..c354f328e563 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/publicIPAddressesUpdateTagsSample.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 { + TagsObject, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Updates public IP address tags. + * + * @summary Updates public IP address tags. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressUpdateTags.json + */ +async function updatePublicIPAddressTags() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const publicIpAddressName = "test-ip"; + const parameters: TagsObject = { tags: { tag1: "value1", tag2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.publicIPAddresses.beginUpdateTagsAndWait( + resourceGroupName, + publicIpAddressName, + parameters + ); + console.log(result); +} + +async function main() { + updatePublicIPAddressTags(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routeTablesCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routeTablesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..d0e1b8e55903 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routeTablesCreateOrUpdateSample.ts @@ -0,0 +1,77 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RouteTable, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Create or updates a route table in a specified resource group. + * + * @summary Create or updates a route table in a specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableCreate.json + */ +async function createRouteTable() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const routeTableName = "testrt"; + const parameters: RouteTable = { location: "westus" }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.routeTables.beginCreateOrUpdateAndWait( + resourceGroupName, + routeTableName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Create or updates a route table in a specified resource group. + * + * @summary Create or updates a route table in a specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableCreateWithRoute.json + */ +async function createRouteTableWithRoute() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const routeTableName = "testrt"; + const parameters: RouteTable = { + disableBgpRoutePropagation: true, + location: "westus", + routes: [ + { + name: "route1", + addressPrefix: "10.0.3.0/24", + nextHopType: "VirtualNetworkGateway" + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.routeTables.beginCreateOrUpdateAndWait( + resourceGroupName, + routeTableName, + parameters + ); + console.log(result); +} + +async function main() { + createRouteTable(); + createRouteTableWithRoute(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routeTablesDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routeTablesDeleteSample.ts new file mode 100644 index 000000000000..94c5e4b2ea2f --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routeTablesDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified route table. + * + * @summary Deletes the specified route table. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableDelete.json + */ +async function deleteRouteTable() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const routeTableName = "testrt"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.routeTables.beginDeleteAndWait( + resourceGroupName, + routeTableName + ); + console.log(result); +} + +async function main() { + deleteRouteTable(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routeTablesGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routeTablesGetSample.ts new file mode 100644 index 000000000000..e71cc1e28dea --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routeTablesGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified route table. + * + * @summary Gets the specified route table. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableGet.json + */ +async function getRouteTable() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const routeTableName = "testrt"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.routeTables.get( + resourceGroupName, + routeTableName + ); + console.log(result); +} + +async function main() { + getRouteTable(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routeTablesListAllSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routeTablesListAllSample.ts new file mode 100644 index 000000000000..9ac691d7240d --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routeTablesListAllSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all route tables in a subscription. + * + * @summary Gets all route tables in a subscription. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableListAll.json + */ +async function listAllRouteTables() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.routeTables.listAll()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAllRouteTables(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routeTablesListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routeTablesListSample.ts new file mode 100644 index 000000000000..30e9741c3642 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routeTablesListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all route tables in a resource group. + * + * @summary Gets all route tables in a resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableList.json + */ +async function listRouteTablesInResourceGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.routeTables.list(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listRouteTablesInResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routeTablesUpdateTagsSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routeTablesUpdateTagsSample.ts new file mode 100644 index 000000000000..2f0cdfb0a290 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routeTablesUpdateTagsSample.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 { + TagsObject, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Updates a route table tags. + * + * @summary Updates a route table tags. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableUpdateTags.json + */ +async function updateRouteTableTags() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const routeTableName = "testrt"; + const parameters: TagsObject = { tags: { tag1: "value1", tag2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.routeTables.beginUpdateTagsAndWait( + resourceGroupName, + routeTableName, + parameters + ); + console.log(result); +} + +async function main() { + updateRouteTableTags(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routesCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..f6cff652a0c3 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routesCreateOrUpdateSample.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 { + Route, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a route in the specified route table. + * + * @summary Creates or updates a route in the specified route table. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableRouteCreate.json + */ +async function createRoute() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const routeTableName = "testrt"; + const routeName = "route1"; + const routeParameters: Route = { + addressPrefix: "10.0.3.0/24", + nextHopType: "VirtualNetworkGateway" + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.routes.beginCreateOrUpdateAndWait( + resourceGroupName, + routeTableName, + routeName, + routeParameters + ); + console.log(result); +} + +async function main() { + createRoute(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routesDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routesDeleteSample.ts new file mode 100644 index 000000000000..86d30c271432 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routesDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified route from a route table. + * + * @summary Deletes the specified route from a route table. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableRouteDelete.json + */ +async function deleteRoute() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const routeTableName = "testrt"; + const routeName = "route1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.routes.beginDeleteAndWait( + resourceGroupName, + routeTableName, + routeName + ); + console.log(result); +} + +async function main() { + deleteRoute(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routesGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routesGetSample.ts new file mode 100644 index 000000000000..9935200cb332 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routesGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified route from a route table. + * + * @summary Gets the specified route from a route table. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableRouteGet.json + */ +async function getRoute() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const routeTableName = "testrt"; + const routeName = "route1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.routes.get( + resourceGroupName, + routeTableName, + routeName + ); + console.log(result); +} + +async function main() { + getRoute(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routesListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routesListSample.ts new file mode 100644 index 000000000000..2f3c6ed7127c --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/routesListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all routes in a route table. + * + * @summary Gets all routes in a route table. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableRouteList.json + */ +async function listRoutes() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const routeTableName = "testrt"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.routes.list( + resourceGroupName, + routeTableName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listRoutes(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/securityRulesCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/securityRulesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..5cb01c7d8eab --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/securityRulesCreateOrUpdateSample.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + SecurityRule, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a security rule in the specified network security group. + * + * @summary Creates or updates a security rule in the specified network security group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupRuleCreate.json + */ +async function createSecurityRule() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkSecurityGroupName = "testnsg"; + const securityRuleName = "rule1"; + const securityRuleParameters: SecurityRule = { + access: "Deny", + destinationAddressPrefix: "11.0.0.0/8", + destinationPortRange: "8080", + direction: "Outbound", + priority: 100, + sourceAddressPrefix: "10.0.0.0/8", + sourcePortRange: "*", + protocol: "*" + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.securityRules.beginCreateOrUpdateAndWait( + resourceGroupName, + networkSecurityGroupName, + securityRuleName, + securityRuleParameters + ); + console.log(result); +} + +async function main() { + createSecurityRule(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/securityRulesDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/securityRulesDeleteSample.ts new file mode 100644 index 000000000000..d3c5b1e52793 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/securityRulesDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified network security rule. + * + * @summary Deletes the specified network security rule. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupRuleDelete.json + */ +async function deleteNetworkSecurityRuleFromNetworkSecurityGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkSecurityGroupName = "testnsg"; + const securityRuleName = "rule1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.securityRules.beginDeleteAndWait( + resourceGroupName, + networkSecurityGroupName, + securityRuleName + ); + console.log(result); +} + +async function main() { + deleteNetworkSecurityRuleFromNetworkSecurityGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/securityRulesGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/securityRulesGetSample.ts new file mode 100644 index 000000000000..8435956252db --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/securityRulesGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get the specified network security rule. + * + * @summary Get the specified network security rule. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupRuleGet.json + */ +async function getNetworkSecurityRuleInNetworkSecurityGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkSecurityGroupName = "testnsg"; + const securityRuleName = "rule1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.securityRules.get( + resourceGroupName, + networkSecurityGroupName, + securityRuleName + ); + console.log(result); +} + +async function main() { + getNetworkSecurityRuleInNetworkSecurityGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/securityRulesListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/securityRulesListSample.ts new file mode 100644 index 000000000000..fa239129ce4d --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/securityRulesListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all security rules in a network security group. + * + * @summary Gets all security rules in a network security group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupRuleList.json + */ +async function listNetworkSecurityRulesInNetworkSecurityGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkSecurityGroupName = "testnsg"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.securityRules.list( + resourceGroupName, + networkSecurityGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listNetworkSecurityRulesInNetworkSecurityGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/subnetsCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/subnetsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..401eaff4613f --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/subnetsCreateOrUpdateSample.ts @@ -0,0 +1,101 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + Subnet, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a subnet in the specified virtual network. + * + * @summary Creates or updates a subnet in the specified virtual network. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetCreate.json + */ +async function createSubnet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = + process.env["NETWORK_RESOURCE_GROUP"] || "subnet-test"; + const virtualNetworkName = "vnetname"; + const subnetName = "subnet1"; + const subnetParameters: Subnet = { addressPrefix: "10.0.0.0/16" }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.subnets.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + subnetName, + subnetParameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a subnet in the specified virtual network. + * + * @summary Creates or updates a subnet in the specified virtual network. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetCreateWithDelegation.json + */ +async function createSubnetWithADelegation() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subId"; + const resourceGroupName = + process.env["NETWORK_RESOURCE_GROUP"] || "subnet-test"; + const virtualNetworkName = "vnetname"; + const subnetName = "subnet1"; + const subnetParameters: Subnet = { addressPrefix: "10.0.0.0/16" }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.subnets.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + subnetName, + subnetParameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a subnet in the specified virtual network. + * + * @summary Creates or updates a subnet in the specified virtual network. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetCreateServiceEndpoint.json + */ +async function createSubnetWithServiceEndpoints() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = + process.env["NETWORK_RESOURCE_GROUP"] || "subnet-test"; + const virtualNetworkName = "vnetname"; + const subnetName = "subnet1"; + const subnetParameters: Subnet = { + addressPrefix: "10.0.0.0/16", + serviceEndpoints: [{ service: "Microsoft.Storage" }] + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.subnets.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + subnetName, + subnetParameters + ); + console.log(result); +} + +async function main() { + createSubnet(); + createSubnetWithADelegation(); + createSubnetWithServiceEndpoints(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/subnetsDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/subnetsDeleteSample.ts new file mode 100644 index 000000000000..500c5cf7fa44 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/subnetsDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified subnet. + * + * @summary Deletes the specified subnet. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetDelete.json + */ +async function deleteSubnet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = + process.env["NETWORK_RESOURCE_GROUP"] || "subnet-test"; + const virtualNetworkName = "vnetname"; + const subnetName = "subnet1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.subnets.beginDeleteAndWait( + resourceGroupName, + virtualNetworkName, + subnetName + ); + console.log(result); +} + +async function main() { + deleteSubnet(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/subnetsGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/subnetsGetSample.ts new file mode 100644 index 000000000000..00766862551d --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/subnetsGetSample.ts @@ -0,0 +1,66 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified subnet by virtual network and resource group. + * + * @summary Gets the specified subnet by virtual network and resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetGet.json + */ +async function getSubnet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = + process.env["NETWORK_RESOURCE_GROUP"] || "subnet-test"; + const virtualNetworkName = "vnetname"; + const subnetName = "subnet1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.subnets.get( + resourceGroupName, + virtualNetworkName, + subnetName + ); + console.log(result); +} + +/** + * This sample demonstrates how to Gets the specified subnet by virtual network and resource group. + * + * @summary Gets the specified subnet by virtual network and resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetGetWithDelegation.json + */ +async function getSubnetWithADelegation() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subId"; + const resourceGroupName = + process.env["NETWORK_RESOURCE_GROUP"] || "subnet-test"; + const virtualNetworkName = "vnetname"; + const subnetName = "subnet1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.subnets.get( + resourceGroupName, + virtualNetworkName, + subnetName + ); + console.log(result); +} + +async function main() { + getSubnet(); + getSubnetWithADelegation(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/subnetsListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/subnetsListSample.ts new file mode 100644 index 000000000000..7fd21249a1ef --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/subnetsListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all subnets in a virtual network. + * + * @summary Gets all subnets in a virtual network. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetList.json + */ +async function listSubnets() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = + process.env["NETWORK_RESOURCE_GROUP"] || "subnet-test"; + const virtualNetworkName = "vnetname"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.subnets.list( + resourceGroupName, + virtualNetworkName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listSubnets(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewayConnectionsCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewayConnectionsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..f01c4ef18bfb --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewayConnectionsCreateOrUpdateSample.ts @@ -0,0 +1,99 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + VirtualNetworkGatewayConnection, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a virtual network gateway connection in the specified resource group. + * + * @summary Creates or updates a virtual network gateway connection in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionCreate.json + */ +async function createVirtualNetworkGatewayConnectionS2S() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayConnectionName = "connS2S"; + const parameters: VirtualNetworkGatewayConnection = { + connectionProtocol: "IKEv2", + connectionType: "IPsec", + enableBgp: false, + ipsecPolicies: [], + localNetworkGateway2: { + etag: 'W/"00000000-0000-0000-0000-000000000000"', + gatewayIpAddress: "x.x.x.x", + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/localNetworkGateways/localgw", + localNetworkAddressSpace: { addressPrefixes: ["10.1.0.0/16"] }, + location: "centralus", + resourceGuid: "00000000-0000-0000-0000-000000000000", + tags: {} + }, + location: "centralus", + routingWeight: 0, + sharedKey: "Abc123", + usePolicyBasedTrafficSelectors: false, + virtualNetworkGateway1: { + active: false, + bgpSettings: { + asn: 65514, + bgpPeeringAddress: "10.0.1.30", + peerWeight: 0 + }, + enableBgp: false, + etag: 'W/"00000000-0000-0000-0000-000000000000"', + gatewayType: "Vpn", + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw", + ipConfigurations: [ + { + name: "gwipconfig1", + etag: 'W/"00000000-0000-0000-0000-000000000000"', + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw/ipConfigurations/gwipconfig1", + privateIPAllocationMethod: "Dynamic", + publicIPAddress: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/gwpip" + }, + subnet: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/GatewaySubnet" + } + } + ], + location: "centralus", + resourceGuid: "00000000-0000-0000-0000-000000000000", + sku: { name: "VpnGw1", capacity: 2, tier: "VpnGw1" }, + tags: {}, + vpnType: "RouteBased" + } + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGatewayConnections.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkGatewayConnectionName, + parameters + ); + console.log(result); +} + +async function main() { + createVirtualNetworkGatewayConnectionS2S(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewayConnectionsDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewayConnectionsDeleteSample.ts new file mode 100644 index 000000000000..a40085b36f9c --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewayConnectionsDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified virtual network Gateway connection. + * + * @summary Deletes the specified virtual network Gateway connection. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionDelete.json + */ +async function deleteVirtualNetworkGatewayConnection() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayConnectionName = "conn1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGatewayConnections.beginDeleteAndWait( + resourceGroupName, + virtualNetworkGatewayConnectionName + ); + console.log(result); +} + +async function main() { + deleteVirtualNetworkGatewayConnection(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewayConnectionsGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewayConnectionsGetSample.ts new file mode 100644 index 000000000000..e1161185363d --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewayConnectionsGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified virtual network gateway connection by resource group. + * + * @summary Gets the specified virtual network gateway connection by resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionGet.json + */ +async function getVirtualNetworkGatewayConnection() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayConnectionName = "connS2S"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGatewayConnections.get( + resourceGroupName, + virtualNetworkGatewayConnectionName + ); + console.log(result); +} + +async function main() { + getVirtualNetworkGatewayConnection(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewayConnectionsGetSharedKeySample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewayConnectionsGetSharedKeySample.ts new file mode 100644 index 000000000000..8737367d23c1 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewayConnectionsGetSharedKeySample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to The Get VirtualNetworkGatewayConnectionSharedKey operation retrieves information about the specified virtual network gateway connection shared key through Network resource provider. + * + * @summary The Get VirtualNetworkGatewayConnectionSharedKey operation retrieves information about the specified virtual network gateway connection shared key through Network resource provider. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionGetSharedKey.json + */ +async function getVirtualNetworkGatewayConnectionSharedKey() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayConnectionName = "connS2S"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGatewayConnections.getSharedKey( + resourceGroupName, + virtualNetworkGatewayConnectionName + ); + console.log(result); +} + +async function main() { + getVirtualNetworkGatewayConnectionSharedKey(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewayConnectionsListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewayConnectionsListSample.ts new file mode 100644 index 000000000000..4bf12d700a63 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewayConnectionsListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to The List VirtualNetworkGatewayConnections operation retrieves all the virtual network gateways connections created. + * + * @summary The List VirtualNetworkGatewayConnections operation retrieves all the virtual network gateways connections created. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionsList.json + */ +async function listVirtualNetworkGatewayConnectionsinResourceGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.virtualNetworkGatewayConnections.list( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listVirtualNetworkGatewayConnectionsinResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewayConnectionsResetSharedKeySample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewayConnectionsResetSharedKeySample.ts new file mode 100644 index 000000000000..38c56fcfc1b2 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewayConnectionsResetSharedKeySample.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 { + ConnectionResetSharedKey, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to The VirtualNetworkGatewayConnectionResetSharedKey operation resets the virtual network gateway connection shared key for passed virtual network gateway connection in the specified resource group through Network resource provider. + * + * @summary The VirtualNetworkGatewayConnectionResetSharedKey operation resets the virtual network gateway connection shared key for passed virtual network gateway connection in the specified resource group through Network resource provider. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionResetSharedKey.json + */ +async function resetVirtualNetworkGatewayConnectionSharedKey() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayConnectionName = "conn1"; + const parameters: ConnectionResetSharedKey = { keyLength: 128 }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGatewayConnections.beginResetSharedKeyAndWait( + resourceGroupName, + virtualNetworkGatewayConnectionName, + parameters + ); + console.log(result); +} + +async function main() { + resetVirtualNetworkGatewayConnectionSharedKey(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewayConnectionsSetSharedKeySample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewayConnectionsSetSharedKeySample.ts new file mode 100644 index 000000000000..d30e092d1b4a --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewayConnectionsSetSharedKeySample.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 { + ConnectionSharedKey, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to The Put VirtualNetworkGatewayConnectionSharedKey operation sets the virtual network gateway connection shared key for passed virtual network gateway connection in the specified resource group through Network resource provider. + * + * @summary The Put VirtualNetworkGatewayConnectionSharedKey operation sets the virtual network gateway connection shared key for passed virtual network gateway connection in the specified resource group through Network resource provider. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionSetSharedKey.json + */ +async function setVirtualNetworkGatewayConnectionSharedKey() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayConnectionName = "connS2S"; + const parameters: ConnectionSharedKey = { value: "AzureAbc123" }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGatewayConnections.beginSetSharedKeyAndWait( + resourceGroupName, + virtualNetworkGatewayConnectionName, + parameters + ); + console.log(result); +} + +async function main() { + setVirtualNetworkGatewayConnectionSharedKey(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewayConnectionsUpdateTagsSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewayConnectionsUpdateTagsSample.ts new file mode 100644 index 000000000000..914ddd96d47a --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewayConnectionsUpdateTagsSample.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 { + TagsObject, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Updates a virtual network gateway connection tags. + * + * @summary Updates a virtual network gateway connection tags. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionUpdateTags.json + */ +async function updateVirtualNetworkGatewayConnectionTags() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayConnectionName = "test"; + const parameters: TagsObject = { tags: { tag1: "value1", tag2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGatewayConnections.beginUpdateTagsAndWait( + resourceGroupName, + virtualNetworkGatewayConnectionName, + parameters + ); + console.log(result); +} + +async function main() { + updateVirtualNetworkGatewayConnectionTags(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysCreateOrUpdateSample.ts new file mode 100644 index 000000000000..6bd4a5991ed6 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysCreateOrUpdateSample.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 { + VirtualNetworkGateway, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a virtual network gateway in the specified resource group. + * + * @summary Creates or updates a virtual network gateway in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayUpdate.json + */ +async function updateVirtualNetworkGateway() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const parameters: VirtualNetworkGateway = { + active: false, + bgpSettings: { asn: 65515, bgpPeeringAddress: "10.0.1.30", peerWeight: 0 }, + enableBgp: false, + gatewayType: "Vpn", + ipConfigurations: [ + { + name: "gwipconfig1", + privateIPAllocationMethod: "Dynamic", + publicIPAddress: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/gwpip" + }, + subnet: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/GatewaySubnet" + } + } + ], + location: "centralus", + sku: { name: "VpnGw1", tier: "VpnGw1" }, + vpnType: "RouteBased" + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkGatewayName, + parameters + ); + console.log(result); +} + +async function main() { + updateVirtualNetworkGateway(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysDeleteSample.ts new file mode 100644 index 000000000000..94b0f59822fb --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified virtual network gateway. + * + * @summary Deletes the specified virtual network gateway. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayDelete.json + */ +async function deleteVirtualNetworkGateway() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginDeleteAndWait( + resourceGroupName, + virtualNetworkGatewayName + ); + console.log(result); +} + +async function main() { + deleteVirtualNetworkGateway(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysGenerateVpnProfileSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysGenerateVpnProfileSample.ts new file mode 100644 index 000000000000..e49652b085e0 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysGenerateVpnProfileSample.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 { + VpnClientParameters, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Generates VPN profile for P2S client of the virtual network gateway in the specified resource group. Used for IKEV2 and radius based authentication. + * + * @summary Generates VPN profile for P2S client of the virtual network gateway in the specified resource group. Used for IKEV2 and radius based authentication. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGenerateVpnProfile.json + */ +async function generateVirtualNetworkGatewayVpnProfile() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const parameters: VpnClientParameters = {}; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginGenerateVpnProfileAndWait( + resourceGroupName, + virtualNetworkGatewayName, + parameters + ); + console.log(result); +} + +async function main() { + generateVirtualNetworkGatewayVpnProfile(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysGeneratevpnclientpackageSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysGeneratevpnclientpackageSample.ts new file mode 100644 index 000000000000..e74145bdf0c8 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysGeneratevpnclientpackageSample.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 { + VpnClientParameters, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Generates VPN client package for P2S client of the virtual network gateway in the specified resource group. + * + * @summary Generates VPN client package for P2S client of the virtual network gateway in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGenerateVpnClientPackage.json + */ +async function generateVpnClientPackage() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const parameters: VpnClientParameters = {}; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginGeneratevpnclientpackageAndWait( + resourceGroupName, + virtualNetworkGatewayName, + parameters + ); + console.log(result); +} + +async function main() { + generateVpnClientPackage(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysGetAdvertisedRoutesSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysGetAdvertisedRoutesSample.ts new file mode 100644 index 000000000000..b1da6b083f40 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysGetAdvertisedRoutesSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to This operation retrieves a list of routes the virtual network gateway is advertising to the specified peer. + * + * @summary This operation retrieves a list of routes the virtual network gateway is advertising to the specified peer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGetAdvertisedRoutes.json + */ +async function getVirtualNetworkGatewayAdvertisedRoutes() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const peer = "test"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginGetAdvertisedRoutesAndWait( + resourceGroupName, + virtualNetworkGatewayName, + peer + ); + console.log(result); +} + +async function main() { + getVirtualNetworkGatewayAdvertisedRoutes(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysGetBgpPeerStatusSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysGetBgpPeerStatusSample.ts new file mode 100644 index 000000000000..c671191e080e --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysGetBgpPeerStatusSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to The GetBgpPeerStatus operation retrieves the status of all BGP peers. + * + * @summary The GetBgpPeerStatus operation retrieves the status of all BGP peers. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGetBGPPeerStatus.json + */ +async function getVirtualNetworkGatewayBgpPeerStatus() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginGetBgpPeerStatusAndWait( + resourceGroupName, + virtualNetworkGatewayName + ); + console.log(result); +} + +async function main() { + getVirtualNetworkGatewayBgpPeerStatus(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysGetLearnedRoutesSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysGetLearnedRoutesSample.ts new file mode 100644 index 000000000000..a5df31de5f05 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysGetLearnedRoutesSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to This operation retrieves a list of routes the virtual network gateway has learned, including routes learned from BGP peers. + * + * @summary This operation retrieves a list of routes the virtual network gateway has learned, including routes learned from BGP peers. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayLearnedRoutes.json + */ +async function getVirtualNetworkGatewayLearnedRoutes() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginGetLearnedRoutesAndWait( + resourceGroupName, + virtualNetworkGatewayName + ); + console.log(result); +} + +async function main() { + getVirtualNetworkGatewayLearnedRoutes(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysGetSample.ts new file mode 100644 index 000000000000..75fb2ee13d4d --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified virtual network gateway by resource group. + * + * @summary Gets the specified virtual network gateway by resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGet.json + */ +async function getVirtualNetworkGateway() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.get( + resourceGroupName, + virtualNetworkGatewayName + ); + console.log(result); +} + +async function main() { + getVirtualNetworkGateway(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysGetVpnProfilePackageUrlSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysGetVpnProfilePackageUrlSample.ts new file mode 100644 index 000000000000..d3408f8d40f9 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysGetVpnProfilePackageUrlSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets pre-generated VPN profile for P2S client of the virtual network gateway in the specified resource group. The profile needs to be generated first using generateVpnProfile. + * + * @summary Gets pre-generated VPN profile for P2S client of the virtual network gateway in the specified resource group. The profile needs to be generated first using generateVpnProfile. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGetVpnProfilePackageUrl.json + */ +async function getVirtualNetworkGatewayVpnProfilePackageUrl() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginGetVpnProfilePackageUrlAndWait( + resourceGroupName, + virtualNetworkGatewayName + ); + console.log(result); +} + +async function main() { + getVirtualNetworkGatewayVpnProfilePackageUrl(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysGetVpnclientIpsecParametersSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysGetVpnclientIpsecParametersSample.ts new file mode 100644 index 000000000000..19346eed6cb3 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysGetVpnclientIpsecParametersSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to The Get VpnclientIpsecParameters operation retrieves information about the vpnclient ipsec policy for P2S client of virtual network gateway in the specified resource group through Network resource provider. + * + * @summary The Get VpnclientIpsecParameters operation retrieves information about the vpnclient ipsec policy for P2S client of virtual network gateway in the specified resource group through Network resource provider. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGetVpnClientIpsecParameters.json + */ +async function getVirtualNetworkGatewayVpnClientIpsecParameters() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginGetVpnclientIpsecParametersAndWait( + resourceGroupName, + virtualNetworkGatewayName + ); + console.log(result); +} + +async function main() { + getVirtualNetworkGatewayVpnClientIpsecParameters(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysListConnectionsSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysListConnectionsSample.ts new file mode 100644 index 000000000000..d2a58336a3c1 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysListConnectionsSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all the connections in a virtual network gateway. + * + * @summary Gets all the connections in a virtual network gateway. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewaysListConnections.json + */ +async function virtualNetworkGatewaysListConnections() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const virtualNetworkGatewayName = "test-vpn-gateway-1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.virtualNetworkGateways.listConnections( + resourceGroupName, + virtualNetworkGatewayName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + virtualNetworkGatewaysListConnections(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysListSample.ts new file mode 100644 index 000000000000..e17ba6c6ab0c --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all virtual network gateways by resource group. + * + * @summary Gets all virtual network gateways by resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayList.json + */ +async function listVirtualNetworkGatewaysinResourceGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.virtualNetworkGateways.list( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listVirtualNetworkGatewaysinResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysResetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysResetSample.ts new file mode 100644 index 000000000000..0b22d71d4c89 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysResetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Resets the primary of the virtual network gateway in the specified resource group. + * + * @summary Resets the primary of the virtual network gateway in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayReset.json + */ +async function resetVirtualNetworkGateway() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginResetAndWait( + resourceGroupName, + virtualNetworkGatewayName + ); + console.log(result); +} + +async function main() { + resetVirtualNetworkGateway(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysResetVpnClientSharedKeySample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysResetVpnClientSharedKeySample.ts new file mode 100644 index 000000000000..4cf577c83d59 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysResetVpnClientSharedKeySample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Resets the VPN client shared key of the virtual network gateway in the specified resource group. + * + * @summary Resets the VPN client shared key of the virtual network gateway in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayResetVpnClientSharedKey.json + */ +async function resetVpnClientSharedKey() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginResetVpnClientSharedKeyAndWait( + resourceGroupName, + virtualNetworkGatewayName + ); + console.log(result); +} + +async function main() { + resetVpnClientSharedKey(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysSetVpnclientIpsecParametersSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysSetVpnclientIpsecParametersSample.ts new file mode 100644 index 000000000000..c25798106cfc --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysSetVpnclientIpsecParametersSample.ts @@ -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. +import { + VpnClientIPsecParameters, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to The Set VpnclientIpsecParameters operation sets the vpnclient ipsec policy for P2S client of virtual network gateway in the specified resource group through Network resource provider. + * + * @summary The Set VpnclientIpsecParameters operation sets the vpnclient ipsec policy for P2S client of virtual network gateway in the specified resource group through Network resource provider. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewaySetVpnClientIpsecParameters.json + */ +async function setVirtualNetworkGatewayVpnClientIpsecParameters() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const vpnclientIpsecParams: VpnClientIPsecParameters = { + dhGroup: "DHGroup2", + ikeEncryption: "AES256", + ikeIntegrity: "SHA384", + ipsecEncryption: "AES256", + ipsecIntegrity: "SHA256", + pfsGroup: "PFS2", + saDataSizeKilobytes: 429497, + saLifeTimeSeconds: 86473 + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginSetVpnclientIpsecParametersAndWait( + resourceGroupName, + virtualNetworkGatewayName, + vpnclientIpsecParams + ); + console.log(result); +} + +async function main() { + setVirtualNetworkGatewayVpnClientIpsecParameters(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysSupportedVpnDevicesSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysSupportedVpnDevicesSample.ts new file mode 100644 index 000000000000..2d72e9103717 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysSupportedVpnDevicesSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets a xml format representation for supported vpn devices. + * + * @summary Gets a xml format representation for supported vpn devices. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewaySupportedVpnDevice.json + */ +async function listVirtualNetworkGatewaySupportedVpnDevices() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.supportedVpnDevices( + resourceGroupName, + virtualNetworkGatewayName + ); + console.log(result); +} + +async function main() { + listVirtualNetworkGatewaySupportedVpnDevices(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysUpdateTagsSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysUpdateTagsSample.ts new file mode 100644 index 000000000000..e61eacf627ef --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysUpdateTagsSample.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 { + TagsObject, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Updates a virtual network gateway tags. + * + * @summary Updates a virtual network gateway tags. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayUpdateTags.json + */ +async function updateVirtualNetworkGatewayTags() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const parameters: TagsObject = { tags: { tag1: "value1", tag2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginUpdateTagsAndWait( + resourceGroupName, + virtualNetworkGatewayName, + parameters + ); + console.log(result); +} + +async function main() { + updateVirtualNetworkGatewayTags(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysVpnDeviceConfigurationScriptSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysVpnDeviceConfigurationScriptSample.ts new file mode 100644 index 000000000000..35b67a7ab20b --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkGatewaysVpnDeviceConfigurationScriptSample.ts @@ -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. +import { + VpnDeviceScriptParameters, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets a xml format representation for vpn device configuration script. + * + * @summary Gets a xml format representation for vpn device configuration script. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayVpnDeviceConfigurationScript.json + */ +async function getVpnDeviceConfigurationScript() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayConnectionName = "vpngw"; + const parameters: VpnDeviceScriptParameters = { + deviceFamily: "ISR", + firmwareVersion: "IOS 15.1 (Preview)", + vendor: "Cisco" + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.vpnDeviceConfigurationScript( + resourceGroupName, + virtualNetworkGatewayConnectionName, + parameters + ); + console.log(result); +} + +async function main() { + getVpnDeviceConfigurationScript(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkPeeringsCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkPeeringsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..af1aa3669d07 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkPeeringsCreateOrUpdateSample.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + VirtualNetworkPeering, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a peering in the specified virtual network. + * + * @summary Creates or updates a peering in the specified virtual network. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkPeeringCreate.json + */ +async function createPeering() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "peerTest"; + const virtualNetworkName = "vnet1"; + const virtualNetworkPeeringName = "peer"; + const virtualNetworkPeeringParameters: VirtualNetworkPeering = { + allowForwardedTraffic: true, + allowGatewayTransit: false, + allowVirtualNetworkAccess: true, + remoteVirtualNetwork: { + id: + "/subscriptions/subid/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet2" + }, + useRemoteGateways: false + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkPeerings.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + virtualNetworkPeeringName, + virtualNetworkPeeringParameters + ); + console.log(result); +} + +async function main() { + createPeering(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkPeeringsDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkPeeringsDeleteSample.ts new file mode 100644 index 000000000000..f59f001d8bad --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkPeeringsDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified virtual network peering. + * + * @summary Deletes the specified virtual network peering. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkPeeringDelete.json + */ +async function deletePeering() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "peerTest"; + const virtualNetworkName = "vnet1"; + const virtualNetworkPeeringName = "peer"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkPeerings.beginDeleteAndWait( + resourceGroupName, + virtualNetworkName, + virtualNetworkPeeringName + ); + console.log(result); +} + +async function main() { + deletePeering(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkPeeringsGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkPeeringsGetSample.ts new file mode 100644 index 000000000000..1a90b18d7c3b --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkPeeringsGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified virtual network peering. + * + * @summary Gets the specified virtual network peering. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkPeeringGet.json + */ +async function getPeering() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "peerTest"; + const virtualNetworkName = "vnet1"; + const virtualNetworkPeeringName = "peer"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkPeerings.get( + resourceGroupName, + virtualNetworkName, + virtualNetworkPeeringName + ); + console.log(result); +} + +async function main() { + getPeering(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkPeeringsListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkPeeringsListSample.ts new file mode 100644 index 000000000000..4d99cad017f6 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworkPeeringsListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all virtual network peerings in a virtual network. + * + * @summary Gets all virtual network peerings in a virtual network. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkPeeringList.json + */ +async function listPeerings() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "peerTest"; + const virtualNetworkName = "vnet1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.virtualNetworkPeerings.list( + resourceGroupName, + virtualNetworkName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listPeerings(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworksCheckIPAddressAvailabilitySample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworksCheckIPAddressAvailabilitySample.ts new file mode 100644 index 000000000000..b35415163265 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworksCheckIPAddressAvailabilitySample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Checks whether a private IP address is available for use. + * + * @summary Checks whether a private IP address is available for use. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkCheckIPAddressAvailability.json + */ +async function checkIPAddressAvailability() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const ipAddress = "10.0.1.4"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.checkIPAddressAvailability( + resourceGroupName, + virtualNetworkName, + ipAddress + ); + console.log(result); +} + +async function main() { + checkIPAddressAvailability(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworksCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworksCreateOrUpdateSample.ts new file mode 100644 index 000000000000..8efb093410a4 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworksCreateOrUpdateSample.ts @@ -0,0 +1,204 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + VirtualNetwork, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a virtual network in the specified resource group. + * + * @summary Creates or updates a virtual network in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkCreate.json + */ +async function createVirtualNetwork() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const parameters: VirtualNetwork = { + addressSpace: { addressPrefixes: ["10.0.0.0/16"] } + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a virtual network in the specified resource group. + * + * @summary Creates or updates a virtual network in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkCreateSubnetWithDelegation.json + */ +async function createVirtualNetworkWithDelegatedSubnets() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subId"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const parameters: VirtualNetwork = { + addressSpace: { addressPrefixes: ["10.0.0.0/16"] }, + subnets: [ + { + name: "test-1", + addressPrefix: "10.0.0.0/24", + delegations: [ + { + name: "myDelegation", + serviceName: "Microsoft.Provider/resourceType" + } + ] + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a virtual network in the specified resource group. + * + * @summary Creates or updates a virtual network in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkCreateServiceEndpoints.json + */ +async function createVirtualNetworkWithServiceEndpoints() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "vnetTest"; + const virtualNetworkName = "vnet1"; + const parameters: VirtualNetwork = { + addressSpace: { addressPrefixes: ["10.0.0.0/16"] }, + subnets: [ + { + name: "test-1", + addressPrefix: "10.0.0.0/16", + serviceEndpoints: [{ service: "Microsoft.Storage" }] + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a virtual network in the specified resource group. + * + * @summary Creates or updates a virtual network in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkCreateServiceEndpointPolicy.json + */ +async function createVirtualNetworkWithServiceEndpointsAndServiceEndpointPolicy() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "vnetTest"; + const virtualNetworkName = "vnet1"; + const parameters: VirtualNetwork = { + addressSpace: { addressPrefixes: ["10.0.0.0/16"] }, + location: "eastus", + subnets: [ + { + name: "test-1", + addressPrefix: "10.0.0.0/16", + serviceEndpointPolicies: [ + { + id: + "/subscriptions/subid/resourceGroups/vnetTest/providers/Microsoft.Network/serviceEndpointPolicies/ServiceEndpointPolicy1" + } + ], + serviceEndpoints: [{ service: "Microsoft.Storage" }] + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a virtual network in the specified resource group. + * + * @summary Creates or updates a virtual network in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkCreateSubnet.json + */ +async function createVirtualNetworkWithSubnet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const parameters: VirtualNetwork = { + addressSpace: { addressPrefixes: ["10.0.0.0/16"] }, + subnets: [{ name: "test-1", addressPrefix: "10.0.0.0/24" }] + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a virtual network in the specified resource group. + * + * @summary Creates or updates a virtual network in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkCreateSubnetWithAddressPrefixes.json + */ +async function createVirtualNetworkWithSubnetContainingAddressPrefixes() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const parameters: VirtualNetwork = { + addressSpace: { addressPrefixes: ["10.0.0.0/16"] }, + subnets: [ + { name: "test-2", addressPrefixes: ["10.0.0.0/28", "10.0.1.0/28"] } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + parameters + ); + console.log(result); +} + +async function main() { + createVirtualNetwork(); + createVirtualNetworkWithDelegatedSubnets(); + createVirtualNetworkWithServiceEndpoints(); + createVirtualNetworkWithServiceEndpointsAndServiceEndpointPolicy(); + createVirtualNetworkWithSubnet(); + createVirtualNetworkWithSubnetContainingAddressPrefixes(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworksDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworksDeleteSample.ts new file mode 100644 index 000000000000..6711e00d1990 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworksDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified virtual network. + * + * @summary Deletes the specified virtual network. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkDelete.json + */ +async function deleteVirtualNetwork() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.beginDeleteAndWait( + resourceGroupName, + virtualNetworkName + ); + console.log(result); +} + +async function main() { + deleteVirtualNetwork(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworksGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworksGetSample.ts new file mode 100644 index 000000000000..6f7c6db5dc81 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworksGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified virtual network by resource group. + * + * @summary Gets the specified virtual network by resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGet.json + */ +async function getVirtualNetwork() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.get( + resourceGroupName, + virtualNetworkName + ); + console.log(result); +} + +/** + * This sample demonstrates how to Gets the specified virtual network by resource group. + * + * @summary Gets the specified virtual network by resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGetWithSubnetDelegation.json + */ +async function getVirtualNetworkWithADelegatedSubnet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subId"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.get( + resourceGroupName, + virtualNetworkName + ); + console.log(result); +} + +/** + * This sample demonstrates how to Gets the specified virtual network by resource group. + * + * @summary Gets the specified virtual network by resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGetWithServiceAssociationLink.json + */ +async function getVirtualNetworkWithServiceAssociationLinks() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subId"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.get( + resourceGroupName, + virtualNetworkName + ); + console.log(result); +} + +async function main() { + getVirtualNetwork(); + getVirtualNetworkWithADelegatedSubnet(); + getVirtualNetworkWithServiceAssociationLinks(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworksListAllSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworksListAllSample.ts new file mode 100644 index 000000000000..5d3ea03bba72 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworksListAllSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all virtual networks in a subscription. + * + * @summary Gets all virtual networks in a subscription. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkListAll.json + */ +async function listAllVirtualNetworks() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.virtualNetworks.listAll()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAllVirtualNetworks(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworksListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworksListSample.ts new file mode 100644 index 000000000000..d06cf0db25f1 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworksListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all virtual networks in a resource group. + * + * @summary Gets all virtual networks in a resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkList.json + */ +async function listVirtualNetworksInResourceGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.virtualNetworks.list(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listVirtualNetworksInResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworksListUsageSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworksListUsageSample.ts new file mode 100644 index 000000000000..8f682e2fa4ee --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworksListUsageSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Lists usage stats. + * + * @summary Lists usage stats. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkListUsage.json + */ +async function vnetGetUsage() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "vnetName"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.virtualNetworks.listUsage( + resourceGroupName, + virtualNetworkName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + vnetGetUsage(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworksUpdateTagsSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworksUpdateTagsSample.ts new file mode 100644 index 000000000000..47da9d0c9ab9 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples-dev/virtualNetworksUpdateTagsSample.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 { + TagsObject, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Updates a virtual network tags. + * + * @summary Updates a virtual network tags. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkUpdateTags.json + */ +async function updateVirtualNetworkTags() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const parameters: TagsObject = { tags: { tag1: "value1", tag2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.beginUpdateTagsAndWait( + resourceGroupName, + virtualNetworkName, + parameters + ); + console.log(result); +} + +async function main() { + updateVirtualNetworkTags(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/README.md b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/README.md new file mode 100644 index 000000000000..8f7486552719 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/README.md @@ -0,0 +1,272 @@ +# client library samples for JavaScript + +These sample programs show how to use the JavaScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| [defaultSecurityRulesGetSample.js][defaultsecurityrulesgetsample] | Get the specified default network security rule. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/DefaultSecurityRuleGet.json | +| [defaultSecurityRulesListSample.js][defaultsecurityruleslistsample] | Gets all default security rules in a network security group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/DefaultSecurityRuleList.json | +| [inboundNatRulesCreateOrUpdateSample.js][inboundnatrulescreateorupdatesample] | Creates or updates a load balancer inbound nat rule. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/InboundNatRuleCreate.json | +| [inboundNatRulesDeleteSample.js][inboundnatrulesdeletesample] | Deletes the specified load balancer inbound nat rule. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/InboundNatRuleDelete.json | +| [inboundNatRulesGetSample.js][inboundnatrulesgetsample] | Gets the specified load balancer inbound nat rule. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/InboundNatRuleGet.json | +| [inboundNatRulesListSample.js][inboundnatruleslistsample] | Gets all the inbound nat rules in a load balancer. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/InboundNatRuleList.json | +| [loadBalancerBackendAddressPoolsGetSample.js][loadbalancerbackendaddresspoolsgetsample] | Gets load balancer backend address pool. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerBackendAddressPoolGet.json | +| [loadBalancerBackendAddressPoolsListSample.js][loadbalancerbackendaddresspoolslistsample] | Gets all the load balancer backed address pools. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerBackendAddressPoolList.json | +| [loadBalancerFrontendIPConfigurationsGetSample.js][loadbalancerfrontendipconfigurationsgetsample] | Gets load balancer frontend IP configuration. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerFrontendIPConfigurationGet.json | +| [loadBalancerFrontendIPConfigurationsListSample.js][loadbalancerfrontendipconfigurationslistsample] | Gets all the load balancer frontend IP configurations. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerFrontendIPConfigurationList.json | +| [loadBalancerLoadBalancingRulesGetSample.js][loadbalancerloadbalancingrulesgetsample] | Gets the specified load balancer load balancing rule. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerLoadBalancingRuleGet.json | +| [loadBalancerLoadBalancingRulesListSample.js][loadbalancerloadbalancingruleslistsample] | Gets all the load balancing rules in a load balancer. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerLoadBalancingRuleList.json | +| [loadBalancerNetworkInterfacesListSample.js][loadbalancernetworkinterfaceslistsample] | Gets associated load balancer network interfaces. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerNetworkInterfaceListSimple.json | +| [loadBalancerOutboundRulesGetSample.js][loadbalanceroutboundrulesgetsample] | Gets the specified load balancer outbound rule. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerOutboundRuleGet.json | +| [loadBalancerOutboundRulesListSample.js][loadbalanceroutboundruleslistsample] | Gets all the outbound rules in a load balancer. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerOutboundRuleList.json | +| [loadBalancerProbesGetSample.js][loadbalancerprobesgetsample] | Gets load balancer probe. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerProbeGet.json | +| [loadBalancerProbesListSample.js][loadbalancerprobeslistsample] | Gets all the load balancer probes. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerProbeList.json | +| [loadBalancersCreateOrUpdateSample.js][loadbalancerscreateorupdatesample] | Creates or updates a load balancer. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerCreate.json | +| [loadBalancersDeleteSample.js][loadbalancersdeletesample] | Deletes the specified load balancer. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerDelete.json | +| [loadBalancersGetSample.js][loadbalancersgetsample] | Gets the specified load balancer. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerGet.json | +| [loadBalancersListAllSample.js][loadbalancerslistallsample] | Gets all the load balancers in a subscription. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerListAll.json | +| [loadBalancersListSample.js][loadbalancerslistsample] | Gets all the load balancers in a resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerList.json | +| [loadBalancersUpdateTagsSample.js][loadbalancersupdatetagssample] | Updates a load balancer tags. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerUpdateTags.json | +| [localNetworkGatewaysCreateOrUpdateSample.js][localnetworkgatewayscreateorupdatesample] | Creates or updates a local network gateway in the specified resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LocalNetworkGatewayCreate.json | +| [localNetworkGatewaysDeleteSample.js][localnetworkgatewaysdeletesample] | Deletes the specified local network gateway. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LocalNetworkGatewayDelete.json | +| [localNetworkGatewaysGetSample.js][localnetworkgatewaysgetsample] | Gets the specified local network gateway in a resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LocalNetworkGatewayGet.json | +| [localNetworkGatewaysListSample.js][localnetworkgatewayslistsample] | Gets all the local network gateways in a resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LocalNetworkGatewayList.json | +| [localNetworkGatewaysUpdateTagsSample.js][localnetworkgatewaysupdatetagssample] | Updates a local network gateway tags. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LocalNetworkGatewayUpdateTags.json | +| [networkInterfaceIPConfigurationsGetSample.js][networkinterfaceipconfigurationsgetsample] | Gets the specified network interface ip configuration. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceIPConfigurationGet.json | +| [networkInterfaceIPConfigurationsListSample.js][networkinterfaceipconfigurationslistsample] | Get all ip configurations in a network interface x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceIPConfigurationList.json | +| [networkInterfaceLoadBalancersListSample.js][networkinterfaceloadbalancerslistsample] | List all load balancers in a network interface. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceLoadBalancerList.json | +| [networkInterfaceTapConfigurationsCreateOrUpdateSample.js][networkinterfacetapconfigurationscreateorupdatesample] | Creates or updates a Tap configuration in the specified NetworkInterface. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceTapConfigurationCreate.json | +| [networkInterfaceTapConfigurationsDeleteSample.js][networkinterfacetapconfigurationsdeletesample] | Deletes the specified tap configuration from the NetworkInterface. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceTapConfigurationDelete.json | +| [networkInterfaceTapConfigurationsGetSample.js][networkinterfacetapconfigurationsgetsample] | Get the specified tap configuration on a network interface. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceTapConfigurationGet.json | +| [networkInterfaceTapConfigurationsListSample.js][networkinterfacetapconfigurationslistsample] | Get all Tap configurations in a network interface x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceTapConfigurationList.json | +| [networkInterfacesCreateOrUpdateSample.js][networkinterfacescreateorupdatesample] | Creates or updates a network interface. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceCreate.json | +| [networkInterfacesDeleteSample.js][networkinterfacesdeletesample] | Deletes the specified network interface. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceDelete.json | +| [networkInterfacesGetEffectiveRouteTableSample.js][networkinterfacesgeteffectiveroutetablesample] | Gets all route tables applied to a network interface. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceEffectiveRouteTableList.json | +| [networkInterfacesGetSample.js][networkinterfacesgetsample] | Gets information about the specified network interface. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceGet.json | +| [networkInterfacesListAllSample.js][networkinterfaceslistallsample] | Gets all network interfaces in a subscription. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceListAll.json | +| [networkInterfacesListEffectiveNetworkSecurityGroupsSample.js][networkinterfaceslisteffectivenetworksecuritygroupssample] | Gets all network security groups applied to a network interface. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceEffectiveNSGList.json | +| [networkInterfacesListSample.js][networkinterfaceslistsample] | Gets all network interfaces in a resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceList.json | +| [networkInterfacesUpdateTagsSample.js][networkinterfacesupdatetagssample] | Updates a network interface tags. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceUpdateTags.json | +| [networkSecurityGroupsCreateOrUpdateSample.js][networksecuritygroupscreateorupdatesample] | Creates or updates a network security group in the specified resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupCreate.json | +| [networkSecurityGroupsDeleteSample.js][networksecuritygroupsdeletesample] | Deletes the specified network security group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupDelete.json | +| [networkSecurityGroupsGetSample.js][networksecuritygroupsgetsample] | Gets the specified network security group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupGet.json | +| [networkSecurityGroupsListAllSample.js][networksecuritygroupslistallsample] | Gets all network security groups in a subscription. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupListAll.json | +| [networkSecurityGroupsListSample.js][networksecuritygroupslistsample] | Gets all network security groups in a resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupList.json | +| [networkSecurityGroupsUpdateTagsSample.js][networksecuritygroupsupdatetagssample] | Updates a network security group tags. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupUpdateTags.json | +| [operationsListSample.js][operationslistsample] | Lists all of the available Network Rest API operations. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/OperationList.json | +| [publicIPAddressesCreateOrUpdateSample.js][publicipaddressescreateorupdatesample] | Creates or updates a static or dynamic public IP address. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressCreateDns.json | +| [publicIPAddressesDeleteSample.js][publicipaddressesdeletesample] | Deletes the specified public IP address. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressDelete.json | +| [publicIPAddressesGetSample.js][publicipaddressesgetsample] | Gets the specified public IP address in a specified resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressGet.json | +| [publicIPAddressesListAllSample.js][publicipaddresseslistallsample] | Gets all the public IP addresses in a subscription. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressListAll.json | +| [publicIPAddressesListSample.js][publicipaddresseslistsample] | Gets all public IP addresses in a resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressList.json | +| [publicIPAddressesUpdateTagsSample.js][publicipaddressesupdatetagssample] | Updates public IP address tags. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressUpdateTags.json | +| [routeTablesCreateOrUpdateSample.js][routetablescreateorupdatesample] | Create or updates a route table in a specified resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableCreate.json | +| [routeTablesDeleteSample.js][routetablesdeletesample] | Deletes the specified route table. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableDelete.json | +| [routeTablesGetSample.js][routetablesgetsample] | Gets the specified route table. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableGet.json | +| [routeTablesListAllSample.js][routetableslistallsample] | Gets all route tables in a subscription. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableListAll.json | +| [routeTablesListSample.js][routetableslistsample] | Gets all route tables in a resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableList.json | +| [routeTablesUpdateTagsSample.js][routetablesupdatetagssample] | Updates a route table tags. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableUpdateTags.json | +| [routesCreateOrUpdateSample.js][routescreateorupdatesample] | Creates or updates a route in the specified route table. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableRouteCreate.json | +| [routesDeleteSample.js][routesdeletesample] | Deletes the specified route from a route table. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableRouteDelete.json | +| [routesGetSample.js][routesgetsample] | Gets the specified route from a route table. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableRouteGet.json | +| [routesListSample.js][routeslistsample] | Gets all routes in a route table. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableRouteList.json | +| [securityRulesCreateOrUpdateSample.js][securityrulescreateorupdatesample] | Creates or updates a security rule in the specified network security group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupRuleCreate.json | +| [securityRulesDeleteSample.js][securityrulesdeletesample] | Deletes the specified network security rule. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupRuleDelete.json | +| [securityRulesGetSample.js][securityrulesgetsample] | Get the specified network security rule. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupRuleGet.json | +| [securityRulesListSample.js][securityruleslistsample] | Gets all security rules in a network security group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupRuleList.json | +| [subnetsCreateOrUpdateSample.js][subnetscreateorupdatesample] | Creates or updates a subnet in the specified virtual network. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetCreate.json | +| [subnetsDeleteSample.js][subnetsdeletesample] | Deletes the specified subnet. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetDelete.json | +| [subnetsGetSample.js][subnetsgetsample] | Gets the specified subnet by virtual network and resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetGet.json | +| [subnetsListSample.js][subnetslistsample] | Gets all subnets in a virtual network. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetList.json | +| [virtualNetworkGatewayConnectionsCreateOrUpdateSample.js][virtualnetworkgatewayconnectionscreateorupdatesample] | Creates or updates a virtual network gateway connection in the specified resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionCreate.json | +| [virtualNetworkGatewayConnectionsDeleteSample.js][virtualnetworkgatewayconnectionsdeletesample] | Deletes the specified virtual network Gateway connection. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionDelete.json | +| [virtualNetworkGatewayConnectionsGetSample.js][virtualnetworkgatewayconnectionsgetsample] | Gets the specified virtual network gateway connection by resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionGet.json | +| [virtualNetworkGatewayConnectionsGetSharedKeySample.js][virtualnetworkgatewayconnectionsgetsharedkeysample] | The Get VirtualNetworkGatewayConnectionSharedKey operation retrieves information about the specified virtual network gateway connection shared key through Network resource provider. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionGetSharedKey.json | +| [virtualNetworkGatewayConnectionsListSample.js][virtualnetworkgatewayconnectionslistsample] | The List VirtualNetworkGatewayConnections operation retrieves all the virtual network gateways connections created. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionsList.json | +| [virtualNetworkGatewayConnectionsResetSharedKeySample.js][virtualnetworkgatewayconnectionsresetsharedkeysample] | The VirtualNetworkGatewayConnectionResetSharedKey operation resets the virtual network gateway connection shared key for passed virtual network gateway connection in the specified resource group through Network resource provider. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionResetSharedKey.json | +| [virtualNetworkGatewayConnectionsSetSharedKeySample.js][virtualnetworkgatewayconnectionssetsharedkeysample] | The Put VirtualNetworkGatewayConnectionSharedKey operation sets the virtual network gateway connection shared key for passed virtual network gateway connection in the specified resource group through Network resource provider. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionSetSharedKey.json | +| [virtualNetworkGatewayConnectionsUpdateTagsSample.js][virtualnetworkgatewayconnectionsupdatetagssample] | Updates a virtual network gateway connection tags. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionUpdateTags.json | +| [virtualNetworkGatewaysCreateOrUpdateSample.js][virtualnetworkgatewayscreateorupdatesample] | Creates or updates a virtual network gateway in the specified resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayUpdate.json | +| [virtualNetworkGatewaysDeleteSample.js][virtualnetworkgatewaysdeletesample] | Deletes the specified virtual network gateway. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayDelete.json | +| [virtualNetworkGatewaysGenerateVpnProfileSample.js][virtualnetworkgatewaysgeneratevpnprofilesample] | Generates VPN profile for P2S client of the virtual network gateway in the specified resource group. Used for IKEV2 and radius based authentication. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGenerateVpnProfile.json | +| [virtualNetworkGatewaysGeneratevpnclientpackageSample.js][virtualnetworkgatewaysgeneratevpnclientpackagesample] | Generates VPN client package for P2S client of the virtual network gateway in the specified resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGenerateVpnClientPackage.json | +| [virtualNetworkGatewaysGetAdvertisedRoutesSample.js][virtualnetworkgatewaysgetadvertisedroutessample] | This operation retrieves a list of routes the virtual network gateway is advertising to the specified peer. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGetAdvertisedRoutes.json | +| [virtualNetworkGatewaysGetBgpPeerStatusSample.js][virtualnetworkgatewaysgetbgppeerstatussample] | The GetBgpPeerStatus operation retrieves the status of all BGP peers. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGetBGPPeerStatus.json | +| [virtualNetworkGatewaysGetLearnedRoutesSample.js][virtualnetworkgatewaysgetlearnedroutessample] | This operation retrieves a list of routes the virtual network gateway has learned, including routes learned from BGP peers. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayLearnedRoutes.json | +| [virtualNetworkGatewaysGetSample.js][virtualnetworkgatewaysgetsample] | Gets the specified virtual network gateway by resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGet.json | +| [virtualNetworkGatewaysGetVpnProfilePackageUrlSample.js][virtualnetworkgatewaysgetvpnprofilepackageurlsample] | Gets pre-generated VPN profile for P2S client of the virtual network gateway in the specified resource group. The profile needs to be generated first using generateVpnProfile. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGetVpnProfilePackageUrl.json | +| [virtualNetworkGatewaysGetVpnclientIpsecParametersSample.js][virtualnetworkgatewaysgetvpnclientipsecparameterssample] | The Get VpnclientIpsecParameters operation retrieves information about the vpnclient ipsec policy for P2S client of virtual network gateway in the specified resource group through Network resource provider. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGetVpnClientIpsecParameters.json | +| [virtualNetworkGatewaysListConnectionsSample.js][virtualnetworkgatewayslistconnectionssample] | Gets all the connections in a virtual network gateway. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewaysListConnections.json | +| [virtualNetworkGatewaysListSample.js][virtualnetworkgatewayslistsample] | Gets all virtual network gateways by resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayList.json | +| [virtualNetworkGatewaysResetSample.js][virtualnetworkgatewaysresetsample] | Resets the primary of the virtual network gateway in the specified resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayReset.json | +| [virtualNetworkGatewaysResetVpnClientSharedKeySample.js][virtualnetworkgatewaysresetvpnclientsharedkeysample] | Resets the VPN client shared key of the virtual network gateway in the specified resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayResetVpnClientSharedKey.json | +| [virtualNetworkGatewaysSetVpnclientIpsecParametersSample.js][virtualnetworkgatewayssetvpnclientipsecparameterssample] | The Set VpnclientIpsecParameters operation sets the vpnclient ipsec policy for P2S client of virtual network gateway in the specified resource group through Network resource provider. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewaySetVpnClientIpsecParameters.json | +| [virtualNetworkGatewaysSupportedVpnDevicesSample.js][virtualnetworkgatewayssupportedvpndevicessample] | Gets a xml format representation for supported vpn devices. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewaySupportedVpnDevice.json | +| [virtualNetworkGatewaysUpdateTagsSample.js][virtualnetworkgatewaysupdatetagssample] | Updates a virtual network gateway tags. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayUpdateTags.json | +| [virtualNetworkGatewaysVpnDeviceConfigurationScriptSample.js][virtualnetworkgatewaysvpndeviceconfigurationscriptsample] | Gets a xml format representation for vpn device configuration script. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayVpnDeviceConfigurationScript.json | +| [virtualNetworkPeeringsCreateOrUpdateSample.js][virtualnetworkpeeringscreateorupdatesample] | Creates or updates a peering in the specified virtual network. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkPeeringCreate.json | +| [virtualNetworkPeeringsDeleteSample.js][virtualnetworkpeeringsdeletesample] | Deletes the specified virtual network peering. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkPeeringDelete.json | +| [virtualNetworkPeeringsGetSample.js][virtualnetworkpeeringsgetsample] | Gets the specified virtual network peering. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkPeeringGet.json | +| [virtualNetworkPeeringsListSample.js][virtualnetworkpeeringslistsample] | Gets all virtual network peerings in a virtual network. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkPeeringList.json | +| [virtualNetworksCheckIPAddressAvailabilitySample.js][virtualnetworkscheckipaddressavailabilitysample] | Checks whether a private IP address is available for use. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkCheckIPAddressAvailability.json | +| [virtualNetworksCreateOrUpdateSample.js][virtualnetworkscreateorupdatesample] | Creates or updates a virtual network in the specified resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkCreate.json | +| [virtualNetworksDeleteSample.js][virtualnetworksdeletesample] | Deletes the specified virtual network. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkDelete.json | +| [virtualNetworksGetSample.js][virtualnetworksgetsample] | Gets the specified virtual network by resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGet.json | +| [virtualNetworksListAllSample.js][virtualnetworkslistallsample] | Gets all virtual networks in a subscription. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkListAll.json | +| [virtualNetworksListSample.js][virtualnetworkslistsample] | Gets all virtual networks in a resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkList.json | +| [virtualNetworksListUsageSample.js][virtualnetworkslistusagesample] | Lists usage stats. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkListUsage.json | +| [virtualNetworksUpdateTagsSample.js][virtualnetworksupdatetagssample] | Updates a virtual network tags. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkUpdateTags.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). + +You need [an Azure subscription][freesub] to run these sample programs. + +Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. + +Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. + +## Setup + +To run the samples using the published version of the package: + +1. Install the dependencies using `npm`: + +```bash +npm install +``` + +2. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. + +3. Run whichever samples you like (note that some samples may require additional setup, see the table above): + +```bash +node defaultSecurityRulesGetSample.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 NETWORK_SUBSCRIPTION_ID="" NETWORK_RESOURCE_GROUP="" node defaultSecurityRulesGetSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[defaultsecurityrulesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/defaultSecurityRulesGetSample.js +[defaultsecurityruleslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/defaultSecurityRulesListSample.js +[inboundnatrulescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/inboundNatRulesCreateOrUpdateSample.js +[inboundnatrulesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/inboundNatRulesDeleteSample.js +[inboundnatrulesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/inboundNatRulesGetSample.js +[inboundnatruleslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/inboundNatRulesListSample.js +[loadbalancerbackendaddresspoolsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerBackendAddressPoolsGetSample.js +[loadbalancerbackendaddresspoolslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerBackendAddressPoolsListSample.js +[loadbalancerfrontendipconfigurationsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerFrontendIPConfigurationsGetSample.js +[loadbalancerfrontendipconfigurationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerFrontendIPConfigurationsListSample.js +[loadbalancerloadbalancingrulesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerLoadBalancingRulesGetSample.js +[loadbalancerloadbalancingruleslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerLoadBalancingRulesListSample.js +[loadbalancernetworkinterfaceslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerNetworkInterfacesListSample.js +[loadbalanceroutboundrulesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerOutboundRulesGetSample.js +[loadbalanceroutboundruleslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerOutboundRulesListSample.js +[loadbalancerprobesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerProbesGetSample.js +[loadbalancerprobeslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerProbesListSample.js +[loadbalancerscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancersCreateOrUpdateSample.js +[loadbalancersdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancersDeleteSample.js +[loadbalancersgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancersGetSample.js +[loadbalancerslistallsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancersListAllSample.js +[loadbalancerslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancersListSample.js +[loadbalancersupdatetagssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancersUpdateTagsSample.js +[localnetworkgatewayscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/localNetworkGatewaysCreateOrUpdateSample.js +[localnetworkgatewaysdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/localNetworkGatewaysDeleteSample.js +[localnetworkgatewaysgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/localNetworkGatewaysGetSample.js +[localnetworkgatewayslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/localNetworkGatewaysListSample.js +[localnetworkgatewaysupdatetagssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/localNetworkGatewaysUpdateTagsSample.js +[networkinterfaceipconfigurationsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceIPConfigurationsGetSample.js +[networkinterfaceipconfigurationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceIPConfigurationsListSample.js +[networkinterfaceloadbalancerslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceLoadBalancersListSample.js +[networkinterfacetapconfigurationscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceTapConfigurationsCreateOrUpdateSample.js +[networkinterfacetapconfigurationsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceTapConfigurationsDeleteSample.js +[networkinterfacetapconfigurationsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceTapConfigurationsGetSample.js +[networkinterfacetapconfigurationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceTapConfigurationsListSample.js +[networkinterfacescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesCreateOrUpdateSample.js +[networkinterfacesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesDeleteSample.js +[networkinterfacesgeteffectiveroutetablesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesGetEffectiveRouteTableSample.js +[networkinterfacesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesGetSample.js +[networkinterfaceslistallsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesListAllSample.js +[networkinterfaceslisteffectivenetworksecuritygroupssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesListEffectiveNetworkSecurityGroupsSample.js +[networkinterfaceslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesListSample.js +[networkinterfacesupdatetagssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesUpdateTagsSample.js +[networksecuritygroupscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkSecurityGroupsCreateOrUpdateSample.js +[networksecuritygroupsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkSecurityGroupsDeleteSample.js +[networksecuritygroupsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkSecurityGroupsGetSample.js +[networksecuritygroupslistallsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkSecurityGroupsListAllSample.js +[networksecuritygroupslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkSecurityGroupsListSample.js +[networksecuritygroupsupdatetagssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkSecurityGroupsUpdateTagsSample.js +[operationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/operationsListSample.js +[publicipaddressescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/publicIPAddressesCreateOrUpdateSample.js +[publicipaddressesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/publicIPAddressesDeleteSample.js +[publicipaddressesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/publicIPAddressesGetSample.js +[publicipaddresseslistallsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/publicIPAddressesListAllSample.js +[publicipaddresseslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/publicIPAddressesListSample.js +[publicipaddressesupdatetagssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/publicIPAddressesUpdateTagsSample.js +[routetablescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routeTablesCreateOrUpdateSample.js +[routetablesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routeTablesDeleteSample.js +[routetablesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routeTablesGetSample.js +[routetableslistallsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routeTablesListAllSample.js +[routetableslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routeTablesListSample.js +[routetablesupdatetagssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routeTablesUpdateTagsSample.js +[routescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routesCreateOrUpdateSample.js +[routesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routesDeleteSample.js +[routesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routesGetSample.js +[routeslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routesListSample.js +[securityrulescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/securityRulesCreateOrUpdateSample.js +[securityrulesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/securityRulesDeleteSample.js +[securityrulesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/securityRulesGetSample.js +[securityruleslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/securityRulesListSample.js +[subnetscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/subnetsCreateOrUpdateSample.js +[subnetsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/subnetsDeleteSample.js +[subnetsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/subnetsGetSample.js +[subnetslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/subnetsListSample.js +[virtualnetworkgatewayconnectionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsCreateOrUpdateSample.js +[virtualnetworkgatewayconnectionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsDeleteSample.js +[virtualnetworkgatewayconnectionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsGetSample.js +[virtualnetworkgatewayconnectionsgetsharedkeysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsGetSharedKeySample.js +[virtualnetworkgatewayconnectionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsListSample.js +[virtualnetworkgatewayconnectionsresetsharedkeysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsResetSharedKeySample.js +[virtualnetworkgatewayconnectionssetsharedkeysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsSetSharedKeySample.js +[virtualnetworkgatewayconnectionsupdatetagssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsUpdateTagsSample.js +[virtualnetworkgatewayscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysCreateOrUpdateSample.js +[virtualnetworkgatewaysdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysDeleteSample.js +[virtualnetworkgatewaysgeneratevpnprofilesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGenerateVpnProfileSample.js +[virtualnetworkgatewaysgeneratevpnclientpackagesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGeneratevpnclientpackageSample.js +[virtualnetworkgatewaysgetadvertisedroutessample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGetAdvertisedRoutesSample.js +[virtualnetworkgatewaysgetbgppeerstatussample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGetBgpPeerStatusSample.js +[virtualnetworkgatewaysgetlearnedroutessample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGetLearnedRoutesSample.js +[virtualnetworkgatewaysgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGetSample.js +[virtualnetworkgatewaysgetvpnprofilepackageurlsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGetVpnProfilePackageUrlSample.js +[virtualnetworkgatewaysgetvpnclientipsecparameterssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGetVpnclientIpsecParametersSample.js +[virtualnetworkgatewayslistconnectionssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysListConnectionsSample.js +[virtualnetworkgatewayslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysListSample.js +[virtualnetworkgatewaysresetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysResetSample.js +[virtualnetworkgatewaysresetvpnclientsharedkeysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysResetVpnClientSharedKeySample.js +[virtualnetworkgatewayssetvpnclientipsecparameterssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysSetVpnclientIpsecParametersSample.js +[virtualnetworkgatewayssupportedvpndevicessample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysSupportedVpnDevicesSample.js +[virtualnetworkgatewaysupdatetagssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysUpdateTagsSample.js +[virtualnetworkgatewaysvpndeviceconfigurationscriptsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysVpnDeviceConfigurationScriptSample.js +[virtualnetworkpeeringscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkPeeringsCreateOrUpdateSample.js +[virtualnetworkpeeringsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkPeeringsDeleteSample.js +[virtualnetworkpeeringsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkPeeringsGetSample.js +[virtualnetworkpeeringslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkPeeringsListSample.js +[virtualnetworkscheckipaddressavailabilitysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksCheckIPAddressAvailabilitySample.js +[virtualnetworkscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksCreateOrUpdateSample.js +[virtualnetworksdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksDeleteSample.js +[virtualnetworksgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksGetSample.js +[virtualnetworkslistallsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksListAllSample.js +[virtualnetworkslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksListSample.js +[virtualnetworkslistusagesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksListUsageSample.js +[virtualnetworksupdatetagssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksUpdateTagsSample.js +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-network-profile-2020-09-01-hybrid?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/network/arm-network-profile-2020-09-01-hybrid/README.md diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/defaultSecurityRulesGetSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/defaultSecurityRulesGetSample.js new file mode 100644 index 000000000000..ed74f3af92e8 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/defaultSecurityRulesGetSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Get the specified default network security rule. + * + * @summary Get the specified default network security rule. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/DefaultSecurityRuleGet.json + */ +async function defaultSecurityRuleGet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const networkSecurityGroupName = "nsg1"; + const defaultSecurityRuleName = "AllowVnetInBound"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.defaultSecurityRules.get( + resourceGroupName, + networkSecurityGroupName, + defaultSecurityRuleName + ); + console.log(result); +} + +async function main() { + defaultSecurityRuleGet(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/defaultSecurityRulesListSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/defaultSecurityRulesListSample.js new file mode 100644 index 000000000000..c6eadde9e998 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/defaultSecurityRulesListSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all default security rules in a network security group. + * + * @summary Gets all default security rules in a network security group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/DefaultSecurityRuleList.json + */ +async function defaultSecurityRuleList() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const networkSecurityGroupName = "nsg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.defaultSecurityRules.list( + resourceGroupName, + networkSecurityGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + defaultSecurityRuleList(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/inboundNatRulesCreateOrUpdateSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/inboundNatRulesCreateOrUpdateSample.js new file mode 100644 index 000000000000..7e742c5ea646 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/inboundNatRulesCreateOrUpdateSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Creates or updates a load balancer inbound nat rule. + * + * @summary Creates or updates a load balancer inbound nat rule. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/InboundNatRuleCreate.json + */ +async function inboundNatRuleCreate() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb1"; + const inboundNatRuleName = "natRule1.1"; + const inboundNatRuleParameters = { + backendPort: 3389, + enableFloatingIP: false, + enableTcpReset: true, + frontendIPConfiguration: { + id: "/subscriptions/subid/resourceGroups/testrg/providers/Microsoft.Network/loadBalancers/lb1/frontendIPConfigurations/ip1", + }, + frontendPort: 3390, + idleTimeoutInMinutes: 4, + protocol: "Tcp", + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.inboundNatRules.beginCreateOrUpdateAndWait( + resourceGroupName, + loadBalancerName, + inboundNatRuleName, + inboundNatRuleParameters + ); + console.log(result); +} + +async function main() { + inboundNatRuleCreate(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/inboundNatRulesDeleteSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/inboundNatRulesDeleteSample.js new file mode 100644 index 000000000000..12910ebee14e --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/inboundNatRulesDeleteSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Deletes the specified load balancer inbound nat rule. + * + * @summary Deletes the specified load balancer inbound nat rule. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/InboundNatRuleDelete.json + */ +async function inboundNatRuleDelete() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb1"; + const inboundNatRuleName = "natRule1.1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.inboundNatRules.beginDeleteAndWait( + resourceGroupName, + loadBalancerName, + inboundNatRuleName + ); + console.log(result); +} + +async function main() { + inboundNatRuleDelete(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/inboundNatRulesGetSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/inboundNatRulesGetSample.js new file mode 100644 index 000000000000..aa42bcf97cbd --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/inboundNatRulesGetSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the specified load balancer inbound nat rule. + * + * @summary Gets the specified load balancer inbound nat rule. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/InboundNatRuleGet.json + */ +async function inboundNatRuleGet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb1"; + const inboundNatRuleName = "natRule1.1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.inboundNatRules.get( + resourceGroupName, + loadBalancerName, + inboundNatRuleName + ); + console.log(result); +} + +async function main() { + inboundNatRuleGet(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/inboundNatRulesListSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/inboundNatRulesListSample.js new file mode 100644 index 000000000000..a75e2f5c3981 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/inboundNatRulesListSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all the inbound nat rules in a load balancer. + * + * @summary Gets all the inbound nat rules in a load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/InboundNatRuleList.json + */ +async function inboundNatRuleList() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.inboundNatRules.list(resourceGroupName, loadBalancerName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + inboundNatRuleList(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerBackendAddressPoolsGetSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerBackendAddressPoolsGetSample.js new file mode 100644 index 000000000000..265dbbe9ee3d --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerBackendAddressPoolsGetSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets load balancer backend address pool. + * + * @summary Gets load balancer backend address pool. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerBackendAddressPoolGet.json + */ +async function loadBalancerBackendAddressPoolGet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb"; + const backendAddressPoolName = "backend"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancerBackendAddressPools.get( + resourceGroupName, + loadBalancerName, + backendAddressPoolName + ); + console.log(result); +} + +async function main() { + loadBalancerBackendAddressPoolGet(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerBackendAddressPoolsListSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerBackendAddressPoolsListSample.js new file mode 100644 index 000000000000..f9ec8feaf590 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerBackendAddressPoolsListSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all the load balancer backed address pools. + * + * @summary Gets all the load balancer backed address pools. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerBackendAddressPoolList.json + */ +async function loadBalancerBackendAddressPoolList() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.loadBalancerBackendAddressPools.list( + resourceGroupName, + loadBalancerName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + loadBalancerBackendAddressPoolList(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerFrontendIPConfigurationsGetSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerFrontendIPConfigurationsGetSample.js new file mode 100644 index 000000000000..5015f07d4ac3 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerFrontendIPConfigurationsGetSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets load balancer frontend IP configuration. + * + * @summary Gets load balancer frontend IP configuration. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerFrontendIPConfigurationGet.json + */ +async function loadBalancerFrontendIPConfigurationGet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb"; + const frontendIPConfigurationName = "frontend"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancerFrontendIPConfigurations.get( + resourceGroupName, + loadBalancerName, + frontendIPConfigurationName + ); + console.log(result); +} + +async function main() { + loadBalancerFrontendIPConfigurationGet(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerFrontendIPConfigurationsListSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerFrontendIPConfigurationsListSample.js new file mode 100644 index 000000000000..dde1464ef6fd --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerFrontendIPConfigurationsListSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all the load balancer frontend IP configurations. + * + * @summary Gets all the load balancer frontend IP configurations. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerFrontendIPConfigurationList.json + */ +async function loadBalancerFrontendIPConfigurationList() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.loadBalancerFrontendIPConfigurations.list( + resourceGroupName, + loadBalancerName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + loadBalancerFrontendIPConfigurationList(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerLoadBalancingRulesGetSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerLoadBalancingRulesGetSample.js new file mode 100644 index 000000000000..262b5420222e --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerLoadBalancingRulesGetSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the specified load balancer load balancing rule. + * + * @summary Gets the specified load balancer load balancing rule. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerLoadBalancingRuleGet.json + */ +async function loadBalancerLoadBalancingRuleGet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb1"; + const loadBalancingRuleName = "rule1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancerLoadBalancingRules.get( + resourceGroupName, + loadBalancerName, + loadBalancingRuleName + ); + console.log(result); +} + +async function main() { + loadBalancerLoadBalancingRuleGet(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerLoadBalancingRulesListSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerLoadBalancingRulesListSample.js new file mode 100644 index 000000000000..9f4cb91f736e --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerLoadBalancingRulesListSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all the load balancing rules in a load balancer. + * + * @summary Gets all the load balancing rules in a load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerLoadBalancingRuleList.json + */ +async function loadBalancerLoadBalancingRuleList() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.loadBalancerLoadBalancingRules.list( + resourceGroupName, + loadBalancerName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + loadBalancerLoadBalancingRuleList(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerNetworkInterfacesListSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerNetworkInterfacesListSample.js new file mode 100644 index 000000000000..3bca0310faac --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerNetworkInterfacesListSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets associated load balancer network interfaces. + * + * @summary Gets associated load balancer network interfaces. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerNetworkInterfaceListSimple.json + */ +async function loadBalancerNetworkInterfaceListSimple() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.loadBalancerNetworkInterfaces.list( + resourceGroupName, + loadBalancerName + )) { + resArray.push(item); + } + console.log(resArray); +} + +/** + * This sample demonstrates how to Gets associated load balancer network interfaces. + * + * @summary Gets associated load balancer network interfaces. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerNetworkInterfaceListVmss.json + */ +async function loadBalancerNetworkInterfaceListVmss() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.loadBalancerNetworkInterfaces.list( + resourceGroupName, + loadBalancerName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + loadBalancerNetworkInterfaceListSimple(); + loadBalancerNetworkInterfaceListVmss(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerOutboundRulesGetSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerOutboundRulesGetSample.js new file mode 100644 index 000000000000..451a065817b3 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerOutboundRulesGetSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the specified load balancer outbound rule. + * + * @summary Gets the specified load balancer outbound rule. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerOutboundRuleGet.json + */ +async function loadBalancerOutboundRuleGet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb1"; + const outboundRuleName = "rule1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancerOutboundRules.get( + resourceGroupName, + loadBalancerName, + outboundRuleName + ); + console.log(result); +} + +async function main() { + loadBalancerOutboundRuleGet(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerOutboundRulesListSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerOutboundRulesListSample.js new file mode 100644 index 000000000000..c4be5de6ff05 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerOutboundRulesListSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all the outbound rules in a load balancer. + * + * @summary Gets all the outbound rules in a load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerOutboundRuleList.json + */ +async function loadBalancerOutboundRuleList() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.loadBalancerOutboundRules.list( + resourceGroupName, + loadBalancerName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + loadBalancerOutboundRuleList(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerProbesGetSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerProbesGetSample.js new file mode 100644 index 000000000000..76f19fcab5d6 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerProbesGetSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets load balancer probe. + * + * @summary Gets load balancer probe. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerProbeGet.json + */ +async function loadBalancerProbeGet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb"; + const probeName = "probe1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancerProbes.get( + resourceGroupName, + loadBalancerName, + probeName + ); + console.log(result); +} + +async function main() { + loadBalancerProbeGet(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerProbesListSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerProbesListSample.js new file mode 100644 index 000000000000..01fa658a26de --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancerProbesListSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all the load balancer probes. + * + * @summary Gets all the load balancer probes. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerProbeList.json + */ +async function loadBalancerProbeList() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.loadBalancerProbes.list(resourceGroupName, loadBalancerName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + loadBalancerProbeList(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancersCreateOrUpdateSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancersCreateOrUpdateSample.js new file mode 100644 index 000000000000..333fb020867c --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancersCreateOrUpdateSample.js @@ -0,0 +1,404 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Creates or updates a load balancer. + * + * @summary Creates or updates a load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerCreate.json + */ +async function createLoadBalancer() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const loadBalancerName = "lb"; + const parameters = { + backendAddressPools: [{ name: "be-lb" }], + frontendIPConfigurations: [ + { + name: "fe-lb", + subnet: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb/subnets/subnetlb", + }, + }, + ], + inboundNatPools: [], + inboundNatRules: [ + { + name: "in-nat-rule", + backendPort: 3389, + enableFloatingIP: true, + enableTcpReset: true, + frontendIPConfiguration: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb", + }, + frontendPort: 3389, + idleTimeoutInMinutes: 15, + protocol: "Tcp", + }, + ], + loadBalancingRules: [ + { + name: "rulelb", + backendAddressPool: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/be-lb", + }, + backendPort: 80, + enableFloatingIP: true, + enableTcpReset: true, + frontendIPConfiguration: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb", + }, + frontendPort: 80, + idleTimeoutInMinutes: 15, + loadDistribution: "Default", + probe: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/probes/probe-lb", + }, + protocol: "Tcp", + }, + ], + probes: [ + { + name: "probe-lb", + intervalInSeconds: 15, + numberOfProbes: 2, + port: 80, + requestPath: "healthcheck.aspx", + protocol: "Http", + }, + ], + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancers.beginCreateOrUpdateAndWait( + resourceGroupName, + loadBalancerName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a load balancer. + * + * @summary Creates or updates a load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerCreateWithZones.json + */ +async function createLoadBalancerWithFrontendIPInZone1() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const loadBalancerName = "lb"; + const parameters = { + backendAddressPools: [{ name: "be-lb" }], + frontendIPConfigurations: [ + { + name: "fe-lb", + subnet: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb/subnets/subnetlb", + }, + zones: ["1"], + }, + ], + inboundNatPools: [], + inboundNatRules: [ + { + name: "in-nat-rule", + backendPort: 3389, + enableFloatingIP: true, + frontendIPConfiguration: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb", + }, + frontendPort: 3389, + idleTimeoutInMinutes: 15, + protocol: "Tcp", + }, + ], + loadBalancingRules: [ + { + name: "rulelb", + backendAddressPool: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/be-lb", + }, + backendPort: 80, + enableFloatingIP: true, + frontendIPConfiguration: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb", + }, + frontendPort: 80, + idleTimeoutInMinutes: 15, + loadDistribution: "Default", + probe: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/probes/probe-lb", + }, + protocol: "Tcp", + }, + ], + outboundRules: [], + probes: [ + { + name: "probe-lb", + intervalInSeconds: 15, + numberOfProbes: 2, + port: 80, + requestPath: "healthcheck.aspx", + protocol: "Http", + }, + ], + sku: { name: "Standard" }, + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancers.beginCreateOrUpdateAndWait( + resourceGroupName, + loadBalancerName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a load balancer. + * + * @summary Creates or updates a load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerCreateStandardSku.json + */ +async function createLoadBalancerWithStandardSku() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const loadBalancerName = "lb"; + const parameters = { + backendAddressPools: [{ name: "be-lb" }], + frontendIPConfigurations: [ + { + name: "fe-lb", + subnet: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb/subnets/subnetlb", + }, + }, + ], + inboundNatPools: [], + inboundNatRules: [ + { + name: "in-nat-rule", + backendPort: 3389, + enableFloatingIP: true, + frontendIPConfiguration: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb", + }, + frontendPort: 3389, + idleTimeoutInMinutes: 15, + protocol: "Tcp", + }, + ], + loadBalancingRules: [ + { + name: "rulelb", + backendAddressPool: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/be-lb", + }, + backendPort: 80, + enableFloatingIP: true, + frontendIPConfiguration: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb", + }, + frontendPort: 80, + idleTimeoutInMinutes: 15, + loadDistribution: "Default", + probe: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/probes/probe-lb", + }, + protocol: "Tcp", + }, + ], + outboundRules: [], + probes: [ + { + name: "probe-lb", + intervalInSeconds: 15, + numberOfProbes: 2, + port: 80, + requestPath: "healthcheck.aspx", + protocol: "Http", + }, + ], + sku: { name: "Standard" }, + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancers.beginCreateOrUpdateAndWait( + resourceGroupName, + loadBalancerName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a load balancer. + * + * @summary Creates or updates a load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerCreateWithInboundNatPool.json + */ +async function createLoadBalancerWithInboundNatPool() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const loadBalancerName = "lb"; + const parameters = { + backendAddressPools: [], + frontendIPConfigurations: [ + { + name: "test", + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/test", + privateIPAllocationMethod: "Dynamic", + subnet: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/lbvnet/subnets/lbsubnet", + resourceNavigationLinks: [], + serviceEndpoints: [], + }, + zones: [], + }, + ], + inboundNatPools: [ + { + name: "test", + backendPort: 8888, + enableFloatingIP: true, + enableTcpReset: true, + frontendIPConfiguration: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/test", + }, + frontendPortRangeEnd: 8085, + frontendPortRangeStart: 8080, + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/inboundNatPools/test", + idleTimeoutInMinutes: 10, + protocol: "Tcp", + }, + ], + inboundNatRules: [], + loadBalancingRules: [], + outboundRules: [], + probes: [], + sku: { name: "Standard" }, + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancers.beginCreateOrUpdateAndWait( + resourceGroupName, + loadBalancerName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a load balancer. + * + * @summary Creates or updates a load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerCreateWithOutboundRules.json + */ +async function createLoadBalancerWithOutboundRules() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const loadBalancerName = "lb"; + const parameters = { + backendAddressPools: [{ name: "be-lb" }], + frontendIPConfigurations: [ + { + name: "fe-lb", + publicIPAddress: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/pip", + }, + }, + ], + inboundNatPools: [], + inboundNatRules: [ + { + name: "in-nat-rule", + backendPort: 3389, + enableFloatingIP: true, + frontendIPConfiguration: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb", + }, + frontendPort: 3389, + idleTimeoutInMinutes: 15, + protocol: "Tcp", + }, + ], + loadBalancingRules: [ + { + name: "rulelb", + backendAddressPool: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/be-lb", + }, + backendPort: 80, + disableOutboundSnat: true, + enableFloatingIP: true, + frontendIPConfiguration: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb", + }, + frontendPort: 80, + idleTimeoutInMinutes: 15, + loadDistribution: "Default", + probe: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/probes/probe-lb", + }, + protocol: "Tcp", + }, + ], + location: "eastus", + outboundRules: [ + { + name: "rule1", + backendAddressPool: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/be-lb", + }, + frontendIPConfigurations: [ + { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb", + }, + ], + protocol: "All", + }, + ], + probes: [ + { + name: "probe-lb", + intervalInSeconds: 15, + numberOfProbes: 2, + port: 80, + requestPath: "healthcheck.aspx", + protocol: "Http", + }, + ], + sku: { name: "Standard" }, + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancers.beginCreateOrUpdateAndWait( + resourceGroupName, + loadBalancerName, + parameters + ); + console.log(result); +} + +async function main() { + createLoadBalancer(); + createLoadBalancerWithFrontendIPInZone1(); + createLoadBalancerWithStandardSku(); + createLoadBalancerWithInboundNatPool(); + createLoadBalancerWithOutboundRules(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancersDeleteSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancersDeleteSample.js new file mode 100644 index 000000000000..a0501ec14554 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancersDeleteSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Deletes the specified load balancer. + * + * @summary Deletes the specified load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerDelete.json + */ +async function deleteLoadBalancer() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const loadBalancerName = "lb"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancers.beginDeleteAndWait(resourceGroupName, loadBalancerName); + console.log(result); +} + +async function main() { + deleteLoadBalancer(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancersGetSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancersGetSample.js new file mode 100644 index 000000000000..5e87a9e4a3c9 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancersGetSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the specified load balancer. + * + * @summary Gets the specified load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerGet.json + */ +async function getLoadBalancer() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const loadBalancerName = "lb"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancers.get(resourceGroupName, loadBalancerName); + console.log(result); +} + +async function main() { + getLoadBalancer(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancersListAllSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancersListAllSample.js new file mode 100644 index 000000000000..c97d5e97ff19 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancersListAllSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all the load balancers in a subscription. + * + * @summary Gets all the load balancers in a subscription. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerListAll.json + */ +async function listAllLoadBalancers() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.loadBalancers.listAll()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAllLoadBalancers(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancersListSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancersListSample.js new file mode 100644 index 000000000000..f3e53f0867c6 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancersListSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all the load balancers in a resource group. + * + * @summary Gets all the load balancers in a resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerList.json + */ +async function listLoadBalancersInResourceGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.loadBalancers.list(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listLoadBalancersInResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancersUpdateTagsSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancersUpdateTagsSample.js new file mode 100644 index 000000000000..1a2f902b1e47 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/loadBalancersUpdateTagsSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Updates a load balancer tags. + * + * @summary Updates a load balancer tags. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerUpdateTags.json + */ +async function updateLoadBalancerTags() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const loadBalancerName = "lb"; + const parameters = { tags: { tag1: "value1", tag2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancers.beginUpdateTagsAndWait( + resourceGroupName, + loadBalancerName, + parameters + ); + console.log(result); +} + +async function main() { + updateLoadBalancerTags(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/localNetworkGatewaysCreateOrUpdateSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/localNetworkGatewaysCreateOrUpdateSample.js new file mode 100644 index 000000000000..2ff77357c05f --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/localNetworkGatewaysCreateOrUpdateSample.js @@ -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. +const { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Creates or updates a local network gateway in the specified resource group. + * + * @summary Creates or updates a local network gateway in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LocalNetworkGatewayCreate.json + */ +async function createLocalNetworkGateway() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const localNetworkGatewayName = "localgw"; + const parameters = { + gatewayIpAddress: "x.x.x.x", + localNetworkAddressSpace: { addressPrefixes: ["10.1.0.0/16"] }, + location: "Central US", + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.localNetworkGateways.beginCreateOrUpdateAndWait( + resourceGroupName, + localNetworkGatewayName, + parameters + ); + console.log(result); +} + +async function main() { + createLocalNetworkGateway(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/localNetworkGatewaysDeleteSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/localNetworkGatewaysDeleteSample.js new file mode 100644 index 000000000000..02842cb9d79f --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/localNetworkGatewaysDeleteSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Deletes the specified local network gateway. + * + * @summary Deletes the specified local network gateway. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LocalNetworkGatewayDelete.json + */ +async function deleteLocalNetworkGateway() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const localNetworkGatewayName = "localgw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.localNetworkGateways.beginDeleteAndWait( + resourceGroupName, + localNetworkGatewayName + ); + console.log(result); +} + +async function main() { + deleteLocalNetworkGateway(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/localNetworkGatewaysGetSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/localNetworkGatewaysGetSample.js new file mode 100644 index 000000000000..12c910763a36 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/localNetworkGatewaysGetSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the specified local network gateway in a resource group. + * + * @summary Gets the specified local network gateway in a resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LocalNetworkGatewayGet.json + */ +async function getLocalNetworkGateway() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const localNetworkGatewayName = "localgw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.localNetworkGateways.get(resourceGroupName, localNetworkGatewayName); + console.log(result); +} + +async function main() { + getLocalNetworkGateway(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/localNetworkGatewaysListSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/localNetworkGatewaysListSample.js new file mode 100644 index 000000000000..d0efeaf7a9dc --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/localNetworkGatewaysListSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all the local network gateways in a resource group. + * + * @summary Gets all the local network gateways in a resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LocalNetworkGatewayList.json + */ +async function listLocalNetworkGateways() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.localNetworkGateways.list(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listLocalNetworkGateways(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/localNetworkGatewaysUpdateTagsSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/localNetworkGatewaysUpdateTagsSample.js new file mode 100644 index 000000000000..57be5fd9a4f6 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/localNetworkGatewaysUpdateTagsSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Updates a local network gateway tags. + * + * @summary Updates a local network gateway tags. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LocalNetworkGatewayUpdateTags.json + */ +async function updateLocalNetworkGatewayTags() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const localNetworkGatewayName = "lgw"; + const parameters = { tags: { tag1: "value1", tag2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.localNetworkGateways.beginUpdateTagsAndWait( + resourceGroupName, + localNetworkGatewayName, + parameters + ); + console.log(result); +} + +async function main() { + updateLocalNetworkGatewayTags(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceIPConfigurationsGetSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceIPConfigurationsGetSample.js new file mode 100644 index 000000000000..531bd4b67690 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceIPConfigurationsGetSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the specified network interface ip configuration. + * + * @summary Gets the specified network interface ip configuration. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceIPConfigurationGet.json + */ +async function networkInterfaceIPConfigurationGet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const networkInterfaceName = "mynic"; + const ipConfigurationName = "ipconfig1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaceIPConfigurations.get( + resourceGroupName, + networkInterfaceName, + ipConfigurationName + ); + console.log(result); +} + +async function main() { + networkInterfaceIPConfigurationGet(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceIPConfigurationsListSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceIPConfigurationsListSample.js new file mode 100644 index 000000000000..21c6f21582cf --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceIPConfigurationsListSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Get all ip configurations in a network interface + * + * @summary Get all ip configurations in a network interface + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceIPConfigurationList.json + */ +async function networkInterfaceIPConfigurationList() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const networkInterfaceName = "nic1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.networkInterfaceIPConfigurations.list( + resourceGroupName, + networkInterfaceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + networkInterfaceIPConfigurationList(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceLoadBalancersListSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceLoadBalancersListSample.js new file mode 100644 index 000000000000..bbd93ac79804 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceLoadBalancersListSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to List all load balancers in a network interface. + * + * @summary List all load balancers in a network interface. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceLoadBalancerList.json + */ +async function networkInterfaceLoadBalancerList() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const networkInterfaceName = "nic1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.networkInterfaceLoadBalancers.list( + resourceGroupName, + networkInterfaceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + networkInterfaceLoadBalancerList(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceTapConfigurationsCreateOrUpdateSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceTapConfigurationsCreateOrUpdateSample.js new file mode 100644 index 000000000000..00dacbe09ed5 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceTapConfigurationsCreateOrUpdateSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Creates or updates a Tap configuration in the specified NetworkInterface. + * + * @summary Creates or updates a Tap configuration in the specified NetworkInterface. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceTapConfigurationCreate.json + */ +async function createNetworkInterfaceTapConfigurations() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const networkInterfaceName = "mynic"; + const tapConfigurationName = "tapconfiguration1"; + const tapConfigurationParameters = { + virtualNetworkTap: { + id: "/subscriptions/subid/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworkTaps/testvtap", + }, + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaceTapConfigurations.beginCreateOrUpdateAndWait( + resourceGroupName, + networkInterfaceName, + tapConfigurationName, + tapConfigurationParameters + ); + console.log(result); +} + +async function main() { + createNetworkInterfaceTapConfigurations(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceTapConfigurationsDeleteSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceTapConfigurationsDeleteSample.js new file mode 100644 index 000000000000..d00bb2f2b11e --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceTapConfigurationsDeleteSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Deletes the specified tap configuration from the NetworkInterface. + * + * @summary Deletes the specified tap configuration from the NetworkInterface. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceTapConfigurationDelete.json + */ +async function deleteTapConfiguration() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkInterfaceName = "test-networkinterface"; + const tapConfigurationName = "test-tapconfiguration"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaceTapConfigurations.beginDeleteAndWait( + resourceGroupName, + networkInterfaceName, + tapConfigurationName + ); + console.log(result); +} + +async function main() { + deleteTapConfiguration(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceTapConfigurationsGetSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceTapConfigurationsGetSample.js new file mode 100644 index 000000000000..1304bf777e0b --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceTapConfigurationsGetSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Get the specified tap configuration on a network interface. + * + * @summary Get the specified tap configuration on a network interface. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceTapConfigurationGet.json + */ +async function getNetworkInterfaceTapConfigurations() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const networkInterfaceName = "mynic"; + const tapConfigurationName = "tapconfiguration1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaceTapConfigurations.get( + resourceGroupName, + networkInterfaceName, + tapConfigurationName + ); + console.log(result); +} + +async function main() { + getNetworkInterfaceTapConfigurations(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceTapConfigurationsListSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceTapConfigurationsListSample.js new file mode 100644 index 000000000000..7aa1a72be3db --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfaceTapConfigurationsListSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Get all Tap configurations in a network interface + * + * @summary Get all Tap configurations in a network interface + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceTapConfigurationList.json + */ +async function listVirtualNetworkTapConfigurations() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkInterfaceName = "mynic"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.networkInterfaceTapConfigurations.list( + resourceGroupName, + networkInterfaceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listVirtualNetworkTapConfigurations(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesCreateOrUpdateSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesCreateOrUpdateSample.js new file mode 100644 index 000000000000..8736d5d35b2b --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesCreateOrUpdateSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Creates or updates a network interface. + * + * @summary Creates or updates a network interface. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceCreate.json + */ +async function createNetworkInterface() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkInterfaceName = "test-nic"; + const parameters = { + enableAcceleratedNetworking: true, + ipConfigurations: [ + { + name: "ipconfig1", + publicIPAddress: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/test-ip", + }, + subnet: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/rg1-vnet/subnets/default", + }, + }, + ], + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaces.beginCreateOrUpdateAndWait( + resourceGroupName, + networkInterfaceName, + parameters + ); + console.log(result); +} + +async function main() { + createNetworkInterface(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesDeleteSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesDeleteSample.js new file mode 100644 index 000000000000..5e08c602a2c6 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesDeleteSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Deletes the specified network interface. + * + * @summary Deletes the specified network interface. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceDelete.json + */ +async function deleteNetworkInterface() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkInterfaceName = "test-nic"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaces.beginDeleteAndWait( + resourceGroupName, + networkInterfaceName + ); + console.log(result); +} + +async function main() { + deleteNetworkInterface(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesGetEffectiveRouteTableSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesGetEffectiveRouteTableSample.js new file mode 100644 index 000000000000..bfddc1b8fc0b --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesGetEffectiveRouteTableSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all route tables applied to a network interface. + * + * @summary Gets all route tables applied to a network interface. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceEffectiveRouteTableList.json + */ +async function showNetworkInterfaceEffectiveRouteTables() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkInterfaceName = "nic1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaces.beginGetEffectiveRouteTableAndWait( + resourceGroupName, + networkInterfaceName + ); + console.log(result); +} + +async function main() { + showNetworkInterfaceEffectiveRouteTables(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesGetSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesGetSample.js new file mode 100644 index 000000000000..c842f3f9dbb9 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesGetSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets information about the specified network interface. + * + * @summary Gets information about the specified network interface. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceGet.json + */ +async function getNetworkInterface() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkInterfaceName = "test-nic"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaces.get(resourceGroupName, networkInterfaceName); + console.log(result); +} + +async function main() { + getNetworkInterface(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesListAllSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesListAllSample.js new file mode 100644 index 000000000000..425a12b2d788 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesListAllSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all network interfaces in a subscription. + * + * @summary Gets all network interfaces in a subscription. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceListAll.json + */ +async function listAllNetworkInterfaces() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.networkInterfaces.listAll()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAllNetworkInterfaces(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesListEffectiveNetworkSecurityGroupsSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesListEffectiveNetworkSecurityGroupsSample.js new file mode 100644 index 000000000000..1314ae900aac --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesListEffectiveNetworkSecurityGroupsSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all network security groups applied to a network interface. + * + * @summary Gets all network security groups applied to a network interface. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceEffectiveNSGList.json + */ +async function listNetworkInterfaceEffectiveNetworkSecurityGroups() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkInterfaceName = "nic1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaces.beginListEffectiveNetworkSecurityGroupsAndWait( + resourceGroupName, + networkInterfaceName + ); + console.log(result); +} + +async function main() { + listNetworkInterfaceEffectiveNetworkSecurityGroups(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesListSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesListSample.js new file mode 100644 index 000000000000..902b335c035c --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesListSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all network interfaces in a resource group. + * + * @summary Gets all network interfaces in a resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceList.json + */ +async function listNetworkInterfacesInResourceGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.networkInterfaces.list(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listNetworkInterfacesInResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesUpdateTagsSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesUpdateTagsSample.js new file mode 100644 index 000000000000..985b2cfe0fde --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkInterfacesUpdateTagsSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Updates a network interface tags. + * + * @summary Updates a network interface tags. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceUpdateTags.json + */ +async function updateNetworkInterfaceTags() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkInterfaceName = "test-nic"; + const parameters = { tags: { tag1: "value1", tag2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaces.beginUpdateTagsAndWait( + resourceGroupName, + networkInterfaceName, + parameters + ); + console.log(result); +} + +async function main() { + updateNetworkInterfaceTags(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkSecurityGroupsCreateOrUpdateSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkSecurityGroupsCreateOrUpdateSample.js new file mode 100644 index 000000000000..17d8448ba785 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkSecurityGroupsCreateOrUpdateSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Creates or updates a network security group in the specified resource group. + * + * @summary Creates or updates a network security group in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupCreate.json + */ +async function createNetworkSecurityGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkSecurityGroupName = "testnsg"; + const parameters = {}; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkSecurityGroups.beginCreateOrUpdateAndWait( + resourceGroupName, + networkSecurityGroupName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a network security group in the specified resource group. + * + * @summary Creates or updates a network security group in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupCreateWithRule.json + */ +async function createNetworkSecurityGroupWithRule() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkSecurityGroupName = "testnsg"; + const parameters = { + securityRules: [ + { + name: "rule1", + access: "Allow", + destinationAddressPrefix: "*", + destinationPortRange: "80", + direction: "Inbound", + priority: 130, + sourceAddressPrefix: "*", + sourcePortRange: "*", + protocol: "*", + }, + ], + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkSecurityGroups.beginCreateOrUpdateAndWait( + resourceGroupName, + networkSecurityGroupName, + parameters + ); + console.log(result); +} + +async function main() { + createNetworkSecurityGroup(); + createNetworkSecurityGroupWithRule(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkSecurityGroupsDeleteSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkSecurityGroupsDeleteSample.js new file mode 100644 index 000000000000..3b99f0b70ece --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkSecurityGroupsDeleteSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Deletes the specified network security group. + * + * @summary Deletes the specified network security group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupDelete.json + */ +async function deleteNetworkSecurityGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkSecurityGroupName = "testnsg"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkSecurityGroups.beginDeleteAndWait( + resourceGroupName, + networkSecurityGroupName + ); + console.log(result); +} + +async function main() { + deleteNetworkSecurityGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkSecurityGroupsGetSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkSecurityGroupsGetSample.js new file mode 100644 index 000000000000..f59b2a01a088 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkSecurityGroupsGetSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the specified network security group. + * + * @summary Gets the specified network security group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupGet.json + */ +async function getNetworkSecurityGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkSecurityGroupName = "testnsg"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkSecurityGroups.get( + resourceGroupName, + networkSecurityGroupName + ); + console.log(result); +} + +async function main() { + getNetworkSecurityGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkSecurityGroupsListAllSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkSecurityGroupsListAllSample.js new file mode 100644 index 000000000000..3e1dc596da86 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkSecurityGroupsListAllSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all network security groups in a subscription. + * + * @summary Gets all network security groups in a subscription. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupListAll.json + */ +async function listAllNetworkSecurityGroups() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.networkSecurityGroups.listAll()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAllNetworkSecurityGroups(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkSecurityGroupsListSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkSecurityGroupsListSample.js new file mode 100644 index 000000000000..2ccf5e5a3ba2 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkSecurityGroupsListSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all network security groups in a resource group. + * + * @summary Gets all network security groups in a resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupList.json + */ +async function listNetworkSecurityGroupsInResourceGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.networkSecurityGroups.list(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listNetworkSecurityGroupsInResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkSecurityGroupsUpdateTagsSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkSecurityGroupsUpdateTagsSample.js new file mode 100644 index 000000000000..267904f2add7 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/networkSecurityGroupsUpdateTagsSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Updates a network security group tags. + * + * @summary Updates a network security group tags. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupUpdateTags.json + */ +async function updateNetworkSecurityGroupTags() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkSecurityGroupName = "testnsg"; + const parameters = { tags: { tag1: "value1", tag2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkSecurityGroups.beginUpdateTagsAndWait( + resourceGroupName, + networkSecurityGroupName, + parameters + ); + console.log(result); +} + +async function main() { + updateNetworkSecurityGroupTags(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/operationsListSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/operationsListSample.js new file mode 100644 index 000000000000..7189d849c243 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/operationsListSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Lists all of the available Network Rest API operations. + * + * @summary Lists all of the available Network Rest API operations. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/OperationList.json + */ +async function getAListOfOperationsForAResourceProvider() { + const subscriptionId = + process.env["NETWORK_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getAListOfOperationsForAResourceProvider(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/package.json b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/package.json new file mode 100644 index 000000000000..9e5f31b1ef75 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/package.json @@ -0,0 +1,32 @@ +{ + "name": "@azure-samples/arm-network-profile-2020-09-01-hybrid-js", + "private": true, + "version": "1.0.0", + "description": " client library samples for JavaScript", + "engines": { + "node": ">=14.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/network/arm-network-profile-2020-09-01-hybrid" + }, + "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/network/arm-network-profile-2020-09-01-hybrid", + "dependencies": { + "@azure/arm-network-profile-2020-09-01-hybrid": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + } +} diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/publicIPAddressesCreateOrUpdateSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/publicIPAddressesCreateOrUpdateSample.js new file mode 100644 index 000000000000..958384f27e93 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/publicIPAddressesCreateOrUpdateSample.js @@ -0,0 +1,91 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Creates or updates a static or dynamic public IP address. + * + * @summary Creates or updates a static or dynamic public IP address. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressCreateDns.json + */ +async function createPublicIPAddressDns() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const publicIpAddressName = "test-ip"; + const parameters = { + dnsSettings: { domainNameLabel: "dnslbl" }, + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.publicIPAddresses.beginCreateOrUpdateAndWait( + resourceGroupName, + publicIpAddressName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a static or dynamic public IP address. + * + * @summary Creates or updates a static or dynamic public IP address. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressCreateCustomizedValues.json + */ +async function createPublicIPAddressAllocationMethod() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const publicIpAddressName = "test-ip"; + const parameters = { + idleTimeoutInMinutes: 10, + publicIPAddressVersion: "IPv4", + publicIPAllocationMethod: "Static", + sku: { name: "Standard" }, + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.publicIPAddresses.beginCreateOrUpdateAndWait( + resourceGroupName, + publicIpAddressName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a static or dynamic public IP address. + * + * @summary Creates or updates a static or dynamic public IP address. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressCreateDefaults.json + */ +async function createPublicIPAddressDefaults() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const publicIpAddressName = "test-ip"; + const parameters = {}; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.publicIPAddresses.beginCreateOrUpdateAndWait( + resourceGroupName, + publicIpAddressName, + parameters + ); + console.log(result); +} + +async function main() { + createPublicIPAddressDns(); + createPublicIPAddressAllocationMethod(); + createPublicIPAddressDefaults(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/publicIPAddressesDeleteSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/publicIPAddressesDeleteSample.js new file mode 100644 index 000000000000..0b7c198443ed --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/publicIPAddressesDeleteSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Deletes the specified public IP address. + * + * @summary Deletes the specified public IP address. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressDelete.json + */ +async function deletePublicIPAddress() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const publicIpAddressName = "test-ip"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.publicIPAddresses.beginDeleteAndWait( + resourceGroupName, + publicIpAddressName + ); + console.log(result); +} + +async function main() { + deletePublicIPAddress(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/publicIPAddressesGetSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/publicIPAddressesGetSample.js new file mode 100644 index 000000000000..a29b9a9df3b1 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/publicIPAddressesGetSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the specified public IP address in a specified resource group. + * + * @summary Gets the specified public IP address in a specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressGet.json + */ +async function getPublicIPAddress() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const publicIpAddressName = "testDNS-ip"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.publicIPAddresses.get(resourceGroupName, publicIpAddressName); + console.log(result); +} + +async function main() { + getPublicIPAddress(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/publicIPAddressesListAllSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/publicIPAddressesListAllSample.js new file mode 100644 index 000000000000..cafb1f510f75 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/publicIPAddressesListAllSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all the public IP addresses in a subscription. + * + * @summary Gets all the public IP addresses in a subscription. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressListAll.json + */ +async function listAllPublicIPAddresses() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.publicIPAddresses.listAll()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAllPublicIPAddresses(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/publicIPAddressesListSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/publicIPAddressesListSample.js new file mode 100644 index 000000000000..28d2ff3845ea --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/publicIPAddressesListSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all public IP addresses in a resource group. + * + * @summary Gets all public IP addresses in a resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressList.json + */ +async function listResourceGroupPublicIPAddresses() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.publicIPAddresses.list(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listResourceGroupPublicIPAddresses(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/publicIPAddressesUpdateTagsSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/publicIPAddressesUpdateTagsSample.js new file mode 100644 index 000000000000..5841d64a7420 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/publicIPAddressesUpdateTagsSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Updates public IP address tags. + * + * @summary Updates public IP address tags. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressUpdateTags.json + */ +async function updatePublicIPAddressTags() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const publicIpAddressName = "test-ip"; + const parameters = { tags: { tag1: "value1", tag2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.publicIPAddresses.beginUpdateTagsAndWait( + resourceGroupName, + publicIpAddressName, + parameters + ); + console.log(result); +} + +async function main() { + updatePublicIPAddressTags(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routeTablesCreateOrUpdateSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routeTablesCreateOrUpdateSample.js new file mode 100644 index 000000000000..699ed03da255 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routeTablesCreateOrUpdateSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Create or updates a route table in a specified resource group. + * + * @summary Create or updates a route table in a specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableCreate.json + */ +async function createRouteTable() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const routeTableName = "testrt"; + const parameters = { location: "westus" }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.routeTables.beginCreateOrUpdateAndWait( + resourceGroupName, + routeTableName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Create or updates a route table in a specified resource group. + * + * @summary Create or updates a route table in a specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableCreateWithRoute.json + */ +async function createRouteTableWithRoute() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const routeTableName = "testrt"; + const parameters = { + disableBgpRoutePropagation: true, + location: "westus", + routes: [ + { + name: "route1", + addressPrefix: "10.0.3.0/24", + nextHopType: "VirtualNetworkGateway", + }, + ], + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.routeTables.beginCreateOrUpdateAndWait( + resourceGroupName, + routeTableName, + parameters + ); + console.log(result); +} + +async function main() { + createRouteTable(); + createRouteTableWithRoute(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routeTablesDeleteSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routeTablesDeleteSample.js new file mode 100644 index 000000000000..ba74cf549e85 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routeTablesDeleteSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Deletes the specified route table. + * + * @summary Deletes the specified route table. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableDelete.json + */ +async function deleteRouteTable() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const routeTableName = "testrt"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.routeTables.beginDeleteAndWait(resourceGroupName, routeTableName); + console.log(result); +} + +async function main() { + deleteRouteTable(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routeTablesGetSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routeTablesGetSample.js new file mode 100644 index 000000000000..e540a186ec59 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routeTablesGetSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the specified route table. + * + * @summary Gets the specified route table. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableGet.json + */ +async function getRouteTable() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const routeTableName = "testrt"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.routeTables.get(resourceGroupName, routeTableName); + console.log(result); +} + +async function main() { + getRouteTable(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routeTablesListAllSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routeTablesListAllSample.js new file mode 100644 index 000000000000..fdcaf8421490 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routeTablesListAllSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all route tables in a subscription. + * + * @summary Gets all route tables in a subscription. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableListAll.json + */ +async function listAllRouteTables() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.routeTables.listAll()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAllRouteTables(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routeTablesListSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routeTablesListSample.js new file mode 100644 index 000000000000..c70e0202ef77 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routeTablesListSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all route tables in a resource group. + * + * @summary Gets all route tables in a resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableList.json + */ +async function listRouteTablesInResourceGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.routeTables.list(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listRouteTablesInResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routeTablesUpdateTagsSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routeTablesUpdateTagsSample.js new file mode 100644 index 000000000000..52fa79580fd4 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routeTablesUpdateTagsSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Updates a route table tags. + * + * @summary Updates a route table tags. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableUpdateTags.json + */ +async function updateRouteTableTags() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const routeTableName = "testrt"; + const parameters = { tags: { tag1: "value1", tag2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.routeTables.beginUpdateTagsAndWait( + resourceGroupName, + routeTableName, + parameters + ); + console.log(result); +} + +async function main() { + updateRouteTableTags(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routesCreateOrUpdateSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routesCreateOrUpdateSample.js new file mode 100644 index 000000000000..662fa1eebd3a --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routesCreateOrUpdateSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Creates or updates a route in the specified route table. + * + * @summary Creates or updates a route in the specified route table. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableRouteCreate.json + */ +async function createRoute() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const routeTableName = "testrt"; + const routeName = "route1"; + const routeParameters = { + addressPrefix: "10.0.3.0/24", + nextHopType: "VirtualNetworkGateway", + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.routes.beginCreateOrUpdateAndWait( + resourceGroupName, + routeTableName, + routeName, + routeParameters + ); + console.log(result); +} + +async function main() { + createRoute(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routesDeleteSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routesDeleteSample.js new file mode 100644 index 000000000000..9aa6b0d766aa --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routesDeleteSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Deletes the specified route from a route table. + * + * @summary Deletes the specified route from a route table. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableRouteDelete.json + */ +async function deleteRoute() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const routeTableName = "testrt"; + const routeName = "route1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.routes.beginDeleteAndWait( + resourceGroupName, + routeTableName, + routeName + ); + console.log(result); +} + +async function main() { + deleteRoute(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routesGetSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routesGetSample.js new file mode 100644 index 000000000000..7b1e3095e75c --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routesGetSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the specified route from a route table. + * + * @summary Gets the specified route from a route table. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableRouteGet.json + */ +async function getRoute() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const routeTableName = "testrt"; + const routeName = "route1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.routes.get(resourceGroupName, routeTableName, routeName); + console.log(result); +} + +async function main() { + getRoute(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routesListSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routesListSample.js new file mode 100644 index 000000000000..325d6acd5dd8 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/routesListSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all routes in a route table. + * + * @summary Gets all routes in a route table. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableRouteList.json + */ +async function listRoutes() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const routeTableName = "testrt"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.routes.list(resourceGroupName, routeTableName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listRoutes(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/sample.env b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/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/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/securityRulesCreateOrUpdateSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/securityRulesCreateOrUpdateSample.js new file mode 100644 index 000000000000..658a0d71b685 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/securityRulesCreateOrUpdateSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Creates or updates a security rule in the specified network security group. + * + * @summary Creates or updates a security rule in the specified network security group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupRuleCreate.json + */ +async function createSecurityRule() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkSecurityGroupName = "testnsg"; + const securityRuleName = "rule1"; + const securityRuleParameters = { + access: "Deny", + destinationAddressPrefix: "11.0.0.0/8", + destinationPortRange: "8080", + direction: "Outbound", + priority: 100, + sourceAddressPrefix: "10.0.0.0/8", + sourcePortRange: "*", + protocol: "*", + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.securityRules.beginCreateOrUpdateAndWait( + resourceGroupName, + networkSecurityGroupName, + securityRuleName, + securityRuleParameters + ); + console.log(result); +} + +async function main() { + createSecurityRule(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/securityRulesDeleteSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/securityRulesDeleteSample.js new file mode 100644 index 000000000000..d10c934061f0 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/securityRulesDeleteSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Deletes the specified network security rule. + * + * @summary Deletes the specified network security rule. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupRuleDelete.json + */ +async function deleteNetworkSecurityRuleFromNetworkSecurityGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkSecurityGroupName = "testnsg"; + const securityRuleName = "rule1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.securityRules.beginDeleteAndWait( + resourceGroupName, + networkSecurityGroupName, + securityRuleName + ); + console.log(result); +} + +async function main() { + deleteNetworkSecurityRuleFromNetworkSecurityGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/securityRulesGetSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/securityRulesGetSample.js new file mode 100644 index 000000000000..076759063dae --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/securityRulesGetSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Get the specified network security rule. + * + * @summary Get the specified network security rule. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupRuleGet.json + */ +async function getNetworkSecurityRuleInNetworkSecurityGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkSecurityGroupName = "testnsg"; + const securityRuleName = "rule1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.securityRules.get( + resourceGroupName, + networkSecurityGroupName, + securityRuleName + ); + console.log(result); +} + +async function main() { + getNetworkSecurityRuleInNetworkSecurityGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/securityRulesListSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/securityRulesListSample.js new file mode 100644 index 000000000000..ab11a501080f --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/securityRulesListSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all security rules in a network security group. + * + * @summary Gets all security rules in a network security group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupRuleList.json + */ +async function listNetworkSecurityRulesInNetworkSecurityGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkSecurityGroupName = "testnsg"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.securityRules.list(resourceGroupName, networkSecurityGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listNetworkSecurityRulesInNetworkSecurityGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/subnetsCreateOrUpdateSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/subnetsCreateOrUpdateSample.js new file mode 100644 index 000000000000..f5d5a5152b83 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/subnetsCreateOrUpdateSample.js @@ -0,0 +1,93 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Creates or updates a subnet in the specified virtual network. + * + * @summary Creates or updates a subnet in the specified virtual network. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetCreate.json + */ +async function createSubnet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "subnet-test"; + const virtualNetworkName = "vnetname"; + const subnetName = "subnet1"; + const subnetParameters = { addressPrefix: "10.0.0.0/16" }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.subnets.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + subnetName, + subnetParameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a subnet in the specified virtual network. + * + * @summary Creates or updates a subnet in the specified virtual network. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetCreateWithDelegation.json + */ +async function createSubnetWithADelegation() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subId"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "subnet-test"; + const virtualNetworkName = "vnetname"; + const subnetName = "subnet1"; + const subnetParameters = { addressPrefix: "10.0.0.0/16" }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.subnets.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + subnetName, + subnetParameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a subnet in the specified virtual network. + * + * @summary Creates or updates a subnet in the specified virtual network. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetCreateServiceEndpoint.json + */ +async function createSubnetWithServiceEndpoints() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "subnet-test"; + const virtualNetworkName = "vnetname"; + const subnetName = "subnet1"; + const subnetParameters = { + addressPrefix: "10.0.0.0/16", + serviceEndpoints: [{ service: "Microsoft.Storage" }], + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.subnets.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + subnetName, + subnetParameters + ); + console.log(result); +} + +async function main() { + createSubnet(); + createSubnetWithADelegation(); + createSubnetWithServiceEndpoints(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/subnetsDeleteSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/subnetsDeleteSample.js new file mode 100644 index 000000000000..36e7254f100f --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/subnetsDeleteSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Deletes the specified subnet. + * + * @summary Deletes the specified subnet. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetDelete.json + */ +async function deleteSubnet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "subnet-test"; + const virtualNetworkName = "vnetname"; + const subnetName = "subnet1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.subnets.beginDeleteAndWait( + resourceGroupName, + virtualNetworkName, + subnetName + ); + console.log(result); +} + +async function main() { + deleteSubnet(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/subnetsGetSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/subnetsGetSample.js new file mode 100644 index 000000000000..65cea5a4c876 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/subnetsGetSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the specified subnet by virtual network and resource group. + * + * @summary Gets the specified subnet by virtual network and resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetGet.json + */ +async function getSubnet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "subnet-test"; + const virtualNetworkName = "vnetname"; + const subnetName = "subnet1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.subnets.get(resourceGroupName, virtualNetworkName, subnetName); + console.log(result); +} + +/** + * This sample demonstrates how to Gets the specified subnet by virtual network and resource group. + * + * @summary Gets the specified subnet by virtual network and resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetGetWithDelegation.json + */ +async function getSubnetWithADelegation() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subId"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "subnet-test"; + const virtualNetworkName = "vnetname"; + const subnetName = "subnet1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.subnets.get(resourceGroupName, virtualNetworkName, subnetName); + console.log(result); +} + +async function main() { + getSubnet(); + getSubnetWithADelegation(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/subnetsListSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/subnetsListSample.js new file mode 100644 index 000000000000..017367bc4cd4 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/subnetsListSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all subnets in a virtual network. + * + * @summary Gets all subnets in a virtual network. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetList.json + */ +async function listSubnets() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "subnet-test"; + const virtualNetworkName = "vnetname"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.subnets.list(resourceGroupName, virtualNetworkName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listSubnets(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsCreateOrUpdateSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsCreateOrUpdateSample.js new file mode 100644 index 000000000000..7c89fe77443c --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsCreateOrUpdateSample.js @@ -0,0 +1,89 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Creates or updates a virtual network gateway connection in the specified resource group. + * + * @summary Creates or updates a virtual network gateway connection in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionCreate.json + */ +async function createVirtualNetworkGatewayConnectionS2S() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayConnectionName = "connS2S"; + const parameters = { + connectionProtocol: "IKEv2", + connectionType: "IPsec", + enableBgp: false, + ipsecPolicies: [], + localNetworkGateway2: { + etag: 'W/"00000000-0000-0000-0000-000000000000"', + gatewayIpAddress: "x.x.x.x", + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/localNetworkGateways/localgw", + localNetworkAddressSpace: { addressPrefixes: ["10.1.0.0/16"] }, + location: "centralus", + resourceGuid: "00000000-0000-0000-0000-000000000000", + tags: {}, + }, + location: "centralus", + routingWeight: 0, + sharedKey: "Abc123", + usePolicyBasedTrafficSelectors: false, + virtualNetworkGateway1: { + active: false, + bgpSettings: { + asn: 65514, + bgpPeeringAddress: "10.0.1.30", + peerWeight: 0, + }, + enableBgp: false, + etag: 'W/"00000000-0000-0000-0000-000000000000"', + gatewayType: "Vpn", + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw", + ipConfigurations: [ + { + name: "gwipconfig1", + etag: 'W/"00000000-0000-0000-0000-000000000000"', + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw/ipConfigurations/gwipconfig1", + privateIPAllocationMethod: "Dynamic", + publicIPAddress: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/gwpip", + }, + subnet: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/GatewaySubnet", + }, + }, + ], + location: "centralus", + resourceGuid: "00000000-0000-0000-0000-000000000000", + sku: { name: "VpnGw1", capacity: 2, tier: "VpnGw1" }, + tags: {}, + vpnType: "RouteBased", + }, + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGatewayConnections.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkGatewayConnectionName, + parameters + ); + console.log(result); +} + +async function main() { + createVirtualNetworkGatewayConnectionS2S(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsDeleteSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsDeleteSample.js new file mode 100644 index 000000000000..b99a3f883c8d --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsDeleteSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Deletes the specified virtual network Gateway connection. + * + * @summary Deletes the specified virtual network Gateway connection. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionDelete.json + */ +async function deleteVirtualNetworkGatewayConnection() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayConnectionName = "conn1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGatewayConnections.beginDeleteAndWait( + resourceGroupName, + virtualNetworkGatewayConnectionName + ); + console.log(result); +} + +async function main() { + deleteVirtualNetworkGatewayConnection(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsGetSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsGetSample.js new file mode 100644 index 000000000000..ba5f829eba86 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsGetSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the specified virtual network gateway connection by resource group. + * + * @summary Gets the specified virtual network gateway connection by resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionGet.json + */ +async function getVirtualNetworkGatewayConnection() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayConnectionName = "connS2S"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGatewayConnections.get( + resourceGroupName, + virtualNetworkGatewayConnectionName + ); + console.log(result); +} + +async function main() { + getVirtualNetworkGatewayConnection(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsGetSharedKeySample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsGetSharedKeySample.js new file mode 100644 index 000000000000..ba9ee8f34f9e --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsGetSharedKeySample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to The Get VirtualNetworkGatewayConnectionSharedKey operation retrieves information about the specified virtual network gateway connection shared key through Network resource provider. + * + * @summary The Get VirtualNetworkGatewayConnectionSharedKey operation retrieves information about the specified virtual network gateway connection shared key through Network resource provider. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionGetSharedKey.json + */ +async function getVirtualNetworkGatewayConnectionSharedKey() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayConnectionName = "connS2S"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGatewayConnections.getSharedKey( + resourceGroupName, + virtualNetworkGatewayConnectionName + ); + console.log(result); +} + +async function main() { + getVirtualNetworkGatewayConnectionSharedKey(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsListSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsListSample.js new file mode 100644 index 000000000000..e1f424a3e69d --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsListSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to The List VirtualNetworkGatewayConnections operation retrieves all the virtual network gateways connections created. + * + * @summary The List VirtualNetworkGatewayConnections operation retrieves all the virtual network gateways connections created. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionsList.json + */ +async function listVirtualNetworkGatewayConnectionsinResourceGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.virtualNetworkGatewayConnections.list(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listVirtualNetworkGatewayConnectionsinResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsResetSharedKeySample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsResetSharedKeySample.js new file mode 100644 index 000000000000..043db5ee37b8 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsResetSharedKeySample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to The VirtualNetworkGatewayConnectionResetSharedKey operation resets the virtual network gateway connection shared key for passed virtual network gateway connection in the specified resource group through Network resource provider. + * + * @summary The VirtualNetworkGatewayConnectionResetSharedKey operation resets the virtual network gateway connection shared key for passed virtual network gateway connection in the specified resource group through Network resource provider. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionResetSharedKey.json + */ +async function resetVirtualNetworkGatewayConnectionSharedKey() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayConnectionName = "conn1"; + const parameters = { keyLength: 128 }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGatewayConnections.beginResetSharedKeyAndWait( + resourceGroupName, + virtualNetworkGatewayConnectionName, + parameters + ); + console.log(result); +} + +async function main() { + resetVirtualNetworkGatewayConnectionSharedKey(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsSetSharedKeySample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsSetSharedKeySample.js new file mode 100644 index 000000000000..0a4370f250f0 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsSetSharedKeySample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to The Put VirtualNetworkGatewayConnectionSharedKey operation sets the virtual network gateway connection shared key for passed virtual network gateway connection in the specified resource group through Network resource provider. + * + * @summary The Put VirtualNetworkGatewayConnectionSharedKey operation sets the virtual network gateway connection shared key for passed virtual network gateway connection in the specified resource group through Network resource provider. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionSetSharedKey.json + */ +async function setVirtualNetworkGatewayConnectionSharedKey() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayConnectionName = "connS2S"; + const parameters = { value: "AzureAbc123" }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGatewayConnections.beginSetSharedKeyAndWait( + resourceGroupName, + virtualNetworkGatewayConnectionName, + parameters + ); + console.log(result); +} + +async function main() { + setVirtualNetworkGatewayConnectionSharedKey(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsUpdateTagsSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsUpdateTagsSample.js new file mode 100644 index 000000000000..dda620798967 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewayConnectionsUpdateTagsSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Updates a virtual network gateway connection tags. + * + * @summary Updates a virtual network gateway connection tags. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionUpdateTags.json + */ +async function updateVirtualNetworkGatewayConnectionTags() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayConnectionName = "test"; + const parameters = { tags: { tag1: "value1", tag2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGatewayConnections.beginUpdateTagsAndWait( + resourceGroupName, + virtualNetworkGatewayConnectionName, + parameters + ); + console.log(result); +} + +async function main() { + updateVirtualNetworkGatewayConnectionTags(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysCreateOrUpdateSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysCreateOrUpdateSample.js new file mode 100644 index 000000000000..2acbaf8ef067 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysCreateOrUpdateSample.js @@ -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. +const { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Creates or updates a virtual network gateway in the specified resource group. + * + * @summary Creates or updates a virtual network gateway in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayUpdate.json + */ +async function updateVirtualNetworkGateway() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const parameters = { + active: false, + bgpSettings: { asn: 65515, bgpPeeringAddress: "10.0.1.30", peerWeight: 0 }, + enableBgp: false, + gatewayType: "Vpn", + ipConfigurations: [ + { + name: "gwipconfig1", + privateIPAllocationMethod: "Dynamic", + publicIPAddress: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/gwpip", + }, + subnet: { + id: "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/GatewaySubnet", + }, + }, + ], + location: "centralus", + sku: { name: "VpnGw1", tier: "VpnGw1" }, + vpnType: "RouteBased", + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkGatewayName, + parameters + ); + console.log(result); +} + +async function main() { + updateVirtualNetworkGateway(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysDeleteSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysDeleteSample.js new file mode 100644 index 000000000000..dc52b082a58f --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysDeleteSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Deletes the specified virtual network gateway. + * + * @summary Deletes the specified virtual network gateway. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayDelete.json + */ +async function deleteVirtualNetworkGateway() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginDeleteAndWait( + resourceGroupName, + virtualNetworkGatewayName + ); + console.log(result); +} + +async function main() { + deleteVirtualNetworkGateway(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGenerateVpnProfileSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGenerateVpnProfileSample.js new file mode 100644 index 000000000000..01f137307414 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGenerateVpnProfileSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Generates VPN profile for P2S client of the virtual network gateway in the specified resource group. Used for IKEV2 and radius based authentication. + * + * @summary Generates VPN profile for P2S client of the virtual network gateway in the specified resource group. Used for IKEV2 and radius based authentication. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGenerateVpnProfile.json + */ +async function generateVirtualNetworkGatewayVpnProfile() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const parameters = {}; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginGenerateVpnProfileAndWait( + resourceGroupName, + virtualNetworkGatewayName, + parameters + ); + console.log(result); +} + +async function main() { + generateVirtualNetworkGatewayVpnProfile(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGeneratevpnclientpackageSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGeneratevpnclientpackageSample.js new file mode 100644 index 000000000000..801b73e06b2b --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGeneratevpnclientpackageSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Generates VPN client package for P2S client of the virtual network gateway in the specified resource group. + * + * @summary Generates VPN client package for P2S client of the virtual network gateway in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGenerateVpnClientPackage.json + */ +async function generateVpnClientPackage() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const parameters = {}; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginGeneratevpnclientpackageAndWait( + resourceGroupName, + virtualNetworkGatewayName, + parameters + ); + console.log(result); +} + +async function main() { + generateVpnClientPackage(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGetAdvertisedRoutesSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGetAdvertisedRoutesSample.js new file mode 100644 index 000000000000..7aa249bf9e49 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGetAdvertisedRoutesSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to This operation retrieves a list of routes the virtual network gateway is advertising to the specified peer. + * + * @summary This operation retrieves a list of routes the virtual network gateway is advertising to the specified peer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGetAdvertisedRoutes.json + */ +async function getVirtualNetworkGatewayAdvertisedRoutes() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const peer = "test"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginGetAdvertisedRoutesAndWait( + resourceGroupName, + virtualNetworkGatewayName, + peer + ); + console.log(result); +} + +async function main() { + getVirtualNetworkGatewayAdvertisedRoutes(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGetBgpPeerStatusSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGetBgpPeerStatusSample.js new file mode 100644 index 000000000000..a020f14475a5 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGetBgpPeerStatusSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to The GetBgpPeerStatus operation retrieves the status of all BGP peers. + * + * @summary The GetBgpPeerStatus operation retrieves the status of all BGP peers. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGetBGPPeerStatus.json + */ +async function getVirtualNetworkGatewayBgpPeerStatus() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginGetBgpPeerStatusAndWait( + resourceGroupName, + virtualNetworkGatewayName + ); + console.log(result); +} + +async function main() { + getVirtualNetworkGatewayBgpPeerStatus(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGetLearnedRoutesSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGetLearnedRoutesSample.js new file mode 100644 index 000000000000..3d9d5515e39f --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGetLearnedRoutesSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to This operation retrieves a list of routes the virtual network gateway has learned, including routes learned from BGP peers. + * + * @summary This operation retrieves a list of routes the virtual network gateway has learned, including routes learned from BGP peers. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayLearnedRoutes.json + */ +async function getVirtualNetworkGatewayLearnedRoutes() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginGetLearnedRoutesAndWait( + resourceGroupName, + virtualNetworkGatewayName + ); + console.log(result); +} + +async function main() { + getVirtualNetworkGatewayLearnedRoutes(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGetSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGetSample.js new file mode 100644 index 000000000000..758550ccba35 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGetSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the specified virtual network gateway by resource group. + * + * @summary Gets the specified virtual network gateway by resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGet.json + */ +async function getVirtualNetworkGateway() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.get( + resourceGroupName, + virtualNetworkGatewayName + ); + console.log(result); +} + +async function main() { + getVirtualNetworkGateway(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGetVpnProfilePackageUrlSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGetVpnProfilePackageUrlSample.js new file mode 100644 index 000000000000..d786f74320bd --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGetVpnProfilePackageUrlSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets pre-generated VPN profile for P2S client of the virtual network gateway in the specified resource group. The profile needs to be generated first using generateVpnProfile. + * + * @summary Gets pre-generated VPN profile for P2S client of the virtual network gateway in the specified resource group. The profile needs to be generated first using generateVpnProfile. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGetVpnProfilePackageUrl.json + */ +async function getVirtualNetworkGatewayVpnProfilePackageUrl() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginGetVpnProfilePackageUrlAndWait( + resourceGroupName, + virtualNetworkGatewayName + ); + console.log(result); +} + +async function main() { + getVirtualNetworkGatewayVpnProfilePackageUrl(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGetVpnclientIpsecParametersSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGetVpnclientIpsecParametersSample.js new file mode 100644 index 000000000000..7ad05d09067e --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysGetVpnclientIpsecParametersSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to The Get VpnclientIpsecParameters operation retrieves information about the vpnclient ipsec policy for P2S client of virtual network gateway in the specified resource group through Network resource provider. + * + * @summary The Get VpnclientIpsecParameters operation retrieves information about the vpnclient ipsec policy for P2S client of virtual network gateway in the specified resource group through Network resource provider. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGetVpnClientIpsecParameters.json + */ +async function getVirtualNetworkGatewayVpnClientIpsecParameters() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginGetVpnclientIpsecParametersAndWait( + resourceGroupName, + virtualNetworkGatewayName + ); + console.log(result); +} + +async function main() { + getVirtualNetworkGatewayVpnClientIpsecParameters(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysListConnectionsSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysListConnectionsSample.js new file mode 100644 index 000000000000..f68d5264d247 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysListConnectionsSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all the connections in a virtual network gateway. + * + * @summary Gets all the connections in a virtual network gateway. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewaysListConnections.json + */ +async function virtualNetworkGatewaysListConnections() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const virtualNetworkGatewayName = "test-vpn-gateway-1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.virtualNetworkGateways.listConnections( + resourceGroupName, + virtualNetworkGatewayName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + virtualNetworkGatewaysListConnections(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysListSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysListSample.js new file mode 100644 index 000000000000..6062dbe49e55 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysListSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all virtual network gateways by resource group. + * + * @summary Gets all virtual network gateways by resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayList.json + */ +async function listVirtualNetworkGatewaysinResourceGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.virtualNetworkGateways.list(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listVirtualNetworkGatewaysinResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysResetSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysResetSample.js new file mode 100644 index 000000000000..e79128dc9ee4 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysResetSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Resets the primary of the virtual network gateway in the specified resource group. + * + * @summary Resets the primary of the virtual network gateway in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayReset.json + */ +async function resetVirtualNetworkGateway() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginResetAndWait( + resourceGroupName, + virtualNetworkGatewayName + ); + console.log(result); +} + +async function main() { + resetVirtualNetworkGateway(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysResetVpnClientSharedKeySample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysResetVpnClientSharedKeySample.js new file mode 100644 index 000000000000..903e02b0663c --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysResetVpnClientSharedKeySample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Resets the VPN client shared key of the virtual network gateway in the specified resource group. + * + * @summary Resets the VPN client shared key of the virtual network gateway in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayResetVpnClientSharedKey.json + */ +async function resetVpnClientSharedKey() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginResetVpnClientSharedKeyAndWait( + resourceGroupName, + virtualNetworkGatewayName + ); + console.log(result); +} + +async function main() { + resetVpnClientSharedKey(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysSetVpnclientIpsecParametersSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysSetVpnclientIpsecParametersSample.js new file mode 100644 index 000000000000..efb35fcdeff1 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysSetVpnclientIpsecParametersSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to The Set VpnclientIpsecParameters operation sets the vpnclient ipsec policy for P2S client of virtual network gateway in the specified resource group through Network resource provider. + * + * @summary The Set VpnclientIpsecParameters operation sets the vpnclient ipsec policy for P2S client of virtual network gateway in the specified resource group through Network resource provider. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewaySetVpnClientIpsecParameters.json + */ +async function setVirtualNetworkGatewayVpnClientIpsecParameters() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const vpnclientIpsecParams = { + dhGroup: "DHGroup2", + ikeEncryption: "AES256", + ikeIntegrity: "SHA384", + ipsecEncryption: "AES256", + ipsecIntegrity: "SHA256", + pfsGroup: "PFS2", + saDataSizeKilobytes: 429497, + saLifeTimeSeconds: 86473, + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginSetVpnclientIpsecParametersAndWait( + resourceGroupName, + virtualNetworkGatewayName, + vpnclientIpsecParams + ); + console.log(result); +} + +async function main() { + setVirtualNetworkGatewayVpnClientIpsecParameters(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysSupportedVpnDevicesSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysSupportedVpnDevicesSample.js new file mode 100644 index 000000000000..a317ab5ce29e --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysSupportedVpnDevicesSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets a xml format representation for supported vpn devices. + * + * @summary Gets a xml format representation for supported vpn devices. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewaySupportedVpnDevice.json + */ +async function listVirtualNetworkGatewaySupportedVpnDevices() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.supportedVpnDevices( + resourceGroupName, + virtualNetworkGatewayName + ); + console.log(result); +} + +async function main() { + listVirtualNetworkGatewaySupportedVpnDevices(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysUpdateTagsSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysUpdateTagsSample.js new file mode 100644 index 000000000000..fd13a782a3cb --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysUpdateTagsSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Updates a virtual network gateway tags. + * + * @summary Updates a virtual network gateway tags. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayUpdateTags.json + */ +async function updateVirtualNetworkGatewayTags() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const parameters = { tags: { tag1: "value1", tag2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginUpdateTagsAndWait( + resourceGroupName, + virtualNetworkGatewayName, + parameters + ); + console.log(result); +} + +async function main() { + updateVirtualNetworkGatewayTags(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysVpnDeviceConfigurationScriptSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysVpnDeviceConfigurationScriptSample.js new file mode 100644 index 000000000000..9f59a3e7ad50 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkGatewaysVpnDeviceConfigurationScriptSample.js @@ -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. +const { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets a xml format representation for vpn device configuration script. + * + * @summary Gets a xml format representation for vpn device configuration script. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayVpnDeviceConfigurationScript.json + */ +async function getVpnDeviceConfigurationScript() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayConnectionName = "vpngw"; + const parameters = { + deviceFamily: "ISR", + firmwareVersion: "IOS 15.1 (Preview)", + vendor: "Cisco", + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.vpnDeviceConfigurationScript( + resourceGroupName, + virtualNetworkGatewayConnectionName, + parameters + ); + console.log(result); +} + +async function main() { + getVpnDeviceConfigurationScript(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkPeeringsCreateOrUpdateSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkPeeringsCreateOrUpdateSample.js new file mode 100644 index 000000000000..0cfe05e1f414 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkPeeringsCreateOrUpdateSample.js @@ -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. +const { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Creates or updates a peering in the specified virtual network. + * + * @summary Creates or updates a peering in the specified virtual network. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkPeeringCreate.json + */ +async function createPeering() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "peerTest"; + const virtualNetworkName = "vnet1"; + const virtualNetworkPeeringName = "peer"; + const virtualNetworkPeeringParameters = { + allowForwardedTraffic: true, + allowGatewayTransit: false, + allowVirtualNetworkAccess: true, + remoteVirtualNetwork: { + id: "/subscriptions/subid/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet2", + }, + useRemoteGateways: false, + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkPeerings.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + virtualNetworkPeeringName, + virtualNetworkPeeringParameters + ); + console.log(result); +} + +async function main() { + createPeering(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkPeeringsDeleteSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkPeeringsDeleteSample.js new file mode 100644 index 000000000000..2e5c67ec4631 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkPeeringsDeleteSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Deletes the specified virtual network peering. + * + * @summary Deletes the specified virtual network peering. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkPeeringDelete.json + */ +async function deletePeering() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "peerTest"; + const virtualNetworkName = "vnet1"; + const virtualNetworkPeeringName = "peer"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkPeerings.beginDeleteAndWait( + resourceGroupName, + virtualNetworkName, + virtualNetworkPeeringName + ); + console.log(result); +} + +async function main() { + deletePeering(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkPeeringsGetSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkPeeringsGetSample.js new file mode 100644 index 000000000000..04a64aae96a2 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkPeeringsGetSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the specified virtual network peering. + * + * @summary Gets the specified virtual network peering. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkPeeringGet.json + */ +async function getPeering() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "peerTest"; + const virtualNetworkName = "vnet1"; + const virtualNetworkPeeringName = "peer"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkPeerings.get( + resourceGroupName, + virtualNetworkName, + virtualNetworkPeeringName + ); + console.log(result); +} + +async function main() { + getPeering(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkPeeringsListSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkPeeringsListSample.js new file mode 100644 index 000000000000..95ba7a747c47 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworkPeeringsListSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all virtual network peerings in a virtual network. + * + * @summary Gets all virtual network peerings in a virtual network. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkPeeringList.json + */ +async function listPeerings() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "peerTest"; + const virtualNetworkName = "vnet1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.virtualNetworkPeerings.list( + resourceGroupName, + virtualNetworkName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listPeerings(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksCheckIPAddressAvailabilitySample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksCheckIPAddressAvailabilitySample.js new file mode 100644 index 000000000000..b71cf327c60c --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksCheckIPAddressAvailabilitySample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Checks whether a private IP address is available for use. + * + * @summary Checks whether a private IP address is available for use. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkCheckIPAddressAvailability.json + */ +async function checkIPAddressAvailability() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const ipAddress = "10.0.1.4"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.checkIPAddressAvailability( + resourceGroupName, + virtualNetworkName, + ipAddress + ); + console.log(result); +} + +async function main() { + checkIPAddressAvailability(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksCreateOrUpdateSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksCreateOrUpdateSample.js new file mode 100644 index 000000000000..2655e67cbf8a --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksCreateOrUpdateSample.js @@ -0,0 +1,196 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Creates or updates a virtual network in the specified resource group. + * + * @summary Creates or updates a virtual network in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkCreate.json + */ +async function createVirtualNetwork() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const parameters = { + addressSpace: { addressPrefixes: ["10.0.0.0/16"] }, + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a virtual network in the specified resource group. + * + * @summary Creates or updates a virtual network in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkCreateSubnetWithDelegation.json + */ +async function createVirtualNetworkWithDelegatedSubnets() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subId"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const parameters = { + addressSpace: { addressPrefixes: ["10.0.0.0/16"] }, + subnets: [ + { + name: "test-1", + addressPrefix: "10.0.0.0/24", + delegations: [ + { + name: "myDelegation", + serviceName: "Microsoft.Provider/resourceType", + }, + ], + }, + ], + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a virtual network in the specified resource group. + * + * @summary Creates or updates a virtual network in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkCreateServiceEndpoints.json + */ +async function createVirtualNetworkWithServiceEndpoints() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "vnetTest"; + const virtualNetworkName = "vnet1"; + const parameters = { + addressSpace: { addressPrefixes: ["10.0.0.0/16"] }, + subnets: [ + { + name: "test-1", + addressPrefix: "10.0.0.0/16", + serviceEndpoints: [{ service: "Microsoft.Storage" }], + }, + ], + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a virtual network in the specified resource group. + * + * @summary Creates or updates a virtual network in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkCreateServiceEndpointPolicy.json + */ +async function createVirtualNetworkWithServiceEndpointsAndServiceEndpointPolicy() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "vnetTest"; + const virtualNetworkName = "vnet1"; + const parameters = { + addressSpace: { addressPrefixes: ["10.0.0.0/16"] }, + location: "eastus", + subnets: [ + { + name: "test-1", + addressPrefix: "10.0.0.0/16", + serviceEndpointPolicies: [ + { + id: "/subscriptions/subid/resourceGroups/vnetTest/providers/Microsoft.Network/serviceEndpointPolicies/ServiceEndpointPolicy1", + }, + ], + serviceEndpoints: [{ service: "Microsoft.Storage" }], + }, + ], + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a virtual network in the specified resource group. + * + * @summary Creates or updates a virtual network in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkCreateSubnet.json + */ +async function createVirtualNetworkWithSubnet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const parameters = { + addressSpace: { addressPrefixes: ["10.0.0.0/16"] }, + subnets: [{ name: "test-1", addressPrefix: "10.0.0.0/24" }], + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a virtual network in the specified resource group. + * + * @summary Creates or updates a virtual network in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkCreateSubnetWithAddressPrefixes.json + */ +async function createVirtualNetworkWithSubnetContainingAddressPrefixes() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const parameters = { + addressSpace: { addressPrefixes: ["10.0.0.0/16"] }, + subnets: [{ name: "test-2", addressPrefixes: ["10.0.0.0/28", "10.0.1.0/28"] }], + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + parameters + ); + console.log(result); +} + +async function main() { + createVirtualNetwork(); + createVirtualNetworkWithDelegatedSubnets(); + createVirtualNetworkWithServiceEndpoints(); + createVirtualNetworkWithServiceEndpointsAndServiceEndpointPolicy(); + createVirtualNetworkWithSubnet(); + createVirtualNetworkWithSubnetContainingAddressPrefixes(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksDeleteSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksDeleteSample.js new file mode 100644 index 000000000000..1f9e9bf2b211 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksDeleteSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Deletes the specified virtual network. + * + * @summary Deletes the specified virtual network. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkDelete.json + */ +async function deleteVirtualNetwork() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.beginDeleteAndWait( + resourceGroupName, + virtualNetworkName + ); + console.log(result); +} + +async function main() { + deleteVirtualNetwork(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksGetSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksGetSample.js new file mode 100644 index 000000000000..6882113f5ade --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksGetSample.js @@ -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. +const { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the specified virtual network by resource group. + * + * @summary Gets the specified virtual network by resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGet.json + */ +async function getVirtualNetwork() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.get(resourceGroupName, virtualNetworkName); + console.log(result); +} + +/** + * This sample demonstrates how to Gets the specified virtual network by resource group. + * + * @summary Gets the specified virtual network by resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGetWithSubnetDelegation.json + */ +async function getVirtualNetworkWithADelegatedSubnet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subId"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.get(resourceGroupName, virtualNetworkName); + console.log(result); +} + +/** + * This sample demonstrates how to Gets the specified virtual network by resource group. + * + * @summary Gets the specified virtual network by resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGetWithServiceAssociationLink.json + */ +async function getVirtualNetworkWithServiceAssociationLinks() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subId"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.get(resourceGroupName, virtualNetworkName); + console.log(result); +} + +async function main() { + getVirtualNetwork(); + getVirtualNetworkWithADelegatedSubnet(); + getVirtualNetworkWithServiceAssociationLinks(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksListAllSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksListAllSample.js new file mode 100644 index 000000000000..13d71247265c --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksListAllSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all virtual networks in a subscription. + * + * @summary Gets all virtual networks in a subscription. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkListAll.json + */ +async function listAllVirtualNetworks() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.virtualNetworks.listAll()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAllVirtualNetworks(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksListSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksListSample.js new file mode 100644 index 000000000000..1d13ffba992d --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksListSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets all virtual networks in a resource group. + * + * @summary Gets all virtual networks in a resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkList.json + */ +async function listVirtualNetworksInResourceGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.virtualNetworks.list(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listVirtualNetworksInResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksListUsageSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksListUsageSample.js new file mode 100644 index 000000000000..fa247121e2c8 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksListUsageSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Lists usage stats. + * + * @summary Lists usage stats. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkListUsage.json + */ +async function vnetGetUsage() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "vnetName"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.virtualNetworks.listUsage(resourceGroupName, virtualNetworkName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + vnetGetUsage(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksUpdateTagsSample.js b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksUpdateTagsSample.js new file mode 100644 index 000000000000..d62e5abe0d8f --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/javascript/virtualNetworksUpdateTagsSample.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 { NetworkManagementClient } = require("@azure/arm-network-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Updates a virtual network tags. + * + * @summary Updates a virtual network tags. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkUpdateTags.json + */ +async function updateVirtualNetworkTags() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const parameters = { tags: { tag1: "value1", tag2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.beginUpdateTagsAndWait( + resourceGroupName, + virtualNetworkName, + parameters + ); + console.log(result); +} + +async function main() { + updateVirtualNetworkTags(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/README.md b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/README.md new file mode 100644 index 000000000000..c5d475135efb --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/README.md @@ -0,0 +1,285 @@ +# client library samples for TypeScript + +These sample programs show how to use the TypeScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| [defaultSecurityRulesGetSample.ts][defaultsecurityrulesgetsample] | Get the specified default network security rule. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/DefaultSecurityRuleGet.json | +| [defaultSecurityRulesListSample.ts][defaultsecurityruleslistsample] | Gets all default security rules in a network security group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/DefaultSecurityRuleList.json | +| [inboundNatRulesCreateOrUpdateSample.ts][inboundnatrulescreateorupdatesample] | Creates or updates a load balancer inbound nat rule. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/InboundNatRuleCreate.json | +| [inboundNatRulesDeleteSample.ts][inboundnatrulesdeletesample] | Deletes the specified load balancer inbound nat rule. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/InboundNatRuleDelete.json | +| [inboundNatRulesGetSample.ts][inboundnatrulesgetsample] | Gets the specified load balancer inbound nat rule. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/InboundNatRuleGet.json | +| [inboundNatRulesListSample.ts][inboundnatruleslistsample] | Gets all the inbound nat rules in a load balancer. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/InboundNatRuleList.json | +| [loadBalancerBackendAddressPoolsGetSample.ts][loadbalancerbackendaddresspoolsgetsample] | Gets load balancer backend address pool. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerBackendAddressPoolGet.json | +| [loadBalancerBackendAddressPoolsListSample.ts][loadbalancerbackendaddresspoolslistsample] | Gets all the load balancer backed address pools. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerBackendAddressPoolList.json | +| [loadBalancerFrontendIPConfigurationsGetSample.ts][loadbalancerfrontendipconfigurationsgetsample] | Gets load balancer frontend IP configuration. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerFrontendIPConfigurationGet.json | +| [loadBalancerFrontendIPConfigurationsListSample.ts][loadbalancerfrontendipconfigurationslistsample] | Gets all the load balancer frontend IP configurations. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerFrontendIPConfigurationList.json | +| [loadBalancerLoadBalancingRulesGetSample.ts][loadbalancerloadbalancingrulesgetsample] | Gets the specified load balancer load balancing rule. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerLoadBalancingRuleGet.json | +| [loadBalancerLoadBalancingRulesListSample.ts][loadbalancerloadbalancingruleslistsample] | Gets all the load balancing rules in a load balancer. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerLoadBalancingRuleList.json | +| [loadBalancerNetworkInterfacesListSample.ts][loadbalancernetworkinterfaceslistsample] | Gets associated load balancer network interfaces. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerNetworkInterfaceListSimple.json | +| [loadBalancerOutboundRulesGetSample.ts][loadbalanceroutboundrulesgetsample] | Gets the specified load balancer outbound rule. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerOutboundRuleGet.json | +| [loadBalancerOutboundRulesListSample.ts][loadbalanceroutboundruleslistsample] | Gets all the outbound rules in a load balancer. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerOutboundRuleList.json | +| [loadBalancerProbesGetSample.ts][loadbalancerprobesgetsample] | Gets load balancer probe. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerProbeGet.json | +| [loadBalancerProbesListSample.ts][loadbalancerprobeslistsample] | Gets all the load balancer probes. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerProbeList.json | +| [loadBalancersCreateOrUpdateSample.ts][loadbalancerscreateorupdatesample] | Creates or updates a load balancer. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerCreate.json | +| [loadBalancersDeleteSample.ts][loadbalancersdeletesample] | Deletes the specified load balancer. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerDelete.json | +| [loadBalancersGetSample.ts][loadbalancersgetsample] | Gets the specified load balancer. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerGet.json | +| [loadBalancersListAllSample.ts][loadbalancerslistallsample] | Gets all the load balancers in a subscription. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerListAll.json | +| [loadBalancersListSample.ts][loadbalancerslistsample] | Gets all the load balancers in a resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerList.json | +| [loadBalancersUpdateTagsSample.ts][loadbalancersupdatetagssample] | Updates a load balancer tags. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerUpdateTags.json | +| [localNetworkGatewaysCreateOrUpdateSample.ts][localnetworkgatewayscreateorupdatesample] | Creates or updates a local network gateway in the specified resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LocalNetworkGatewayCreate.json | +| [localNetworkGatewaysDeleteSample.ts][localnetworkgatewaysdeletesample] | Deletes the specified local network gateway. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LocalNetworkGatewayDelete.json | +| [localNetworkGatewaysGetSample.ts][localnetworkgatewaysgetsample] | Gets the specified local network gateway in a resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LocalNetworkGatewayGet.json | +| [localNetworkGatewaysListSample.ts][localnetworkgatewayslistsample] | Gets all the local network gateways in a resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LocalNetworkGatewayList.json | +| [localNetworkGatewaysUpdateTagsSample.ts][localnetworkgatewaysupdatetagssample] | Updates a local network gateway tags. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LocalNetworkGatewayUpdateTags.json | +| [networkInterfaceIPConfigurationsGetSample.ts][networkinterfaceipconfigurationsgetsample] | Gets the specified network interface ip configuration. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceIPConfigurationGet.json | +| [networkInterfaceIPConfigurationsListSample.ts][networkinterfaceipconfigurationslistsample] | Get all ip configurations in a network interface x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceIPConfigurationList.json | +| [networkInterfaceLoadBalancersListSample.ts][networkinterfaceloadbalancerslistsample] | List all load balancers in a network interface. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceLoadBalancerList.json | +| [networkInterfaceTapConfigurationsCreateOrUpdateSample.ts][networkinterfacetapconfigurationscreateorupdatesample] | Creates or updates a Tap configuration in the specified NetworkInterface. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceTapConfigurationCreate.json | +| [networkInterfaceTapConfigurationsDeleteSample.ts][networkinterfacetapconfigurationsdeletesample] | Deletes the specified tap configuration from the NetworkInterface. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceTapConfigurationDelete.json | +| [networkInterfaceTapConfigurationsGetSample.ts][networkinterfacetapconfigurationsgetsample] | Get the specified tap configuration on a network interface. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceTapConfigurationGet.json | +| [networkInterfaceTapConfigurationsListSample.ts][networkinterfacetapconfigurationslistsample] | Get all Tap configurations in a network interface x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceTapConfigurationList.json | +| [networkInterfacesCreateOrUpdateSample.ts][networkinterfacescreateorupdatesample] | Creates or updates a network interface. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceCreate.json | +| [networkInterfacesDeleteSample.ts][networkinterfacesdeletesample] | Deletes the specified network interface. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceDelete.json | +| [networkInterfacesGetEffectiveRouteTableSample.ts][networkinterfacesgeteffectiveroutetablesample] | Gets all route tables applied to a network interface. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceEffectiveRouteTableList.json | +| [networkInterfacesGetSample.ts][networkinterfacesgetsample] | Gets information about the specified network interface. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceGet.json | +| [networkInterfacesListAllSample.ts][networkinterfaceslistallsample] | Gets all network interfaces in a subscription. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceListAll.json | +| [networkInterfacesListEffectiveNetworkSecurityGroupsSample.ts][networkinterfaceslisteffectivenetworksecuritygroupssample] | Gets all network security groups applied to a network interface. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceEffectiveNSGList.json | +| [networkInterfacesListSample.ts][networkinterfaceslistsample] | Gets all network interfaces in a resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceList.json | +| [networkInterfacesUpdateTagsSample.ts][networkinterfacesupdatetagssample] | Updates a network interface tags. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceUpdateTags.json | +| [networkSecurityGroupsCreateOrUpdateSample.ts][networksecuritygroupscreateorupdatesample] | Creates or updates a network security group in the specified resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupCreate.json | +| [networkSecurityGroupsDeleteSample.ts][networksecuritygroupsdeletesample] | Deletes the specified network security group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupDelete.json | +| [networkSecurityGroupsGetSample.ts][networksecuritygroupsgetsample] | Gets the specified network security group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupGet.json | +| [networkSecurityGroupsListAllSample.ts][networksecuritygroupslistallsample] | Gets all network security groups in a subscription. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupListAll.json | +| [networkSecurityGroupsListSample.ts][networksecuritygroupslistsample] | Gets all network security groups in a resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupList.json | +| [networkSecurityGroupsUpdateTagsSample.ts][networksecuritygroupsupdatetagssample] | Updates a network security group tags. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupUpdateTags.json | +| [operationsListSample.ts][operationslistsample] | Lists all of the available Network Rest API operations. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/OperationList.json | +| [publicIPAddressesCreateOrUpdateSample.ts][publicipaddressescreateorupdatesample] | Creates or updates a static or dynamic public IP address. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressCreateDns.json | +| [publicIPAddressesDeleteSample.ts][publicipaddressesdeletesample] | Deletes the specified public IP address. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressDelete.json | +| [publicIPAddressesGetSample.ts][publicipaddressesgetsample] | Gets the specified public IP address in a specified resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressGet.json | +| [publicIPAddressesListAllSample.ts][publicipaddresseslistallsample] | Gets all the public IP addresses in a subscription. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressListAll.json | +| [publicIPAddressesListSample.ts][publicipaddresseslistsample] | Gets all public IP addresses in a resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressList.json | +| [publicIPAddressesUpdateTagsSample.ts][publicipaddressesupdatetagssample] | Updates public IP address tags. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressUpdateTags.json | +| [routeTablesCreateOrUpdateSample.ts][routetablescreateorupdatesample] | Create or updates a route table in a specified resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableCreate.json | +| [routeTablesDeleteSample.ts][routetablesdeletesample] | Deletes the specified route table. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableDelete.json | +| [routeTablesGetSample.ts][routetablesgetsample] | Gets the specified route table. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableGet.json | +| [routeTablesListAllSample.ts][routetableslistallsample] | Gets all route tables in a subscription. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableListAll.json | +| [routeTablesListSample.ts][routetableslistsample] | Gets all route tables in a resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableList.json | +| [routeTablesUpdateTagsSample.ts][routetablesupdatetagssample] | Updates a route table tags. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableUpdateTags.json | +| [routesCreateOrUpdateSample.ts][routescreateorupdatesample] | Creates or updates a route in the specified route table. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableRouteCreate.json | +| [routesDeleteSample.ts][routesdeletesample] | Deletes the specified route from a route table. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableRouteDelete.json | +| [routesGetSample.ts][routesgetsample] | Gets the specified route from a route table. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableRouteGet.json | +| [routesListSample.ts][routeslistsample] | Gets all routes in a route table. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableRouteList.json | +| [securityRulesCreateOrUpdateSample.ts][securityrulescreateorupdatesample] | Creates or updates a security rule in the specified network security group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupRuleCreate.json | +| [securityRulesDeleteSample.ts][securityrulesdeletesample] | Deletes the specified network security rule. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupRuleDelete.json | +| [securityRulesGetSample.ts][securityrulesgetsample] | Get the specified network security rule. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupRuleGet.json | +| [securityRulesListSample.ts][securityruleslistsample] | Gets all security rules in a network security group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupRuleList.json | +| [subnetsCreateOrUpdateSample.ts][subnetscreateorupdatesample] | Creates or updates a subnet in the specified virtual network. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetCreate.json | +| [subnetsDeleteSample.ts][subnetsdeletesample] | Deletes the specified subnet. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetDelete.json | +| [subnetsGetSample.ts][subnetsgetsample] | Gets the specified subnet by virtual network and resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetGet.json | +| [subnetsListSample.ts][subnetslistsample] | Gets all subnets in a virtual network. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetList.json | +| [virtualNetworkGatewayConnectionsCreateOrUpdateSample.ts][virtualnetworkgatewayconnectionscreateorupdatesample] | Creates or updates a virtual network gateway connection in the specified resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionCreate.json | +| [virtualNetworkGatewayConnectionsDeleteSample.ts][virtualnetworkgatewayconnectionsdeletesample] | Deletes the specified virtual network Gateway connection. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionDelete.json | +| [virtualNetworkGatewayConnectionsGetSample.ts][virtualnetworkgatewayconnectionsgetsample] | Gets the specified virtual network gateway connection by resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionGet.json | +| [virtualNetworkGatewayConnectionsGetSharedKeySample.ts][virtualnetworkgatewayconnectionsgetsharedkeysample] | The Get VirtualNetworkGatewayConnectionSharedKey operation retrieves information about the specified virtual network gateway connection shared key through Network resource provider. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionGetSharedKey.json | +| [virtualNetworkGatewayConnectionsListSample.ts][virtualnetworkgatewayconnectionslistsample] | The List VirtualNetworkGatewayConnections operation retrieves all the virtual network gateways connections created. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionsList.json | +| [virtualNetworkGatewayConnectionsResetSharedKeySample.ts][virtualnetworkgatewayconnectionsresetsharedkeysample] | The VirtualNetworkGatewayConnectionResetSharedKey operation resets the virtual network gateway connection shared key for passed virtual network gateway connection in the specified resource group through Network resource provider. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionResetSharedKey.json | +| [virtualNetworkGatewayConnectionsSetSharedKeySample.ts][virtualnetworkgatewayconnectionssetsharedkeysample] | The Put VirtualNetworkGatewayConnectionSharedKey operation sets the virtual network gateway connection shared key for passed virtual network gateway connection in the specified resource group through Network resource provider. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionSetSharedKey.json | +| [virtualNetworkGatewayConnectionsUpdateTagsSample.ts][virtualnetworkgatewayconnectionsupdatetagssample] | Updates a virtual network gateway connection tags. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionUpdateTags.json | +| [virtualNetworkGatewaysCreateOrUpdateSample.ts][virtualnetworkgatewayscreateorupdatesample] | Creates or updates a virtual network gateway in the specified resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayUpdate.json | +| [virtualNetworkGatewaysDeleteSample.ts][virtualnetworkgatewaysdeletesample] | Deletes the specified virtual network gateway. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayDelete.json | +| [virtualNetworkGatewaysGenerateVpnProfileSample.ts][virtualnetworkgatewaysgeneratevpnprofilesample] | Generates VPN profile for P2S client of the virtual network gateway in the specified resource group. Used for IKEV2 and radius based authentication. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGenerateVpnProfile.json | +| [virtualNetworkGatewaysGeneratevpnclientpackageSample.ts][virtualnetworkgatewaysgeneratevpnclientpackagesample] | Generates VPN client package for P2S client of the virtual network gateway in the specified resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGenerateVpnClientPackage.json | +| [virtualNetworkGatewaysGetAdvertisedRoutesSample.ts][virtualnetworkgatewaysgetadvertisedroutessample] | This operation retrieves a list of routes the virtual network gateway is advertising to the specified peer. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGetAdvertisedRoutes.json | +| [virtualNetworkGatewaysGetBgpPeerStatusSample.ts][virtualnetworkgatewaysgetbgppeerstatussample] | The GetBgpPeerStatus operation retrieves the status of all BGP peers. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGetBGPPeerStatus.json | +| [virtualNetworkGatewaysGetLearnedRoutesSample.ts][virtualnetworkgatewaysgetlearnedroutessample] | This operation retrieves a list of routes the virtual network gateway has learned, including routes learned from BGP peers. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayLearnedRoutes.json | +| [virtualNetworkGatewaysGetSample.ts][virtualnetworkgatewaysgetsample] | Gets the specified virtual network gateway by resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGet.json | +| [virtualNetworkGatewaysGetVpnProfilePackageUrlSample.ts][virtualnetworkgatewaysgetvpnprofilepackageurlsample] | Gets pre-generated VPN profile for P2S client of the virtual network gateway in the specified resource group. The profile needs to be generated first using generateVpnProfile. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGetVpnProfilePackageUrl.json | +| [virtualNetworkGatewaysGetVpnclientIpsecParametersSample.ts][virtualnetworkgatewaysgetvpnclientipsecparameterssample] | The Get VpnclientIpsecParameters operation retrieves information about the vpnclient ipsec policy for P2S client of virtual network gateway in the specified resource group through Network resource provider. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGetVpnClientIpsecParameters.json | +| [virtualNetworkGatewaysListConnectionsSample.ts][virtualnetworkgatewayslistconnectionssample] | Gets all the connections in a virtual network gateway. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewaysListConnections.json | +| [virtualNetworkGatewaysListSample.ts][virtualnetworkgatewayslistsample] | Gets all virtual network gateways by resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayList.json | +| [virtualNetworkGatewaysResetSample.ts][virtualnetworkgatewaysresetsample] | Resets the primary of the virtual network gateway in the specified resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayReset.json | +| [virtualNetworkGatewaysResetVpnClientSharedKeySample.ts][virtualnetworkgatewaysresetvpnclientsharedkeysample] | Resets the VPN client shared key of the virtual network gateway in the specified resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayResetVpnClientSharedKey.json | +| [virtualNetworkGatewaysSetVpnclientIpsecParametersSample.ts][virtualnetworkgatewayssetvpnclientipsecparameterssample] | The Set VpnclientIpsecParameters operation sets the vpnclient ipsec policy for P2S client of virtual network gateway in the specified resource group through Network resource provider. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewaySetVpnClientIpsecParameters.json | +| [virtualNetworkGatewaysSupportedVpnDevicesSample.ts][virtualnetworkgatewayssupportedvpndevicessample] | Gets a xml format representation for supported vpn devices. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewaySupportedVpnDevice.json | +| [virtualNetworkGatewaysUpdateTagsSample.ts][virtualnetworkgatewaysupdatetagssample] | Updates a virtual network gateway tags. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayUpdateTags.json | +| [virtualNetworkGatewaysVpnDeviceConfigurationScriptSample.ts][virtualnetworkgatewaysvpndeviceconfigurationscriptsample] | Gets a xml format representation for vpn device configuration script. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayVpnDeviceConfigurationScript.json | +| [virtualNetworkPeeringsCreateOrUpdateSample.ts][virtualnetworkpeeringscreateorupdatesample] | Creates or updates a peering in the specified virtual network. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkPeeringCreate.json | +| [virtualNetworkPeeringsDeleteSample.ts][virtualnetworkpeeringsdeletesample] | Deletes the specified virtual network peering. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkPeeringDelete.json | +| [virtualNetworkPeeringsGetSample.ts][virtualnetworkpeeringsgetsample] | Gets the specified virtual network peering. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkPeeringGet.json | +| [virtualNetworkPeeringsListSample.ts][virtualnetworkpeeringslistsample] | Gets all virtual network peerings in a virtual network. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkPeeringList.json | +| [virtualNetworksCheckIPAddressAvailabilitySample.ts][virtualnetworkscheckipaddressavailabilitysample] | Checks whether a private IP address is available for use. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkCheckIPAddressAvailability.json | +| [virtualNetworksCreateOrUpdateSample.ts][virtualnetworkscreateorupdatesample] | Creates or updates a virtual network in the specified resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkCreate.json | +| [virtualNetworksDeleteSample.ts][virtualnetworksdeletesample] | Deletes the specified virtual network. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkDelete.json | +| [virtualNetworksGetSample.ts][virtualnetworksgetsample] | Gets the specified virtual network by resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGet.json | +| [virtualNetworksListAllSample.ts][virtualnetworkslistallsample] | Gets all virtual networks in a subscription. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkListAll.json | +| [virtualNetworksListSample.ts][virtualnetworkslistsample] | Gets all virtual networks in a resource group. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkList.json | +| [virtualNetworksListUsageSample.ts][virtualnetworkslistusagesample] | Lists usage stats. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkListUsage.json | +| [virtualNetworksUpdateTagsSample.ts][virtualnetworksupdatetagssample] | Updates a virtual network tags. x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkUpdateTags.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). + +Before running the samples in Node, they must be compiled to JavaScript using the TypeScript compiler. For more information on TypeScript, see the [TypeScript documentation][typescript]. Install the TypeScript compiler using: + +```bash +npm install -g typescript +``` + +You need [an Azure subscription][freesub] to run these sample programs. + +Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. + +Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. + +## Setup + +To run the samples using the published version of the package: + +1. Install the dependencies using `npm`: + +```bash +npm install +``` + +2. Compile the samples: + +```bash +npm run build +``` + +3. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. + +4. Run whichever samples you like (note that some samples may require additional setup, see the table above): + +```bash +node dist/defaultSecurityRulesGetSample.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 NETWORK_SUBSCRIPTION_ID="" NETWORK_RESOURCE_GROUP="" node dist/defaultSecurityRulesGetSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[defaultsecurityrulesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/defaultSecurityRulesGetSample.ts +[defaultsecurityruleslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/defaultSecurityRulesListSample.ts +[inboundnatrulescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/inboundNatRulesCreateOrUpdateSample.ts +[inboundnatrulesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/inboundNatRulesDeleteSample.ts +[inboundnatrulesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/inboundNatRulesGetSample.ts +[inboundnatruleslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/inboundNatRulesListSample.ts +[loadbalancerbackendaddresspoolsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerBackendAddressPoolsGetSample.ts +[loadbalancerbackendaddresspoolslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerBackendAddressPoolsListSample.ts +[loadbalancerfrontendipconfigurationsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerFrontendIPConfigurationsGetSample.ts +[loadbalancerfrontendipconfigurationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerFrontendIPConfigurationsListSample.ts +[loadbalancerloadbalancingrulesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerLoadBalancingRulesGetSample.ts +[loadbalancerloadbalancingruleslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerLoadBalancingRulesListSample.ts +[loadbalancernetworkinterfaceslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerNetworkInterfacesListSample.ts +[loadbalanceroutboundrulesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerOutboundRulesGetSample.ts +[loadbalanceroutboundruleslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerOutboundRulesListSample.ts +[loadbalancerprobesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerProbesGetSample.ts +[loadbalancerprobeslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerProbesListSample.ts +[loadbalancerscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancersCreateOrUpdateSample.ts +[loadbalancersdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancersDeleteSample.ts +[loadbalancersgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancersGetSample.ts +[loadbalancerslistallsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancersListAllSample.ts +[loadbalancerslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancersListSample.ts +[loadbalancersupdatetagssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancersUpdateTagsSample.ts +[localnetworkgatewayscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/localNetworkGatewaysCreateOrUpdateSample.ts +[localnetworkgatewaysdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/localNetworkGatewaysDeleteSample.ts +[localnetworkgatewaysgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/localNetworkGatewaysGetSample.ts +[localnetworkgatewayslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/localNetworkGatewaysListSample.ts +[localnetworkgatewaysupdatetagssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/localNetworkGatewaysUpdateTagsSample.ts +[networkinterfaceipconfigurationsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceIPConfigurationsGetSample.ts +[networkinterfaceipconfigurationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceIPConfigurationsListSample.ts +[networkinterfaceloadbalancerslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceLoadBalancersListSample.ts +[networkinterfacetapconfigurationscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceTapConfigurationsCreateOrUpdateSample.ts +[networkinterfacetapconfigurationsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceTapConfigurationsDeleteSample.ts +[networkinterfacetapconfigurationsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceTapConfigurationsGetSample.ts +[networkinterfacetapconfigurationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceTapConfigurationsListSample.ts +[networkinterfacescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesCreateOrUpdateSample.ts +[networkinterfacesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesDeleteSample.ts +[networkinterfacesgeteffectiveroutetablesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesGetEffectiveRouteTableSample.ts +[networkinterfacesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesGetSample.ts +[networkinterfaceslistallsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesListAllSample.ts +[networkinterfaceslisteffectivenetworksecuritygroupssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesListEffectiveNetworkSecurityGroupsSample.ts +[networkinterfaceslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesListSample.ts +[networkinterfacesupdatetagssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesUpdateTagsSample.ts +[networksecuritygroupscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkSecurityGroupsCreateOrUpdateSample.ts +[networksecuritygroupsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkSecurityGroupsDeleteSample.ts +[networksecuritygroupsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkSecurityGroupsGetSample.ts +[networksecuritygroupslistallsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkSecurityGroupsListAllSample.ts +[networksecuritygroupslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkSecurityGroupsListSample.ts +[networksecuritygroupsupdatetagssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkSecurityGroupsUpdateTagsSample.ts +[operationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/operationsListSample.ts +[publicipaddressescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/publicIPAddressesCreateOrUpdateSample.ts +[publicipaddressesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/publicIPAddressesDeleteSample.ts +[publicipaddressesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/publicIPAddressesGetSample.ts +[publicipaddresseslistallsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/publicIPAddressesListAllSample.ts +[publicipaddresseslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/publicIPAddressesListSample.ts +[publicipaddressesupdatetagssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/publicIPAddressesUpdateTagsSample.ts +[routetablescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routeTablesCreateOrUpdateSample.ts +[routetablesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routeTablesDeleteSample.ts +[routetablesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routeTablesGetSample.ts +[routetableslistallsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routeTablesListAllSample.ts +[routetableslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routeTablesListSample.ts +[routetablesupdatetagssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routeTablesUpdateTagsSample.ts +[routescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routesCreateOrUpdateSample.ts +[routesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routesDeleteSample.ts +[routesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routesGetSample.ts +[routeslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routesListSample.ts +[securityrulescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/securityRulesCreateOrUpdateSample.ts +[securityrulesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/securityRulesDeleteSample.ts +[securityrulesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/securityRulesGetSample.ts +[securityruleslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/securityRulesListSample.ts +[subnetscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/subnetsCreateOrUpdateSample.ts +[subnetsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/subnetsDeleteSample.ts +[subnetsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/subnetsGetSample.ts +[subnetslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/subnetsListSample.ts +[virtualnetworkgatewayconnectionscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsCreateOrUpdateSample.ts +[virtualnetworkgatewayconnectionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsDeleteSample.ts +[virtualnetworkgatewayconnectionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsGetSample.ts +[virtualnetworkgatewayconnectionsgetsharedkeysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsGetSharedKeySample.ts +[virtualnetworkgatewayconnectionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsListSample.ts +[virtualnetworkgatewayconnectionsresetsharedkeysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsResetSharedKeySample.ts +[virtualnetworkgatewayconnectionssetsharedkeysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsSetSharedKeySample.ts +[virtualnetworkgatewayconnectionsupdatetagssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsUpdateTagsSample.ts +[virtualnetworkgatewayscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysCreateOrUpdateSample.ts +[virtualnetworkgatewaysdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysDeleteSample.ts +[virtualnetworkgatewaysgeneratevpnprofilesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGenerateVpnProfileSample.ts +[virtualnetworkgatewaysgeneratevpnclientpackagesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGeneratevpnclientpackageSample.ts +[virtualnetworkgatewaysgetadvertisedroutessample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGetAdvertisedRoutesSample.ts +[virtualnetworkgatewaysgetbgppeerstatussample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGetBgpPeerStatusSample.ts +[virtualnetworkgatewaysgetlearnedroutessample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGetLearnedRoutesSample.ts +[virtualnetworkgatewaysgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGetSample.ts +[virtualnetworkgatewaysgetvpnprofilepackageurlsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGetVpnProfilePackageUrlSample.ts +[virtualnetworkgatewaysgetvpnclientipsecparameterssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGetVpnclientIpsecParametersSample.ts +[virtualnetworkgatewayslistconnectionssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysListConnectionsSample.ts +[virtualnetworkgatewayslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysListSample.ts +[virtualnetworkgatewaysresetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysResetSample.ts +[virtualnetworkgatewaysresetvpnclientsharedkeysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysResetVpnClientSharedKeySample.ts +[virtualnetworkgatewayssetvpnclientipsecparameterssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysSetVpnclientIpsecParametersSample.ts +[virtualnetworkgatewayssupportedvpndevicessample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysSupportedVpnDevicesSample.ts +[virtualnetworkgatewaysupdatetagssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysUpdateTagsSample.ts +[virtualnetworkgatewaysvpndeviceconfigurationscriptsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysVpnDeviceConfigurationScriptSample.ts +[virtualnetworkpeeringscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkPeeringsCreateOrUpdateSample.ts +[virtualnetworkpeeringsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkPeeringsDeleteSample.ts +[virtualnetworkpeeringsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkPeeringsGetSample.ts +[virtualnetworkpeeringslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkPeeringsListSample.ts +[virtualnetworkscheckipaddressavailabilitysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksCheckIPAddressAvailabilitySample.ts +[virtualnetworkscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksCreateOrUpdateSample.ts +[virtualnetworksdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksDeleteSample.ts +[virtualnetworksgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksGetSample.ts +[virtualnetworkslistallsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksListAllSample.ts +[virtualnetworkslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksListSample.ts +[virtualnetworkslistusagesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksListUsageSample.ts +[virtualnetworksupdatetagssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksUpdateTagsSample.ts +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-network-profile-2020-09-01-hybrid?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/network/arm-network-profile-2020-09-01-hybrid/README.md +[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/package.json b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/package.json new file mode 100644 index 000000000000..65b32f76ba23 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/package.json @@ -0,0 +1,41 @@ +{ + "name": "@azure-samples/arm-network-profile-2020-09-01-hybrid-ts", + "private": true, + "version": "1.0.0", + "description": " client library samples for TypeScript", + "engines": { + "node": ">=14.0.0" + }, + "scripts": { + "build": "tsc", + "prebuild": "rimraf dist/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/network/arm-network-profile-2020-09-01-hybrid" + }, + "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/network/arm-network-profile-2020-09-01-hybrid", + "dependencies": { + "@azure/arm-network-profile-2020-09-01-hybrid": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + }, + "devDependencies": { + "@types/node": "^14.0.0", + "typescript": "~4.8.0", + "rimraf": "latest" + } +} diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/sample.env b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/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/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/defaultSecurityRulesGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/defaultSecurityRulesGetSample.ts new file mode 100644 index 000000000000..ff59d9ce97b5 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/defaultSecurityRulesGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get the specified default network security rule. + * + * @summary Get the specified default network security rule. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/DefaultSecurityRuleGet.json + */ +async function defaultSecurityRuleGet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const networkSecurityGroupName = "nsg1"; + const defaultSecurityRuleName = "AllowVnetInBound"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.defaultSecurityRules.get( + resourceGroupName, + networkSecurityGroupName, + defaultSecurityRuleName + ); + console.log(result); +} + +async function main() { + defaultSecurityRuleGet(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/defaultSecurityRulesListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/defaultSecurityRulesListSample.ts new file mode 100644 index 000000000000..a66bcfc71a9a --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/defaultSecurityRulesListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all default security rules in a network security group. + * + * @summary Gets all default security rules in a network security group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/DefaultSecurityRuleList.json + */ +async function defaultSecurityRuleList() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const networkSecurityGroupName = "nsg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.defaultSecurityRules.list( + resourceGroupName, + networkSecurityGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + defaultSecurityRuleList(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/inboundNatRulesCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/inboundNatRulesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..b2ce30545481 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/inboundNatRulesCreateOrUpdateSample.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + InboundNatRule, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a load balancer inbound nat rule. + * + * @summary Creates or updates a load balancer inbound nat rule. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/InboundNatRuleCreate.json + */ +async function inboundNatRuleCreate() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb1"; + const inboundNatRuleName = "natRule1.1"; + const inboundNatRuleParameters: InboundNatRule = { + backendPort: 3389, + enableFloatingIP: false, + enableTcpReset: true, + frontendIPConfiguration: { + id: + "/subscriptions/subid/resourceGroups/testrg/providers/Microsoft.Network/loadBalancers/lb1/frontendIPConfigurations/ip1" + }, + frontendPort: 3390, + idleTimeoutInMinutes: 4, + protocol: "Tcp" + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.inboundNatRules.beginCreateOrUpdateAndWait( + resourceGroupName, + loadBalancerName, + inboundNatRuleName, + inboundNatRuleParameters + ); + console.log(result); +} + +async function main() { + inboundNatRuleCreate(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/inboundNatRulesDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/inboundNatRulesDeleteSample.ts new file mode 100644 index 000000000000..128b2850f35b --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/inboundNatRulesDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified load balancer inbound nat rule. + * + * @summary Deletes the specified load balancer inbound nat rule. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/InboundNatRuleDelete.json + */ +async function inboundNatRuleDelete() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb1"; + const inboundNatRuleName = "natRule1.1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.inboundNatRules.beginDeleteAndWait( + resourceGroupName, + loadBalancerName, + inboundNatRuleName + ); + console.log(result); +} + +async function main() { + inboundNatRuleDelete(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/inboundNatRulesGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/inboundNatRulesGetSample.ts new file mode 100644 index 000000000000..0b903dd70b3b --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/inboundNatRulesGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified load balancer inbound nat rule. + * + * @summary Gets the specified load balancer inbound nat rule. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/InboundNatRuleGet.json + */ +async function inboundNatRuleGet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb1"; + const inboundNatRuleName = "natRule1.1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.inboundNatRules.get( + resourceGroupName, + loadBalancerName, + inboundNatRuleName + ); + console.log(result); +} + +async function main() { + inboundNatRuleGet(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/inboundNatRulesListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/inboundNatRulesListSample.ts new file mode 100644 index 000000000000..318477df357b --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/inboundNatRulesListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all the inbound nat rules in a load balancer. + * + * @summary Gets all the inbound nat rules in a load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/InboundNatRuleList.json + */ +async function inboundNatRuleList() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.inboundNatRules.list( + resourceGroupName, + loadBalancerName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + inboundNatRuleList(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerBackendAddressPoolsGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerBackendAddressPoolsGetSample.ts new file mode 100644 index 000000000000..eaef1c62ebc2 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerBackendAddressPoolsGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets load balancer backend address pool. + * + * @summary Gets load balancer backend address pool. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerBackendAddressPoolGet.json + */ +async function loadBalancerBackendAddressPoolGet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb"; + const backendAddressPoolName = "backend"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancerBackendAddressPools.get( + resourceGroupName, + loadBalancerName, + backendAddressPoolName + ); + console.log(result); +} + +async function main() { + loadBalancerBackendAddressPoolGet(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerBackendAddressPoolsListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerBackendAddressPoolsListSample.ts new file mode 100644 index 000000000000..5415ce4e703d --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerBackendAddressPoolsListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all the load balancer backed address pools. + * + * @summary Gets all the load balancer backed address pools. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerBackendAddressPoolList.json + */ +async function loadBalancerBackendAddressPoolList() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.loadBalancerBackendAddressPools.list( + resourceGroupName, + loadBalancerName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + loadBalancerBackendAddressPoolList(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerFrontendIPConfigurationsGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerFrontendIPConfigurationsGetSample.ts new file mode 100644 index 000000000000..86ac76580a7c --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerFrontendIPConfigurationsGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets load balancer frontend IP configuration. + * + * @summary Gets load balancer frontend IP configuration. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerFrontendIPConfigurationGet.json + */ +async function loadBalancerFrontendIPConfigurationGet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb"; + const frontendIPConfigurationName = "frontend"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancerFrontendIPConfigurations.get( + resourceGroupName, + loadBalancerName, + frontendIPConfigurationName + ); + console.log(result); +} + +async function main() { + loadBalancerFrontendIPConfigurationGet(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerFrontendIPConfigurationsListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerFrontendIPConfigurationsListSample.ts new file mode 100644 index 000000000000..64972b28ca26 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerFrontendIPConfigurationsListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all the load balancer frontend IP configurations. + * + * @summary Gets all the load balancer frontend IP configurations. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerFrontendIPConfigurationList.json + */ +async function loadBalancerFrontendIPConfigurationList() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.loadBalancerFrontendIPConfigurations.list( + resourceGroupName, + loadBalancerName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + loadBalancerFrontendIPConfigurationList(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerLoadBalancingRulesGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerLoadBalancingRulesGetSample.ts new file mode 100644 index 000000000000..169adf0055c2 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerLoadBalancingRulesGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified load balancer load balancing rule. + * + * @summary Gets the specified load balancer load balancing rule. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerLoadBalancingRuleGet.json + */ +async function loadBalancerLoadBalancingRuleGet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb1"; + const loadBalancingRuleName = "rule1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancerLoadBalancingRules.get( + resourceGroupName, + loadBalancerName, + loadBalancingRuleName + ); + console.log(result); +} + +async function main() { + loadBalancerLoadBalancingRuleGet(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerLoadBalancingRulesListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerLoadBalancingRulesListSample.ts new file mode 100644 index 000000000000..685ea4d9466c --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerLoadBalancingRulesListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all the load balancing rules in a load balancer. + * + * @summary Gets all the load balancing rules in a load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerLoadBalancingRuleList.json + */ +async function loadBalancerLoadBalancingRuleList() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.loadBalancerLoadBalancingRules.list( + resourceGroupName, + loadBalancerName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + loadBalancerLoadBalancingRuleList(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerNetworkInterfacesListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerNetworkInterfacesListSample.ts new file mode 100644 index 000000000000..554f347b2be5 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerNetworkInterfacesListSample.ts @@ -0,0 +1,66 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets associated load balancer network interfaces. + * + * @summary Gets associated load balancer network interfaces. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerNetworkInterfaceListSimple.json + */ +async function loadBalancerNetworkInterfaceListSimple() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.loadBalancerNetworkInterfaces.list( + resourceGroupName, + loadBalancerName + )) { + resArray.push(item); + } + console.log(resArray); +} + +/** + * This sample demonstrates how to Gets associated load balancer network interfaces. + * + * @summary Gets associated load balancer network interfaces. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerNetworkInterfaceListVmss.json + */ +async function loadBalancerNetworkInterfaceListVmss() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.loadBalancerNetworkInterfaces.list( + resourceGroupName, + loadBalancerName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + loadBalancerNetworkInterfaceListSimple(); + loadBalancerNetworkInterfaceListVmss(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerOutboundRulesGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerOutboundRulesGetSample.ts new file mode 100644 index 000000000000..698b52cab4c2 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerOutboundRulesGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified load balancer outbound rule. + * + * @summary Gets the specified load balancer outbound rule. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerOutboundRuleGet.json + */ +async function loadBalancerOutboundRuleGet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb1"; + const outboundRuleName = "rule1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancerOutboundRules.get( + resourceGroupName, + loadBalancerName, + outboundRuleName + ); + console.log(result); +} + +async function main() { + loadBalancerOutboundRuleGet(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerOutboundRulesListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerOutboundRulesListSample.ts new file mode 100644 index 000000000000..edcbb14fc436 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerOutboundRulesListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all the outbound rules in a load balancer. + * + * @summary Gets all the outbound rules in a load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerOutboundRuleList.json + */ +async function loadBalancerOutboundRuleList() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.loadBalancerOutboundRules.list( + resourceGroupName, + loadBalancerName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + loadBalancerOutboundRuleList(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerProbesGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerProbesGetSample.ts new file mode 100644 index 000000000000..893e6251d43d --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerProbesGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets load balancer probe. + * + * @summary Gets load balancer probe. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerProbeGet.json + */ +async function loadBalancerProbeGet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb"; + const probeName = "probe1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancerProbes.get( + resourceGroupName, + loadBalancerName, + probeName + ); + console.log(result); +} + +async function main() { + loadBalancerProbeGet(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerProbesListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerProbesListSample.ts new file mode 100644 index 000000000000..1a6aa24824bf --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancerProbesListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all the load balancer probes. + * + * @summary Gets all the load balancer probes. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerProbeList.json + */ +async function loadBalancerProbeList() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const loadBalancerName = "lb"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.loadBalancerProbes.list( + resourceGroupName, + loadBalancerName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + loadBalancerProbeList(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancersCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancersCreateOrUpdateSample.ts new file mode 100644 index 000000000000..b89de9395fa1 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancersCreateOrUpdateSample.ts @@ -0,0 +1,435 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + LoadBalancer, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a load balancer. + * + * @summary Creates or updates a load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerCreate.json + */ +async function createLoadBalancer() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const loadBalancerName = "lb"; + const parameters: LoadBalancer = { + backendAddressPools: [{ name: "be-lb" }], + frontendIPConfigurations: [ + { + name: "fe-lb", + subnet: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb/subnets/subnetlb" + } + } + ], + inboundNatPools: [], + inboundNatRules: [ + { + name: "in-nat-rule", + backendPort: 3389, + enableFloatingIP: true, + enableTcpReset: true, + frontendIPConfiguration: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb" + }, + frontendPort: 3389, + idleTimeoutInMinutes: 15, + protocol: "Tcp" + } + ], + loadBalancingRules: [ + { + name: "rulelb", + backendAddressPool: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/be-lb" + }, + backendPort: 80, + enableFloatingIP: true, + enableTcpReset: true, + frontendIPConfiguration: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb" + }, + frontendPort: 80, + idleTimeoutInMinutes: 15, + loadDistribution: "Default", + probe: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/probes/probe-lb" + }, + protocol: "Tcp" + } + ], + probes: [ + { + name: "probe-lb", + intervalInSeconds: 15, + numberOfProbes: 2, + port: 80, + requestPath: "healthcheck.aspx", + protocol: "Http" + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancers.beginCreateOrUpdateAndWait( + resourceGroupName, + loadBalancerName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a load balancer. + * + * @summary Creates or updates a load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerCreateWithZones.json + */ +async function createLoadBalancerWithFrontendIPInZone1() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const loadBalancerName = "lb"; + const parameters: LoadBalancer = { + backendAddressPools: [{ name: "be-lb" }], + frontendIPConfigurations: [ + { + name: "fe-lb", + subnet: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb/subnets/subnetlb" + }, + zones: ["1"] + } + ], + inboundNatPools: [], + inboundNatRules: [ + { + name: "in-nat-rule", + backendPort: 3389, + enableFloatingIP: true, + frontendIPConfiguration: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb" + }, + frontendPort: 3389, + idleTimeoutInMinutes: 15, + protocol: "Tcp" + } + ], + loadBalancingRules: [ + { + name: "rulelb", + backendAddressPool: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/be-lb" + }, + backendPort: 80, + enableFloatingIP: true, + frontendIPConfiguration: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb" + }, + frontendPort: 80, + idleTimeoutInMinutes: 15, + loadDistribution: "Default", + probe: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/probes/probe-lb" + }, + protocol: "Tcp" + } + ], + outboundRules: [], + probes: [ + { + name: "probe-lb", + intervalInSeconds: 15, + numberOfProbes: 2, + port: 80, + requestPath: "healthcheck.aspx", + protocol: "Http" + } + ], + sku: { name: "Standard" } + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancers.beginCreateOrUpdateAndWait( + resourceGroupName, + loadBalancerName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a load balancer. + * + * @summary Creates or updates a load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerCreateStandardSku.json + */ +async function createLoadBalancerWithStandardSku() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const loadBalancerName = "lb"; + const parameters: LoadBalancer = { + backendAddressPools: [{ name: "be-lb" }], + frontendIPConfigurations: [ + { + name: "fe-lb", + subnet: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb/subnets/subnetlb" + } + } + ], + inboundNatPools: [], + inboundNatRules: [ + { + name: "in-nat-rule", + backendPort: 3389, + enableFloatingIP: true, + frontendIPConfiguration: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb" + }, + frontendPort: 3389, + idleTimeoutInMinutes: 15, + protocol: "Tcp" + } + ], + loadBalancingRules: [ + { + name: "rulelb", + backendAddressPool: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/be-lb" + }, + backendPort: 80, + enableFloatingIP: true, + frontendIPConfiguration: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb" + }, + frontendPort: 80, + idleTimeoutInMinutes: 15, + loadDistribution: "Default", + probe: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/probes/probe-lb" + }, + protocol: "Tcp" + } + ], + outboundRules: [], + probes: [ + { + name: "probe-lb", + intervalInSeconds: 15, + numberOfProbes: 2, + port: 80, + requestPath: "healthcheck.aspx", + protocol: "Http" + } + ], + sku: { name: "Standard" } + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancers.beginCreateOrUpdateAndWait( + resourceGroupName, + loadBalancerName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a load balancer. + * + * @summary Creates or updates a load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerCreateWithInboundNatPool.json + */ +async function createLoadBalancerWithInboundNatPool() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const loadBalancerName = "lb"; + const parameters: LoadBalancer = { + backendAddressPools: [], + frontendIPConfigurations: [ + { + name: "test", + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/test", + privateIPAllocationMethod: "Dynamic", + subnet: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/lbvnet/subnets/lbsubnet", + resourceNavigationLinks: [], + serviceEndpoints: [] + }, + zones: [] + } + ], + inboundNatPools: [ + { + name: "test", + backendPort: 8888, + enableFloatingIP: true, + enableTcpReset: true, + frontendIPConfiguration: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/test" + }, + frontendPortRangeEnd: 8085, + frontendPortRangeStart: 8080, + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/inboundNatPools/test", + idleTimeoutInMinutes: 10, + protocol: "Tcp" + } + ], + inboundNatRules: [], + loadBalancingRules: [], + outboundRules: [], + probes: [], + sku: { name: "Standard" } + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancers.beginCreateOrUpdateAndWait( + resourceGroupName, + loadBalancerName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a load balancer. + * + * @summary Creates or updates a load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerCreateWithOutboundRules.json + */ +async function createLoadBalancerWithOutboundRules() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const loadBalancerName = "lb"; + const parameters: LoadBalancer = { + backendAddressPools: [{ name: "be-lb" }], + frontendIPConfigurations: [ + { + name: "fe-lb", + publicIPAddress: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/pip" + } + } + ], + inboundNatPools: [], + inboundNatRules: [ + { + name: "in-nat-rule", + backendPort: 3389, + enableFloatingIP: true, + frontendIPConfiguration: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb" + }, + frontendPort: 3389, + idleTimeoutInMinutes: 15, + protocol: "Tcp" + } + ], + loadBalancingRules: [ + { + name: "rulelb", + backendAddressPool: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/be-lb" + }, + backendPort: 80, + disableOutboundSnat: true, + enableFloatingIP: true, + frontendIPConfiguration: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb" + }, + frontendPort: 80, + idleTimeoutInMinutes: 15, + loadDistribution: "Default", + probe: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/probes/probe-lb" + }, + protocol: "Tcp" + } + ], + location: "eastus", + outboundRules: [ + { + name: "rule1", + backendAddressPool: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/be-lb" + }, + frontendIPConfigurations: [ + { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb" + } + ], + protocol: "All" + } + ], + probes: [ + { + name: "probe-lb", + intervalInSeconds: 15, + numberOfProbes: 2, + port: 80, + requestPath: "healthcheck.aspx", + protocol: "Http" + } + ], + sku: { name: "Standard" } + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancers.beginCreateOrUpdateAndWait( + resourceGroupName, + loadBalancerName, + parameters + ); + console.log(result); +} + +async function main() { + createLoadBalancer(); + createLoadBalancerWithFrontendIPInZone1(); + createLoadBalancerWithStandardSku(); + createLoadBalancerWithInboundNatPool(); + createLoadBalancerWithOutboundRules(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancersDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancersDeleteSample.ts new file mode 100644 index 000000000000..e837f3284210 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancersDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified load balancer. + * + * @summary Deletes the specified load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerDelete.json + */ +async function deleteLoadBalancer() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const loadBalancerName = "lb"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancers.beginDeleteAndWait( + resourceGroupName, + loadBalancerName + ); + console.log(result); +} + +async function main() { + deleteLoadBalancer(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancersGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancersGetSample.ts new file mode 100644 index 000000000000..788563a98cac --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancersGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified load balancer. + * + * @summary Gets the specified load balancer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerGet.json + */ +async function getLoadBalancer() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const loadBalancerName = "lb"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancers.get( + resourceGroupName, + loadBalancerName + ); + console.log(result); +} + +async function main() { + getLoadBalancer(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancersListAllSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancersListAllSample.ts new file mode 100644 index 000000000000..fdac0824edaf --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancersListAllSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all the load balancers in a subscription. + * + * @summary Gets all the load balancers in a subscription. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerListAll.json + */ +async function listAllLoadBalancers() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.loadBalancers.listAll()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAllLoadBalancers(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancersListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancersListSample.ts new file mode 100644 index 000000000000..3cb16a2c278a --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancersListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all the load balancers in a resource group. + * + * @summary Gets all the load balancers in a resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerList.json + */ +async function listLoadBalancersInResourceGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.loadBalancers.list(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listLoadBalancersInResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancersUpdateTagsSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancersUpdateTagsSample.ts new file mode 100644 index 000000000000..68aa086e7032 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/loadBalancersUpdateTagsSample.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 { + TagsObject, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Updates a load balancer tags. + * + * @summary Updates a load balancer tags. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LoadBalancerUpdateTags.json + */ +async function updateLoadBalancerTags() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const loadBalancerName = "lb"; + const parameters: TagsObject = { tags: { tag1: "value1", tag2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.loadBalancers.beginUpdateTagsAndWait( + resourceGroupName, + loadBalancerName, + parameters + ); + console.log(result); +} + +async function main() { + updateLoadBalancerTags(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/localNetworkGatewaysCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/localNetworkGatewaysCreateOrUpdateSample.ts new file mode 100644 index 000000000000..40690c895536 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/localNetworkGatewaysCreateOrUpdateSample.ts @@ -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. +import { + LocalNetworkGateway, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a local network gateway in the specified resource group. + * + * @summary Creates or updates a local network gateway in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LocalNetworkGatewayCreate.json + */ +async function createLocalNetworkGateway() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const localNetworkGatewayName = "localgw"; + const parameters: LocalNetworkGateway = { + gatewayIpAddress: "x.x.x.x", + localNetworkAddressSpace: { addressPrefixes: ["10.1.0.0/16"] }, + location: "Central US" + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.localNetworkGateways.beginCreateOrUpdateAndWait( + resourceGroupName, + localNetworkGatewayName, + parameters + ); + console.log(result); +} + +async function main() { + createLocalNetworkGateway(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/localNetworkGatewaysDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/localNetworkGatewaysDeleteSample.ts new file mode 100644 index 000000000000..aa49bd1984bd --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/localNetworkGatewaysDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified local network gateway. + * + * @summary Deletes the specified local network gateway. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LocalNetworkGatewayDelete.json + */ +async function deleteLocalNetworkGateway() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const localNetworkGatewayName = "localgw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.localNetworkGateways.beginDeleteAndWait( + resourceGroupName, + localNetworkGatewayName + ); + console.log(result); +} + +async function main() { + deleteLocalNetworkGateway(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/localNetworkGatewaysGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/localNetworkGatewaysGetSample.ts new file mode 100644 index 000000000000..54b700ec3661 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/localNetworkGatewaysGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified local network gateway in a resource group. + * + * @summary Gets the specified local network gateway in a resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LocalNetworkGatewayGet.json + */ +async function getLocalNetworkGateway() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const localNetworkGatewayName = "localgw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.localNetworkGateways.get( + resourceGroupName, + localNetworkGatewayName + ); + console.log(result); +} + +async function main() { + getLocalNetworkGateway(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/localNetworkGatewaysListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/localNetworkGatewaysListSample.ts new file mode 100644 index 000000000000..798efd0e9c5d --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/localNetworkGatewaysListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all the local network gateways in a resource group. + * + * @summary Gets all the local network gateways in a resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LocalNetworkGatewayList.json + */ +async function listLocalNetworkGateways() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.localNetworkGateways.list(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listLocalNetworkGateways(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/localNetworkGatewaysUpdateTagsSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/localNetworkGatewaysUpdateTagsSample.ts new file mode 100644 index 000000000000..2bf34ecc51d1 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/localNetworkGatewaysUpdateTagsSample.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 { + TagsObject, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Updates a local network gateway tags. + * + * @summary Updates a local network gateway tags. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/LocalNetworkGatewayUpdateTags.json + */ +async function updateLocalNetworkGatewayTags() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const localNetworkGatewayName = "lgw"; + const parameters: TagsObject = { tags: { tag1: "value1", tag2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.localNetworkGateways.beginUpdateTagsAndWait( + resourceGroupName, + localNetworkGatewayName, + parameters + ); + console.log(result); +} + +async function main() { + updateLocalNetworkGatewayTags(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceIPConfigurationsGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceIPConfigurationsGetSample.ts new file mode 100644 index 000000000000..b5bdd5840b04 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceIPConfigurationsGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified network interface ip configuration. + * + * @summary Gets the specified network interface ip configuration. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceIPConfigurationGet.json + */ +async function networkInterfaceIPConfigurationGet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const networkInterfaceName = "mynic"; + const ipConfigurationName = "ipconfig1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaceIPConfigurations.get( + resourceGroupName, + networkInterfaceName, + ipConfigurationName + ); + console.log(result); +} + +async function main() { + networkInterfaceIPConfigurationGet(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceIPConfigurationsListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceIPConfigurationsListSample.ts new file mode 100644 index 000000000000..36e785391151 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceIPConfigurationsListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get all ip configurations in a network interface + * + * @summary Get all ip configurations in a network interface + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceIPConfigurationList.json + */ +async function networkInterfaceIPConfigurationList() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const networkInterfaceName = "nic1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.networkInterfaceIPConfigurations.list( + resourceGroupName, + networkInterfaceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + networkInterfaceIPConfigurationList(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceLoadBalancersListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceLoadBalancersListSample.ts new file mode 100644 index 000000000000..356cf0731884 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceLoadBalancersListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List all load balancers in a network interface. + * + * @summary List all load balancers in a network interface. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceLoadBalancerList.json + */ +async function networkInterfaceLoadBalancerList() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const networkInterfaceName = "nic1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.networkInterfaceLoadBalancers.list( + resourceGroupName, + networkInterfaceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + networkInterfaceLoadBalancerList(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceTapConfigurationsCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceTapConfigurationsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..724027dc1c67 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceTapConfigurationsCreateOrUpdateSample.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + NetworkInterfaceTapConfiguration, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a Tap configuration in the specified NetworkInterface. + * + * @summary Creates or updates a Tap configuration in the specified NetworkInterface. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceTapConfigurationCreate.json + */ +async function createNetworkInterfaceTapConfigurations() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const networkInterfaceName = "mynic"; + const tapConfigurationName = "tapconfiguration1"; + const tapConfigurationParameters: NetworkInterfaceTapConfiguration = { + virtualNetworkTap: { + id: + "/subscriptions/subid/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworkTaps/testvtap" + } + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaceTapConfigurations.beginCreateOrUpdateAndWait( + resourceGroupName, + networkInterfaceName, + tapConfigurationName, + tapConfigurationParameters + ); + console.log(result); +} + +async function main() { + createNetworkInterfaceTapConfigurations(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceTapConfigurationsDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceTapConfigurationsDeleteSample.ts new file mode 100644 index 000000000000..be01a69b9c84 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceTapConfigurationsDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified tap configuration from the NetworkInterface. + * + * @summary Deletes the specified tap configuration from the NetworkInterface. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceTapConfigurationDelete.json + */ +async function deleteTapConfiguration() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkInterfaceName = "test-networkinterface"; + const tapConfigurationName = "test-tapconfiguration"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaceTapConfigurations.beginDeleteAndWait( + resourceGroupName, + networkInterfaceName, + tapConfigurationName + ); + console.log(result); +} + +async function main() { + deleteTapConfiguration(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceTapConfigurationsGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceTapConfigurationsGetSample.ts new file mode 100644 index 000000000000..f0c79f385fb6 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceTapConfigurationsGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get the specified tap configuration on a network interface. + * + * @summary Get the specified tap configuration on a network interface. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceTapConfigurationGet.json + */ +async function getNetworkInterfaceTapConfigurations() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const networkInterfaceName = "mynic"; + const tapConfigurationName = "tapconfiguration1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaceTapConfigurations.get( + resourceGroupName, + networkInterfaceName, + tapConfigurationName + ); + console.log(result); +} + +async function main() { + getNetworkInterfaceTapConfigurations(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceTapConfigurationsListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceTapConfigurationsListSample.ts new file mode 100644 index 000000000000..7285d70b794e --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfaceTapConfigurationsListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get all Tap configurations in a network interface + * + * @summary Get all Tap configurations in a network interface + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceTapConfigurationList.json + */ +async function listVirtualNetworkTapConfigurations() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkInterfaceName = "mynic"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.networkInterfaceTapConfigurations.list( + resourceGroupName, + networkInterfaceName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listVirtualNetworkTapConfigurations(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..17c86b96dd00 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesCreateOrUpdateSample.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 { + NetworkInterface, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a network interface. + * + * @summary Creates or updates a network interface. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceCreate.json + */ +async function createNetworkInterface() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkInterfaceName = "test-nic"; + const parameters: NetworkInterface = { + enableAcceleratedNetworking: true, + ipConfigurations: [ + { + name: "ipconfig1", + publicIPAddress: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/test-ip" + }, + subnet: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/rg1-vnet/subnets/default" + } + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaces.beginCreateOrUpdateAndWait( + resourceGroupName, + networkInterfaceName, + parameters + ); + console.log(result); +} + +async function main() { + createNetworkInterface(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesDeleteSample.ts new file mode 100644 index 000000000000..bbc4889537ec --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified network interface. + * + * @summary Deletes the specified network interface. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceDelete.json + */ +async function deleteNetworkInterface() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkInterfaceName = "test-nic"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaces.beginDeleteAndWait( + resourceGroupName, + networkInterfaceName + ); + console.log(result); +} + +async function main() { + deleteNetworkInterface(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesGetEffectiveRouteTableSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesGetEffectiveRouteTableSample.ts new file mode 100644 index 000000000000..56637d3a94a3 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesGetEffectiveRouteTableSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all route tables applied to a network interface. + * + * @summary Gets all route tables applied to a network interface. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceEffectiveRouteTableList.json + */ +async function showNetworkInterfaceEffectiveRouteTables() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkInterfaceName = "nic1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaces.beginGetEffectiveRouteTableAndWait( + resourceGroupName, + networkInterfaceName + ); + console.log(result); +} + +async function main() { + showNetworkInterfaceEffectiveRouteTables(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesGetSample.ts new file mode 100644 index 000000000000..c8ffeb31e9c3 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets information about the specified network interface. + * + * @summary Gets information about the specified network interface. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceGet.json + */ +async function getNetworkInterface() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkInterfaceName = "test-nic"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaces.get( + resourceGroupName, + networkInterfaceName + ); + console.log(result); +} + +async function main() { + getNetworkInterface(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesListAllSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesListAllSample.ts new file mode 100644 index 000000000000..471ec3cd8a9c --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesListAllSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all network interfaces in a subscription. + * + * @summary Gets all network interfaces in a subscription. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceListAll.json + */ +async function listAllNetworkInterfaces() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.networkInterfaces.listAll()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAllNetworkInterfaces(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesListEffectiveNetworkSecurityGroupsSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesListEffectiveNetworkSecurityGroupsSample.ts new file mode 100644 index 000000000000..0590cd6b2f39 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesListEffectiveNetworkSecurityGroupsSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all network security groups applied to a network interface. + * + * @summary Gets all network security groups applied to a network interface. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceEffectiveNSGList.json + */ +async function listNetworkInterfaceEffectiveNetworkSecurityGroups() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkInterfaceName = "nic1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaces.beginListEffectiveNetworkSecurityGroupsAndWait( + resourceGroupName, + networkInterfaceName + ); + console.log(result); +} + +async function main() { + listNetworkInterfaceEffectiveNetworkSecurityGroups(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesListSample.ts new file mode 100644 index 000000000000..5fad48780ee1 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all network interfaces in a resource group. + * + * @summary Gets all network interfaces in a resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceList.json + */ +async function listNetworkInterfacesInResourceGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.networkInterfaces.list(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listNetworkInterfacesInResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesUpdateTagsSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesUpdateTagsSample.ts new file mode 100644 index 000000000000..d26718d128c2 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkInterfacesUpdateTagsSample.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 { + TagsObject, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Updates a network interface tags. + * + * @summary Updates a network interface tags. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkInterfaceUpdateTags.json + */ +async function updateNetworkInterfaceTags() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkInterfaceName = "test-nic"; + const parameters: TagsObject = { tags: { tag1: "value1", tag2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkInterfaces.beginUpdateTagsAndWait( + resourceGroupName, + networkInterfaceName, + parameters + ); + console.log(result); +} + +async function main() { + updateNetworkInterfaceTags(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkSecurityGroupsCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkSecurityGroupsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..e9de37d80152 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkSecurityGroupsCreateOrUpdateSample.ts @@ -0,0 +1,81 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + NetworkSecurityGroup, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a network security group in the specified resource group. + * + * @summary Creates or updates a network security group in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupCreate.json + */ +async function createNetworkSecurityGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkSecurityGroupName = "testnsg"; + const parameters: NetworkSecurityGroup = {}; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkSecurityGroups.beginCreateOrUpdateAndWait( + resourceGroupName, + networkSecurityGroupName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a network security group in the specified resource group. + * + * @summary Creates or updates a network security group in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupCreateWithRule.json + */ +async function createNetworkSecurityGroupWithRule() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkSecurityGroupName = "testnsg"; + const parameters: NetworkSecurityGroup = { + securityRules: [ + { + name: "rule1", + access: "Allow", + destinationAddressPrefix: "*", + destinationPortRange: "80", + direction: "Inbound", + priority: 130, + sourceAddressPrefix: "*", + sourcePortRange: "*", + protocol: "*" + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkSecurityGroups.beginCreateOrUpdateAndWait( + resourceGroupName, + networkSecurityGroupName, + parameters + ); + console.log(result); +} + +async function main() { + createNetworkSecurityGroup(); + createNetworkSecurityGroupWithRule(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkSecurityGroupsDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkSecurityGroupsDeleteSample.ts new file mode 100644 index 000000000000..32bf62ce02c5 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkSecurityGroupsDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified network security group. + * + * @summary Deletes the specified network security group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupDelete.json + */ +async function deleteNetworkSecurityGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkSecurityGroupName = "testnsg"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkSecurityGroups.beginDeleteAndWait( + resourceGroupName, + networkSecurityGroupName + ); + console.log(result); +} + +async function main() { + deleteNetworkSecurityGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkSecurityGroupsGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkSecurityGroupsGetSample.ts new file mode 100644 index 000000000000..f05464ca69d3 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkSecurityGroupsGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified network security group. + * + * @summary Gets the specified network security group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupGet.json + */ +async function getNetworkSecurityGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkSecurityGroupName = "testnsg"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkSecurityGroups.get( + resourceGroupName, + networkSecurityGroupName + ); + console.log(result); +} + +async function main() { + getNetworkSecurityGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkSecurityGroupsListAllSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkSecurityGroupsListAllSample.ts new file mode 100644 index 000000000000..81e6c6cb0fdf --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkSecurityGroupsListAllSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all network security groups in a subscription. + * + * @summary Gets all network security groups in a subscription. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupListAll.json + */ +async function listAllNetworkSecurityGroups() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.networkSecurityGroups.listAll()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAllNetworkSecurityGroups(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkSecurityGroupsListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkSecurityGroupsListSample.ts new file mode 100644 index 000000000000..c2b4e025b89b --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkSecurityGroupsListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all network security groups in a resource group. + * + * @summary Gets all network security groups in a resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupList.json + */ +async function listNetworkSecurityGroupsInResourceGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.networkSecurityGroups.list(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listNetworkSecurityGroupsInResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkSecurityGroupsUpdateTagsSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkSecurityGroupsUpdateTagsSample.ts new file mode 100644 index 000000000000..b0afb89975ef --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/networkSecurityGroupsUpdateTagsSample.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 { + TagsObject, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Updates a network security group tags. + * + * @summary Updates a network security group tags. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupUpdateTags.json + */ +async function updateNetworkSecurityGroupTags() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkSecurityGroupName = "testnsg"; + const parameters: TagsObject = { tags: { tag1: "value1", tag2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.networkSecurityGroups.beginUpdateTagsAndWait( + resourceGroupName, + networkSecurityGroupName, + parameters + ); + console.log(result); +} + +async function main() { + updateNetworkSecurityGroupTags(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/operationsListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/operationsListSample.ts new file mode 100644 index 000000000000..939bad352ea7 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/operationsListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Lists all of the available Network Rest API operations. + * + * @summary Lists all of the available Network Rest API operations. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/OperationList.json + */ +async function getAListOfOperationsForAResourceProvider() { + const subscriptionId = + process.env["NETWORK_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + getAListOfOperationsForAResourceProvider(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/publicIPAddressesCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/publicIPAddressesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..df333efefc7e --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/publicIPAddressesCreateOrUpdateSample.ts @@ -0,0 +1,96 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + PublicIPAddress, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a static or dynamic public IP address. + * + * @summary Creates or updates a static or dynamic public IP address. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressCreateDns.json + */ +async function createPublicIPAddressDns() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const publicIpAddressName = "test-ip"; + const parameters: PublicIPAddress = { + dnsSettings: { domainNameLabel: "dnslbl" } + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.publicIPAddresses.beginCreateOrUpdateAndWait( + resourceGroupName, + publicIpAddressName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a static or dynamic public IP address. + * + * @summary Creates or updates a static or dynamic public IP address. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressCreateCustomizedValues.json + */ +async function createPublicIPAddressAllocationMethod() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const publicIpAddressName = "test-ip"; + const parameters: PublicIPAddress = { + idleTimeoutInMinutes: 10, + publicIPAddressVersion: "IPv4", + publicIPAllocationMethod: "Static", + sku: { name: "Standard" } + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.publicIPAddresses.beginCreateOrUpdateAndWait( + resourceGroupName, + publicIpAddressName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a static or dynamic public IP address. + * + * @summary Creates or updates a static or dynamic public IP address. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressCreateDefaults.json + */ +async function createPublicIPAddressDefaults() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const publicIpAddressName = "test-ip"; + const parameters: PublicIPAddress = {}; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.publicIPAddresses.beginCreateOrUpdateAndWait( + resourceGroupName, + publicIpAddressName, + parameters + ); + console.log(result); +} + +async function main() { + createPublicIPAddressDns(); + createPublicIPAddressAllocationMethod(); + createPublicIPAddressDefaults(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/publicIPAddressesDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/publicIPAddressesDeleteSample.ts new file mode 100644 index 000000000000..6e7c0d6dc519 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/publicIPAddressesDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified public IP address. + * + * @summary Deletes the specified public IP address. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressDelete.json + */ +async function deletePublicIPAddress() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const publicIpAddressName = "test-ip"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.publicIPAddresses.beginDeleteAndWait( + resourceGroupName, + publicIpAddressName + ); + console.log(result); +} + +async function main() { + deletePublicIPAddress(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/publicIPAddressesGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/publicIPAddressesGetSample.ts new file mode 100644 index 000000000000..450428f16f8c --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/publicIPAddressesGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified public IP address in a specified resource group. + * + * @summary Gets the specified public IP address in a specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressGet.json + */ +async function getPublicIPAddress() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const publicIpAddressName = "testDNS-ip"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.publicIPAddresses.get( + resourceGroupName, + publicIpAddressName + ); + console.log(result); +} + +async function main() { + getPublicIPAddress(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/publicIPAddressesListAllSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/publicIPAddressesListAllSample.ts new file mode 100644 index 000000000000..be3867944bf9 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/publicIPAddressesListAllSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all the public IP addresses in a subscription. + * + * @summary Gets all the public IP addresses in a subscription. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressListAll.json + */ +async function listAllPublicIPAddresses() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.publicIPAddresses.listAll()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAllPublicIPAddresses(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/publicIPAddressesListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/publicIPAddressesListSample.ts new file mode 100644 index 000000000000..35c93fab9890 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/publicIPAddressesListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all public IP addresses in a resource group. + * + * @summary Gets all public IP addresses in a resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressList.json + */ +async function listResourceGroupPublicIPAddresses() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.publicIPAddresses.list(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listResourceGroupPublicIPAddresses(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/publicIPAddressesUpdateTagsSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/publicIPAddressesUpdateTagsSample.ts new file mode 100644 index 000000000000..c354f328e563 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/publicIPAddressesUpdateTagsSample.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 { + TagsObject, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Updates public IP address tags. + * + * @summary Updates public IP address tags. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/PublicIpAddressUpdateTags.json + */ +async function updatePublicIPAddressTags() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const publicIpAddressName = "test-ip"; + const parameters: TagsObject = { tags: { tag1: "value1", tag2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.publicIPAddresses.beginUpdateTagsAndWait( + resourceGroupName, + publicIpAddressName, + parameters + ); + console.log(result); +} + +async function main() { + updatePublicIPAddressTags(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routeTablesCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routeTablesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..d0e1b8e55903 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routeTablesCreateOrUpdateSample.ts @@ -0,0 +1,77 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + RouteTable, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Create or updates a route table in a specified resource group. + * + * @summary Create or updates a route table in a specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableCreate.json + */ +async function createRouteTable() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const routeTableName = "testrt"; + const parameters: RouteTable = { location: "westus" }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.routeTables.beginCreateOrUpdateAndWait( + resourceGroupName, + routeTableName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Create or updates a route table in a specified resource group. + * + * @summary Create or updates a route table in a specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableCreateWithRoute.json + */ +async function createRouteTableWithRoute() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const routeTableName = "testrt"; + const parameters: RouteTable = { + disableBgpRoutePropagation: true, + location: "westus", + routes: [ + { + name: "route1", + addressPrefix: "10.0.3.0/24", + nextHopType: "VirtualNetworkGateway" + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.routeTables.beginCreateOrUpdateAndWait( + resourceGroupName, + routeTableName, + parameters + ); + console.log(result); +} + +async function main() { + createRouteTable(); + createRouteTableWithRoute(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routeTablesDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routeTablesDeleteSample.ts new file mode 100644 index 000000000000..94c5e4b2ea2f --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routeTablesDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified route table. + * + * @summary Deletes the specified route table. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableDelete.json + */ +async function deleteRouteTable() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const routeTableName = "testrt"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.routeTables.beginDeleteAndWait( + resourceGroupName, + routeTableName + ); + console.log(result); +} + +async function main() { + deleteRouteTable(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routeTablesGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routeTablesGetSample.ts new file mode 100644 index 000000000000..e71cc1e28dea --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routeTablesGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified route table. + * + * @summary Gets the specified route table. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableGet.json + */ +async function getRouteTable() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const routeTableName = "testrt"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.routeTables.get( + resourceGroupName, + routeTableName + ); + console.log(result); +} + +async function main() { + getRouteTable(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routeTablesListAllSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routeTablesListAllSample.ts new file mode 100644 index 000000000000..9ac691d7240d --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routeTablesListAllSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all route tables in a subscription. + * + * @summary Gets all route tables in a subscription. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableListAll.json + */ +async function listAllRouteTables() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.routeTables.listAll()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAllRouteTables(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routeTablesListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routeTablesListSample.ts new file mode 100644 index 000000000000..30e9741c3642 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routeTablesListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all route tables in a resource group. + * + * @summary Gets all route tables in a resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableList.json + */ +async function listRouteTablesInResourceGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.routeTables.list(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listRouteTablesInResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routeTablesUpdateTagsSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routeTablesUpdateTagsSample.ts new file mode 100644 index 000000000000..2f0cdfb0a290 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routeTablesUpdateTagsSample.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 { + TagsObject, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Updates a route table tags. + * + * @summary Updates a route table tags. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableUpdateTags.json + */ +async function updateRouteTableTags() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const routeTableName = "testrt"; + const parameters: TagsObject = { tags: { tag1: "value1", tag2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.routeTables.beginUpdateTagsAndWait( + resourceGroupName, + routeTableName, + parameters + ); + console.log(result); +} + +async function main() { + updateRouteTableTags(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routesCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..f6cff652a0c3 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routesCreateOrUpdateSample.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 { + Route, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a route in the specified route table. + * + * @summary Creates or updates a route in the specified route table. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableRouteCreate.json + */ +async function createRoute() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const routeTableName = "testrt"; + const routeName = "route1"; + const routeParameters: Route = { + addressPrefix: "10.0.3.0/24", + nextHopType: "VirtualNetworkGateway" + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.routes.beginCreateOrUpdateAndWait( + resourceGroupName, + routeTableName, + routeName, + routeParameters + ); + console.log(result); +} + +async function main() { + createRoute(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routesDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routesDeleteSample.ts new file mode 100644 index 000000000000..86d30c271432 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routesDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified route from a route table. + * + * @summary Deletes the specified route from a route table. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableRouteDelete.json + */ +async function deleteRoute() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const routeTableName = "testrt"; + const routeName = "route1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.routes.beginDeleteAndWait( + resourceGroupName, + routeTableName, + routeName + ); + console.log(result); +} + +async function main() { + deleteRoute(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routesGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routesGetSample.ts new file mode 100644 index 000000000000..9935200cb332 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routesGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified route from a route table. + * + * @summary Gets the specified route from a route table. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableRouteGet.json + */ +async function getRoute() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const routeTableName = "testrt"; + const routeName = "route1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.routes.get( + resourceGroupName, + routeTableName, + routeName + ); + console.log(result); +} + +async function main() { + getRoute(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routesListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routesListSample.ts new file mode 100644 index 000000000000..2f3c6ed7127c --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/routesListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all routes in a route table. + * + * @summary Gets all routes in a route table. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/RouteTableRouteList.json + */ +async function listRoutes() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const routeTableName = "testrt"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.routes.list( + resourceGroupName, + routeTableName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listRoutes(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/securityRulesCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/securityRulesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..5cb01c7d8eab --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/securityRulesCreateOrUpdateSample.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + SecurityRule, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a security rule in the specified network security group. + * + * @summary Creates or updates a security rule in the specified network security group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupRuleCreate.json + */ +async function createSecurityRule() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkSecurityGroupName = "testnsg"; + const securityRuleName = "rule1"; + const securityRuleParameters: SecurityRule = { + access: "Deny", + destinationAddressPrefix: "11.0.0.0/8", + destinationPortRange: "8080", + direction: "Outbound", + priority: 100, + sourceAddressPrefix: "10.0.0.0/8", + sourcePortRange: "*", + protocol: "*" + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.securityRules.beginCreateOrUpdateAndWait( + resourceGroupName, + networkSecurityGroupName, + securityRuleName, + securityRuleParameters + ); + console.log(result); +} + +async function main() { + createSecurityRule(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/securityRulesDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/securityRulesDeleteSample.ts new file mode 100644 index 000000000000..d3c5b1e52793 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/securityRulesDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified network security rule. + * + * @summary Deletes the specified network security rule. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupRuleDelete.json + */ +async function deleteNetworkSecurityRuleFromNetworkSecurityGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkSecurityGroupName = "testnsg"; + const securityRuleName = "rule1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.securityRules.beginDeleteAndWait( + resourceGroupName, + networkSecurityGroupName, + securityRuleName + ); + console.log(result); +} + +async function main() { + deleteNetworkSecurityRuleFromNetworkSecurityGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/securityRulesGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/securityRulesGetSample.ts new file mode 100644 index 000000000000..8435956252db --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/securityRulesGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get the specified network security rule. + * + * @summary Get the specified network security rule. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupRuleGet.json + */ +async function getNetworkSecurityRuleInNetworkSecurityGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkSecurityGroupName = "testnsg"; + const securityRuleName = "rule1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.securityRules.get( + resourceGroupName, + networkSecurityGroupName, + securityRuleName + ); + console.log(result); +} + +async function main() { + getNetworkSecurityRuleInNetworkSecurityGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/securityRulesListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/securityRulesListSample.ts new file mode 100644 index 000000000000..fa239129ce4d --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/securityRulesListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all security rules in a network security group. + * + * @summary Gets all security rules in a network security group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/NetworkSecurityGroupRuleList.json + */ +async function listNetworkSecurityRulesInNetworkSecurityGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const networkSecurityGroupName = "testnsg"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.securityRules.list( + resourceGroupName, + networkSecurityGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listNetworkSecurityRulesInNetworkSecurityGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/subnetsCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/subnetsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..401eaff4613f --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/subnetsCreateOrUpdateSample.ts @@ -0,0 +1,101 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + Subnet, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a subnet in the specified virtual network. + * + * @summary Creates or updates a subnet in the specified virtual network. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetCreate.json + */ +async function createSubnet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = + process.env["NETWORK_RESOURCE_GROUP"] || "subnet-test"; + const virtualNetworkName = "vnetname"; + const subnetName = "subnet1"; + const subnetParameters: Subnet = { addressPrefix: "10.0.0.0/16" }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.subnets.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + subnetName, + subnetParameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a subnet in the specified virtual network. + * + * @summary Creates or updates a subnet in the specified virtual network. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetCreateWithDelegation.json + */ +async function createSubnetWithADelegation() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subId"; + const resourceGroupName = + process.env["NETWORK_RESOURCE_GROUP"] || "subnet-test"; + const virtualNetworkName = "vnetname"; + const subnetName = "subnet1"; + const subnetParameters: Subnet = { addressPrefix: "10.0.0.0/16" }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.subnets.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + subnetName, + subnetParameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a subnet in the specified virtual network. + * + * @summary Creates or updates a subnet in the specified virtual network. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetCreateServiceEndpoint.json + */ +async function createSubnetWithServiceEndpoints() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = + process.env["NETWORK_RESOURCE_GROUP"] || "subnet-test"; + const virtualNetworkName = "vnetname"; + const subnetName = "subnet1"; + const subnetParameters: Subnet = { + addressPrefix: "10.0.0.0/16", + serviceEndpoints: [{ service: "Microsoft.Storage" }] + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.subnets.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + subnetName, + subnetParameters + ); + console.log(result); +} + +async function main() { + createSubnet(); + createSubnetWithADelegation(); + createSubnetWithServiceEndpoints(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/subnetsDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/subnetsDeleteSample.ts new file mode 100644 index 000000000000..500c5cf7fa44 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/subnetsDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified subnet. + * + * @summary Deletes the specified subnet. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetDelete.json + */ +async function deleteSubnet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = + process.env["NETWORK_RESOURCE_GROUP"] || "subnet-test"; + const virtualNetworkName = "vnetname"; + const subnetName = "subnet1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.subnets.beginDeleteAndWait( + resourceGroupName, + virtualNetworkName, + subnetName + ); + console.log(result); +} + +async function main() { + deleteSubnet(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/subnetsGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/subnetsGetSample.ts new file mode 100644 index 000000000000..00766862551d --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/subnetsGetSample.ts @@ -0,0 +1,66 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified subnet by virtual network and resource group. + * + * @summary Gets the specified subnet by virtual network and resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetGet.json + */ +async function getSubnet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = + process.env["NETWORK_RESOURCE_GROUP"] || "subnet-test"; + const virtualNetworkName = "vnetname"; + const subnetName = "subnet1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.subnets.get( + resourceGroupName, + virtualNetworkName, + subnetName + ); + console.log(result); +} + +/** + * This sample demonstrates how to Gets the specified subnet by virtual network and resource group. + * + * @summary Gets the specified subnet by virtual network and resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetGetWithDelegation.json + */ +async function getSubnetWithADelegation() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subId"; + const resourceGroupName = + process.env["NETWORK_RESOURCE_GROUP"] || "subnet-test"; + const virtualNetworkName = "vnetname"; + const subnetName = "subnet1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.subnets.get( + resourceGroupName, + virtualNetworkName, + subnetName + ); + console.log(result); +} + +async function main() { + getSubnet(); + getSubnetWithADelegation(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/subnetsListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/subnetsListSample.ts new file mode 100644 index 000000000000..7fd21249a1ef --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/subnetsListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all subnets in a virtual network. + * + * @summary Gets all subnets in a virtual network. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/SubnetList.json + */ +async function listSubnets() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = + process.env["NETWORK_RESOURCE_GROUP"] || "subnet-test"; + const virtualNetworkName = "vnetname"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.subnets.list( + resourceGroupName, + virtualNetworkName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listSubnets(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..f01c4ef18bfb --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsCreateOrUpdateSample.ts @@ -0,0 +1,99 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + VirtualNetworkGatewayConnection, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a virtual network gateway connection in the specified resource group. + * + * @summary Creates or updates a virtual network gateway connection in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionCreate.json + */ +async function createVirtualNetworkGatewayConnectionS2S() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayConnectionName = "connS2S"; + const parameters: VirtualNetworkGatewayConnection = { + connectionProtocol: "IKEv2", + connectionType: "IPsec", + enableBgp: false, + ipsecPolicies: [], + localNetworkGateway2: { + etag: 'W/"00000000-0000-0000-0000-000000000000"', + gatewayIpAddress: "x.x.x.x", + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/localNetworkGateways/localgw", + localNetworkAddressSpace: { addressPrefixes: ["10.1.0.0/16"] }, + location: "centralus", + resourceGuid: "00000000-0000-0000-0000-000000000000", + tags: {} + }, + location: "centralus", + routingWeight: 0, + sharedKey: "Abc123", + usePolicyBasedTrafficSelectors: false, + virtualNetworkGateway1: { + active: false, + bgpSettings: { + asn: 65514, + bgpPeeringAddress: "10.0.1.30", + peerWeight: 0 + }, + enableBgp: false, + etag: 'W/"00000000-0000-0000-0000-000000000000"', + gatewayType: "Vpn", + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw", + ipConfigurations: [ + { + name: "gwipconfig1", + etag: 'W/"00000000-0000-0000-0000-000000000000"', + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw/ipConfigurations/gwipconfig1", + privateIPAllocationMethod: "Dynamic", + publicIPAddress: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/gwpip" + }, + subnet: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/GatewaySubnet" + } + } + ], + location: "centralus", + resourceGuid: "00000000-0000-0000-0000-000000000000", + sku: { name: "VpnGw1", capacity: 2, tier: "VpnGw1" }, + tags: {}, + vpnType: "RouteBased" + } + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGatewayConnections.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkGatewayConnectionName, + parameters + ); + console.log(result); +} + +async function main() { + createVirtualNetworkGatewayConnectionS2S(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsDeleteSample.ts new file mode 100644 index 000000000000..a40085b36f9c --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified virtual network Gateway connection. + * + * @summary Deletes the specified virtual network Gateway connection. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionDelete.json + */ +async function deleteVirtualNetworkGatewayConnection() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayConnectionName = "conn1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGatewayConnections.beginDeleteAndWait( + resourceGroupName, + virtualNetworkGatewayConnectionName + ); + console.log(result); +} + +async function main() { + deleteVirtualNetworkGatewayConnection(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsGetSample.ts new file mode 100644 index 000000000000..e1161185363d --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified virtual network gateway connection by resource group. + * + * @summary Gets the specified virtual network gateway connection by resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionGet.json + */ +async function getVirtualNetworkGatewayConnection() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayConnectionName = "connS2S"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGatewayConnections.get( + resourceGroupName, + virtualNetworkGatewayConnectionName + ); + console.log(result); +} + +async function main() { + getVirtualNetworkGatewayConnection(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsGetSharedKeySample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsGetSharedKeySample.ts new file mode 100644 index 000000000000..8737367d23c1 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsGetSharedKeySample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to The Get VirtualNetworkGatewayConnectionSharedKey operation retrieves information about the specified virtual network gateway connection shared key through Network resource provider. + * + * @summary The Get VirtualNetworkGatewayConnectionSharedKey operation retrieves information about the specified virtual network gateway connection shared key through Network resource provider. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionGetSharedKey.json + */ +async function getVirtualNetworkGatewayConnectionSharedKey() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayConnectionName = "connS2S"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGatewayConnections.getSharedKey( + resourceGroupName, + virtualNetworkGatewayConnectionName + ); + console.log(result); +} + +async function main() { + getVirtualNetworkGatewayConnectionSharedKey(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsListSample.ts new file mode 100644 index 000000000000..4bf12d700a63 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to The List VirtualNetworkGatewayConnections operation retrieves all the virtual network gateways connections created. + * + * @summary The List VirtualNetworkGatewayConnections operation retrieves all the virtual network gateways connections created. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionsList.json + */ +async function listVirtualNetworkGatewayConnectionsinResourceGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.virtualNetworkGatewayConnections.list( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listVirtualNetworkGatewayConnectionsinResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsResetSharedKeySample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsResetSharedKeySample.ts new file mode 100644 index 000000000000..38c56fcfc1b2 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsResetSharedKeySample.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 { + ConnectionResetSharedKey, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to The VirtualNetworkGatewayConnectionResetSharedKey operation resets the virtual network gateway connection shared key for passed virtual network gateway connection in the specified resource group through Network resource provider. + * + * @summary The VirtualNetworkGatewayConnectionResetSharedKey operation resets the virtual network gateway connection shared key for passed virtual network gateway connection in the specified resource group through Network resource provider. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionResetSharedKey.json + */ +async function resetVirtualNetworkGatewayConnectionSharedKey() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayConnectionName = "conn1"; + const parameters: ConnectionResetSharedKey = { keyLength: 128 }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGatewayConnections.beginResetSharedKeyAndWait( + resourceGroupName, + virtualNetworkGatewayConnectionName, + parameters + ); + console.log(result); +} + +async function main() { + resetVirtualNetworkGatewayConnectionSharedKey(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsSetSharedKeySample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsSetSharedKeySample.ts new file mode 100644 index 000000000000..d30e092d1b4a --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsSetSharedKeySample.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 { + ConnectionSharedKey, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to The Put VirtualNetworkGatewayConnectionSharedKey operation sets the virtual network gateway connection shared key for passed virtual network gateway connection in the specified resource group through Network resource provider. + * + * @summary The Put VirtualNetworkGatewayConnectionSharedKey operation sets the virtual network gateway connection shared key for passed virtual network gateway connection in the specified resource group through Network resource provider. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionSetSharedKey.json + */ +async function setVirtualNetworkGatewayConnectionSharedKey() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayConnectionName = "connS2S"; + const parameters: ConnectionSharedKey = { value: "AzureAbc123" }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGatewayConnections.beginSetSharedKeyAndWait( + resourceGroupName, + virtualNetworkGatewayConnectionName, + parameters + ); + console.log(result); +} + +async function main() { + setVirtualNetworkGatewayConnectionSharedKey(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsUpdateTagsSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsUpdateTagsSample.ts new file mode 100644 index 000000000000..914ddd96d47a --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewayConnectionsUpdateTagsSample.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 { + TagsObject, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Updates a virtual network gateway connection tags. + * + * @summary Updates a virtual network gateway connection tags. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayConnectionUpdateTags.json + */ +async function updateVirtualNetworkGatewayConnectionTags() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayConnectionName = "test"; + const parameters: TagsObject = { tags: { tag1: "value1", tag2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGatewayConnections.beginUpdateTagsAndWait( + resourceGroupName, + virtualNetworkGatewayConnectionName, + parameters + ); + console.log(result); +} + +async function main() { + updateVirtualNetworkGatewayConnectionTags(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysCreateOrUpdateSample.ts new file mode 100644 index 000000000000..6bd4a5991ed6 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysCreateOrUpdateSample.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 { + VirtualNetworkGateway, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a virtual network gateway in the specified resource group. + * + * @summary Creates or updates a virtual network gateway in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayUpdate.json + */ +async function updateVirtualNetworkGateway() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const parameters: VirtualNetworkGateway = { + active: false, + bgpSettings: { asn: 65515, bgpPeeringAddress: "10.0.1.30", peerWeight: 0 }, + enableBgp: false, + gatewayType: "Vpn", + ipConfigurations: [ + { + name: "gwipconfig1", + privateIPAllocationMethod: "Dynamic", + publicIPAddress: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/gwpip" + }, + subnet: { + id: + "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/GatewaySubnet" + } + } + ], + location: "centralus", + sku: { name: "VpnGw1", tier: "VpnGw1" }, + vpnType: "RouteBased" + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkGatewayName, + parameters + ); + console.log(result); +} + +async function main() { + updateVirtualNetworkGateway(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysDeleteSample.ts new file mode 100644 index 000000000000..94b0f59822fb --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified virtual network gateway. + * + * @summary Deletes the specified virtual network gateway. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayDelete.json + */ +async function deleteVirtualNetworkGateway() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginDeleteAndWait( + resourceGroupName, + virtualNetworkGatewayName + ); + console.log(result); +} + +async function main() { + deleteVirtualNetworkGateway(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGenerateVpnProfileSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGenerateVpnProfileSample.ts new file mode 100644 index 000000000000..e49652b085e0 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGenerateVpnProfileSample.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 { + VpnClientParameters, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Generates VPN profile for P2S client of the virtual network gateway in the specified resource group. Used for IKEV2 and radius based authentication. + * + * @summary Generates VPN profile for P2S client of the virtual network gateway in the specified resource group. Used for IKEV2 and radius based authentication. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGenerateVpnProfile.json + */ +async function generateVirtualNetworkGatewayVpnProfile() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const parameters: VpnClientParameters = {}; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginGenerateVpnProfileAndWait( + resourceGroupName, + virtualNetworkGatewayName, + parameters + ); + console.log(result); +} + +async function main() { + generateVirtualNetworkGatewayVpnProfile(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGeneratevpnclientpackageSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGeneratevpnclientpackageSample.ts new file mode 100644 index 000000000000..e74145bdf0c8 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGeneratevpnclientpackageSample.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 { + VpnClientParameters, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Generates VPN client package for P2S client of the virtual network gateway in the specified resource group. + * + * @summary Generates VPN client package for P2S client of the virtual network gateway in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGenerateVpnClientPackage.json + */ +async function generateVpnClientPackage() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const parameters: VpnClientParameters = {}; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginGeneratevpnclientpackageAndWait( + resourceGroupName, + virtualNetworkGatewayName, + parameters + ); + console.log(result); +} + +async function main() { + generateVpnClientPackage(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGetAdvertisedRoutesSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGetAdvertisedRoutesSample.ts new file mode 100644 index 000000000000..b1da6b083f40 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGetAdvertisedRoutesSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to This operation retrieves a list of routes the virtual network gateway is advertising to the specified peer. + * + * @summary This operation retrieves a list of routes the virtual network gateway is advertising to the specified peer. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGetAdvertisedRoutes.json + */ +async function getVirtualNetworkGatewayAdvertisedRoutes() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const peer = "test"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginGetAdvertisedRoutesAndWait( + resourceGroupName, + virtualNetworkGatewayName, + peer + ); + console.log(result); +} + +async function main() { + getVirtualNetworkGatewayAdvertisedRoutes(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGetBgpPeerStatusSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGetBgpPeerStatusSample.ts new file mode 100644 index 000000000000..c671191e080e --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGetBgpPeerStatusSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to The GetBgpPeerStatus operation retrieves the status of all BGP peers. + * + * @summary The GetBgpPeerStatus operation retrieves the status of all BGP peers. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGetBGPPeerStatus.json + */ +async function getVirtualNetworkGatewayBgpPeerStatus() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginGetBgpPeerStatusAndWait( + resourceGroupName, + virtualNetworkGatewayName + ); + console.log(result); +} + +async function main() { + getVirtualNetworkGatewayBgpPeerStatus(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGetLearnedRoutesSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGetLearnedRoutesSample.ts new file mode 100644 index 000000000000..a5df31de5f05 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGetLearnedRoutesSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to This operation retrieves a list of routes the virtual network gateway has learned, including routes learned from BGP peers. + * + * @summary This operation retrieves a list of routes the virtual network gateway has learned, including routes learned from BGP peers. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayLearnedRoutes.json + */ +async function getVirtualNetworkGatewayLearnedRoutes() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginGetLearnedRoutesAndWait( + resourceGroupName, + virtualNetworkGatewayName + ); + console.log(result); +} + +async function main() { + getVirtualNetworkGatewayLearnedRoutes(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGetSample.ts new file mode 100644 index 000000000000..75fb2ee13d4d --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified virtual network gateway by resource group. + * + * @summary Gets the specified virtual network gateway by resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGet.json + */ +async function getVirtualNetworkGateway() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.get( + resourceGroupName, + virtualNetworkGatewayName + ); + console.log(result); +} + +async function main() { + getVirtualNetworkGateway(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGetVpnProfilePackageUrlSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGetVpnProfilePackageUrlSample.ts new file mode 100644 index 000000000000..d3408f8d40f9 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGetVpnProfilePackageUrlSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets pre-generated VPN profile for P2S client of the virtual network gateway in the specified resource group. The profile needs to be generated first using generateVpnProfile. + * + * @summary Gets pre-generated VPN profile for P2S client of the virtual network gateway in the specified resource group. The profile needs to be generated first using generateVpnProfile. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGetVpnProfilePackageUrl.json + */ +async function getVirtualNetworkGatewayVpnProfilePackageUrl() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginGetVpnProfilePackageUrlAndWait( + resourceGroupName, + virtualNetworkGatewayName + ); + console.log(result); +} + +async function main() { + getVirtualNetworkGatewayVpnProfilePackageUrl(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGetVpnclientIpsecParametersSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGetVpnclientIpsecParametersSample.ts new file mode 100644 index 000000000000..19346eed6cb3 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysGetVpnclientIpsecParametersSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to The Get VpnclientIpsecParameters operation retrieves information about the vpnclient ipsec policy for P2S client of virtual network gateway in the specified resource group through Network resource provider. + * + * @summary The Get VpnclientIpsecParameters operation retrieves information about the vpnclient ipsec policy for P2S client of virtual network gateway in the specified resource group through Network resource provider. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayGetVpnClientIpsecParameters.json + */ +async function getVirtualNetworkGatewayVpnClientIpsecParameters() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginGetVpnclientIpsecParametersAndWait( + resourceGroupName, + virtualNetworkGatewayName + ); + console.log(result); +} + +async function main() { + getVirtualNetworkGatewayVpnClientIpsecParameters(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysListConnectionsSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysListConnectionsSample.ts new file mode 100644 index 000000000000..d2a58336a3c1 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysListConnectionsSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all the connections in a virtual network gateway. + * + * @summary Gets all the connections in a virtual network gateway. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewaysListConnections.json + */ +async function virtualNetworkGatewaysListConnections() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "testrg"; + const virtualNetworkGatewayName = "test-vpn-gateway-1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.virtualNetworkGateways.listConnections( + resourceGroupName, + virtualNetworkGatewayName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + virtualNetworkGatewaysListConnections(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysListSample.ts new file mode 100644 index 000000000000..e17ba6c6ab0c --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all virtual network gateways by resource group. + * + * @summary Gets all virtual network gateways by resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayList.json + */ +async function listVirtualNetworkGatewaysinResourceGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.virtualNetworkGateways.list( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listVirtualNetworkGatewaysinResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysResetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysResetSample.ts new file mode 100644 index 000000000000..0b22d71d4c89 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysResetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Resets the primary of the virtual network gateway in the specified resource group. + * + * @summary Resets the primary of the virtual network gateway in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayReset.json + */ +async function resetVirtualNetworkGateway() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginResetAndWait( + resourceGroupName, + virtualNetworkGatewayName + ); + console.log(result); +} + +async function main() { + resetVirtualNetworkGateway(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysResetVpnClientSharedKeySample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysResetVpnClientSharedKeySample.ts new file mode 100644 index 000000000000..4cf577c83d59 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysResetVpnClientSharedKeySample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Resets the VPN client shared key of the virtual network gateway in the specified resource group. + * + * @summary Resets the VPN client shared key of the virtual network gateway in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayResetVpnClientSharedKey.json + */ +async function resetVpnClientSharedKey() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginResetVpnClientSharedKeyAndWait( + resourceGroupName, + virtualNetworkGatewayName + ); + console.log(result); +} + +async function main() { + resetVpnClientSharedKey(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysSetVpnclientIpsecParametersSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysSetVpnclientIpsecParametersSample.ts new file mode 100644 index 000000000000..c25798106cfc --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysSetVpnclientIpsecParametersSample.ts @@ -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. +import { + VpnClientIPsecParameters, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to The Set VpnclientIpsecParameters operation sets the vpnclient ipsec policy for P2S client of virtual network gateway in the specified resource group through Network resource provider. + * + * @summary The Set VpnclientIpsecParameters operation sets the vpnclient ipsec policy for P2S client of virtual network gateway in the specified resource group through Network resource provider. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewaySetVpnClientIpsecParameters.json + */ +async function setVirtualNetworkGatewayVpnClientIpsecParameters() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const vpnclientIpsecParams: VpnClientIPsecParameters = { + dhGroup: "DHGroup2", + ikeEncryption: "AES256", + ikeIntegrity: "SHA384", + ipsecEncryption: "AES256", + ipsecIntegrity: "SHA256", + pfsGroup: "PFS2", + saDataSizeKilobytes: 429497, + saLifeTimeSeconds: 86473 + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginSetVpnclientIpsecParametersAndWait( + resourceGroupName, + virtualNetworkGatewayName, + vpnclientIpsecParams + ); + console.log(result); +} + +async function main() { + setVirtualNetworkGatewayVpnClientIpsecParameters(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysSupportedVpnDevicesSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysSupportedVpnDevicesSample.ts new file mode 100644 index 000000000000..2d72e9103717 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysSupportedVpnDevicesSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets a xml format representation for supported vpn devices. + * + * @summary Gets a xml format representation for supported vpn devices. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewaySupportedVpnDevice.json + */ +async function listVirtualNetworkGatewaySupportedVpnDevices() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.supportedVpnDevices( + resourceGroupName, + virtualNetworkGatewayName + ); + console.log(result); +} + +async function main() { + listVirtualNetworkGatewaySupportedVpnDevices(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysUpdateTagsSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysUpdateTagsSample.ts new file mode 100644 index 000000000000..e61eacf627ef --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysUpdateTagsSample.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 { + TagsObject, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Updates a virtual network gateway tags. + * + * @summary Updates a virtual network gateway tags. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayUpdateTags.json + */ +async function updateVirtualNetworkGatewayTags() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayName = "vpngw"; + const parameters: TagsObject = { tags: { tag1: "value1", tag2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.beginUpdateTagsAndWait( + resourceGroupName, + virtualNetworkGatewayName, + parameters + ); + console.log(result); +} + +async function main() { + updateVirtualNetworkGatewayTags(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysVpnDeviceConfigurationScriptSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysVpnDeviceConfigurationScriptSample.ts new file mode 100644 index 000000000000..35b67a7ab20b --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkGatewaysVpnDeviceConfigurationScriptSample.ts @@ -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. +import { + VpnDeviceScriptParameters, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets a xml format representation for vpn device configuration script. + * + * @summary Gets a xml format representation for vpn device configuration script. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGatewayVpnDeviceConfigurationScript.json + */ +async function getVpnDeviceConfigurationScript() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkGatewayConnectionName = "vpngw"; + const parameters: VpnDeviceScriptParameters = { + deviceFamily: "ISR", + firmwareVersion: "IOS 15.1 (Preview)", + vendor: "Cisco" + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkGateways.vpnDeviceConfigurationScript( + resourceGroupName, + virtualNetworkGatewayConnectionName, + parameters + ); + console.log(result); +} + +async function main() { + getVpnDeviceConfigurationScript(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkPeeringsCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkPeeringsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..af1aa3669d07 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkPeeringsCreateOrUpdateSample.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + VirtualNetworkPeering, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a peering in the specified virtual network. + * + * @summary Creates or updates a peering in the specified virtual network. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkPeeringCreate.json + */ +async function createPeering() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "peerTest"; + const virtualNetworkName = "vnet1"; + const virtualNetworkPeeringName = "peer"; + const virtualNetworkPeeringParameters: VirtualNetworkPeering = { + allowForwardedTraffic: true, + allowGatewayTransit: false, + allowVirtualNetworkAccess: true, + remoteVirtualNetwork: { + id: + "/subscriptions/subid/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet2" + }, + useRemoteGateways: false + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkPeerings.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + virtualNetworkPeeringName, + virtualNetworkPeeringParameters + ); + console.log(result); +} + +async function main() { + createPeering(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkPeeringsDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkPeeringsDeleteSample.ts new file mode 100644 index 000000000000..f59f001d8bad --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkPeeringsDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified virtual network peering. + * + * @summary Deletes the specified virtual network peering. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkPeeringDelete.json + */ +async function deletePeering() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "peerTest"; + const virtualNetworkName = "vnet1"; + const virtualNetworkPeeringName = "peer"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkPeerings.beginDeleteAndWait( + resourceGroupName, + virtualNetworkName, + virtualNetworkPeeringName + ); + console.log(result); +} + +async function main() { + deletePeering(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkPeeringsGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkPeeringsGetSample.ts new file mode 100644 index 000000000000..1a90b18d7c3b --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkPeeringsGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified virtual network peering. + * + * @summary Gets the specified virtual network peering. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkPeeringGet.json + */ +async function getPeering() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "peerTest"; + const virtualNetworkName = "vnet1"; + const virtualNetworkPeeringName = "peer"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworkPeerings.get( + resourceGroupName, + virtualNetworkName, + virtualNetworkPeeringName + ); + console.log(result); +} + +async function main() { + getPeering(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkPeeringsListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkPeeringsListSample.ts new file mode 100644 index 000000000000..4d99cad017f6 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworkPeeringsListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all virtual network peerings in a virtual network. + * + * @summary Gets all virtual network peerings in a virtual network. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkPeeringList.json + */ +async function listPeerings() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "peerTest"; + const virtualNetworkName = "vnet1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.virtualNetworkPeerings.list( + resourceGroupName, + virtualNetworkName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listPeerings(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksCheckIPAddressAvailabilitySample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksCheckIPAddressAvailabilitySample.ts new file mode 100644 index 000000000000..b35415163265 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksCheckIPAddressAvailabilitySample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Checks whether a private IP address is available for use. + * + * @summary Checks whether a private IP address is available for use. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkCheckIPAddressAvailability.json + */ +async function checkIPAddressAvailability() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const ipAddress = "10.0.1.4"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.checkIPAddressAvailability( + resourceGroupName, + virtualNetworkName, + ipAddress + ); + console.log(result); +} + +async function main() { + checkIPAddressAvailability(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksCreateOrUpdateSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksCreateOrUpdateSample.ts new file mode 100644 index 000000000000..8efb093410a4 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksCreateOrUpdateSample.ts @@ -0,0 +1,204 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + VirtualNetwork, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Creates or updates a virtual network in the specified resource group. + * + * @summary Creates or updates a virtual network in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkCreate.json + */ +async function createVirtualNetwork() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const parameters: VirtualNetwork = { + addressSpace: { addressPrefixes: ["10.0.0.0/16"] } + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a virtual network in the specified resource group. + * + * @summary Creates or updates a virtual network in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkCreateSubnetWithDelegation.json + */ +async function createVirtualNetworkWithDelegatedSubnets() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subId"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const parameters: VirtualNetwork = { + addressSpace: { addressPrefixes: ["10.0.0.0/16"] }, + subnets: [ + { + name: "test-1", + addressPrefix: "10.0.0.0/24", + delegations: [ + { + name: "myDelegation", + serviceName: "Microsoft.Provider/resourceType" + } + ] + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a virtual network in the specified resource group. + * + * @summary Creates or updates a virtual network in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkCreateServiceEndpoints.json + */ +async function createVirtualNetworkWithServiceEndpoints() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "vnetTest"; + const virtualNetworkName = "vnet1"; + const parameters: VirtualNetwork = { + addressSpace: { addressPrefixes: ["10.0.0.0/16"] }, + subnets: [ + { + name: "test-1", + addressPrefix: "10.0.0.0/16", + serviceEndpoints: [{ service: "Microsoft.Storage" }] + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a virtual network in the specified resource group. + * + * @summary Creates or updates a virtual network in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkCreateServiceEndpointPolicy.json + */ +async function createVirtualNetworkWithServiceEndpointsAndServiceEndpointPolicy() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "vnetTest"; + const virtualNetworkName = "vnet1"; + const parameters: VirtualNetwork = { + addressSpace: { addressPrefixes: ["10.0.0.0/16"] }, + location: "eastus", + subnets: [ + { + name: "test-1", + addressPrefix: "10.0.0.0/16", + serviceEndpointPolicies: [ + { + id: + "/subscriptions/subid/resourceGroups/vnetTest/providers/Microsoft.Network/serviceEndpointPolicies/ServiceEndpointPolicy1" + } + ], + serviceEndpoints: [{ service: "Microsoft.Storage" }] + } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a virtual network in the specified resource group. + * + * @summary Creates or updates a virtual network in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkCreateSubnet.json + */ +async function createVirtualNetworkWithSubnet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const parameters: VirtualNetwork = { + addressSpace: { addressPrefixes: ["10.0.0.0/16"] }, + subnets: [{ name: "test-1", addressPrefix: "10.0.0.0/24" }] + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to Creates or updates a virtual network in the specified resource group. + * + * @summary Creates or updates a virtual network in the specified resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkCreateSubnetWithAddressPrefixes.json + */ +async function createVirtualNetworkWithSubnetContainingAddressPrefixes() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const parameters: VirtualNetwork = { + addressSpace: { addressPrefixes: ["10.0.0.0/16"] }, + subnets: [ + { name: "test-2", addressPrefixes: ["10.0.0.0/28", "10.0.1.0/28"] } + ] + }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.beginCreateOrUpdateAndWait( + resourceGroupName, + virtualNetworkName, + parameters + ); + console.log(result); +} + +async function main() { + createVirtualNetwork(); + createVirtualNetworkWithDelegatedSubnets(); + createVirtualNetworkWithServiceEndpoints(); + createVirtualNetworkWithServiceEndpointsAndServiceEndpointPolicy(); + createVirtualNetworkWithSubnet(); + createVirtualNetworkWithSubnetContainingAddressPrefixes(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksDeleteSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksDeleteSample.ts new file mode 100644 index 000000000000..6711e00d1990 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksDeleteSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified virtual network. + * + * @summary Deletes the specified virtual network. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkDelete.json + */ +async function deleteVirtualNetwork() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.beginDeleteAndWait( + resourceGroupName, + virtualNetworkName + ); + console.log(result); +} + +async function main() { + deleteVirtualNetwork(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksGetSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksGetSample.ts new file mode 100644 index 000000000000..6f7c6db5dc81 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksGetSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified virtual network by resource group. + * + * @summary Gets the specified virtual network by resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGet.json + */ +async function getVirtualNetwork() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.get( + resourceGroupName, + virtualNetworkName + ); + console.log(result); +} + +/** + * This sample demonstrates how to Gets the specified virtual network by resource group. + * + * @summary Gets the specified virtual network by resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGetWithSubnetDelegation.json + */ +async function getVirtualNetworkWithADelegatedSubnet() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subId"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.get( + resourceGroupName, + virtualNetworkName + ); + console.log(result); +} + +/** + * This sample demonstrates how to Gets the specified virtual network by resource group. + * + * @summary Gets the specified virtual network by resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkGetWithServiceAssociationLink.json + */ +async function getVirtualNetworkWithServiceAssociationLinks() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subId"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.get( + resourceGroupName, + virtualNetworkName + ); + console.log(result); +} + +async function main() { + getVirtualNetwork(); + getVirtualNetworkWithADelegatedSubnet(); + getVirtualNetworkWithServiceAssociationLinks(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksListAllSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksListAllSample.ts new file mode 100644 index 000000000000..5d3ea03bba72 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksListAllSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all virtual networks in a subscription. + * + * @summary Gets all virtual networks in a subscription. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkListAll.json + */ +async function listAllVirtualNetworks() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.virtualNetworks.listAll()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listAllVirtualNetworks(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksListSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksListSample.ts new file mode 100644 index 000000000000..d06cf0db25f1 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksListSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets all virtual networks in a resource group. + * + * @summary Gets all virtual networks in a resource group. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkList.json + */ +async function listVirtualNetworksInResourceGroup() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.virtualNetworks.list(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + listVirtualNetworksInResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksListUsageSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksListUsageSample.ts new file mode 100644 index 000000000000..8f682e2fa4ee --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksListUsageSample.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 { NetworkManagementClient } from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Lists usage stats. + * + * @summary Lists usage stats. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkListUsage.json + */ +async function vnetGetUsage() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "vnetName"; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.virtualNetworks.listUsage( + resourceGroupName, + virtualNetworkName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + vnetGetUsage(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksUpdateTagsSample.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksUpdateTagsSample.ts new file mode 100644 index 000000000000..47da9d0c9ab9 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/src/virtualNetworksUpdateTagsSample.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 { + TagsObject, + NetworkManagementClient +} from "@azure/arm-network-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Updates a virtual network tags. + * + * @summary Updates a virtual network tags. + * x-ms-original-file: specification/network/resource-manager/Microsoft.Network/stable/2018-11-01/examples/VirtualNetworkUpdateTags.json + */ +async function updateVirtualNetworkTags() { + const subscriptionId = process.env["NETWORK_SUBSCRIPTION_ID"] || "subid"; + const resourceGroupName = process.env["NETWORK_RESOURCE_GROUP"] || "rg1"; + const virtualNetworkName = "test-vnet"; + const parameters: TagsObject = { tags: { tag1: "value1", tag2: "value2" } }; + const credential = new DefaultAzureCredential(); + const client = new NetworkManagementClient(credential, subscriptionId); + const result = await client.virtualNetworks.beginUpdateTagsAndWait( + resourceGroupName, + virtualNetworkName, + parameters + ); + console.log(result); +} + +async function main() { + updateVirtualNetworkTags(); +} + +main().catch(console.error); diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/tsconfig.json b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/tsconfig.json new file mode 100644 index 000000000000..e26ce2a6d8f7 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/samples/v2/typescript/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "commonjs", + "moduleResolution": "node", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "alwaysStrict": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": [ + "src/**.ts" + ] +} diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/index.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/index.ts index 366865e77d90..65eb8f7a375d 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/index.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/index.ts @@ -7,6 +7,7 @@ */ /// +export { getContinuationToken } from "./pagingHelper"; export * from "./models"; export { NetworkManagementClient } from "./networkManagementClient"; export * from "./operationsInterfaces"; diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/models/index.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/models/index.ts index 3bbfcc1f46ef..55d1b69982cf 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/models/index.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/models/index.ts @@ -904,7 +904,7 @@ export interface Components1Jq1T4ISchemasManagedserviceidentityPropertiesUserass } /** IP configuration for virtual network gateway */ -export type VirtualNetworkGatewayIPConfiguration = SubResource & { +export interface VirtualNetworkGatewayIPConfiguration extends SubResource { /** The name of the resource that is unique within a resource group. This name can be used to access the resource. */ name?: string; /** A unique read-only string that changes whenever the resource is updated. */ @@ -920,10 +920,10 @@ export type VirtualNetworkGatewayIPConfiguration = SubResource & { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly provisioningState?: string; -}; +} /** VPN client root certificate of virtual network gateway */ -export type VpnClientRootCertificate = SubResource & { +export interface VpnClientRootCertificate extends SubResource { /** The name of the resource that is unique within a resource group. This name can be used to access the resource. */ name?: string; /** A unique read-only string that changes whenever the resource is updated. */ @@ -935,10 +935,10 @@ export type VpnClientRootCertificate = SubResource & { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly provisioningState?: string; -}; +} /** VPN client revoked certificate of virtual network gateway. */ -export type VpnClientRevokedCertificate = SubResource & { +export interface VpnClientRevokedCertificate extends SubResource { /** The name of the resource that is unique within a resource group. This name can be used to access the resource. */ name?: string; /** A unique read-only string that changes whenever the resource is updated. */ @@ -950,16 +950,16 @@ export type VpnClientRevokedCertificate = SubResource & { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly provisioningState?: string; -}; +} /** Response for GetConnectionSharedKey API service call */ -export type ConnectionSharedKey = SubResource & { +export interface ConnectionSharedKey extends SubResource { /** The virtual network connection shared key value. */ value: string; -}; +} /** Network security rule. */ -export type SecurityRule = SubResource & { +export interface SecurityRule extends SubResource { /** The name of the resource that is unique within a resource group. This name can be used to access the resource. */ name?: string; /** A unique read-only string that changes whenever the resource is updated. */ @@ -996,10 +996,10 @@ export type SecurityRule = SubResource & { direction?: SecurityRuleDirection; /** The provisioning state of the public IP resource. Possible values are: 'Updating', 'Deleting', and 'Failed'. */ provisioningState?: string; -}; +} /** Tap configuration in a Network Interface */ -export type NetworkInterfaceTapConfiguration = SubResource & { +export interface NetworkInterfaceTapConfiguration extends SubResource { /** The name of the resource that is unique within a resource group. This name can be used to access the resource. */ name?: string; /** A unique read-only string that changes whenever the resource is updated. */ @@ -1016,10 +1016,10 @@ export type NetworkInterfaceTapConfiguration = SubResource & { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly provisioningState?: string; -}; +} /** Backend Address Pool of an application gateway. */ -export type ApplicationGatewayBackendAddressPool = SubResource & { +export interface ApplicationGatewayBackendAddressPool extends SubResource { /** Name of the backend address pool that is unique within an Application Gateway. */ name?: string; /** A unique read-only string that changes whenever the resource is updated. */ @@ -1032,10 +1032,10 @@ export type ApplicationGatewayBackendAddressPool = SubResource & { backendAddresses?: ApplicationGatewayBackendAddress[]; /** Provisioning state of the backend address pool resource. Possible values are: 'Updating', 'Deleting', and 'Failed'. */ provisioningState?: string; -}; +} /** Pool of backend IP addresses. */ -export type BackendAddressPool = SubResource & { +export interface BackendAddressPool extends SubResource { /** Gets name of the resource that is unique within a resource group. This name can be used to access the resource. */ name?: string; /** A unique read-only string that changes whenever the resource is updated. */ @@ -1062,10 +1062,10 @@ export type BackendAddressPool = SubResource & { readonly outboundRules?: SubResource[]; /** Get provisioning state of the public IP resource. Possible values are: 'Updating', 'Deleting', and 'Failed'. */ provisioningState?: string; -}; +} /** Inbound NAT rule of the load balancer. */ -export type InboundNatRule = SubResource & { +export interface InboundNatRule extends SubResource { /** Gets name of the resource that is unique within a resource group. This name can be used to access the resource. */ name?: string; /** A unique read-only string that changes whenever the resource is updated. */ @@ -1091,10 +1091,10 @@ export type InboundNatRule = SubResource & { enableTcpReset?: boolean; /** Gets the provisioning state of the public IP resource. Possible values are: 'Updating', 'Deleting', and 'Failed'. */ provisioningState?: string; -}; +} /** IP configuration */ -export type IPConfiguration = SubResource & { +export interface IPConfiguration extends SubResource { /** The name of the resource that is unique within a resource group. This name can be used to access the resource. */ name?: string; /** A unique read-only string that changes whenever the resource is updated. */ @@ -1109,10 +1109,10 @@ export type IPConfiguration = SubResource & { publicIPAddress?: PublicIPAddress; /** Gets the provisioning state of the public IP resource. Possible values are: 'Updating', 'Deleting', and 'Failed'. */ provisioningState?: string; -}; +} /** IPConfiguration in a network interface. */ -export type NetworkInterfaceIPConfiguration = SubResource & { +export interface NetworkInterfaceIPConfiguration extends SubResource { /** The name of the resource that is unique within a resource group. This name can be used to access the resource. */ name?: string; /** A unique read-only string that changes whenever the resource is updated. */ @@ -1141,10 +1141,10 @@ export type NetworkInterfaceIPConfiguration = SubResource & { applicationSecurityGroups?: ApplicationSecurityGroup[]; /** The provisioning state of the network interface IP configuration. Possible values are: 'Updating', 'Deleting', and 'Failed'. */ provisioningState?: string; -}; +} /** Route resource */ -export type Route = SubResource & { +export interface Route extends SubResource { /** The name of the resource that is unique within a resource group. This name can be used to access the resource. */ name?: string; /** A unique read-only string that changes whenever the resource is updated. */ @@ -1157,10 +1157,10 @@ export type Route = SubResource & { nextHopIpAddress?: string; /** The provisioning state of the resource. Possible values are: 'Updating', 'Deleting', and 'Failed'. */ provisioningState?: string; -}; +} /** Service Endpoint policy definitions. */ -export type ServiceEndpointPolicyDefinition = SubResource & { +export interface ServiceEndpointPolicyDefinition extends SubResource { /** The name of the resource that is unique within a resource group. This name can be used to access the resource. */ name?: string; /** A unique read-only string that changes whenever the resource is updated. */ @@ -1176,10 +1176,10 @@ export type ServiceEndpointPolicyDefinition = SubResource & { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly provisioningState?: string; -}; +} /** IP configuration profile child resource. */ -export type IPConfigurationProfile = SubResource & { +export interface IPConfigurationProfile extends SubResource { /** The name of the resource. This name can be used to access the resource. */ name?: string; /** @@ -1196,10 +1196,10 @@ export type IPConfigurationProfile = SubResource & { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly provisioningState?: string; -}; +} /** ResourceNavigationLink resource. */ -export type ResourceNavigationLink = SubResource & { +export interface ResourceNavigationLink extends SubResource { /** Name of the resource that is unique within a resource group. This name can be used to access the resource. */ name?: string; /** @@ -1216,10 +1216,10 @@ export type ResourceNavigationLink = SubResource & { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly provisioningState?: string; -}; +} /** ServiceAssociationLink resource. */ -export type ServiceAssociationLink = SubResource & { +export interface ServiceAssociationLink extends SubResource { /** Name of the resource that is unique within a resource group. This name can be used to access the resource. */ name?: string; /** @@ -1236,10 +1236,10 @@ export type ServiceAssociationLink = SubResource & { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly provisioningState?: string; -}; +} /** Details the service to which the subnet is delegated. */ -export type Delegation = SubResource & { +export interface Delegation extends SubResource { /** The name of the resource that is unique within a subnet. This name can be used to access the resource. */ name?: string; /** A unique read-only string that changes whenever the resource is updated. */ @@ -1253,10 +1253,10 @@ export type Delegation = SubResource & { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly provisioningState?: string; -}; +} /** Subnet in a virtual network resource. */ -export type Subnet = SubResource & { +export interface Subnet extends SubResource { /** The name of the resource that is unique within a resource group. This name can be used to access the resource. */ name?: string; /** A unique read-only string that changes whenever the resource is updated. */ @@ -1301,10 +1301,10 @@ export type Subnet = SubResource & { readonly purpose?: string; /** The provisioning state of the resource. */ provisioningState?: string; -}; +} /** Frontend IP address of the load balancer. */ -export type FrontendIPConfiguration = SubResource & { +export interface FrontendIPConfiguration extends SubResource { /** The name of the resource that is unique within a resource group. This name can be used to access the resource. */ name?: string; /** A unique read-only string that changes whenever the resource is updated. */ @@ -1343,10 +1343,10 @@ export type FrontendIPConfiguration = SubResource & { publicIPPrefix?: SubResource; /** Gets the provisioning state of the public IP resource. Possible values are: 'Updating', 'Deleting', and 'Failed'. */ provisioningState?: string; -}; +} /** A load balancing rule for a load balancer. */ -export type LoadBalancingRule = SubResource & { +export interface LoadBalancingRule extends SubResource { /** The name of the resource that is unique within a resource group. This name can be used to access the resource. */ name?: string; /** A unique read-only string that changes whenever the resource is updated. */ @@ -1375,10 +1375,10 @@ export type LoadBalancingRule = SubResource & { disableOutboundSnat?: boolean; /** Gets the provisioning state of the PublicIP resource. Possible values are: 'Updating', 'Deleting', and 'Failed'. */ provisioningState?: string; -}; +} /** A load balancer probe. */ -export type Probe = SubResource & { +export interface Probe extends SubResource { /** Gets name of the resource that is unique within a resource group. This name can be used to access the resource. */ name?: string; /** A unique read-only string that changes whenever the resource is updated. */ @@ -1400,10 +1400,10 @@ export type Probe = SubResource & { requestPath?: string; /** Gets the provisioning state of the public IP resource. Possible values are: 'Updating', 'Deleting', and 'Failed'. */ provisioningState?: string; -}; +} /** Inbound NAT pool of the load balancer. */ -export type InboundNatPool = SubResource & { +export interface InboundNatPool extends SubResource { /** The name of the resource that is unique within a resource group. This name can be used to access the resource. */ name?: string; /** A unique read-only string that changes whenever the resource is updated. */ @@ -1426,10 +1426,10 @@ export type InboundNatPool = SubResource & { enableTcpReset?: boolean; /** Gets the provisioning state of the PublicIP resource. Possible values are: 'Updating', 'Deleting', and 'Failed'. */ provisioningState?: string; -}; +} /** Outbound rule of the load balancer. */ -export type OutboundRule = SubResource & { +export interface OutboundRule extends SubResource { /** The name of the resource that is unique within a resource group. This name can be used to access the resource. */ name?: string; /** A unique read-only string that changes whenever the resource is updated. */ @@ -1448,10 +1448,10 @@ export type OutboundRule = SubResource & { enableTcpReset?: boolean; /** The timeout for the TCP idle connection */ idleTimeoutInMinutes?: number; -}; +} /** Peerings in a virtual network resource. */ -export type VirtualNetworkPeering = SubResource & { +export interface VirtualNetworkPeering extends SubResource { /** The name of the resource that is unique within a resource group. This name can be used to access the resource. */ name?: string; /** A unique read-only string that changes whenever the resource is updated. */ @@ -1472,10 +1472,10 @@ export type VirtualNetworkPeering = SubResource & { peeringState?: VirtualNetworkPeeringState; /** The provisioning state of the resource. */ provisioningState?: string; -}; +} /** A common class for general resource information */ -export type VirtualNetworkGateway = Resource & { +export interface VirtualNetworkGateway extends Resource { /** Gets a unique read-only string that changes whenever the resource is updated. */ etag?: string; /** IP configurations for virtual network gateway. */ @@ -1503,10 +1503,10 @@ export type VirtualNetworkGateway = Resource & { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly provisioningState?: string; -}; +} /** A common class for general resource information */ -export type VirtualNetworkGatewayConnectionListEntity = Resource & { +export interface VirtualNetworkGatewayConnectionListEntity extends Resource { /** Gets a unique read-only string that changes whenever the resource is updated. */ etag?: string; /** The authorizationKey. */ @@ -1562,10 +1562,10 @@ export type VirtualNetworkGatewayConnectionListEntity = Resource & { readonly provisioningState?: string; /** Bypass ExpressRoute Gateway for data forwarding */ expressRouteGatewayBypass?: boolean; -}; +} /** A common class for general resource information */ -export type LocalNetworkGateway = Resource & { +export interface LocalNetworkGateway extends Resource { /** A unique read-only string that changes whenever the resource is updated. */ etag?: string; /** Local network site address space. */ @@ -1581,10 +1581,10 @@ export type LocalNetworkGateway = Resource & { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly provisioningState?: string; -}; +} /** A common class for general resource information */ -export type VirtualNetworkGatewayConnection = Resource & { +export interface VirtualNetworkGatewayConnection extends Resource { /** Gets a unique read-only string that changes whenever the resource is updated. */ etag?: string; /** The authorizationKey. */ @@ -1640,10 +1640,10 @@ export type VirtualNetworkGatewayConnection = Resource & { readonly provisioningState?: string; /** Bypass ExpressRoute Gateway for data forwarding */ expressRouteGatewayBypass?: boolean; -}; +} /** An application security group in a resource group. */ -export type ApplicationSecurityGroup = Resource & { +export interface ApplicationSecurityGroup extends Resource { /** * A unique read-only string that changes whenever the resource is updated. * NOTE: This property will not be serialized. It can only be populated by the server. @@ -1659,10 +1659,10 @@ export type ApplicationSecurityGroup = Resource & { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly provisioningState?: string; -}; +} /** Interface endpoint resource. */ -export type InterfaceEndpoint = Resource & { +export interface InterfaceEndpoint extends Resource { /** Gets a unique read-only string that changes whenever the resource is updated. */ etag?: string; /** A first-party service's FQDN that is mapped to the private IP allocated via this interface endpoint. */ @@ -1686,10 +1686,10 @@ export type InterfaceEndpoint = Resource & { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly provisioningState?: string; -}; +} /** Virtual Network Tap resource */ -export type VirtualNetworkTap = Resource & { +export interface VirtualNetworkTap extends Resource { /** Gets a unique read-only string that changes whenever the resource is updated. */ etag?: string; /** @@ -1713,10 +1713,10 @@ export type VirtualNetworkTap = Resource & { destinationLoadBalancerFrontEndIPConfiguration?: FrontendIPConfiguration; /** The VXLAN destination port that will receive the tapped traffic. */ destinationPort?: number; -}; +} /** Public IP address resource. */ -export type PublicIPAddress = Resource & { +export interface PublicIPAddress extends Resource { /** The public IP address SKU. */ sku?: PublicIPAddressSku; /** A unique read-only string that changes whenever the resource is updated. */ @@ -1748,10 +1748,10 @@ export type PublicIPAddress = Resource & { resourceGuid?: string; /** The provisioning state of the PublicIP resource. Possible values are: 'Updating', 'Deleting', and 'Failed'. */ provisioningState?: string; -}; +} /** A network interface in a resource group. */ -export type NetworkInterface = Resource & { +export interface NetworkInterface extends Resource { /** A unique read-only string that changes whenever the resource is updated. */ etag?: string; /** @@ -1789,10 +1789,10 @@ export type NetworkInterface = Resource & { resourceGuid?: string; /** The provisioning state of the public IP resource. Possible values are: 'Updating', 'Deleting', and 'Failed'. */ provisioningState?: string; -}; +} /** NetworkSecurityGroup resource. */ -export type NetworkSecurityGroup = Resource & { +export interface NetworkSecurityGroup extends Resource { /** A unique read-only string that changes whenever the resource is updated. */ etag?: string; /** A collection of security rules of the network security group. */ @@ -1813,10 +1813,10 @@ export type NetworkSecurityGroup = Resource & { resourceGuid?: string; /** The provisioning state of the public IP resource. Possible values are: 'Updating', 'Deleting', and 'Failed'. */ provisioningState?: string; -}; +} /** Route table resource. */ -export type RouteTable = Resource & { +export interface RouteTable extends Resource { /** Gets a unique read-only string that changes whenever the resource is updated. */ etag?: string; /** Collection of routes contained within a route table. */ @@ -1830,10 +1830,10 @@ export type RouteTable = Resource & { disableBgpRoutePropagation?: boolean; /** The provisioning state of the resource. Possible values are: 'Updating', 'Deleting', and 'Failed'. */ provisioningState?: string; -}; +} /** Service End point policy resource. */ -export type ServiceEndpointPolicy = Resource & { +export interface ServiceEndpointPolicy extends Resource { /** A unique read-only string that changes whenever the resource is updated. */ etag?: string; /** A collection of service endpoint policy definitions of the service endpoint policy. */ @@ -1853,10 +1853,10 @@ export type ServiceEndpointPolicy = Resource & { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly provisioningState?: string; -}; +} /** LoadBalancer resource */ -export type LoadBalancer = Resource & { +export interface LoadBalancer extends Resource { /** The load balancer SKU. */ sku?: LoadBalancerSku; /** A unique read-only string that changes whenever the resource is updated. */ @@ -1879,10 +1879,10 @@ export type LoadBalancer = Resource & { resourceGuid?: string; /** Gets the provisioning state of the PublicIP resource. Possible values are: 'Updating', 'Deleting', and 'Failed'. */ provisioningState?: string; -}; +} /** Virtual Network resource. */ -export type VirtualNetwork = Resource & { +export interface VirtualNetwork extends Resource { /** Gets a unique read-only string that changes whenever the resource is updated. */ etag?: string; /** The AddressSpace that contains an array of IP address ranges that can be used by subnets. */ @@ -1903,11 +1903,13 @@ export type VirtualNetwork = Resource & { enableVmProtection?: boolean; /** The DDoS protection plan associated with the virtual network. */ ddosProtectionPlan?: SubResource; -}; +} /** Known values of {@link IPAllocationMethod} that the service accepts. */ export enum KnownIPAllocationMethod { + /** Static */ Static = "Static", + /** Dynamic */ Dynamic = "Dynamic" } @@ -1923,7 +1925,9 @@ export type IPAllocationMethod = string; /** Known values of {@link VirtualNetworkGatewayType} that the service accepts. */ export enum KnownVirtualNetworkGatewayType { + /** Vpn */ Vpn = "Vpn", + /** ExpressRoute */ ExpressRoute = "ExpressRoute" } @@ -1939,7 +1943,9 @@ export type VirtualNetworkGatewayType = string; /** Known values of {@link VpnType} that the service accepts. */ export enum KnownVpnType { + /** PolicyBased */ PolicyBased = "PolicyBased", + /** RouteBased */ RouteBased = "RouteBased" } @@ -1955,18 +1961,31 @@ export type VpnType = string; /** Known values of {@link VirtualNetworkGatewaySkuName} that the service accepts. */ export enum KnownVirtualNetworkGatewaySkuName { + /** Basic */ Basic = "Basic", + /** HighPerformance */ HighPerformance = "HighPerformance", + /** Standard */ Standard = "Standard", + /** UltraPerformance */ UltraPerformance = "UltraPerformance", + /** VpnGw1 */ VpnGw1 = "VpnGw1", + /** VpnGw2 */ VpnGw2 = "VpnGw2", + /** VpnGw3 */ VpnGw3 = "VpnGw3", + /** VpnGw1AZ */ VpnGw1AZ = "VpnGw1AZ", + /** VpnGw2AZ */ VpnGw2AZ = "VpnGw2AZ", + /** VpnGw3AZ */ VpnGw3AZ = "VpnGw3AZ", + /** ErGw1AZ */ ErGw1AZ = "ErGw1AZ", + /** ErGw2AZ */ ErGw2AZ = "ErGw2AZ", + /** ErGw3AZ */ ErGw3AZ = "ErGw3AZ" } @@ -1993,18 +2012,31 @@ export type VirtualNetworkGatewaySkuName = string; /** Known values of {@link VirtualNetworkGatewaySkuTier} that the service accepts. */ export enum KnownVirtualNetworkGatewaySkuTier { + /** Basic */ Basic = "Basic", + /** HighPerformance */ HighPerformance = "HighPerformance", + /** Standard */ Standard = "Standard", + /** UltraPerformance */ UltraPerformance = "UltraPerformance", + /** VpnGw1 */ VpnGw1 = "VpnGw1", + /** VpnGw2 */ VpnGw2 = "VpnGw2", + /** VpnGw3 */ VpnGw3 = "VpnGw3", + /** VpnGw1AZ */ VpnGw1AZ = "VpnGw1AZ", + /** VpnGw2AZ */ VpnGw2AZ = "VpnGw2AZ", + /** VpnGw3AZ */ VpnGw3AZ = "VpnGw3AZ", + /** ErGw1AZ */ ErGw1AZ = "ErGw1AZ", + /** ErGw2AZ */ ErGw2AZ = "ErGw2AZ", + /** ErGw3AZ */ ErGw3AZ = "ErGw3AZ" } @@ -2031,8 +2063,11 @@ export type VirtualNetworkGatewaySkuTier = string; /** Known values of {@link VpnClientProtocol} that the service accepts. */ export enum KnownVpnClientProtocol { + /** IkeV2 */ IkeV2 = "IkeV2", + /** Sstp */ Sstp = "SSTP", + /** OpenVPN */ OpenVPN = "OpenVPN" } @@ -2049,14 +2084,23 @@ export type VpnClientProtocol = string; /** Known values of {@link IpsecEncryption} that the service accepts. */ export enum KnownIpsecEncryption { + /** None */ None = "None", + /** DES */ DES = "DES", + /** DES3 */ DES3 = "DES3", + /** AES128 */ AES128 = "AES128", + /** AES192 */ AES192 = "AES192", + /** AES256 */ AES256 = "AES256", + /** Gcmaes128 */ Gcmaes128 = "GCMAES128", + /** Gcmaes192 */ Gcmaes192 = "GCMAES192", + /** Gcmaes256 */ Gcmaes256 = "GCMAES256" } @@ -2079,11 +2123,17 @@ export type IpsecEncryption = string; /** Known values of {@link IpsecIntegrity} that the service accepts. */ export enum KnownIpsecIntegrity { + /** MD5 */ MD5 = "MD5", + /** SHA1 */ SHA1 = "SHA1", + /** SHA256 */ SHA256 = "SHA256", + /** Gcmaes128 */ Gcmaes128 = "GCMAES128", + /** Gcmaes192 */ Gcmaes192 = "GCMAES192", + /** Gcmaes256 */ Gcmaes256 = "GCMAES256" } @@ -2103,12 +2153,19 @@ export type IpsecIntegrity = string; /** Known values of {@link IkeEncryption} that the service accepts. */ export enum KnownIkeEncryption { + /** DES */ DES = "DES", + /** DES3 */ DES3 = "DES3", + /** AES128 */ AES128 = "AES128", + /** AES192 */ AES192 = "AES192", + /** AES256 */ AES256 = "AES256", + /** Gcmaes256 */ Gcmaes256 = "GCMAES256", + /** Gcmaes128 */ Gcmaes128 = "GCMAES128" } @@ -2129,11 +2186,17 @@ export type IkeEncryption = string; /** Known values of {@link IkeIntegrity} that the service accepts. */ export enum KnownIkeIntegrity { + /** MD5 */ MD5 = "MD5", + /** SHA1 */ SHA1 = "SHA1", + /** SHA256 */ SHA256 = "SHA256", + /** SHA384 */ SHA384 = "SHA384", + /** Gcmaes256 */ Gcmaes256 = "GCMAES256", + /** Gcmaes128 */ Gcmaes128 = "GCMAES128" } @@ -2153,13 +2216,21 @@ export type IkeIntegrity = string; /** Known values of {@link DhGroup} that the service accepts. */ export enum KnownDhGroup { + /** None */ None = "None", + /** DHGroup1 */ DHGroup1 = "DHGroup1", + /** DHGroup2 */ DHGroup2 = "DHGroup2", + /** DHGroup14 */ DHGroup14 = "DHGroup14", + /** DHGroup2048 */ DHGroup2048 = "DHGroup2048", + /** ECP256 */ ECP256 = "ECP256", + /** ECP384 */ ECP384 = "ECP384", + /** DHGroup24 */ DHGroup24 = "DHGroup24" } @@ -2181,14 +2252,23 @@ export type DhGroup = string; /** Known values of {@link PfsGroup} that the service accepts. */ export enum KnownPfsGroup { + /** None */ None = "None", + /** PFS1 */ PFS1 = "PFS1", + /** PFS2 */ PFS2 = "PFS2", + /** PFS2048 */ PFS2048 = "PFS2048", + /** ECP256 */ ECP256 = "ECP256", + /** ECP384 */ ECP384 = "ECP384", + /** PFS24 */ PFS24 = "PFS24", + /** PFS14 */ PFS14 = "PFS14", + /** Pfsmm */ Pfsmm = "PFSMM" } @@ -2211,9 +2291,13 @@ export type PfsGroup = string; /** Known values of {@link VirtualNetworkGatewayConnectionType} that the service accepts. */ export enum KnownVirtualNetworkGatewayConnectionType { + /** IPsec */ IPsec = "IPsec", + /** Vnet2Vnet */ Vnet2Vnet = "Vnet2Vnet", + /** ExpressRoute */ ExpressRoute = "ExpressRoute", + /** VPNClient */ VPNClient = "VPNClient" } @@ -2231,7 +2315,9 @@ export type VirtualNetworkGatewayConnectionType = string; /** Known values of {@link VirtualNetworkGatewayConnectionProtocol} that the service accepts. */ export enum KnownVirtualNetworkGatewayConnectionProtocol { + /** IKEv2 */ IKEv2 = "IKEv2", + /** IKEv1 */ IKEv1 = "IKEv1" } @@ -2247,9 +2333,13 @@ export type VirtualNetworkGatewayConnectionProtocol = string; /** Known values of {@link VirtualNetworkGatewayConnectionStatus} that the service accepts. */ export enum KnownVirtualNetworkGatewayConnectionStatus { + /** Unknown */ Unknown = "Unknown", + /** Connecting */ Connecting = "Connecting", + /** Connected */ Connected = "Connected", + /** NotConnected */ NotConnected = "NotConnected" } @@ -2267,7 +2357,9 @@ export type VirtualNetworkGatewayConnectionStatus = string; /** Known values of {@link ProcessorArchitecture} that the service accepts. */ export enum KnownProcessorArchitecture { + /** Amd64 */ Amd64 = "Amd64", + /** X86 */ X86 = "X86" } @@ -2283,7 +2375,9 @@ export type ProcessorArchitecture = string; /** Known values of {@link AuthenticationMethod} that the service accepts. */ export enum KnownAuthenticationMethod { + /** Eaptls */ Eaptls = "EAPTLS", + /** EapmschaPv2 */ EapmschaPv2 = "EAPMSCHAPv2" } @@ -2299,10 +2393,15 @@ export type AuthenticationMethod = string; /** Known values of {@link BgpPeerState} that the service accepts. */ export enum KnownBgpPeerState { + /** Unknown */ Unknown = "Unknown", + /** Stopped */ Stopped = "Stopped", + /** Idle */ Idle = "Idle", + /** Connecting */ Connecting = "Connecting", + /** Connected */ Connected = "Connected" } @@ -2321,7 +2420,9 @@ export type BgpPeerState = string; /** Known values of {@link LoadBalancerSkuName} that the service accepts. */ export enum KnownLoadBalancerSkuName { + /** Basic */ Basic = "Basic", + /** Standard */ Standard = "Standard" } @@ -2337,8 +2438,11 @@ export type LoadBalancerSkuName = string; /** Known values of {@link SecurityRuleProtocol} that the service accepts. */ export enum KnownSecurityRuleProtocol { + /** Tcp */ Tcp = "Tcp", + /** Udp */ Udp = "Udp", + /** Asterisk */ Asterisk = "*" } @@ -2355,7 +2459,9 @@ export type SecurityRuleProtocol = string; /** Known values of {@link SecurityRuleAccess} that the service accepts. */ export enum KnownSecurityRuleAccess { + /** Allow */ Allow = "Allow", + /** Deny */ Deny = "Deny" } @@ -2371,7 +2477,9 @@ export type SecurityRuleAccess = string; /** Known values of {@link SecurityRuleDirection} that the service accepts. */ export enum KnownSecurityRuleDirection { + /** Inbound */ Inbound = "Inbound", + /** Outbound */ Outbound = "Outbound" } @@ -2387,8 +2495,11 @@ export type SecurityRuleDirection = string; /** Known values of {@link TransportProtocol} that the service accepts. */ export enum KnownTransportProtocol { + /** Udp */ Udp = "Udp", + /** Tcp */ Tcp = "Tcp", + /** All */ All = "All" } @@ -2405,7 +2516,9 @@ export type TransportProtocol = string; /** Known values of {@link IPVersion} that the service accepts. */ export enum KnownIPVersion { + /** IPv4 */ IPv4 = "IPv4", + /** IPv6 */ IPv6 = "IPv6" } @@ -2421,7 +2534,9 @@ export type IPVersion = string; /** Known values of {@link PublicIPAddressSkuName} that the service accepts. */ export enum KnownPublicIPAddressSkuName { + /** Basic */ Basic = "Basic", + /** Standard */ Standard = "Standard" } @@ -2437,7 +2552,9 @@ export type PublicIPAddressSkuName = string; /** Known values of {@link DdosSettingsProtectionCoverage} that the service accepts. */ export enum KnownDdosSettingsProtectionCoverage { + /** Basic */ Basic = "Basic", + /** Standard */ Standard = "Standard" } @@ -2453,10 +2570,15 @@ export type DdosSettingsProtectionCoverage = string; /** Known values of {@link RouteNextHopType} that the service accepts. */ export enum KnownRouteNextHopType { + /** VirtualNetworkGateway */ VirtualNetworkGateway = "VirtualNetworkGateway", + /** VnetLocal */ VnetLocal = "VnetLocal", + /** Internet */ Internet = "Internet", + /** VirtualAppliance */ VirtualAppliance = "VirtualAppliance", + /** None */ None = "None" } @@ -2475,8 +2597,11 @@ export type RouteNextHopType = string; /** Known values of {@link LoadDistribution} that the service accepts. */ export enum KnownLoadDistribution { + /** Default */ Default = "Default", + /** SourceIP */ SourceIP = "SourceIP", + /** SourceIPProtocol */ SourceIPProtocol = "SourceIPProtocol" } @@ -2493,8 +2618,11 @@ export type LoadDistribution = string; /** Known values of {@link ProbeProtocol} that the service accepts. */ export enum KnownProbeProtocol { + /** Http */ Http = "Http", + /** Tcp */ Tcp = "Tcp", + /** Https */ Https = "Https" } @@ -2511,8 +2639,11 @@ export type ProbeProtocol = string; /** Known values of {@link OutboundRulePropertiesFormatProtocol} that the service accepts. */ export enum KnownOutboundRulePropertiesFormatProtocol { + /** Tcp */ Tcp = "Tcp", + /** Udp */ Udp = "Udp", + /** All */ All = "All" } @@ -2529,9 +2660,13 @@ export type OutboundRulePropertiesFormatProtocol = string; /** Known values of {@link EffectiveRouteSource} that the service accepts. */ export enum KnownEffectiveRouteSource { + /** Unknown */ Unknown = "Unknown", + /** User */ User = "User", + /** VirtualNetworkGateway */ VirtualNetworkGateway = "VirtualNetworkGateway", + /** Default */ Default = "Default" } @@ -2549,7 +2684,9 @@ export type EffectiveRouteSource = string; /** Known values of {@link EffectiveRouteState} that the service accepts. */ export enum KnownEffectiveRouteState { + /** Active */ Active = "Active", + /** Invalid */ Invalid = "Invalid" } @@ -2565,8 +2702,11 @@ export type EffectiveRouteState = string; /** Known values of {@link EffectiveSecurityRuleProtocol} that the service accepts. */ export enum KnownEffectiveSecurityRuleProtocol { + /** Tcp */ Tcp = "Tcp", + /** Udp */ Udp = "Udp", + /** All */ All = "All" } @@ -2583,8 +2723,11 @@ export type EffectiveSecurityRuleProtocol = string; /** Known values of {@link VirtualNetworkPeeringState} that the service accepts. */ export enum KnownVirtualNetworkPeeringState { + /** Initiated */ Initiated = "Initiated", + /** Connected */ Connected = "Connected", + /** Disconnected */ Disconnected = "Disconnected" } @@ -2601,8 +2744,11 @@ export type VirtualNetworkPeeringState = string; /** Known values of {@link NetworkOperationStatus} that the service accepts. */ export enum KnownNetworkOperationStatus { + /** InProgress */ InProgress = "InProgress", + /** Succeeded */ Succeeded = "Succeeded", + /** Failed */ Failed = "Failed" } diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/networkManagementClient.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/networkManagementClient.ts index 367107f6f7a7..1a4ab3a26705 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/networkManagementClient.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/networkManagementClient.ts @@ -7,6 +7,12 @@ */ import * as coreClient from "@azure/core-client"; +import * as coreRestPipeline from "@azure/core-rest-pipeline"; +import { + PipelineRequest, + PipelineResponse, + SendRequest +} from "@azure/core-rest-pipeline"; import * as coreAuth from "@azure/core-auth"; import { VirtualNetworkGatewaysImpl, @@ -97,24 +103,54 @@ export class NetworkManagementClient extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-network-profile-2020-09-01-hybrid/2.0.1`; + const packageDetails = `azsdk-js-arm-network-profile-2020-09-01-hybrid/2.1.0`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` : `${packageDetails}`; - if (!options.credentialScopes) { - options.credentialScopes = ["https://management.azure.com/.default"]; - } const optionsWithDefaults = { ...defaults, ...options, userAgentOptions: { userAgentPrefix }, - baseUri: options.endpoint || "https://management.azure.com" + endpoint: + options.endpoint ?? options.baseUri ?? "https://management.azure.com" }; super(optionsWithDefaults); + + let bearerTokenAuthenticationPolicyFound: boolean = false; + if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { + const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies(); + bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( + (pipelinePolicy) => + pipelinePolicy.name === + coreRestPipeline.bearerTokenAuthenticationPolicyName + ); + } + if ( + !options || + !options.pipeline || + options.pipeline.getOrderedPolicies().length == 0 || + !bearerTokenAuthenticationPolicyFound + ) { + this.pipeline.removePolicy({ + name: coreRestPipeline.bearerTokenAuthenticationPolicyName + }); + this.pipeline.addPolicy( + coreRestPipeline.bearerTokenAuthenticationPolicy({ + credential: credentials, + scopes: + optionsWithDefaults.credentialScopes ?? + `${optionsWithDefaults.endpoint}/.default`, + challengeCallbacks: { + authorizeRequestOnChallenge: + coreClient.authorizeRequestOnClaimChallenge + } + }) + ); + } // Parameter assignments this.subscriptionId = subscriptionId; @@ -162,6 +198,35 @@ export class NetworkManagementClient extends coreClient.ServiceClient { this.virtualNetworks = new VirtualNetworksImpl(this); this.subnets = new SubnetsImpl(this); this.virtualNetworkPeerings = new VirtualNetworkPeeringsImpl(this); + this.addCustomApiVersionPolicy(options.apiVersion); + } + + /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */ + private addCustomApiVersionPolicy(apiVersion?: string) { + if (!apiVersion) { + return; + } + const apiVersionPolicy = { + name: "CustomApiVersionPolicy", + async sendRequest( + request: PipelineRequest, + next: SendRequest + ): Promise { + const param = request.url.split("?"); + if (param.length > 1) { + const newParams = param[1].split("&").map((item) => { + if (item.indexOf("api-version") > -1) { + return "api-version=" + apiVersion; + } else { + return item; + } + }); + request.url = param[0] + "?" + newParams.join("&"); + } + return next(request); + } + }; + this.pipeline.addPolicy(apiVersionPolicy); } virtualNetworkGateways: VirtualNetworkGateways; diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/defaultSecurityRules.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/defaultSecurityRules.ts index 28bff7cfed1f..ed0dbaf3204a 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/defaultSecurityRules.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/defaultSecurityRules.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { DefaultSecurityRules } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -58,11 +59,15 @@ export class DefaultSecurityRulesImpl implements DefaultSecurityRules { [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listPagingPage( resourceGroupName, networkSecurityGroupName, - options + options, + settings ); } }; @@ -71,15 +76,22 @@ export class DefaultSecurityRulesImpl implements DefaultSecurityRules { private async *listPagingPage( resourceGroupName: string, networkSecurityGroupName: string, - options?: DefaultSecurityRulesListOptionalParams + options?: DefaultSecurityRulesListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list( - resourceGroupName, - networkSecurityGroupName, - options - ); - yield result.value || []; - let continuationToken = result.nextLink; + let result: DefaultSecurityRulesListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list( + resourceGroupName, + networkSecurityGroupName, + options + ); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext( resourceGroupName, @@ -88,7 +100,9 @@ export class DefaultSecurityRulesImpl implements DefaultSecurityRules { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -216,7 +230,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.SecurityRuleListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/inboundNatRules.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/inboundNatRules.ts index 1b3522bbc314..74727b4e45dd 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/inboundNatRules.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/inboundNatRules.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { InboundNatRules } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -63,11 +64,15 @@ export class InboundNatRulesImpl implements InboundNatRules { [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listPagingPage( resourceGroupName, loadBalancerName, - options + options, + settings ); } }; @@ -76,11 +81,18 @@ export class InboundNatRulesImpl implements InboundNatRules { private async *listPagingPage( resourceGroupName: string, loadBalancerName: string, - options?: InboundNatRulesListOptionalParams + options?: InboundNatRulesListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(resourceGroupName, loadBalancerName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: InboundNatRulesListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(resourceGroupName, loadBalancerName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext( resourceGroupName, @@ -89,7 +101,9 @@ export class InboundNatRulesImpl implements InboundNatRules { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -181,10 +195,12 @@ export class InboundNatRulesImpl implements InboundNatRules { { resourceGroupName, loadBalancerName, inboundNatRuleName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -299,10 +315,12 @@ export class InboundNatRulesImpl implements InboundNatRules { }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -446,7 +464,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.InboundNatRuleListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancerBackendAddressPools.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancerBackendAddressPools.ts index 1e5d36d2dc3a..7185bee1d49c 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancerBackendAddressPools.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancerBackendAddressPools.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { LoadBalancerBackendAddressPools } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -59,11 +60,15 @@ export class LoadBalancerBackendAddressPoolsImpl [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listPagingPage( resourceGroupName, loadBalancerName, - options + options, + settings ); } }; @@ -72,11 +77,18 @@ export class LoadBalancerBackendAddressPoolsImpl private async *listPagingPage( resourceGroupName: string, loadBalancerName: string, - options?: LoadBalancerBackendAddressPoolsListOptionalParams + options?: LoadBalancerBackendAddressPoolsListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(resourceGroupName, loadBalancerName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: LoadBalancerBackendAddressPoolsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(resourceGroupName, loadBalancerName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext( resourceGroupName, @@ -85,7 +97,9 @@ export class LoadBalancerBackendAddressPoolsImpl options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -208,7 +222,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.LoadBalancerBackendAddressPoolListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancerFrontendIPConfigurations.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancerFrontendIPConfigurations.ts index 02b753aed5d9..c4495317ac09 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancerFrontendIPConfigurations.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancerFrontendIPConfigurations.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { LoadBalancerFrontendIPConfigurations } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -59,11 +60,15 @@ export class LoadBalancerFrontendIPConfigurationsImpl [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listPagingPage( resourceGroupName, loadBalancerName, - options + options, + settings ); } }; @@ -72,11 +77,18 @@ export class LoadBalancerFrontendIPConfigurationsImpl private async *listPagingPage( resourceGroupName: string, loadBalancerName: string, - options?: LoadBalancerFrontendIPConfigurationsListOptionalParams + options?: LoadBalancerFrontendIPConfigurationsListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(resourceGroupName, loadBalancerName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: LoadBalancerFrontendIPConfigurationsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(resourceGroupName, loadBalancerName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext( resourceGroupName, @@ -85,7 +97,9 @@ export class LoadBalancerFrontendIPConfigurationsImpl options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -213,7 +227,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.LoadBalancerFrontendIPConfigurationListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancerLoadBalancingRules.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancerLoadBalancingRules.ts index 40ac1d9aa8ed..5f10bcc79fa1 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancerLoadBalancingRules.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancerLoadBalancingRules.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { LoadBalancerLoadBalancingRules } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -59,11 +60,15 @@ export class LoadBalancerLoadBalancingRulesImpl [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listPagingPage( resourceGroupName, loadBalancerName, - options + options, + settings ); } }; @@ -72,11 +77,18 @@ export class LoadBalancerLoadBalancingRulesImpl private async *listPagingPage( resourceGroupName: string, loadBalancerName: string, - options?: LoadBalancerLoadBalancingRulesListOptionalParams + options?: LoadBalancerLoadBalancingRulesListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(resourceGroupName, loadBalancerName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: LoadBalancerLoadBalancingRulesListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(resourceGroupName, loadBalancerName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext( resourceGroupName, @@ -85,7 +97,9 @@ export class LoadBalancerLoadBalancingRulesImpl options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -208,7 +222,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.LoadBalancerLoadBalancingRuleListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancerNetworkInterfaces.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancerNetworkInterfaces.ts index 428abcdf7505..156d13149669 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancerNetworkInterfaces.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancerNetworkInterfaces.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { LoadBalancerNetworkInterfaces } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -57,11 +58,15 @@ export class LoadBalancerNetworkInterfacesImpl [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listPagingPage( resourceGroupName, loadBalancerName, - options + options, + settings ); } }; @@ -70,11 +75,18 @@ export class LoadBalancerNetworkInterfacesImpl private async *listPagingPage( resourceGroupName: string, loadBalancerName: string, - options?: LoadBalancerNetworkInterfacesListOptionalParams + options?: LoadBalancerNetworkInterfacesListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(resourceGroupName, loadBalancerName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: LoadBalancerNetworkInterfacesListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(resourceGroupName, loadBalancerName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext( resourceGroupName, @@ -83,7 +95,9 @@ export class LoadBalancerNetworkInterfacesImpl options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -167,7 +181,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.NetworkInterfaceListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancerOutboundRules.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancerOutboundRules.ts index 1a72623617cd..ab091666fce2 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancerOutboundRules.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancerOutboundRules.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { LoadBalancerOutboundRules } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -59,11 +60,15 @@ export class LoadBalancerOutboundRulesImpl [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listPagingPage( resourceGroupName, loadBalancerName, - options + options, + settings ); } }; @@ -72,11 +77,18 @@ export class LoadBalancerOutboundRulesImpl private async *listPagingPage( resourceGroupName: string, loadBalancerName: string, - options?: LoadBalancerOutboundRulesListOptionalParams + options?: LoadBalancerOutboundRulesListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(resourceGroupName, loadBalancerName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: LoadBalancerOutboundRulesListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(resourceGroupName, loadBalancerName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext( resourceGroupName, @@ -85,7 +97,9 @@ export class LoadBalancerOutboundRulesImpl options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -208,7 +222,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.LoadBalancerOutboundRuleListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancerProbes.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancerProbes.ts index 19a727a5e080..97d07b1db58a 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancerProbes.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancerProbes.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { LoadBalancerProbes } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -58,11 +59,15 @@ export class LoadBalancerProbesImpl implements LoadBalancerProbes { [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listPagingPage( resourceGroupName, loadBalancerName, - options + options, + settings ); } }; @@ -71,11 +76,18 @@ export class LoadBalancerProbesImpl implements LoadBalancerProbes { private async *listPagingPage( resourceGroupName: string, loadBalancerName: string, - options?: LoadBalancerProbesListOptionalParams + options?: LoadBalancerProbesListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(resourceGroupName, loadBalancerName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: LoadBalancerProbesListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(resourceGroupName, loadBalancerName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext( resourceGroupName, @@ -84,7 +96,9 @@ export class LoadBalancerProbesImpl implements LoadBalancerProbes { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -207,7 +221,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.LoadBalancerProbeListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancers.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancers.ts index 3330400fb845..9bbc08b3567e 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancers.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/loadBalancers.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { LoadBalancers } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -18,8 +19,10 @@ import { LoadBalancer, LoadBalancersListAllNextOptionalParams, LoadBalancersListAllOptionalParams, + LoadBalancersListAllResponse, LoadBalancersListNextOptionalParams, LoadBalancersListOptionalParams, + LoadBalancersListResponse, LoadBalancersDeleteOptionalParams, LoadBalancersGetOptionalParams, LoadBalancersGetResponse, @@ -28,8 +31,6 @@ import { TagsObject, LoadBalancersUpdateTagsOptionalParams, LoadBalancersUpdateTagsResponse, - LoadBalancersListAllResponse, - LoadBalancersListResponse, LoadBalancersListAllNextResponse, LoadBalancersListNextResponse } from "../models"; @@ -62,22 +63,34 @@ export class LoadBalancersImpl implements LoadBalancers { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listAllPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listAllPagingPage(options, settings); } }; } private async *listAllPagingPage( - options?: LoadBalancersListAllOptionalParams + options?: LoadBalancersListAllOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listAll(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: LoadBalancersListAllResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listAll(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listAllNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -106,19 +119,29 @@ export class LoadBalancersImpl implements LoadBalancers { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(resourceGroupName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(resourceGroupName, options, settings); } }; } private async *listPagingPage( resourceGroupName: string, - options?: LoadBalancersListOptionalParams + options?: LoadBalancersListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(resourceGroupName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: LoadBalancersListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(resourceGroupName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext( resourceGroupName, @@ -126,7 +149,9 @@ export class LoadBalancersImpl implements LoadBalancers { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -194,10 +219,12 @@ export class LoadBalancersImpl implements LoadBalancers { { resourceGroupName, loadBalancerName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -298,10 +325,12 @@ export class LoadBalancersImpl implements LoadBalancers { { resourceGroupName, loadBalancerName, parameters, options }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -388,10 +417,12 @@ export class LoadBalancersImpl implements LoadBalancers { { resourceGroupName, loadBalancerName, parameters, options }, updateTagsOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -609,7 +640,6 @@ const listAllNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.LoadBalancerListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, @@ -626,7 +656,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.LoadBalancerListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/localNetworkGateways.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/localNetworkGateways.ts index 3238e1cc96ac..fba94dc56352 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/localNetworkGateways.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/localNetworkGateways.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { LocalNetworkGateways } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -18,6 +19,7 @@ import { LocalNetworkGateway, LocalNetworkGatewaysListNextOptionalParams, LocalNetworkGatewaysListOptionalParams, + LocalNetworkGatewaysListResponse, LocalNetworkGatewaysCreateOrUpdateOptionalParams, LocalNetworkGatewaysCreateOrUpdateResponse, LocalNetworkGatewaysGetOptionalParams, @@ -26,7 +28,6 @@ import { TagsObject, LocalNetworkGatewaysUpdateTagsOptionalParams, LocalNetworkGatewaysUpdateTagsResponse, - LocalNetworkGatewaysListResponse, LocalNetworkGatewaysListNextResponse } from "../models"; @@ -60,19 +61,29 @@ export class LocalNetworkGatewaysImpl implements LocalNetworkGateways { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(resourceGroupName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(resourceGroupName, options, settings); } }; } private async *listPagingPage( resourceGroupName: string, - options?: LocalNetworkGatewaysListOptionalParams + options?: LocalNetworkGatewaysListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(resourceGroupName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: LocalNetworkGatewaysListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(resourceGroupName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext( resourceGroupName, @@ -80,7 +91,9 @@ export class LocalNetworkGatewaysImpl implements LocalNetworkGateways { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -155,11 +168,13 @@ export class LocalNetworkGatewaysImpl implements LocalNetworkGateways { { resourceGroupName, localNetworkGatewayName, parameters, options }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, lroResourceLocationConfig: "azure-async-operation" }); + await poller.poll(); + return poller; } /** @@ -256,11 +271,13 @@ export class LocalNetworkGatewaysImpl implements LocalNetworkGateways { { resourceGroupName, localNetworkGatewayName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, lroResourceLocationConfig: "location" }); + await poller.poll(); + return poller; } /** @@ -344,10 +361,12 @@ export class LocalNetworkGatewaysImpl implements LocalNetworkGateways { { resourceGroupName, localNetworkGatewayName, parameters, options }, updateTagsOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -526,7 +545,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.LocalNetworkGatewayListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/networkInterfaceIPConfigurations.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/networkInterfaceIPConfigurations.ts index 9cd3e86347d4..ff14657cd464 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/networkInterfaceIPConfigurations.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/networkInterfaceIPConfigurations.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { NetworkInterfaceIPConfigurations } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -59,11 +60,15 @@ export class NetworkInterfaceIPConfigurationsImpl [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listPagingPage( resourceGroupName, networkInterfaceName, - options + options, + settings ); } }; @@ -72,15 +77,22 @@ export class NetworkInterfaceIPConfigurationsImpl private async *listPagingPage( resourceGroupName: string, networkInterfaceName: string, - options?: NetworkInterfaceIPConfigurationsListOptionalParams + options?: NetworkInterfaceIPConfigurationsListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list( - resourceGroupName, - networkInterfaceName, - options - ); - yield result.value || []; - let continuationToken = result.nextLink; + let result: NetworkInterfaceIPConfigurationsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list( + resourceGroupName, + networkInterfaceName, + options + ); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext( resourceGroupName, @@ -89,7 +101,9 @@ export class NetworkInterfaceIPConfigurationsImpl options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -212,7 +226,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.NetworkInterfaceIPConfigurationListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/networkInterfaceLoadBalancers.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/networkInterfaceLoadBalancers.ts index c377dc63580c..4fc8079d447e 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/networkInterfaceLoadBalancers.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/networkInterfaceLoadBalancers.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { NetworkInterfaceLoadBalancers } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -57,11 +58,15 @@ export class NetworkInterfaceLoadBalancersImpl [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listPagingPage( resourceGroupName, networkInterfaceName, - options + options, + settings ); } }; @@ -70,15 +75,22 @@ export class NetworkInterfaceLoadBalancersImpl private async *listPagingPage( resourceGroupName: string, networkInterfaceName: string, - options?: NetworkInterfaceLoadBalancersListOptionalParams + options?: NetworkInterfaceLoadBalancersListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list( - resourceGroupName, - networkInterfaceName, - options - ); - yield result.value || []; - let continuationToken = result.nextLink; + let result: NetworkInterfaceLoadBalancersListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list( + resourceGroupName, + networkInterfaceName, + options + ); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext( resourceGroupName, @@ -87,7 +99,9 @@ export class NetworkInterfaceLoadBalancersImpl options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -171,7 +185,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.NetworkInterfaceLoadBalancerListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/networkInterfaceTapConfigurations.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/networkInterfaceTapConfigurations.ts index 54bf1d1fc2bb..9dba5b03034c 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/networkInterfaceTapConfigurations.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/networkInterfaceTapConfigurations.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { NetworkInterfaceTapConfigurations } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -18,12 +19,12 @@ import { NetworkInterfaceTapConfiguration, NetworkInterfaceTapConfigurationsListNextOptionalParams, NetworkInterfaceTapConfigurationsListOptionalParams, + NetworkInterfaceTapConfigurationsListResponse, NetworkInterfaceTapConfigurationsDeleteOptionalParams, NetworkInterfaceTapConfigurationsGetOptionalParams, NetworkInterfaceTapConfigurationsGetResponse, NetworkInterfaceTapConfigurationsCreateOrUpdateOptionalParams, NetworkInterfaceTapConfigurationsCreateOrUpdateResponse, - NetworkInterfaceTapConfigurationsListResponse, NetworkInterfaceTapConfigurationsListNextResponse } from "../models"; @@ -64,11 +65,15 @@ export class NetworkInterfaceTapConfigurationsImpl [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listPagingPage( resourceGroupName, networkInterfaceName, - options + options, + settings ); } }; @@ -77,15 +82,22 @@ export class NetworkInterfaceTapConfigurationsImpl private async *listPagingPage( resourceGroupName: string, networkInterfaceName: string, - options?: NetworkInterfaceTapConfigurationsListOptionalParams + options?: NetworkInterfaceTapConfigurationsListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list( - resourceGroupName, - networkInterfaceName, - options - ); - yield result.value || []; - let continuationToken = result.nextLink; + let result: NetworkInterfaceTapConfigurationsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list( + resourceGroupName, + networkInterfaceName, + options + ); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext( resourceGroupName, @@ -94,7 +106,9 @@ export class NetworkInterfaceTapConfigurationsImpl options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -174,10 +188,12 @@ export class NetworkInterfaceTapConfigurationsImpl }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -299,10 +315,12 @@ export class NetworkInterfaceTapConfigurationsImpl }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -463,7 +481,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.NetworkInterfaceTapConfigurationListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/networkInterfaces.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/networkInterfaces.ts index d851202f0417..337f7f642b5c 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/networkInterfaces.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/networkInterfaces.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { NetworkInterfaces } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -18,8 +19,10 @@ import { NetworkInterface, NetworkInterfacesListAllNextOptionalParams, NetworkInterfacesListAllOptionalParams, + NetworkInterfacesListAllResponse, NetworkInterfacesListNextOptionalParams, NetworkInterfacesListOptionalParams, + NetworkInterfacesListResponse, NetworkInterfacesDeleteOptionalParams, NetworkInterfacesGetOptionalParams, NetworkInterfacesGetResponse, @@ -28,8 +31,6 @@ import { TagsObject, NetworkInterfacesUpdateTagsOptionalParams, NetworkInterfacesUpdateTagsResponse, - NetworkInterfacesListAllResponse, - NetworkInterfacesListResponse, NetworkInterfacesGetEffectiveRouteTableOptionalParams, NetworkInterfacesGetEffectiveRouteTableResponse, NetworkInterfacesListEffectiveNetworkSecurityGroupsOptionalParams, @@ -66,22 +67,34 @@ export class NetworkInterfacesImpl implements NetworkInterfaces { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listAllPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listAllPagingPage(options, settings); } }; } private async *listAllPagingPage( - options?: NetworkInterfacesListAllOptionalParams + options?: NetworkInterfacesListAllOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listAll(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: NetworkInterfacesListAllResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listAll(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listAllNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -110,19 +123,29 @@ export class NetworkInterfacesImpl implements NetworkInterfaces { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(resourceGroupName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(resourceGroupName, options, settings); } }; } private async *listPagingPage( resourceGroupName: string, - options?: NetworkInterfacesListOptionalParams + options?: NetworkInterfacesListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(resourceGroupName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: NetworkInterfacesListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(resourceGroupName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext( resourceGroupName, @@ -130,7 +153,9 @@ export class NetworkInterfacesImpl implements NetworkInterfaces { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -198,10 +223,12 @@ export class NetworkInterfacesImpl implements NetworkInterfaces { { resourceGroupName, networkInterfaceName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -302,10 +329,12 @@ export class NetworkInterfacesImpl implements NetworkInterfaces { { resourceGroupName, networkInterfaceName, parameters, options }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -392,10 +421,12 @@ export class NetworkInterfacesImpl implements NetworkInterfaces { { resourceGroupName, networkInterfaceName, parameters, options }, updateTagsOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -505,10 +536,12 @@ export class NetworkInterfacesImpl implements NetworkInterfaces { { resourceGroupName, networkInterfaceName, options }, getEffectiveRouteTableOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -592,10 +625,12 @@ export class NetworkInterfacesImpl implements NetworkInterfaces { { resourceGroupName, networkInterfaceName, options }, listEffectiveNetworkSecurityGroupsOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -841,7 +876,6 @@ const listAllNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.NetworkInterfaceListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, @@ -858,7 +892,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.NetworkInterfaceListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/networkSecurityGroups.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/networkSecurityGroups.ts index c7614e6fc9eb..d30573a80c6b 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/networkSecurityGroups.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/networkSecurityGroups.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { NetworkSecurityGroups } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -18,8 +19,10 @@ import { NetworkSecurityGroup, NetworkSecurityGroupsListAllNextOptionalParams, NetworkSecurityGroupsListAllOptionalParams, + NetworkSecurityGroupsListAllResponse, NetworkSecurityGroupsListNextOptionalParams, NetworkSecurityGroupsListOptionalParams, + NetworkSecurityGroupsListResponse, NetworkSecurityGroupsDeleteOptionalParams, NetworkSecurityGroupsGetOptionalParams, NetworkSecurityGroupsGetResponse, @@ -28,8 +31,6 @@ import { TagsObject, NetworkSecurityGroupsUpdateTagsOptionalParams, NetworkSecurityGroupsUpdateTagsResponse, - NetworkSecurityGroupsListAllResponse, - NetworkSecurityGroupsListResponse, NetworkSecurityGroupsListAllNextResponse, NetworkSecurityGroupsListNextResponse } from "../models"; @@ -62,22 +63,34 @@ export class NetworkSecurityGroupsImpl implements NetworkSecurityGroups { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listAllPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listAllPagingPage(options, settings); } }; } private async *listAllPagingPage( - options?: NetworkSecurityGroupsListAllOptionalParams + options?: NetworkSecurityGroupsListAllOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listAll(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: NetworkSecurityGroupsListAllResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listAll(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listAllNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -106,19 +119,29 @@ export class NetworkSecurityGroupsImpl implements NetworkSecurityGroups { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(resourceGroupName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(resourceGroupName, options, settings); } }; } private async *listPagingPage( resourceGroupName: string, - options?: NetworkSecurityGroupsListOptionalParams + options?: NetworkSecurityGroupsListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(resourceGroupName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: NetworkSecurityGroupsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(resourceGroupName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext( resourceGroupName, @@ -126,7 +149,9 @@ export class NetworkSecurityGroupsImpl implements NetworkSecurityGroups { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -194,10 +219,12 @@ export class NetworkSecurityGroupsImpl implements NetworkSecurityGroups { { resourceGroupName, networkSecurityGroupName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -298,10 +325,12 @@ export class NetworkSecurityGroupsImpl implements NetworkSecurityGroups { { resourceGroupName, networkSecurityGroupName, parameters, options }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -388,10 +417,12 @@ export class NetworkSecurityGroupsImpl implements NetworkSecurityGroups { { resourceGroupName, networkSecurityGroupName, parameters, options }, updateTagsOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -609,7 +640,6 @@ const listAllNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.NetworkSecurityGroupListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, @@ -626,7 +656,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.NetworkSecurityGroupListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/operations.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/operations.ts index d6ca366c2f97..3147a6b94f3e 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/operations.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/operations.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { Operations } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -48,22 +49,34 @@ export class OperationsImpl implements Operations { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); } }; } private async *listPagingPage( - options?: OperationsListOptionalParams + options?: OperationsListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: OperationsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -124,7 +137,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.OperationListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.$host, Parameters.nextLink], headerParameters: [Parameters.accept], serializer diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/publicIPAddresses.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/publicIPAddresses.ts index cd3e7b4b8925..98fc62bd21c8 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/publicIPAddresses.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/publicIPAddresses.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { PublicIPAddresses } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -18,8 +19,10 @@ import { PublicIPAddress, PublicIPAddressesListAllNextOptionalParams, PublicIPAddressesListAllOptionalParams, + PublicIPAddressesListAllResponse, PublicIPAddressesListNextOptionalParams, PublicIPAddressesListOptionalParams, + PublicIPAddressesListResponse, PublicIPAddressesDeleteOptionalParams, PublicIPAddressesGetOptionalParams, PublicIPAddressesGetResponse, @@ -28,8 +31,6 @@ import { TagsObject, PublicIPAddressesUpdateTagsOptionalParams, PublicIPAddressesUpdateTagsResponse, - PublicIPAddressesListAllResponse, - PublicIPAddressesListResponse, PublicIPAddressesListAllNextResponse, PublicIPAddressesListNextResponse } from "../models"; @@ -62,22 +63,34 @@ export class PublicIPAddressesImpl implements PublicIPAddresses { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listAllPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listAllPagingPage(options, settings); } }; } private async *listAllPagingPage( - options?: PublicIPAddressesListAllOptionalParams + options?: PublicIPAddressesListAllOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listAll(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: PublicIPAddressesListAllResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listAll(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listAllNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -106,19 +119,29 @@ export class PublicIPAddressesImpl implements PublicIPAddresses { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(resourceGroupName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(resourceGroupName, options, settings); } }; } private async *listPagingPage( resourceGroupName: string, - options?: PublicIPAddressesListOptionalParams + options?: PublicIPAddressesListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(resourceGroupName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: PublicIPAddressesListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(resourceGroupName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext( resourceGroupName, @@ -126,7 +149,9 @@ export class PublicIPAddressesImpl implements PublicIPAddresses { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -194,10 +219,12 @@ export class PublicIPAddressesImpl implements PublicIPAddresses { { resourceGroupName, publicIpAddressName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -298,10 +325,12 @@ export class PublicIPAddressesImpl implements PublicIPAddresses { { resourceGroupName, publicIpAddressName, parameters, options }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -388,10 +417,12 @@ export class PublicIPAddressesImpl implements PublicIPAddresses { { resourceGroupName, publicIpAddressName, parameters, options }, updateTagsOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -609,7 +640,6 @@ const listAllNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.PublicIPAddressListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, @@ -626,7 +656,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.PublicIPAddressListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/routeTables.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/routeTables.ts index e4ceef518755..046cf4e3d496 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/routeTables.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/routeTables.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { RouteTables } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -18,8 +19,10 @@ import { RouteTable, RouteTablesListNextOptionalParams, RouteTablesListOptionalParams, + RouteTablesListResponse, RouteTablesListAllNextOptionalParams, RouteTablesListAllOptionalParams, + RouteTablesListAllResponse, RouteTablesDeleteOptionalParams, RouteTablesGetOptionalParams, RouteTablesGetResponse, @@ -28,8 +31,6 @@ import { TagsObject, RouteTablesUpdateTagsOptionalParams, RouteTablesUpdateTagsResponse, - RouteTablesListResponse, - RouteTablesListAllResponse, RouteTablesListNextResponse, RouteTablesListAllNextResponse } from "../models"; @@ -64,19 +65,29 @@ export class RouteTablesImpl implements RouteTables { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(resourceGroupName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(resourceGroupName, options, settings); } }; } private async *listPagingPage( resourceGroupName: string, - options?: RouteTablesListOptionalParams + options?: RouteTablesListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(resourceGroupName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: RouteTablesListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(resourceGroupName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext( resourceGroupName, @@ -84,7 +95,9 @@ export class RouteTablesImpl implements RouteTables { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -112,22 +125,34 @@ export class RouteTablesImpl implements RouteTables { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listAllPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listAllPagingPage(options, settings); } }; } private async *listAllPagingPage( - options?: RouteTablesListAllOptionalParams + options?: RouteTablesListAllOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listAll(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: RouteTablesListAllResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listAll(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listAllNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -194,10 +219,12 @@ export class RouteTablesImpl implements RouteTables { { resourceGroupName, routeTableName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -298,10 +325,12 @@ export class RouteTablesImpl implements RouteTables { { resourceGroupName, routeTableName, parameters, options }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -388,10 +417,12 @@ export class RouteTablesImpl implements RouteTables { { resourceGroupName, routeTableName, parameters, options }, updateTagsOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -609,7 +640,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.RouteTableListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, @@ -627,7 +657,6 @@ const listAllNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.RouteTableListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/routes.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/routes.ts index 36403e8873cb..e79b93b6171e 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/routes.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/routes.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { Routes } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -18,12 +19,12 @@ import { Route, RoutesListNextOptionalParams, RoutesListOptionalParams, + RoutesListResponse, RoutesDeleteOptionalParams, RoutesGetOptionalParams, RoutesGetResponse, RoutesCreateOrUpdateOptionalParams, RoutesCreateOrUpdateResponse, - RoutesListResponse, RoutesListNextResponse } from "../models"; @@ -59,8 +60,16 @@ export class RoutesImpl implements Routes { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(resourceGroupName, routeTableName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage( + resourceGroupName, + routeTableName, + options, + settings + ); } }; } @@ -68,11 +77,18 @@ export class RoutesImpl implements Routes { private async *listPagingPage( resourceGroupName: string, routeTableName: string, - options?: RoutesListOptionalParams + options?: RoutesListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(resourceGroupName, routeTableName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: RoutesListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(resourceGroupName, routeTableName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext( resourceGroupName, @@ -81,7 +97,9 @@ export class RoutesImpl implements Routes { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -156,10 +174,12 @@ export class RoutesImpl implements Routes { { resourceGroupName, routeTableName, routeName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -273,10 +293,12 @@ export class RoutesImpl implements Routes { }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -436,7 +458,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.RouteListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/securityRules.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/securityRules.ts index 32c521c37a68..23d85167e58c 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/securityRules.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/securityRules.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { SecurityRules } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -18,12 +19,12 @@ import { SecurityRule, SecurityRulesListNextOptionalParams, SecurityRulesListOptionalParams, + SecurityRulesListResponse, SecurityRulesDeleteOptionalParams, SecurityRulesGetOptionalParams, SecurityRulesGetResponse, SecurityRulesCreateOrUpdateOptionalParams, SecurityRulesCreateOrUpdateResponse, - SecurityRulesListResponse, SecurityRulesListNextResponse } from "../models"; @@ -63,11 +64,15 @@ export class SecurityRulesImpl implements SecurityRules { [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listPagingPage( resourceGroupName, networkSecurityGroupName, - options + options, + settings ); } }; @@ -76,15 +81,22 @@ export class SecurityRulesImpl implements SecurityRules { private async *listPagingPage( resourceGroupName: string, networkSecurityGroupName: string, - options?: SecurityRulesListOptionalParams + options?: SecurityRulesListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list( - resourceGroupName, - networkSecurityGroupName, - options - ); - yield result.value || []; - let continuationToken = result.nextLink; + let result: SecurityRulesListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list( + resourceGroupName, + networkSecurityGroupName, + options + ); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext( resourceGroupName, @@ -93,7 +105,9 @@ export class SecurityRulesImpl implements SecurityRules { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -173,10 +187,12 @@ export class SecurityRulesImpl implements SecurityRules { }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -296,10 +312,12 @@ export class SecurityRulesImpl implements SecurityRules { }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -460,7 +478,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.SecurityRuleListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/subnets.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/subnets.ts index 4717cf111cf9..58f8278333a4 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/subnets.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/subnets.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { Subnets } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -18,12 +19,12 @@ import { Subnet, SubnetsListNextOptionalParams, SubnetsListOptionalParams, + SubnetsListResponse, SubnetsDeleteOptionalParams, SubnetsGetOptionalParams, SubnetsGetResponse, SubnetsCreateOrUpdateOptionalParams, SubnetsCreateOrUpdateResponse, - SubnetsListResponse, SubnetsListNextResponse } from "../models"; @@ -63,11 +64,15 @@ export class SubnetsImpl implements Subnets { [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listPagingPage( resourceGroupName, virtualNetworkName, - options + options, + settings ); } }; @@ -76,15 +81,18 @@ export class SubnetsImpl implements Subnets { private async *listPagingPage( resourceGroupName: string, virtualNetworkName: string, - options?: SubnetsListOptionalParams + options?: SubnetsListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list( - resourceGroupName, - virtualNetworkName, - options - ); - yield result.value || []; - let continuationToken = result.nextLink; + let result: SubnetsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(resourceGroupName, virtualNetworkName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext( resourceGroupName, @@ -93,7 +101,9 @@ export class SubnetsImpl implements Subnets { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -168,10 +178,12 @@ export class SubnetsImpl implements Subnets { { resourceGroupName, virtualNetworkName, subnetName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -285,10 +297,12 @@ export class SubnetsImpl implements Subnets { }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -448,7 +462,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.SubnetListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/virtualNetworkGatewayConnections.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/virtualNetworkGatewayConnections.ts index c1c2fca72391..9ff1e3e08627 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/virtualNetworkGatewayConnections.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/virtualNetworkGatewayConnections.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { VirtualNetworkGatewayConnections } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -18,6 +19,7 @@ import { VirtualNetworkGatewayConnection, VirtualNetworkGatewayConnectionsListNextOptionalParams, VirtualNetworkGatewayConnectionsListOptionalParams, + VirtualNetworkGatewayConnectionsListResponse, VirtualNetworkGatewayConnectionsCreateOrUpdateOptionalParams, VirtualNetworkGatewayConnectionsCreateOrUpdateResponse, VirtualNetworkGatewayConnectionsGetOptionalParams, @@ -31,7 +33,6 @@ import { VirtualNetworkGatewayConnectionsSetSharedKeyResponse, VirtualNetworkGatewayConnectionsGetSharedKeyOptionalParams, VirtualNetworkGatewayConnectionsGetSharedKeyResponse, - VirtualNetworkGatewayConnectionsListResponse, ConnectionResetSharedKey, VirtualNetworkGatewayConnectionsResetSharedKeyOptionalParams, VirtualNetworkGatewayConnectionsResetSharedKeyResponse, @@ -70,19 +71,29 @@ export class VirtualNetworkGatewayConnectionsImpl [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(resourceGroupName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(resourceGroupName, options, settings); } }; } private async *listPagingPage( resourceGroupName: string, - options?: VirtualNetworkGatewayConnectionsListOptionalParams + options?: VirtualNetworkGatewayConnectionsListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(resourceGroupName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: VirtualNetworkGatewayConnectionsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(resourceGroupName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext( resourceGroupName, @@ -90,7 +101,9 @@ export class VirtualNetworkGatewayConnectionsImpl options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -173,11 +186,13 @@ export class VirtualNetworkGatewayConnectionsImpl }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, lroResourceLocationConfig: "azure-async-operation" }); + await poller.poll(); + return poller; } /** @@ -275,11 +290,13 @@ export class VirtualNetworkGatewayConnectionsImpl { resourceGroupName, virtualNetworkGatewayConnectionName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, lroResourceLocationConfig: "location" }); + await poller.poll(); + return poller; } /** @@ -368,10 +385,12 @@ export class VirtualNetworkGatewayConnectionsImpl }, updateTagsOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -466,11 +485,13 @@ export class VirtualNetworkGatewayConnectionsImpl }, setSharedKeyOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, lroResourceLocationConfig: "azure-async-operation" }); + await poller.poll(); + return poller; } /** @@ -605,11 +626,13 @@ export class VirtualNetworkGatewayConnectionsImpl }, resetSharedKeyOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, lroResourceLocationConfig: "location" }); + await poller.poll(); + return poller; } /** @@ -856,7 +879,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.VirtualNetworkGatewayConnectionListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/virtualNetworkGateways.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/virtualNetworkGateways.ts index 565feb8434b6..c50dd85775df 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/virtualNetworkGateways.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/virtualNetworkGateways.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { VirtualNetworkGateways } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -18,9 +19,11 @@ import { VirtualNetworkGateway, VirtualNetworkGatewaysListNextOptionalParams, VirtualNetworkGatewaysListOptionalParams, + VirtualNetworkGatewaysListResponse, VirtualNetworkGatewayConnectionListEntity, VirtualNetworkGatewaysListConnectionsNextOptionalParams, VirtualNetworkGatewaysListConnectionsOptionalParams, + VirtualNetworkGatewaysListConnectionsResponse, VirtualNetworkGatewaysCreateOrUpdateOptionalParams, VirtualNetworkGatewaysCreateOrUpdateResponse, VirtualNetworkGatewaysGetOptionalParams, @@ -29,8 +32,6 @@ import { TagsObject, VirtualNetworkGatewaysUpdateTagsOptionalParams, VirtualNetworkGatewaysUpdateTagsResponse, - VirtualNetworkGatewaysListResponse, - VirtualNetworkGatewaysListConnectionsResponse, VirtualNetworkGatewaysResetOptionalParams, VirtualNetworkGatewaysResetResponse, VirtualNetworkGatewaysResetVpnClientSharedKeyOptionalParams, @@ -91,19 +92,29 @@ export class VirtualNetworkGatewaysImpl implements VirtualNetworkGateways { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(resourceGroupName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(resourceGroupName, options, settings); } }; } private async *listPagingPage( resourceGroupName: string, - options?: VirtualNetworkGatewaysListOptionalParams + options?: VirtualNetworkGatewaysListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(resourceGroupName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: VirtualNetworkGatewaysListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(resourceGroupName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext( resourceGroupName, @@ -111,7 +122,9 @@ export class VirtualNetworkGatewaysImpl implements VirtualNetworkGateways { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -147,11 +160,15 @@ export class VirtualNetworkGatewaysImpl implements VirtualNetworkGateways { [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listConnectionsPagingPage( resourceGroupName, virtualNetworkGatewayName, - options + options, + settings ); } }; @@ -160,15 +177,22 @@ export class VirtualNetworkGatewaysImpl implements VirtualNetworkGateways { private async *listConnectionsPagingPage( resourceGroupName: string, virtualNetworkGatewayName: string, - options?: VirtualNetworkGatewaysListConnectionsOptionalParams + options?: VirtualNetworkGatewaysListConnectionsOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listConnections( - resourceGroupName, - virtualNetworkGatewayName, - options - ); - yield result.value || []; - let continuationToken = result.nextLink; + let result: VirtualNetworkGatewaysListConnectionsResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listConnections( + resourceGroupName, + virtualNetworkGatewayName, + options + ); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listConnectionsNext( resourceGroupName, @@ -177,7 +201,9 @@ export class VirtualNetworkGatewaysImpl implements VirtualNetworkGateways { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -257,11 +283,13 @@ export class VirtualNetworkGatewaysImpl implements VirtualNetworkGateways { { resourceGroupName, virtualNetworkGatewayName, parameters, options }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, lroResourceLocationConfig: "azure-async-operation" }); + await poller.poll(); + return poller; } /** @@ -358,11 +386,13 @@ export class VirtualNetworkGatewaysImpl implements VirtualNetworkGateways { { resourceGroupName, virtualNetworkGatewayName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, lroResourceLocationConfig: "location" }); + await poller.poll(); + return poller; } /** @@ -446,10 +476,12 @@ export class VirtualNetworkGatewaysImpl implements VirtualNetworkGateways { { resourceGroupName, virtualNetworkGatewayName, parameters, options }, updateTagsOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -566,11 +598,13 @@ export class VirtualNetworkGatewaysImpl implements VirtualNetworkGateways { { resourceGroupName, virtualNetworkGatewayName, options }, resetOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, lroResourceLocationConfig: "location" }); + await poller.poll(); + return poller; } /** @@ -647,11 +681,13 @@ export class VirtualNetworkGatewaysImpl implements VirtualNetworkGateways { { resourceGroupName, virtualNetworkGatewayName, options }, resetVpnClientSharedKeyOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, lroResourceLocationConfig: "location" }); + await poller.poll(); + return poller; } /** @@ -739,11 +775,13 @@ export class VirtualNetworkGatewaysImpl implements VirtualNetworkGateways { { resourceGroupName, virtualNetworkGatewayName, parameters, options }, generatevpnclientpackageOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, lroResourceLocationConfig: "location" }); + await poller.poll(); + return poller; } /** @@ -834,11 +872,13 @@ export class VirtualNetworkGatewaysImpl implements VirtualNetworkGateways { { resourceGroupName, virtualNetworkGatewayName, parameters, options }, generateVpnProfileOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, lroResourceLocationConfig: "location" }); + await poller.poll(); + return poller; } /** @@ -926,11 +966,13 @@ export class VirtualNetworkGatewaysImpl implements VirtualNetworkGateways { { resourceGroupName, virtualNetworkGatewayName, options }, getVpnProfilePackageUrlOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, lroResourceLocationConfig: "location" }); + await poller.poll(); + return poller; } /** @@ -1013,11 +1055,13 @@ export class VirtualNetworkGatewaysImpl implements VirtualNetworkGateways { { resourceGroupName, virtualNetworkGatewayName, options }, getBgpPeerStatusOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, lroResourceLocationConfig: "location" }); + await poller.poll(); + return poller; } /** @@ -1117,11 +1161,13 @@ export class VirtualNetworkGatewaysImpl implements VirtualNetworkGateways { { resourceGroupName, virtualNetworkGatewayName, options }, getLearnedRoutesOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, lroResourceLocationConfig: "location" }); + await poller.poll(); + return poller; } /** @@ -1207,11 +1253,13 @@ export class VirtualNetworkGatewaysImpl implements VirtualNetworkGateways { { resourceGroupName, virtualNetworkGatewayName, peer, options }, getAdvertisedRoutesOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, lroResourceLocationConfig: "location" }); + await poller.poll(); + return poller; } /** @@ -1308,11 +1356,13 @@ export class VirtualNetworkGatewaysImpl implements VirtualNetworkGateways { }, setVpnclientIpsecParametersOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, lroResourceLocationConfig: "location" }); + await poller.poll(); + return poller; } /** @@ -1403,11 +1453,13 @@ export class VirtualNetworkGatewaysImpl implements VirtualNetworkGateways { { resourceGroupName, virtualNetworkGatewayName, options }, getVpnclientIpsecParametersOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, lroResourceLocationConfig: "location" }); + await poller.poll(); + return poller; } /** @@ -1945,7 +1997,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.VirtualNetworkGatewayListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, @@ -1963,7 +2014,6 @@ const listConnectionsNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.VirtualNetworkGatewayListConnectionsResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/virtualNetworkPeerings.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/virtualNetworkPeerings.ts index dda7f9602e6c..70092ea00abe 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/virtualNetworkPeerings.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/virtualNetworkPeerings.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { VirtualNetworkPeerings } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -18,12 +19,12 @@ import { VirtualNetworkPeering, VirtualNetworkPeeringsListNextOptionalParams, VirtualNetworkPeeringsListOptionalParams, + VirtualNetworkPeeringsListResponse, VirtualNetworkPeeringsDeleteOptionalParams, VirtualNetworkPeeringsGetOptionalParams, VirtualNetworkPeeringsGetResponse, VirtualNetworkPeeringsCreateOrUpdateOptionalParams, VirtualNetworkPeeringsCreateOrUpdateResponse, - VirtualNetworkPeeringsListResponse, VirtualNetworkPeeringsListNextResponse } from "../models"; @@ -63,11 +64,15 @@ export class VirtualNetworkPeeringsImpl implements VirtualNetworkPeerings { [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listPagingPage( resourceGroupName, virtualNetworkName, - options + options, + settings ); } }; @@ -76,15 +81,18 @@ export class VirtualNetworkPeeringsImpl implements VirtualNetworkPeerings { private async *listPagingPage( resourceGroupName: string, virtualNetworkName: string, - options?: VirtualNetworkPeeringsListOptionalParams + options?: VirtualNetworkPeeringsListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list( - resourceGroupName, - virtualNetworkName, - options - ); - yield result.value || []; - let continuationToken = result.nextLink; + let result: VirtualNetworkPeeringsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(resourceGroupName, virtualNetworkName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext( resourceGroupName, @@ -93,7 +101,9 @@ export class VirtualNetworkPeeringsImpl implements VirtualNetworkPeerings { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -173,10 +183,12 @@ export class VirtualNetworkPeeringsImpl implements VirtualNetworkPeerings { }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -296,10 +308,12 @@ export class VirtualNetworkPeeringsImpl implements VirtualNetworkPeerings { }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -460,7 +474,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.VirtualNetworkPeeringListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/virtualNetworks.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/virtualNetworks.ts index 765df522878b..c802c6a27a05 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/virtualNetworks.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/operations/virtualNetworks.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { VirtualNetworks } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -18,11 +19,14 @@ import { VirtualNetwork, VirtualNetworksListAllNextOptionalParams, VirtualNetworksListAllOptionalParams, + VirtualNetworksListAllResponse, VirtualNetworksListNextOptionalParams, VirtualNetworksListOptionalParams, + VirtualNetworksListResponse, VirtualNetworkUsage, VirtualNetworksListUsageNextOptionalParams, VirtualNetworksListUsageOptionalParams, + VirtualNetworksListUsageResponse, VirtualNetworksDeleteOptionalParams, VirtualNetworksGetOptionalParams, VirtualNetworksGetResponse, @@ -31,11 +35,8 @@ import { TagsObject, VirtualNetworksUpdateTagsOptionalParams, VirtualNetworksUpdateTagsResponse, - VirtualNetworksListAllResponse, - VirtualNetworksListResponse, VirtualNetworksCheckIPAddressAvailabilityOptionalParams, VirtualNetworksCheckIPAddressAvailabilityResponse, - VirtualNetworksListUsageResponse, VirtualNetworksListAllNextResponse, VirtualNetworksListNextResponse, VirtualNetworksListUsageNextResponse @@ -69,22 +70,34 @@ export class VirtualNetworksImpl implements VirtualNetworks { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listAllPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listAllPagingPage(options, settings); } }; } private async *listAllPagingPage( - options?: VirtualNetworksListAllOptionalParams + options?: VirtualNetworksListAllOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listAll(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: VirtualNetworksListAllResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listAll(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listAllNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -113,19 +126,29 @@ export class VirtualNetworksImpl implements VirtualNetworks { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(resourceGroupName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(resourceGroupName, options, settings); } }; } private async *listPagingPage( resourceGroupName: string, - options?: VirtualNetworksListOptionalParams + options?: VirtualNetworksListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(resourceGroupName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: VirtualNetworksListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(resourceGroupName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext( resourceGroupName, @@ -133,7 +156,9 @@ export class VirtualNetworksImpl implements VirtualNetworks { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -169,11 +194,15 @@ export class VirtualNetworksImpl implements VirtualNetworks { [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listUsagePagingPage( resourceGroupName, virtualNetworkName, - options + options, + settings ); } }; @@ -182,15 +211,22 @@ export class VirtualNetworksImpl implements VirtualNetworks { private async *listUsagePagingPage( resourceGroupName: string, virtualNetworkName: string, - options?: VirtualNetworksListUsageOptionalParams + options?: VirtualNetworksListUsageOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listUsage( - resourceGroupName, - virtualNetworkName, - options - ); - yield result.value || []; - let continuationToken = result.nextLink; + let result: VirtualNetworksListUsageResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listUsage( + resourceGroupName, + virtualNetworkName, + options + ); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listUsageNext( resourceGroupName, @@ -199,7 +235,9 @@ export class VirtualNetworksImpl implements VirtualNetworks { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -272,10 +310,12 @@ export class VirtualNetworksImpl implements VirtualNetworks { { resourceGroupName, virtualNetworkName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -376,10 +416,12 @@ export class VirtualNetworksImpl implements VirtualNetworks { { resourceGroupName, virtualNetworkName, parameters, options }, createOrUpdateOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -466,10 +508,12 @@ export class VirtualNetworksImpl implements VirtualNetworks { { resourceGroupName, virtualNetworkName, parameters, options }, updateTagsOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -780,7 +824,6 @@ const listAllNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.VirtualNetworkListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, @@ -797,7 +840,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.VirtualNetworkListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, @@ -815,7 +857,6 @@ const listUsageNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.VirtualNetworkListUsageResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.resourceGroupName, diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/src/pagingHelper.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/pagingHelper.ts new file mode 100644 index 000000000000..269a2b9814b5 --- /dev/null +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/src/pagingHelper.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export interface PageInfo { + continuationToken?: string; +} + +const pageMap = new WeakMap(); + +/** + * Given the last `.value` produced by the `byPage` iterator, + * returns a continuation token that can be used to begin paging from + * that point later. + * @param page An object from accessing `value` on the IteratorResult from a `byPage` iterator. + * @returns The continuation token that can be passed into byPage() during future calls. + */ +export function getContinuationToken(page: unknown): string | undefined { + if (typeof page !== "object" || page === null) { + return undefined; + } + return pageMap.get(page)?.continuationToken; +} + +export function setContinuationToken( + page: unknown, + continuationToken: string | undefined +): void { + if (typeof page !== "object" || page === null || !continuationToken) { + return; + } + const pageInfo = pageMap.get(page) ?? {}; + pageInfo.continuationToken = continuationToken; + pageMap.set(page, pageInfo); +} diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/test/sampleTest.ts b/sdk/network/arm-network-profile-2020-09-01-hybrid/test/sampleTest.ts index 7ed89b043e1b..25aeb3ebcc36 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/test/sampleTest.ts +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/test/sampleTest.ts @@ -7,35 +7,30 @@ */ import { - env, - record, - RecorderEnvironmentSetup, - Recorder + Recorder, + RecorderStartOptions, + env } from "@azure-tools/test-recorder"; -import * as assert from "assert"; +import { assert } from "chai"; +import { Context } from "mocha"; -const recorderEnvSetup: RecorderEnvironmentSetup = { - replaceableVariables: { - AZURE_CLIENT_ID: "azure_client_id", - AZURE_CLIENT_SECRET: "azure_client_secret", - AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", - SUBSCRIPTION_ID: "azure_subscription_id" - }, - customizationsOnRecordings: [ - (recording: any): any => - recording.replace( - /"access_token":"[^"]*"/g, - `"access_token":"access_token"` - ) - ], - queryParametersToSkip: [] +const replaceableVariables: Record = { + AZURE_CLIENT_ID: "azure_client_id", + AZURE_CLIENT_SECRET: "azure_client_secret", + AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", + SUBSCRIPTION_ID: "azure_subscription_id" +}; + +const recorderOptions: RecorderStartOptions = { + envSetupForPlayback: replaceableVariables }; describe("My test", () => { let recorder: Recorder; - beforeEach(async function() { - recorder = record(this, recorderEnvSetup); + beforeEach(async function(this: Context) { + recorder = new Recorder(this.currentTest); + await recorder.start(recorderOptions); }); afterEach(async function() { diff --git a/sdk/network/arm-network-profile-2020-09-01-hybrid/tsconfig.json b/sdk/network/arm-network-profile-2020-09-01-hybrid/tsconfig.json index 3e6ae96443f3..3d8f3c87e2f4 100644 --- a/sdk/network/arm-network-profile-2020-09-01-hybrid/tsconfig.json +++ b/sdk/network/arm-network-profile-2020-09-01-hybrid/tsconfig.json @@ -15,11 +15,17 @@ ], "declaration": true, "outDir": "./dist-esm", - "importHelpers": true + "importHelpers": true, + "paths": { + "@azure/arm-network-profile-2020-09-01-hybrid": [ + "./src/index" + ] + } }, "include": [ "./src/**/*.ts", - "./test/**/*.ts" + "./test/**/*.ts", + "samples-dev/**/*.ts" ], "exclude": [ "node_modules" diff --git a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/CHANGELOG.md b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/CHANGELOG.md index a9c89aef0af0..961c22d2e825 100644 --- a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/CHANGELOG.md +++ b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/CHANGELOG.md @@ -1,15 +1,14 @@ # Release History - -## 2.0.1 (Unreleased) - -### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes - + +## 2.1.0 (2022-12-22) + +**Features** + + - Interface PolicyAssignmentsListForResourceGroupNextOptionalParams no longer has parameter filter + - Interface PolicyAssignmentsListForResourceNextOptionalParams no longer has parameter filter + - Interface PolicyAssignmentsListNextOptionalParams no longer has parameter filter + + ## 2.0.0 (2022-03-08) The package of @azure/arm-policy-profile-2020-09-01-hybrid is using our next generation design principles since version 2.0.0, which contains breaking changes. diff --git a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/_meta.json b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/_meta.json index b1e2d4a349cc..511d5d05a3df 100644 --- a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/_meta.json +++ b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/_meta.json @@ -1,7 +1,8 @@ { "commit": "989a7d0e47a71a77d9a8e56f2a3eee0d366b6909", "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:\\mydev\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\resources\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-beta.16 --tag=package-policy-2016-12 --profile-content=profile-hybrid-2020-09-01", + "autorest_command": "autorest --version=3.9.3 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=F:\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\resources\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-rc.5.20221215.1 --generate-sample=true --profile-content=profile-hybrid-2020-09-01 --tag=package-policy-2016-12", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "use": "@autorest/typescript@6.0.0-beta.16" + "release_tool": "@azure-tools/js-sdk-release-tools@2.5.4", + "use": "@autorest/typescript@6.0.0-rc.5.20221215.1" } \ No newline at end of file diff --git a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/package.json b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/package.json index 1ec6e17e2030..42103e5358a5 100644 --- a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/package.json +++ b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/package.json @@ -3,15 +3,15 @@ "sdk-type": "mgmt", "author": "Microsoft Corporation", "description": "A generated SDK for PolicyClient.", - "version": "2.0.1", + "version": "2.1.0", "engines": { "node": ">=14.0.0" }, "dependencies": { "@azure/core-paging": "^1.2.0", - "@azure/core-client": "^1.0.0", + "@azure/core-client": "^1.6.1", "@azure/core-auth": "^1.3.0", - "@azure/core-rest-pipeline": "^1.1.0", + "@azure/core-rest-pipeline": "^1.8.0", "tslib": "^2.2.0" }, "keywords": [ @@ -34,15 +34,20 @@ "mkdirp": "^1.0.4", "rollup": "^2.66.1", "rollup-plugin-sourcemaps": "^0.6.3", - "typescript": "~4.2.0", + "typescript": "~4.8.0", "uglify-js": "^3.4.9", "rimraf": "^3.0.0", + "dotenv": "^8.2.0", "@azure/identity": "^2.0.1", - "@azure-tools/test-recorder": "^1.0.0", + "@azure-tools/test-recorder": "^2.0.0", + "@azure-tools/test-credential": "^1.0.0", "mocha": "^7.1.1", - "cross-env": "^7.0.2" + "@types/chai": "^4.2.8", + "chai": "^4.2.0", + "cross-env": "^7.0.2", + "@types/node": "^14.0.0", + "@azure/dev-tool": "^1.0.0" }, - "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/policy/arm-policy-profile-2020-09-01-hybrid", "repository": { "type": "git", "url": "https://github.com/Azure/azure-sdk-for-js.git" @@ -91,9 +96,8 @@ "unit-test:node": "cross-env TEST_MODE=playback npm run integration-test:node", "unit-test:browser": "echo skipped", "integration-test": "npm run integration-test:node && npm run integration-test:browser", - "integration-test:node": "mocha -r esm --require ts-node/register --timeout 1200000 --full-trace test/*.ts --reporter ../../../common/tools/mocha-multi-reporter.js", - "integration-test:browser": "echo skipped", - "docs": "echo skipped" + "integration-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 'test/*.ts'", + "integration-test:browser": "echo skipped" }, "sideEffects": false, "//metadata": { @@ -104,5 +108,6 @@ } ] }, - "autoPublish": true + "autoPublish": true, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/policy/arm-policy-profile-2020-09-01-hybrid" } diff --git a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/recordings/node/my_test/recording_sample_test.json b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/recordings/node/my_test/recording_sample_test.json new file mode 100644 index 000000000000..f721723386d8 --- /dev/null +++ b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/recordings/node/my_test/recording_sample_test.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} diff --git a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/review/arm-policy-profile-2020-09-01-hybrid.api.md b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/review/arm-policy-profile-2020-09-01-hybrid.api.md index 9a88a884e511..d349dbf8d678 100644 --- a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/review/arm-policy-profile-2020-09-01-hybrid.api.md +++ b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/review/arm-policy-profile-2020-09-01-hybrid.api.md @@ -8,23 +8,20 @@ import * as coreAuth from '@azure/core-auth'; import * as coreClient from '@azure/core-client'; import { PagedAsyncIterableIterator } from '@azure/core-paging'; +// @public +export function getContinuationToken(page: unknown): string | undefined; + // @public export enum KnownPolicyMode { - // (undocumented) All = "All", - // (undocumented) Indexed = "Indexed", - // (undocumented) NotSpecified = "NotSpecified" } // @public export enum KnownPolicyType { - // (undocumented) BuiltIn = "BuiltIn", - // (undocumented) Custom = "Custom", - // (undocumented) NotSpecified = "NotSpecified" } @@ -103,7 +100,6 @@ export type PolicyAssignmentsGetResponse = PolicyAssignment; // @public export interface PolicyAssignmentsListForResourceGroupNextOptionalParams extends coreClient.OperationOptions { - filter?: string; } // @public @@ -119,7 +115,6 @@ export type PolicyAssignmentsListForResourceGroupResponse = PolicyAssignmentList // @public export interface PolicyAssignmentsListForResourceNextOptionalParams extends coreClient.OperationOptions { - filter?: string; } // @public @@ -135,7 +130,6 @@ export type PolicyAssignmentsListForResourceResponse = PolicyAssignmentListResul // @public export interface PolicyAssignmentsListNextOptionalParams extends coreClient.OperationOptions { - filter?: string; } // @public diff --git a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/sample.env b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/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-profile-2020-09-01-hybrid/src/index.ts b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/index.ts index 14d3fdaf1092..c5035f4f210c 100644 --- a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/index.ts +++ b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/index.ts @@ -7,6 +7,7 @@ */ /// +export { getContinuationToken } from "./pagingHelper"; export * from "./models"; export { PolicyClient } from "./policyClient"; export * from "./operationsInterfaces"; diff --git a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/models/index.ts b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/models/index.ts index 649e58d09671..bc6c4a95ee74 100644 --- a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/models/index.ts +++ b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/models/index.ts @@ -77,8 +77,11 @@ export interface PolicyAssignmentListResult { /** Known values of {@link PolicyType} that the service accepts. */ export enum KnownPolicyType { + /** NotSpecified */ NotSpecified = "NotSpecified", + /** BuiltIn */ BuiltIn = "BuiltIn", + /** Custom */ Custom = "Custom" } @@ -95,8 +98,11 @@ export type PolicyType = string; /** Known values of {@link PolicyMode} that the service accepts. */ export enum KnownPolicyMode { + /** NotSpecified */ NotSpecified = "NotSpecified", + /** Indexed */ Indexed = "Indexed", + /** All */ All = "All" } @@ -270,30 +276,21 @@ export type PolicyAssignmentsGetByIdResponse = PolicyAssignment; /** Optional parameters. */ export interface PolicyAssignmentsListForResourceGroupNextOptionalParams - extends coreClient.OperationOptions { - /** The filter to apply on the operation. */ - filter?: string; -} + extends coreClient.OperationOptions {} /** Contains response data for the listForResourceGroupNext operation. */ export type PolicyAssignmentsListForResourceGroupNextResponse = PolicyAssignmentListResult; /** Optional parameters. */ export interface PolicyAssignmentsListForResourceNextOptionalParams - extends coreClient.OperationOptions { - /** The filter to apply on the operation. */ - filter?: string; -} + extends coreClient.OperationOptions {} /** Contains response data for the listForResourceNext operation. */ export type PolicyAssignmentsListForResourceNextResponse = PolicyAssignmentListResult; /** Optional parameters. */ export interface PolicyAssignmentsListNextOptionalParams - extends coreClient.OperationOptions { - /** The filter to apply on the operation. */ - filter?: string; -} + extends coreClient.OperationOptions {} /** Contains response data for the listNext operation. */ export type PolicyAssignmentsListNextResponse = PolicyAssignmentListResult; diff --git a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/operations/policyAssignments.ts b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/operations/policyAssignments.ts index 2b2f98fbe5e8..5dadf9170569 100644 --- a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/operations/policyAssignments.ts +++ b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/operations/policyAssignments.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { PolicyAssignments } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -16,19 +17,19 @@ import { PolicyAssignment, PolicyAssignmentsListForResourceGroupNextOptionalParams, PolicyAssignmentsListForResourceGroupOptionalParams, + PolicyAssignmentsListForResourceGroupResponse, PolicyAssignmentsListForResourceNextOptionalParams, PolicyAssignmentsListForResourceOptionalParams, + PolicyAssignmentsListForResourceResponse, PolicyAssignmentsListNextOptionalParams, PolicyAssignmentsListOptionalParams, + PolicyAssignmentsListResponse, PolicyAssignmentsDeleteOptionalParams, PolicyAssignmentsDeleteResponse, PolicyAssignmentsCreateOptionalParams, PolicyAssignmentsCreateResponse, PolicyAssignmentsGetOptionalParams, PolicyAssignmentsGetResponse, - PolicyAssignmentsListForResourceGroupResponse, - PolicyAssignmentsListForResourceResponse, - PolicyAssignmentsListResponse, PolicyAssignmentsDeleteByIdOptionalParams, PolicyAssignmentsDeleteByIdResponse, PolicyAssignmentsCreateByIdOptionalParams, @@ -70,19 +71,33 @@ export class PolicyAssignmentsImpl implements PolicyAssignments { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listForResourceGroupPagingPage(resourceGroupName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listForResourceGroupPagingPage( + resourceGroupName, + options, + settings + ); } }; } private async *listForResourceGroupPagingPage( resourceGroupName: string, - options?: PolicyAssignmentsListForResourceGroupOptionalParams + options?: PolicyAssignmentsListForResourceGroupOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listForResourceGroup(resourceGroupName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: PolicyAssignmentsListForResourceGroupResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listForResourceGroup(resourceGroupName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listForResourceGroupNext( resourceGroupName, @@ -90,7 +105,9 @@ export class PolicyAssignmentsImpl implements PolicyAssignments { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -139,14 +156,18 @@ export class PolicyAssignmentsImpl implements PolicyAssignments { [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listForResourcePagingPage( resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, - options + options, + settings ); } }; @@ -158,18 +179,25 @@ export class PolicyAssignmentsImpl implements PolicyAssignments { parentResourcePath: string, resourceType: string, resourceName: string, - options?: PolicyAssignmentsListForResourceOptionalParams + options?: PolicyAssignmentsListForResourceOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listForResource( - resourceGroupName, - resourceProviderNamespace, - parentResourcePath, - resourceType, - resourceName, - options - ); - yield result.value || []; - let continuationToken = result.nextLink; + let result: PolicyAssignmentsListForResourceResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listForResource( + resourceGroupName, + resourceProviderNamespace, + parentResourcePath, + resourceType, + resourceName, + options + ); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listForResourceNext( resourceGroupName, @@ -181,7 +209,9 @@ export class PolicyAssignmentsImpl implements PolicyAssignments { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -220,22 +250,34 @@ export class PolicyAssignmentsImpl implements PolicyAssignments { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); } }; } private async *listPagingPage( - options?: PolicyAssignmentsListOptionalParams + options?: PolicyAssignmentsListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: PolicyAssignmentsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -649,7 +691,6 @@ const listForResourceGroupNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.PolicyAssignmentListResult } }, - queryParameters: [Parameters.apiVersion, Parameters.filter], urlParameters: [ Parameters.$host, Parameters.subscriptionId, @@ -667,7 +708,6 @@ const listForResourceNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.PolicyAssignmentListResult } }, - queryParameters: [Parameters.apiVersion, Parameters.filter1], urlParameters: [ Parameters.$host, Parameters.subscriptionId, @@ -689,7 +729,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.PolicyAssignmentListResult } }, - queryParameters: [Parameters.apiVersion, Parameters.filter1], urlParameters: [ Parameters.$host, Parameters.subscriptionId, diff --git a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/operations/policyDefinitions.ts b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/operations/policyDefinitions.ts index 199e9b61a5e7..161d00769419 100644 --- a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/operations/policyDefinitions.ts +++ b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/operations/policyDefinitions.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { PolicyDefinitions } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -16,10 +17,13 @@ import { PolicyDefinition, PolicyDefinitionsListNextOptionalParams, PolicyDefinitionsListOptionalParams, + PolicyDefinitionsListResponse, PolicyDefinitionsListBuiltInNextOptionalParams, PolicyDefinitionsListBuiltInOptionalParams, + PolicyDefinitionsListBuiltInResponse, PolicyDefinitionsListByManagementGroupNextOptionalParams, PolicyDefinitionsListByManagementGroupOptionalParams, + PolicyDefinitionsListByManagementGroupResponse, PolicyDefinitionsCreateOrUpdateOptionalParams, PolicyDefinitionsCreateOrUpdateResponse, PolicyDefinitionsDeleteOptionalParams, @@ -32,9 +36,6 @@ import { PolicyDefinitionsDeleteAtManagementGroupOptionalParams, PolicyDefinitionsGetAtManagementGroupOptionalParams, PolicyDefinitionsGetAtManagementGroupResponse, - PolicyDefinitionsListResponse, - PolicyDefinitionsListBuiltInResponse, - PolicyDefinitionsListByManagementGroupResponse, PolicyDefinitionsListNextResponse, PolicyDefinitionsListBuiltInNextResponse, PolicyDefinitionsListByManagementGroupNextResponse @@ -68,22 +69,34 @@ export class PolicyDefinitionsImpl implements PolicyDefinitions { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); } }; } private async *listPagingPage( - options?: PolicyDefinitionsListOptionalParams + options?: PolicyDefinitionsListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: PolicyDefinitionsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -110,22 +123,34 @@ export class PolicyDefinitionsImpl implements PolicyDefinitions { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listBuiltInPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listBuiltInPagingPage(options, settings); } }; } private async *listBuiltInPagingPage( - options?: PolicyDefinitionsListBuiltInOptionalParams + options?: PolicyDefinitionsListBuiltInOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listBuiltIn(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: PolicyDefinitionsListBuiltInResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listBuiltIn(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listBuiltInNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -157,19 +182,33 @@ export class PolicyDefinitionsImpl implements PolicyDefinitions { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listByManagementGroupPagingPage(managementGroupId, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listByManagementGroupPagingPage( + managementGroupId, + options, + settings + ); } }; } private async *listByManagementGroupPagingPage( managementGroupId: string, - options?: PolicyDefinitionsListByManagementGroupOptionalParams + options?: PolicyDefinitionsListByManagementGroupOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listByManagementGroup(managementGroupId, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: PolicyDefinitionsListByManagementGroupResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listByManagementGroup(managementGroupId, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listByManagementGroupNext( managementGroupId, @@ -177,7 +216,9 @@ export class PolicyDefinitionsImpl implements PolicyDefinitions { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -561,7 +602,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.PolicyDefinitionListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, @@ -578,7 +618,6 @@ const listBuiltInNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.PolicyDefinitionListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.$host, Parameters.nextLink], headerParameters: [Parameters.accept], serializer @@ -591,7 +630,6 @@ const listByManagementGroupNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.PolicyDefinitionListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.managementGroupId, diff --git a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/pagingHelper.ts b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/pagingHelper.ts new file mode 100644 index 000000000000..269a2b9814b5 --- /dev/null +++ b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/pagingHelper.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export interface PageInfo { + continuationToken?: string; +} + +const pageMap = new WeakMap(); + +/** + * Given the last `.value` produced by the `byPage` iterator, + * returns a continuation token that can be used to begin paging from + * that point later. + * @param page An object from accessing `value` on the IteratorResult from a `byPage` iterator. + * @returns The continuation token that can be passed into byPage() during future calls. + */ +export function getContinuationToken(page: unknown): string | undefined { + if (typeof page !== "object" || page === null) { + return undefined; + } + return pageMap.get(page)?.continuationToken; +} + +export function setContinuationToken( + page: unknown, + continuationToken: string | undefined +): void { + if (typeof page !== "object" || page === null || !continuationToken) { + return; + } + const pageInfo = pageMap.get(page) ?? {}; + pageInfo.continuationToken = continuationToken; + pageMap.set(page, pageInfo); +} diff --git a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/policyClient.ts b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/policyClient.ts index 32115f4971d4..e02ab5cea9e4 100644 --- a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/policyClient.ts +++ b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/src/policyClient.ts @@ -7,6 +7,12 @@ */ import * as coreClient from "@azure/core-client"; +import * as coreRestPipeline from "@azure/core-rest-pipeline"; +import { + PipelineRequest, + PipelineResponse, + SendRequest +} from "@azure/core-rest-pipeline"; import * as coreAuth from "@azure/core-auth"; import { PolicyDefinitionsImpl, PolicyAssignmentsImpl } from "./operations"; import { PolicyDefinitions, PolicyAssignments } from "./operationsInterfaces"; @@ -44,24 +50,54 @@ export class PolicyClient extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-policy-profile-2020-09-01-hybrid/2.0.1`; + const packageDetails = `azsdk-js-arm-policy-profile-2020-09-01-hybrid/2.1.0`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` : `${packageDetails}`; - if (!options.credentialScopes) { - options.credentialScopes = ["https://management.azure.com/.default"]; - } const optionsWithDefaults = { ...defaults, ...options, userAgentOptions: { userAgentPrefix }, - baseUri: options.endpoint || "https://management.azure.com" + endpoint: + options.endpoint ?? options.baseUri ?? "https://management.azure.com" }; super(optionsWithDefaults); + + let bearerTokenAuthenticationPolicyFound: boolean = false; + if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { + const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies(); + bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( + (pipelinePolicy) => + pipelinePolicy.name === + coreRestPipeline.bearerTokenAuthenticationPolicyName + ); + } + if ( + !options || + !options.pipeline || + options.pipeline.getOrderedPolicies().length == 0 || + !bearerTokenAuthenticationPolicyFound + ) { + this.pipeline.removePolicy({ + name: coreRestPipeline.bearerTokenAuthenticationPolicyName + }); + this.pipeline.addPolicy( + coreRestPipeline.bearerTokenAuthenticationPolicy({ + credential: credentials, + scopes: + optionsWithDefaults.credentialScopes ?? + `${optionsWithDefaults.endpoint}/.default`, + challengeCallbacks: { + authorizeRequestOnChallenge: + coreClient.authorizeRequestOnClaimChallenge + } + }) + ); + } // Parameter assignments this.subscriptionId = subscriptionId; @@ -70,6 +106,35 @@ export class PolicyClient extends coreClient.ServiceClient { this.apiVersion = options.apiVersion || "2016-12-01"; this.policyDefinitions = new PolicyDefinitionsImpl(this); this.policyAssignments = new PolicyAssignmentsImpl(this); + this.addCustomApiVersionPolicy(options.apiVersion); + } + + /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */ + private addCustomApiVersionPolicy(apiVersion?: string) { + if (!apiVersion) { + return; + } + const apiVersionPolicy = { + name: "CustomApiVersionPolicy", + async sendRequest( + request: PipelineRequest, + next: SendRequest + ): Promise { + const param = request.url.split("?"); + if (param.length > 1) { + const newParams = param[1].split("&").map((item) => { + if (item.indexOf("api-version") > -1) { + return "api-version=" + apiVersion; + } else { + return item; + } + }); + request.url = param[0] + "?" + newParams.join("&"); + } + return next(request); + } + }; + this.pipeline.addPolicy(apiVersionPolicy); } policyDefinitions: PolicyDefinitions; diff --git a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/test/sampleTest.ts b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/test/sampleTest.ts index 7ed89b043e1b..25aeb3ebcc36 100644 --- a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/test/sampleTest.ts +++ b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/test/sampleTest.ts @@ -7,35 +7,30 @@ */ import { - env, - record, - RecorderEnvironmentSetup, - Recorder + Recorder, + RecorderStartOptions, + env } from "@azure-tools/test-recorder"; -import * as assert from "assert"; +import { assert } from "chai"; +import { Context } from "mocha"; -const recorderEnvSetup: RecorderEnvironmentSetup = { - replaceableVariables: { - AZURE_CLIENT_ID: "azure_client_id", - AZURE_CLIENT_SECRET: "azure_client_secret", - AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", - SUBSCRIPTION_ID: "azure_subscription_id" - }, - customizationsOnRecordings: [ - (recording: any): any => - recording.replace( - /"access_token":"[^"]*"/g, - `"access_token":"access_token"` - ) - ], - queryParametersToSkip: [] +const replaceableVariables: Record = { + AZURE_CLIENT_ID: "azure_client_id", + AZURE_CLIENT_SECRET: "azure_client_secret", + AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", + SUBSCRIPTION_ID: "azure_subscription_id" +}; + +const recorderOptions: RecorderStartOptions = { + envSetupForPlayback: replaceableVariables }; describe("My test", () => { let recorder: Recorder; - beforeEach(async function() { - recorder = record(this, recorderEnvSetup); + beforeEach(async function(this: Context) { + recorder = new Recorder(this.currentTest); + await recorder.start(recorderOptions); }); afterEach(async function() { diff --git a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/tsconfig.json b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/tsconfig.json index 3e6ae96443f3..565c4c4caad6 100644 --- a/sdk/policy/arm-policy-profile-2020-09-01-hybrid/tsconfig.json +++ b/sdk/policy/arm-policy-profile-2020-09-01-hybrid/tsconfig.json @@ -15,11 +15,17 @@ ], "declaration": true, "outDir": "./dist-esm", - "importHelpers": true + "importHelpers": true, + "paths": { + "@azure/arm-policy-profile-2020-09-01-hybrid": [ + "./src/index" + ] + } }, "include": [ "./src/**/*.ts", - "./test/**/*.ts" + "./test/**/*.ts", + "samples-dev/**/*.ts" ], "exclude": [ "node_modules" diff --git a/sdk/postgresql/arm-postgresql-flexible/CHANGELOG.md b/sdk/postgresql/arm-postgresql-flexible/CHANGELOG.md index fb94c5803225..8fd61a44ca3c 100644 --- a/sdk/postgresql/arm-postgresql-flexible/CHANGELOG.md +++ b/sdk/postgresql/arm-postgresql-flexible/CHANGELOG.md @@ -1,15 +1,18 @@ # Release History + +## 6.1.0 (2022-12-22) + +**Features** -## 6.0.1 (Unreleased) - -### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes - + - Added Interface Configuration + - Added Interface Database + - Added Interface FirewallRule + - Added Interface ProxyResource + - Added Interface Server + - Added Interface TrackedResource + - Added function getContinuationToken + + ## 6.0.0 (2022-04-28) **Features** diff --git a/sdk/postgresql/arm-postgresql-flexible/_meta.json b/sdk/postgresql/arm-postgresql-flexible/_meta.json index b1699e8a6406..35ced31261a3 100644 --- a/sdk/postgresql/arm-postgresql-flexible/_meta.json +++ b/sdk/postgresql/arm-postgresql-flexible/_meta.json @@ -1,8 +1,8 @@ { "commit": "0cd7b3e83d5e7e21222dcc4bdde4565562da0cdf", - "readme": "specification\\postgresql\\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\\postgresql\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-alpha.19.20220408.1 --generate-sample=true", + "readme": "specification/postgresql/resource-manager/readme.md", + "autorest_command": "autorest --version=3.9.3 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=F:\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\postgresql\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-rc.5.20221215.1 --generate-sample=true --profile-content=profile-hybrid-2020-09-01 --tag=package-flexibleserver-2021-06", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "release_tool": "@azure-tools/js-sdk-release-tools@2.3.0", - "use": "@autorest/typescript@6.0.0-alpha.19.20220408.1" -} + "release_tool": "@azure-tools/js-sdk-release-tools@2.5.4", + "use": "@autorest/typescript@6.0.0-rc.5.20221215.1" +} \ No newline at end of file diff --git a/sdk/postgresql/arm-postgresql-flexible/package.json b/sdk/postgresql/arm-postgresql-flexible/package.json index ff35026f141f..a4d3e4f02495 100644 --- a/sdk/postgresql/arm-postgresql-flexible/package.json +++ b/sdk/postgresql/arm-postgresql-flexible/package.json @@ -3,7 +3,7 @@ "sdk-type": "mgmt", "author": "Microsoft Corporation", "description": "A generated SDK for PostgreSQLManagementFlexibleServerClient.", - "version": "6.0.1", + "version": "6.1.0", "engines": { "node": ">=14.0.0" }, @@ -11,7 +11,7 @@ "@azure/core-lro": "^2.2.0", "@azure/abort-controller": "^1.0.0", "@azure/core-paging": "^1.2.0", - "@azure/core-client": "^1.5.0", + "@azure/core-client": "^1.6.1", "@azure/core-auth": "^1.3.0", "@azure/core-rest-pipeline": "^1.8.0", "tslib": "^2.2.0" @@ -36,15 +36,20 @@ "mkdirp": "^1.0.4", "rollup": "^2.66.1", "rollup-plugin-sourcemaps": "^0.6.3", - "typescript": "~4.2.0", + "typescript": "~4.8.0", "uglify-js": "^3.4.9", "rimraf": "^3.0.0", + "dotenv": "^8.2.0", "@azure/identity": "^2.0.1", - "@azure-tools/test-recorder": "^1.0.0", + "@azure-tools/test-recorder": "^2.0.0", + "@azure-tools/test-credential": "^1.0.0", "mocha": "^7.1.1", - "cross-env": "^7.0.2" + "@types/chai": "^4.2.8", + "chai": "^4.2.0", + "cross-env": "^7.0.2", + "@types/node": "^14.0.0", + "@azure/dev-tool": "^1.0.0" }, - "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/postgresql/arm-postgresql-flexible", "repository": { "type": "git", "url": "https://github.com/Azure/azure-sdk-for-js.git" @@ -93,9 +98,8 @@ "unit-test:node": "cross-env TEST_MODE=playback npm run integration-test:node", "unit-test:browser": "echo skipped", "integration-test": "npm run integration-test:node && npm run integration-test:browser", - "integration-test:node": "mocha -r esm --require ts-node/register --timeout 1200000 --full-trace test/*.ts --reporter ../../../common/tools/mocha-multi-reporter.js", - "integration-test:browser": "echo skipped", - "docs": "echo skipped" + "integration-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 'test/*.ts'", + "integration-test:browser": "echo skipped" }, "sideEffects": false, "//metadata": { @@ -107,6 +111,7 @@ ] }, "autoPublish": true, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/postgresql/arm-postgresql-flexible", "//sampleConfiguration": { "productName": "", "productSlugs": [ @@ -115,4 +120,4 @@ "disableDocsMs": true, "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-postgresql-flexible?view=azure-node-preview" } -} +} \ No newline at end of file diff --git a/sdk/postgresql/arm-postgresql-flexible/recordings/node/my_test/recording_sample_test.js b/sdk/postgresql/arm-postgresql-flexible/recordings/node/my_test/recording_sample_test.js deleted file mode 100644 index 0f6ecb857acf..000000000000 --- a/sdk/postgresql/arm-postgresql-flexible/recordings/node/my_test/recording_sample_test.js +++ /dev/null @@ -1,5 +0,0 @@ -let nock = require('nock'); - -module.exports.hash = "7a6be38bb8cb644d64b4094802301751"; - -module.exports.testInfo = {"uniqueName":{},"newDate":{}} diff --git a/sdk/postgresql/arm-postgresql-flexible/recordings/node/my_test/recording_sample_test.json b/sdk/postgresql/arm-postgresql-flexible/recordings/node/my_test/recording_sample_test.json new file mode 100644 index 000000000000..f721723386d8 --- /dev/null +++ b/sdk/postgresql/arm-postgresql-flexible/recordings/node/my_test/recording_sample_test.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} diff --git a/sdk/postgresql/arm-postgresql-flexible/review/arm-postgresql-flexible.api.md b/sdk/postgresql/arm-postgresql-flexible/review/arm-postgresql-flexible.api.md index 9b01b0fb2a6a..a7f47d249dfe 100644 --- a/sdk/postgresql/arm-postgresql-flexible/review/arm-postgresql-flexible.api.md +++ b/sdk/postgresql/arm-postgresql-flexible/review/arm-postgresql-flexible.api.md @@ -52,20 +52,20 @@ export interface CloudError { } // @public -export type Configuration = ProxyResource & { - readonly systemData?: SystemData; - value?: string; - readonly description?: string; - readonly defaultValue?: string; - readonly dataType?: ConfigurationDataType; +export interface Configuration extends ProxyResource { readonly allowedValues?: string; - source?: string; + readonly dataType?: ConfigurationDataType; + readonly defaultValue?: string; + readonly description?: string; + readonly documentationLink?: string; + readonly isConfigPendingRestart?: boolean; readonly isDynamicConfig?: boolean; readonly isReadOnly?: boolean; - readonly isConfigPendingRestart?: boolean; + source?: string; + readonly systemData?: SystemData; readonly unit?: string; - readonly documentationLink?: string; -}; + value?: string; +} // @public export type ConfigurationDataType = string; @@ -135,11 +135,11 @@ export type CreateMode = string; export type CreateModeForUpdate = string; // @public -export type Database = ProxyResource & { - readonly systemData?: SystemData; +export interface Database extends ProxyResource { charset?: string; collation?: string; -}; + readonly systemData?: SystemData; +} // @public export interface DatabaseListResult { @@ -218,11 +218,11 @@ export interface ErrorResponse { export type FailoverMode = string; // @public -export type FirewallRule = ProxyResource & { - readonly systemData?: SystemData; - startIpAddress: string; +export interface FirewallRule extends ProxyResource { endIpAddress: string; -}; + startIpAddress: string; + readonly systemData?: SystemData; +} // @public export interface FirewallRuleListResult { @@ -287,6 +287,9 @@ export interface FlexibleServerEditionCapability { // @public export type GeoRedundantBackupEnum = string; +// @public +export function getContinuationToken(page: unknown): string | undefined; + // @public export interface GetPrivateDnsZoneSuffix { execute(options?: GetPrivateDnsZoneSuffixExecuteOptionalParams): Promise; @@ -322,153 +325,105 @@ export interface HyperscaleNodeEditionCapability { // @public export enum KnownConfigurationDataType { - // (undocumented) Boolean = "Boolean", - // (undocumented) Enumeration = "Enumeration", - // (undocumented) Integer = "Integer", - // (undocumented) Numeric = "Numeric" } // @public export enum KnownCreatedByType { - // (undocumented) Application = "Application", - // (undocumented) Key = "Key", - // (undocumented) ManagedIdentity = "ManagedIdentity", - // (undocumented) User = "User" } // @public export enum KnownCreateMode { - // (undocumented) Create = "Create", - // (undocumented) Default = "Default", - // (undocumented) PointInTimeRestore = "PointInTimeRestore", - // (undocumented) Update = "Update" } // @public export enum KnownCreateModeForUpdate { - // (undocumented) Default = "Default", - // (undocumented) Update = "Update" } // @public export enum KnownFailoverMode { - // (undocumented) ForcedFailover = "ForcedFailover", - // (undocumented) ForcedSwitchover = "ForcedSwitchover", - // (undocumented) PlannedFailover = "PlannedFailover", - // (undocumented) PlannedSwitchover = "PlannedSwitchover" } // @public export enum KnownGeoRedundantBackupEnum { - // (undocumented) Disabled = "Disabled", - // (undocumented) Enabled = "Enabled" } // @public export enum KnownHighAvailabilityMode { - // (undocumented) Disabled = "Disabled", - // (undocumented) ZoneRedundant = "ZoneRedundant" } // @public export enum KnownOperationOrigin { - // (undocumented) NotSpecified = "NotSpecified", - // (undocumented) System = "system", - // (undocumented) User = "user" } // @public export enum KnownReason { - // (undocumented) AlreadyExists = "AlreadyExists", - // (undocumented) Invalid = "Invalid" } // @public export enum KnownServerHAState { - // (undocumented) CreatingStandby = "CreatingStandby", - // (undocumented) FailingOver = "FailingOver", - // (undocumented) Healthy = "Healthy", - // (undocumented) NotEnabled = "NotEnabled", - // (undocumented) RemovingStandby = "RemovingStandby", - // (undocumented) ReplicatingData = "ReplicatingData" } // @public export enum KnownServerPublicNetworkAccessState { - // (undocumented) Disabled = "Disabled", - // (undocumented) Enabled = "Enabled" } // @public export enum KnownServerState { - // (undocumented) Disabled = "Disabled", - // (undocumented) Dropping = "Dropping", - // (undocumented) Ready = "Ready", - // (undocumented) Starting = "Starting", - // (undocumented) Stopped = "Stopped", - // (undocumented) Stopping = "Stopping", - // (undocumented) Updating = "Updating" } // @public export enum KnownServerVersion { - // (undocumented) Eleven = "11", - // (undocumented) Thirteen = "13", - // (undocumented) Twelve = "12" } // @public export enum KnownSkuTier { - // (undocumented) Burstable = "Burstable", - // (undocumented) GeneralPurpose = "GeneralPurpose", - // (undocumented) MemoryOptimized = "MemoryOptimized" } @@ -605,7 +560,8 @@ export interface PostgreSQLManagementFlexibleServerClientOptionalParams extends } // @public -export type ProxyResource = Resource & {}; +export interface ProxyResource extends Resource { +} // @public export type Reason = string; @@ -624,25 +580,25 @@ export interface RestartParameter { } // @public -export type Server = TrackedResource & { - sku?: Sku; - readonly systemData?: SystemData; +export interface Server extends TrackedResource { administratorLogin?: string; administratorLoginPassword?: string; - version?: ServerVersion; - readonly minorVersion?: string; - readonly state?: ServerState; - readonly fullyQualifiedDomainName?: string; - storage?: Storage_2; + availabilityZone?: string; backup?: Backup; - network?: Network; + createMode?: CreateMode; + readonly fullyQualifiedDomainName?: string; highAvailability?: HighAvailability; maintenanceWindow?: MaintenanceWindow; - sourceServerResourceId?: string; + readonly minorVersion?: string; + network?: Network; pointInTimeUTC?: Date; - availabilityZone?: string; - createMode?: CreateMode; -}; + sku?: Sku; + sourceServerResourceId?: string; + readonly state?: ServerState; + storage?: Storage_2; + readonly systemData?: SystemData; + version?: ServerVersion; +} // @public export interface ServerForUpdate { @@ -822,12 +778,12 @@ export interface SystemData { } // @public -export type TrackedResource = Resource & { +export interface TrackedResource extends Resource { + location: string; tags?: { [propertyName: string]: string; }; - location: string; -}; +} // @public export interface VcoreCapability { diff --git a/sdk/postgresql/arm-postgresql-flexible/samples-dev/checkNameAvailabilityExecuteSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples-dev/checkNameAvailabilityExecuteSample.ts index 27138b209948..dcac5c6b0113 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples-dev/checkNameAvailabilityExecuteSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples-dev/checkNameAvailabilityExecuteSample.ts @@ -13,6 +13,9 @@ import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Check the availability of name for resource @@ -21,7 +24,9 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/CheckNameAvailability.json */ async function nameAvailability() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; const nameAvailabilityRequest: NameAvailabilityRequest = { name: "name1", type: "Microsoft.DBforPostgreSQL/flexibleServers" @@ -37,4 +42,8 @@ async function nameAvailability() { console.log(result); } -nameAvailability().catch(console.error); +async function main() { + nameAvailability(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples-dev/configurationsGetSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples-dev/configurationsGetSample.ts index 17e8e75cb27f..905da22ef1a7 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples-dev/configurationsGetSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples-dev/configurationsGetSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Gets information about a configuration of server. @@ -18,8 +21,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ConfigurationGet.json */ async function configurationGet() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const configurationName = "array_nulls"; const credential = new DefaultAzureCredential(); @@ -35,4 +41,8 @@ async function configurationGet() { console.log(result); } -configurationGet().catch(console.error); +async function main() { + configurationGet(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples-dev/configurationsListByServerSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples-dev/configurationsListByServerSample.ts index 210988b8a687..737d5cbdd381 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples-dev/configurationsListByServerSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples-dev/configurationsListByServerSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to List all the configurations in a given server. @@ -18,8 +21,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ConfigurationListByServer.json */ async function configurationList() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( @@ -36,4 +42,8 @@ async function configurationList() { console.log(resArray); } -configurationList().catch(console.error); +async function main() { + configurationList(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples-dev/configurationsPutSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples-dev/configurationsPutSample.ts index 6cd6f81296b3..ea847c7bc65b 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples-dev/configurationsPutSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples-dev/configurationsPutSample.ts @@ -13,6 +13,9 @@ import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Updates a configuration of a server. @@ -21,8 +24,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ConfigurationUpdate.json */ async function updateAUserConfiguration() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const configurationName = "event_scheduler"; const parameters: Configuration = { source: "user-override", value: "on" }; @@ -40,4 +46,8 @@ async function updateAUserConfiguration() { console.log(result); } -updateAUserConfiguration().catch(console.error); +async function main() { + updateAUserConfiguration(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples-dev/configurationsUpdateSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples-dev/configurationsUpdateSample.ts index fc37d1591fae..3d4a15e7bf42 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples-dev/configurationsUpdateSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples-dev/configurationsUpdateSample.ts @@ -13,6 +13,9 @@ import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Updates a configuration of a server. @@ -21,8 +24,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ConfigurationUpdate.json */ async function updateAUserConfiguration() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const configurationName = "event_scheduler"; const parameters: Configuration = { source: "user-override", value: "on" }; @@ -40,4 +46,8 @@ async function updateAUserConfiguration() { console.log(result); } -updateAUserConfiguration().catch(console.error); +async function main() { + updateAUserConfiguration(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples-dev/databasesCreateSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples-dev/databasesCreateSample.ts index cc56d8eabe2b..8cc9829376be 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples-dev/databasesCreateSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples-dev/databasesCreateSample.ts @@ -13,6 +13,9 @@ import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Creates a new database or updates an existing database. @@ -21,8 +24,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/DatabaseCreate.json */ async function createADatabase() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "TestGroup"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "TestGroup"; const serverName = "testserver"; const databaseName = "db1"; const parameters: Database = { charset: "utf8", collation: "en_US.utf8" }; @@ -40,4 +46,8 @@ async function createADatabase() { console.log(result); } -createADatabase().catch(console.error); +async function main() { + createADatabase(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples-dev/databasesDeleteSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples-dev/databasesDeleteSample.ts index 852bd5869b05..4b549e840a8a 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples-dev/databasesDeleteSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples-dev/databasesDeleteSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Deletes a database. @@ -18,8 +21,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/DatabaseDelete.json */ async function deleteADatabase() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "TestGroup"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "TestGroup"; const serverName = "testserver"; const databaseName = "db1"; const credential = new DefaultAzureCredential(); @@ -35,4 +41,8 @@ async function deleteADatabase() { console.log(result); } -deleteADatabase().catch(console.error); +async function main() { + deleteADatabase(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples-dev/databasesGetSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples-dev/databasesGetSample.ts index 7219b4f615cb..803492bd1629 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples-dev/databasesGetSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples-dev/databasesGetSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Gets information about a database. @@ -18,8 +21,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/DatabaseGet.json */ async function getADatabase() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "TestGroup"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "TestGroup"; const serverName = "testserver"; const databaseName = "db1"; const credential = new DefaultAzureCredential(); @@ -35,4 +41,8 @@ async function getADatabase() { console.log(result); } -getADatabase().catch(console.error); +async function main() { + getADatabase(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples-dev/databasesListByServerSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples-dev/databasesListByServerSample.ts index 67933bbf1c7d..245e78b91a66 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples-dev/databasesListByServerSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples-dev/databasesListByServerSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to List all the databases in a given server. @@ -18,8 +21,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/DatabasesListByServer.json */ async function listDatabasesInAServer() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "TestGroup"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "TestGroup"; const serverName = "testserver"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( @@ -36,4 +42,8 @@ async function listDatabasesInAServer() { console.log(resArray); } -listDatabasesInAServer().catch(console.error); +async function main() { + listDatabasesInAServer(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples-dev/firewallRulesCreateOrUpdateSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples-dev/firewallRulesCreateOrUpdateSample.ts index 23a026163e3a..3fdeeecd07af 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples-dev/firewallRulesCreateOrUpdateSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples-dev/firewallRulesCreateOrUpdateSample.ts @@ -13,6 +13,9 @@ import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Creates a new firewall rule or updates an existing firewall rule. @@ -21,8 +24,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/FirewallRuleCreate.json */ async function firewallRuleCreate() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const firewallRuleName = "rule1"; const parameters: FirewallRule = { @@ -43,4 +49,8 @@ async function firewallRuleCreate() { console.log(result); } -firewallRuleCreate().catch(console.error); +async function main() { + firewallRuleCreate(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples-dev/firewallRulesDeleteSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples-dev/firewallRulesDeleteSample.ts index 3579768cd7c7..72f2c2c03713 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples-dev/firewallRulesDeleteSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples-dev/firewallRulesDeleteSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Deletes a PostgreSQL server firewall rule. @@ -18,8 +21,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/FirewallRuleDelete.json */ async function firewallRuleDelete() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const firewallRuleName = "rule1"; const credential = new DefaultAzureCredential(); @@ -35,4 +41,8 @@ async function firewallRuleDelete() { console.log(result); } -firewallRuleDelete().catch(console.error); +async function main() { + firewallRuleDelete(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples-dev/firewallRulesGetSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples-dev/firewallRulesGetSample.ts index 976320b82321..fd7b03e630a7 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples-dev/firewallRulesGetSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples-dev/firewallRulesGetSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to List all the firewall rules in a given server. @@ -18,8 +21,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/FirewallRuleGet.json */ async function firewallRuleList() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const firewallRuleName = "rule1"; const credential = new DefaultAzureCredential(); @@ -35,4 +41,8 @@ async function firewallRuleList() { console.log(result); } -firewallRuleList().catch(console.error); +async function main() { + firewallRuleList(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples-dev/firewallRulesListByServerSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples-dev/firewallRulesListByServerSample.ts index f411a15db1d0..b3d9639cbaca 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples-dev/firewallRulesListByServerSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples-dev/firewallRulesListByServerSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to List all the firewall rules in a given PostgreSQL server. @@ -18,8 +21,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/FirewallRuleListByServer.json */ async function firewallRuleList() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( @@ -36,4 +42,8 @@ async function firewallRuleList() { console.log(resArray); } -firewallRuleList().catch(console.error); +async function main() { + firewallRuleList(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples-dev/getPrivateDnsZoneSuffixExecuteSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples-dev/getPrivateDnsZoneSuffixExecuteSample.ts index 934ea52bf7df..bcb2d2869084 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples-dev/getPrivateDnsZoneSuffixExecuteSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples-dev/getPrivateDnsZoneSuffixExecuteSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Get private DNS zone suffix in the cloud @@ -18,7 +21,9 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/GetPrivateDnsZoneSuffix.json */ async function getPrivateDnsZoneSuffix() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( credential, @@ -28,4 +33,8 @@ async function getPrivateDnsZoneSuffix() { console.log(result); } -getPrivateDnsZoneSuffix().catch(console.error); +async function main() { + getPrivateDnsZoneSuffix(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples-dev/locationBasedCapabilitiesExecuteSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples-dev/locationBasedCapabilitiesExecuteSample.ts index e8d6f53f68c9..baadcbbb5efc 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples-dev/locationBasedCapabilitiesExecuteSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples-dev/locationBasedCapabilitiesExecuteSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Get capabilities at specified location in a given subscription. @@ -18,7 +21,9 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/CapabilitiesByLocation.json */ async function capabilitiesList() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; const locationName = "westus"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( @@ -34,4 +39,8 @@ async function capabilitiesList() { console.log(resArray); } -capabilitiesList().catch(console.error); +async function main() { + capabilitiesList(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples-dev/operationsListSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples-dev/operationsListSample.ts index bec6e21bf320..41d50797bdfd 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples-dev/operationsListSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples-dev/operationsListSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Lists all of the available REST API operations. @@ -18,7 +21,9 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/OperationList.json */ async function operationList() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( credential, @@ -28,4 +33,8 @@ async function operationList() { console.log(result); } -operationList().catch(console.error); +async function main() { + operationList(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversCreateSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversCreateSample.ts index 39de05f88c04..0876c991d441 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversCreateSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversCreateSample.ts @@ -13,6 +13,9 @@ import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Creates a new server. @@ -21,8 +24,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerCreatePointInTimeRestore.json */ async function createADatabaseAsAPointInTimeRestore() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "pgtestsvc5"; const parameters: Server = { createMode: "PointInTimeRestore", @@ -44,8 +50,6 @@ async function createADatabaseAsAPointInTimeRestore() { console.log(result); } -createADatabaseAsAPointInTimeRestore().catch(console.error); - /** * This sample demonstrates how to Creates a new server. * @@ -53,8 +57,11 @@ createADatabaseAsAPointInTimeRestore().catch(console.error); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerCreate.json */ async function createANewServer() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "pgtestsvc4"; const parameters: Server = { administratorLogin: "cloudsa", @@ -88,4 +95,9 @@ async function createANewServer() { console.log(result); } -createANewServer().catch(console.error); +async function main() { + createADatabaseAsAPointInTimeRestore(); + createANewServer(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversDeleteSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversDeleteSample.ts index 9ae9a4b50b5b..8e70766051c3 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversDeleteSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversDeleteSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Deletes a server. @@ -18,8 +21,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerDelete.json */ async function serverDelete() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( @@ -33,4 +39,8 @@ async function serverDelete() { console.log(result); } -serverDelete().catch(console.error); +async function main() { + serverDelete(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversGetSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversGetSample.ts index c84447eaa048..140bb59ab82c 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversGetSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversGetSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Gets information about a server. @@ -18,8 +21,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerGet.json */ async function serverGet() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "pgtestsvc1"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( @@ -30,8 +36,6 @@ async function serverGet() { console.log(result); } -serverGet().catch(console.error); - /** * This sample demonstrates how to Gets information about a server. * @@ -39,8 +43,11 @@ serverGet().catch(console.error); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerGetWithVnet.json */ async function serverGetWithVnet() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "pgtestsvc4"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( @@ -51,4 +58,9 @@ async function serverGetWithVnet() { console.log(result); } -serverGetWithVnet().catch(console.error); +async function main() { + serverGet(); + serverGetWithVnet(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversListByResourceGroupSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversListByResourceGroupSample.ts index 6c984bdf3476..915e850a8f63 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversListByResourceGroupSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversListByResourceGroupSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to List all the servers in a given resource group. @@ -18,8 +21,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerListByResourceGroup.json */ async function serverListByResourceGroup() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( credential, @@ -34,4 +40,8 @@ async function serverListByResourceGroup() { console.log(resArray); } -serverListByResourceGroup().catch(console.error); +async function main() { + serverListByResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversListSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversListSample.ts index 02a4c3561ba4..5b40e473d774 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversListSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversListSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to List all the servers in a given subscription. @@ -18,7 +21,9 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerList.json */ async function serverList() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( credential, @@ -31,4 +36,8 @@ async function serverList() { console.log(resArray); } -serverList().catch(console.error); +async function main() { + serverList(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversRestartSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversRestartSample.ts index 1650a45d6720..71956c32463b 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversRestartSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversRestartSample.ts @@ -14,6 +14,9 @@ import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Restarts a server. @@ -22,8 +25,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerRestart.json */ async function serverRestart() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( @@ -37,8 +43,6 @@ async function serverRestart() { console.log(result); } -serverRestart().catch(console.error); - /** * This sample demonstrates how to Restarts a server. * @@ -46,8 +50,11 @@ serverRestart().catch(console.error); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerRestartWithFailover.json */ async function serverRestartWithFailover() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const parameters: RestartParameter = { failoverMode: "ForcedFailover", @@ -67,4 +74,9 @@ async function serverRestartWithFailover() { console.log(result); } -serverRestartWithFailover().catch(console.error); +async function main() { + serverRestart(); + serverRestartWithFailover(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversStartSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversStartSample.ts index 11272131c64d..89967735ba05 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversStartSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversStartSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Starts a server. @@ -18,8 +21,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerStart.json */ async function serverStart() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( @@ -33,4 +39,8 @@ async function serverStart() { console.log(result); } -serverStart().catch(console.error); +async function main() { + serverStart(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversStopSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversStopSample.ts index 6739c9fb51cc..ceb103200f60 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversStopSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversStopSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Stops a server. @@ -18,8 +21,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerStop.json */ async function serverStop() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( @@ -33,4 +39,8 @@ async function serverStop() { console.log(result); } -serverStop().catch(console.error); +async function main() { + serverStop(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversUpdateSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversUpdateSample.ts index f86249acc561..4dac0a63ae86 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversUpdateSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples-dev/serversUpdateSample.ts @@ -13,6 +13,9 @@ import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Updates an existing server. The request body can contain one to many of the properties present in the normal server definition. @@ -21,8 +24,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerUpdate.json */ async function serverUpdate() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "TestGroup"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "TestGroup"; const serverName = "pgtestsvc4"; const parameters: ServerForUpdate = { administratorLoginPassword: "newpassword", @@ -45,8 +51,6 @@ async function serverUpdate() { console.log(result); } -serverUpdate().catch(console.error); - /** * This sample demonstrates how to Updates an existing server. The request body can contain one to many of the properties present in the normal server definition. * @@ -54,8 +58,11 @@ serverUpdate().catch(console.error); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerUpdateWithCustomerMaintenanceWindow.json */ async function serverUpdateWithCustomerMaintenanceWindow() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "pgtestsvc4"; const parameters: ServerForUpdate = { createMode: "Update", @@ -80,4 +87,9 @@ async function serverUpdateWithCustomerMaintenanceWindow() { console.log(result); } -serverUpdateWithCustomerMaintenanceWindow().catch(console.error); +async function main() { + serverUpdate(); + serverUpdateWithCustomerMaintenanceWindow(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples-dev/virtualNetworkSubnetUsageExecuteSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples-dev/virtualNetworkSubnetUsageExecuteSample.ts index d0a2307bcd2e..a98d0b4ce9d5 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples-dev/virtualNetworkSubnetUsageExecuteSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples-dev/virtualNetworkSubnetUsageExecuteSample.ts @@ -13,6 +13,9 @@ import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Get virtual network subnet usage for a given vNet resource id. @@ -21,7 +24,9 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/VirtualNetworkSubnetUsage.json */ async function virtualNetworkSubnetUsageList() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; const locationName = "westus"; const parameters: VirtualNetworkSubnetUsageParameter = { virtualNetworkArmResourceId: @@ -39,4 +44,8 @@ async function virtualNetworkSubnetUsageList() { console.log(result); } -virtualNetworkSubnetUsageList().catch(console.error); +async function main() { + virtualNetworkSubnetUsageList(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/README.md b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/README.md index 476cd39a7386..7b25e1a3f5f0 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/README.md +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/README.md @@ -62,7 +62,7 @@ node checkNameAvailabilityExecuteSample.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 checkNameAvailabilityExecuteSample.js +npx cross-env POSTGRESQL_SUBSCRIPTION_ID="" node checkNameAvailabilityExecuteSample.js ``` ## Next Steps diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/checkNameAvailabilityExecuteSample.js b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/checkNameAvailabilityExecuteSample.js index aabfa46fbe59..e77fadb1333f 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/checkNameAvailabilityExecuteSample.js +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/checkNameAvailabilityExecuteSample.js @@ -10,6 +10,7 @@ // Licensed under the MIT License. const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible"); const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); /** * This sample demonstrates how to Check the availability of name for resource @@ -18,7 +19,8 @@ const { DefaultAzureCredential } = require("@azure/identity"); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/CheckNameAvailability.json */ async function nameAvailability() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; const nameAvailabilityRequest = { name: "name1", type: "Microsoft.DBforPostgreSQL/flexibleServers", @@ -29,4 +31,8 @@ async function nameAvailability() { console.log(result); } -nameAvailability().catch(console.error); +async function main() { + nameAvailability(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/configurationsGetSample.js b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/configurationsGetSample.js index 3f80702fb759..891e3df47d81 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/configurationsGetSample.js +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/configurationsGetSample.js @@ -10,6 +10,7 @@ // Licensed under the MIT License. const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible"); const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); /** * This sample demonstrates how to Gets information about a configuration of server. @@ -18,8 +19,9 @@ const { DefaultAzureCredential } = require("@azure/identity"); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ConfigurationGet.json */ async function configurationGet() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const configurationName = "array_nulls"; const credential = new DefaultAzureCredential(); @@ -28,4 +30,8 @@ async function configurationGet() { console.log(result); } -configurationGet().catch(console.error); +async function main() { + configurationGet(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/configurationsListByServerSample.js b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/configurationsListByServerSample.js index f70447bf1ac1..0c20c2a09111 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/configurationsListByServerSample.js +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/configurationsListByServerSample.js @@ -10,6 +10,7 @@ // Licensed under the MIT License. const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible"); const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); /** * This sample demonstrates how to List all the configurations in a given server. @@ -18,8 +19,9 @@ const { DefaultAzureCredential } = require("@azure/identity"); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ConfigurationListByServer.json */ async function configurationList() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId); @@ -30,4 +32,8 @@ async function configurationList() { console.log(resArray); } -configurationList().catch(console.error); +async function main() { + configurationList(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/configurationsPutSample.js b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/configurationsPutSample.js index f3b584f5e4d8..6e20441058d2 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/configurationsPutSample.js +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/configurationsPutSample.js @@ -10,6 +10,7 @@ // Licensed under the MIT License. const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible"); const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); /** * This sample demonstrates how to Updates a configuration of a server. @@ -18,8 +19,9 @@ const { DefaultAzureCredential } = require("@azure/identity"); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ConfigurationUpdate.json */ async function updateAUserConfiguration() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const configurationName = "event_scheduler"; const parameters = { source: "user-override", value: "on" }; @@ -34,4 +36,8 @@ async function updateAUserConfiguration() { console.log(result); } -updateAUserConfiguration().catch(console.error); +async function main() { + updateAUserConfiguration(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/configurationsUpdateSample.js b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/configurationsUpdateSample.js index 87cbf0a4ce6f..a0a555c1988d 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/configurationsUpdateSample.js +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/configurationsUpdateSample.js @@ -10,6 +10,7 @@ // Licensed under the MIT License. const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible"); const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); /** * This sample demonstrates how to Updates a configuration of a server. @@ -18,8 +19,9 @@ const { DefaultAzureCredential } = require("@azure/identity"); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ConfigurationUpdate.json */ async function updateAUserConfiguration() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const configurationName = "event_scheduler"; const parameters = { source: "user-override", value: "on" }; @@ -34,4 +36,8 @@ async function updateAUserConfiguration() { console.log(result); } -updateAUserConfiguration().catch(console.error); +async function main() { + updateAUserConfiguration(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/databasesCreateSample.js b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/databasesCreateSample.js index 75e1e2c9a89c..6c5f43677f19 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/databasesCreateSample.js +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/databasesCreateSample.js @@ -10,6 +10,7 @@ // Licensed under the MIT License. const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible"); const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); /** * This sample demonstrates how to Creates a new database or updates an existing database. @@ -18,8 +19,9 @@ const { DefaultAzureCredential } = require("@azure/identity"); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/DatabaseCreate.json */ async function createADatabase() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "TestGroup"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "TestGroup"; const serverName = "testserver"; const databaseName = "db1"; const parameters = { charset: "utf8", collation: "en_US.utf8" }; @@ -34,4 +36,8 @@ async function createADatabase() { console.log(result); } -createADatabase().catch(console.error); +async function main() { + createADatabase(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/databasesDeleteSample.js b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/databasesDeleteSample.js index f0fe4429399c..93a5ba4e9fc3 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/databasesDeleteSample.js +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/databasesDeleteSample.js @@ -10,6 +10,7 @@ // Licensed under the MIT License. const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible"); const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); /** * This sample demonstrates how to Deletes a database. @@ -18,8 +19,9 @@ const { DefaultAzureCredential } = require("@azure/identity"); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/DatabaseDelete.json */ async function deleteADatabase() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "TestGroup"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "TestGroup"; const serverName = "testserver"; const databaseName = "db1"; const credential = new DefaultAzureCredential(); @@ -32,4 +34,8 @@ async function deleteADatabase() { console.log(result); } -deleteADatabase().catch(console.error); +async function main() { + deleteADatabase(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/databasesGetSample.js b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/databasesGetSample.js index e28c766d95bf..4e72aff6fd41 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/databasesGetSample.js +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/databasesGetSample.js @@ -10,6 +10,7 @@ // Licensed under the MIT License. const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible"); const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); /** * This sample demonstrates how to Gets information about a database. @@ -18,8 +19,9 @@ const { DefaultAzureCredential } = require("@azure/identity"); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/DatabaseGet.json */ async function getADatabase() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "TestGroup"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "TestGroup"; const serverName = "testserver"; const databaseName = "db1"; const credential = new DefaultAzureCredential(); @@ -28,4 +30,8 @@ async function getADatabase() { console.log(result); } -getADatabase().catch(console.error); +async function main() { + getADatabase(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/databasesListByServerSample.js b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/databasesListByServerSample.js index 5dcdd0eafdd8..fb2352b797f8 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/databasesListByServerSample.js +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/databasesListByServerSample.js @@ -10,6 +10,7 @@ // Licensed under the MIT License. const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible"); const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); /** * This sample demonstrates how to List all the databases in a given server. @@ -18,8 +19,9 @@ const { DefaultAzureCredential } = require("@azure/identity"); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/DatabasesListByServer.json */ async function listDatabasesInAServer() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "TestGroup"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "TestGroup"; const serverName = "testserver"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId); @@ -30,4 +32,8 @@ async function listDatabasesInAServer() { console.log(resArray); } -listDatabasesInAServer().catch(console.error); +async function main() { + listDatabasesInAServer(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/firewallRulesCreateOrUpdateSample.js b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/firewallRulesCreateOrUpdateSample.js index f48fc8cb19a2..be0c4e14cadb 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/firewallRulesCreateOrUpdateSample.js +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/firewallRulesCreateOrUpdateSample.js @@ -10,6 +10,7 @@ // Licensed under the MIT License. const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible"); const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); /** * This sample demonstrates how to Creates a new firewall rule or updates an existing firewall rule. @@ -18,8 +19,9 @@ const { DefaultAzureCredential } = require("@azure/identity"); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/FirewallRuleCreate.json */ async function firewallRuleCreate() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const firewallRuleName = "rule1"; const parameters = { @@ -37,4 +39,8 @@ async function firewallRuleCreate() { console.log(result); } -firewallRuleCreate().catch(console.error); +async function main() { + firewallRuleCreate(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/firewallRulesDeleteSample.js b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/firewallRulesDeleteSample.js index cf0427783f93..bc4da50d1abe 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/firewallRulesDeleteSample.js +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/firewallRulesDeleteSample.js @@ -10,6 +10,7 @@ // Licensed under the MIT License. const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible"); const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); /** * This sample demonstrates how to Deletes a PostgreSQL server firewall rule. @@ -18,8 +19,9 @@ const { DefaultAzureCredential } = require("@azure/identity"); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/FirewallRuleDelete.json */ async function firewallRuleDelete() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const firewallRuleName = "rule1"; const credential = new DefaultAzureCredential(); @@ -32,4 +34,8 @@ async function firewallRuleDelete() { console.log(result); } -firewallRuleDelete().catch(console.error); +async function main() { + firewallRuleDelete(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/firewallRulesGetSample.js b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/firewallRulesGetSample.js index 6626c64c0346..ad8bb057c9f3 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/firewallRulesGetSample.js +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/firewallRulesGetSample.js @@ -10,6 +10,7 @@ // Licensed under the MIT License. const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible"); const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); /** * This sample demonstrates how to List all the firewall rules in a given server. @@ -18,8 +19,9 @@ const { DefaultAzureCredential } = require("@azure/identity"); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/FirewallRuleGet.json */ async function firewallRuleList() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const firewallRuleName = "rule1"; const credential = new DefaultAzureCredential(); @@ -28,4 +30,8 @@ async function firewallRuleList() { console.log(result); } -firewallRuleList().catch(console.error); +async function main() { + firewallRuleList(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/firewallRulesListByServerSample.js b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/firewallRulesListByServerSample.js index 61849b6a1552..1ce54c0fe6a0 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/firewallRulesListByServerSample.js +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/firewallRulesListByServerSample.js @@ -10,6 +10,7 @@ // Licensed under the MIT License. const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible"); const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); /** * This sample demonstrates how to List all the firewall rules in a given PostgreSQL server. @@ -18,8 +19,9 @@ const { DefaultAzureCredential } = require("@azure/identity"); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/FirewallRuleListByServer.json */ async function firewallRuleList() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId); @@ -30,4 +32,8 @@ async function firewallRuleList() { console.log(resArray); } -firewallRuleList().catch(console.error); +async function main() { + firewallRuleList(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/getPrivateDnsZoneSuffixExecuteSample.js b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/getPrivateDnsZoneSuffixExecuteSample.js index 3f618b1292d5..55558d6cab16 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/getPrivateDnsZoneSuffixExecuteSample.js +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/getPrivateDnsZoneSuffixExecuteSample.js @@ -10,6 +10,7 @@ // Licensed under the MIT License. const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible"); const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); /** * This sample demonstrates how to Get private DNS zone suffix in the cloud @@ -18,11 +19,16 @@ const { DefaultAzureCredential } = require("@azure/identity"); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/GetPrivateDnsZoneSuffix.json */ async function getPrivateDnsZoneSuffix() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId); const result = await client.getPrivateDnsZoneSuffix.execute(); console.log(result); } -getPrivateDnsZoneSuffix().catch(console.error); +async function main() { + getPrivateDnsZoneSuffix(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/locationBasedCapabilitiesExecuteSample.js b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/locationBasedCapabilitiesExecuteSample.js index 995e6df0d09a..77e7e0c007a4 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/locationBasedCapabilitiesExecuteSample.js +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/locationBasedCapabilitiesExecuteSample.js @@ -10,6 +10,7 @@ // Licensed under the MIT License. const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible"); const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); /** * This sample demonstrates how to Get capabilities at specified location in a given subscription. @@ -18,7 +19,8 @@ const { DefaultAzureCredential } = require("@azure/identity"); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/CapabilitiesByLocation.json */ async function capabilitiesList() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; const locationName = "westus"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId); @@ -29,4 +31,8 @@ async function capabilitiesList() { console.log(resArray); } -capabilitiesList().catch(console.error); +async function main() { + capabilitiesList(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/operationsListSample.js b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/operationsListSample.js index dad5d3b39b46..fe72ebd5b659 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/operationsListSample.js +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/operationsListSample.js @@ -10,6 +10,7 @@ // Licensed under the MIT License. const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible"); const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); /** * This sample demonstrates how to Lists all of the available REST API operations. @@ -18,11 +19,16 @@ const { DefaultAzureCredential } = require("@azure/identity"); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/OperationList.json */ async function operationList() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId); const result = await client.operations.list(); console.log(result); } -operationList().catch(console.error); +async function main() { + operationList(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversCreateSample.js b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversCreateSample.js index 43a84b1ede08..4ce5c7223dd5 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversCreateSample.js +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversCreateSample.js @@ -10,6 +10,7 @@ // Licensed under the MIT License. const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible"); const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); /** * This sample demonstrates how to Creates a new server. @@ -18,8 +19,9 @@ const { DefaultAzureCredential } = require("@azure/identity"); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerCreatePointInTimeRestore.json */ async function createADatabaseAsAPointInTimeRestore() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "pgtestsvc5"; const parameters = { createMode: "PointInTimeRestore", @@ -34,8 +36,6 @@ async function createADatabaseAsAPointInTimeRestore() { console.log(result); } -createADatabaseAsAPointInTimeRestore().catch(console.error); - /** * This sample demonstrates how to Creates a new server. * @@ -43,8 +43,9 @@ createADatabaseAsAPointInTimeRestore().catch(console.error); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerCreate.json */ async function createANewServer() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "pgtestsvc4"; const parameters = { administratorLogin: "cloudsa", @@ -71,4 +72,9 @@ async function createANewServer() { console.log(result); } -createANewServer().catch(console.error); +async function main() { + createADatabaseAsAPointInTimeRestore(); + createANewServer(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversDeleteSample.js b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversDeleteSample.js index 541f32a2f4a6..a428aefe308f 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversDeleteSample.js +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversDeleteSample.js @@ -10,6 +10,7 @@ // Licensed under the MIT License. const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible"); const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); /** * This sample demonstrates how to Deletes a server. @@ -18,8 +19,9 @@ const { DefaultAzureCredential } = require("@azure/identity"); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerDelete.json */ async function serverDelete() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId); @@ -27,4 +29,8 @@ async function serverDelete() { console.log(result); } -serverDelete().catch(console.error); +async function main() { + serverDelete(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversGetSample.js b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversGetSample.js index 45cbb637daec..33f79135e483 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversGetSample.js +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversGetSample.js @@ -10,6 +10,7 @@ // Licensed under the MIT License. const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible"); const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); /** * This sample demonstrates how to Gets information about a server. @@ -18,8 +19,9 @@ const { DefaultAzureCredential } = require("@azure/identity"); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerGet.json */ async function serverGet() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "pgtestsvc1"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId); @@ -27,8 +29,6 @@ async function serverGet() { console.log(result); } -serverGet().catch(console.error); - /** * This sample demonstrates how to Gets information about a server. * @@ -36,8 +36,9 @@ serverGet().catch(console.error); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerGetWithVnet.json */ async function serverGetWithVnet() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "pgtestsvc4"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId); @@ -45,4 +46,9 @@ async function serverGetWithVnet() { console.log(result); } -serverGetWithVnet().catch(console.error); +async function main() { + serverGet(); + serverGetWithVnet(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversListByResourceGroupSample.js b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversListByResourceGroupSample.js index 914f0b9aa2cc..796d028e44f2 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversListByResourceGroupSample.js +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversListByResourceGroupSample.js @@ -10,6 +10,7 @@ // Licensed under the MIT License. const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible"); const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); /** * This sample demonstrates how to List all the servers in a given resource group. @@ -18,8 +19,9 @@ const { DefaultAzureCredential } = require("@azure/identity"); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerListByResourceGroup.json */ async function serverListByResourceGroup() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId); const resArray = new Array(); @@ -29,4 +31,8 @@ async function serverListByResourceGroup() { console.log(resArray); } -serverListByResourceGroup().catch(console.error); +async function main() { + serverListByResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversListSample.js b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversListSample.js index 5cb9184959be..ba36b15420e2 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversListSample.js +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversListSample.js @@ -10,6 +10,7 @@ // Licensed under the MIT License. const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible"); const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); /** * This sample demonstrates how to List all the servers in a given subscription. @@ -18,7 +19,8 @@ const { DefaultAzureCredential } = require("@azure/identity"); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerList.json */ async function serverList() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId); const resArray = new Array(); @@ -28,4 +30,8 @@ async function serverList() { console.log(resArray); } -serverList().catch(console.error); +async function main() { + serverList(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversRestartSample.js b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversRestartSample.js index b8923a5cb80e..f4e1f60514d0 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversRestartSample.js +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversRestartSample.js @@ -10,6 +10,7 @@ // Licensed under the MIT License. const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible"); const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); /** * This sample demonstrates how to Restarts a server. @@ -18,8 +19,9 @@ const { DefaultAzureCredential } = require("@azure/identity"); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerRestart.json */ async function serverRestart() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId); @@ -27,8 +29,6 @@ async function serverRestart() { console.log(result); } -serverRestart().catch(console.error); - /** * This sample demonstrates how to Restarts a server. * @@ -36,8 +36,9 @@ serverRestart().catch(console.error); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerRestartWithFailover.json */ async function serverRestartWithFailover() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const parameters = { failoverMode: "ForcedFailover", @@ -50,4 +51,9 @@ async function serverRestartWithFailover() { console.log(result); } -serverRestartWithFailover().catch(console.error); +async function main() { + serverRestart(); + serverRestartWithFailover(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversStartSample.js b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversStartSample.js index a939beb3874a..c4372ce24815 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversStartSample.js +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversStartSample.js @@ -10,6 +10,7 @@ // Licensed under the MIT License. const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible"); const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); /** * This sample demonstrates how to Starts a server. @@ -18,8 +19,9 @@ const { DefaultAzureCredential } = require("@azure/identity"); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerStart.json */ async function serverStart() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId); @@ -27,4 +29,8 @@ async function serverStart() { console.log(result); } -serverStart().catch(console.error); +async function main() { + serverStart(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversStopSample.js b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversStopSample.js index 467f8cb546e7..04a43aa30b8a 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversStopSample.js +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversStopSample.js @@ -10,6 +10,7 @@ // Licensed under the MIT License. const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible"); const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); /** * This sample demonstrates how to Stops a server. @@ -18,8 +19,9 @@ const { DefaultAzureCredential } = require("@azure/identity"); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerStop.json */ async function serverStop() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient(credential, subscriptionId); @@ -27,4 +29,8 @@ async function serverStop() { console.log(result); } -serverStop().catch(console.error); +async function main() { + serverStop(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversUpdateSample.js b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversUpdateSample.js index 6e4272b450b3..75f5814a918b 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversUpdateSample.js +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/serversUpdateSample.js @@ -10,6 +10,7 @@ // Licensed under the MIT License. const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible"); const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); /** * This sample demonstrates how to Updates an existing server. The request body can contain one to many of the properties present in the normal server definition. @@ -18,8 +19,9 @@ const { DefaultAzureCredential } = require("@azure/identity"); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerUpdate.json */ async function serverUpdate() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "TestGroup"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "TestGroup"; const serverName = "pgtestsvc4"; const parameters = { administratorLoginPassword: "newpassword", @@ -35,8 +37,6 @@ async function serverUpdate() { console.log(result); } -serverUpdate().catch(console.error); - /** * This sample demonstrates how to Updates an existing server. The request body can contain one to many of the properties present in the normal server definition. * @@ -44,8 +44,9 @@ serverUpdate().catch(console.error); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerUpdateWithCustomerMaintenanceWindow.json */ async function serverUpdateWithCustomerMaintenanceWindow() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "pgtestsvc4"; const parameters = { createMode: "Update", @@ -63,4 +64,9 @@ async function serverUpdateWithCustomerMaintenanceWindow() { console.log(result); } -serverUpdateWithCustomerMaintenanceWindow().catch(console.error); +async function main() { + serverUpdate(); + serverUpdateWithCustomerMaintenanceWindow(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/virtualNetworkSubnetUsageExecuteSample.js b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/virtualNetworkSubnetUsageExecuteSample.js index 5345ae06ca7b..3bbee96e1e3b 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/virtualNetworkSubnetUsageExecuteSample.js +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/javascript/virtualNetworkSubnetUsageExecuteSample.js @@ -10,6 +10,7 @@ // Licensed under the MIT License. const { PostgreSQLManagementFlexibleServerClient } = require("@azure/arm-postgresql-flexible"); const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); /** * This sample demonstrates how to Get virtual network subnet usage for a given vNet resource id. @@ -18,7 +19,8 @@ const { DefaultAzureCredential } = require("@azure/identity"); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/VirtualNetworkSubnetUsage.json */ async function virtualNetworkSubnetUsageList() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || "ffffffff-ffff-ffff-ffff-ffffffffffff"; const locationName = "westus"; const parameters = { virtualNetworkArmResourceId: @@ -30,4 +32,8 @@ async function virtualNetworkSubnetUsageList() { console.log(result); } -virtualNetworkSubnetUsageList().catch(console.error); +async function main() { + virtualNetworkSubnetUsageList(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/README.md b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/README.md index b01c872dba9c..78da6cbe7669 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/README.md +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/README.md @@ -74,7 +74,7 @@ node dist/checkNameAvailabilityExecuteSample.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/checkNameAvailabilityExecuteSample.js +npx cross-env POSTGRESQL_SUBSCRIPTION_ID="" node dist/checkNameAvailabilityExecuteSample.js ``` ## Next Steps diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/package.json b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/package.json index 2f742108d73a..e2df645ac8f7 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/package.json +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/package.json @@ -35,7 +35,7 @@ }, "devDependencies": { "@types/node": "^14.0.0", - "typescript": "~4.4.0", + "typescript": "~4.8.0", "rimraf": "latest" } } diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/checkNameAvailabilityExecuteSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/checkNameAvailabilityExecuteSample.ts index 27138b209948..dcac5c6b0113 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/checkNameAvailabilityExecuteSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/checkNameAvailabilityExecuteSample.ts @@ -13,6 +13,9 @@ import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Check the availability of name for resource @@ -21,7 +24,9 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/CheckNameAvailability.json */ async function nameAvailability() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; const nameAvailabilityRequest: NameAvailabilityRequest = { name: "name1", type: "Microsoft.DBforPostgreSQL/flexibleServers" @@ -37,4 +42,8 @@ async function nameAvailability() { console.log(result); } -nameAvailability().catch(console.error); +async function main() { + nameAvailability(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/configurationsGetSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/configurationsGetSample.ts index 17e8e75cb27f..905da22ef1a7 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/configurationsGetSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/configurationsGetSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Gets information about a configuration of server. @@ -18,8 +21,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ConfigurationGet.json */ async function configurationGet() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const configurationName = "array_nulls"; const credential = new DefaultAzureCredential(); @@ -35,4 +41,8 @@ async function configurationGet() { console.log(result); } -configurationGet().catch(console.error); +async function main() { + configurationGet(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/configurationsListByServerSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/configurationsListByServerSample.ts index 210988b8a687..737d5cbdd381 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/configurationsListByServerSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/configurationsListByServerSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to List all the configurations in a given server. @@ -18,8 +21,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ConfigurationListByServer.json */ async function configurationList() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( @@ -36,4 +42,8 @@ async function configurationList() { console.log(resArray); } -configurationList().catch(console.error); +async function main() { + configurationList(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/configurationsPutSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/configurationsPutSample.ts index 6cd6f81296b3..ea847c7bc65b 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/configurationsPutSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/configurationsPutSample.ts @@ -13,6 +13,9 @@ import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Updates a configuration of a server. @@ -21,8 +24,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ConfigurationUpdate.json */ async function updateAUserConfiguration() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const configurationName = "event_scheduler"; const parameters: Configuration = { source: "user-override", value: "on" }; @@ -40,4 +46,8 @@ async function updateAUserConfiguration() { console.log(result); } -updateAUserConfiguration().catch(console.error); +async function main() { + updateAUserConfiguration(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/configurationsUpdateSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/configurationsUpdateSample.ts index fc37d1591fae..3d4a15e7bf42 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/configurationsUpdateSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/configurationsUpdateSample.ts @@ -13,6 +13,9 @@ import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Updates a configuration of a server. @@ -21,8 +24,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ConfigurationUpdate.json */ async function updateAUserConfiguration() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const configurationName = "event_scheduler"; const parameters: Configuration = { source: "user-override", value: "on" }; @@ -40,4 +46,8 @@ async function updateAUserConfiguration() { console.log(result); } -updateAUserConfiguration().catch(console.error); +async function main() { + updateAUserConfiguration(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/databasesCreateSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/databasesCreateSample.ts index cc56d8eabe2b..8cc9829376be 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/databasesCreateSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/databasesCreateSample.ts @@ -13,6 +13,9 @@ import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Creates a new database or updates an existing database. @@ -21,8 +24,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/DatabaseCreate.json */ async function createADatabase() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "TestGroup"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "TestGroup"; const serverName = "testserver"; const databaseName = "db1"; const parameters: Database = { charset: "utf8", collation: "en_US.utf8" }; @@ -40,4 +46,8 @@ async function createADatabase() { console.log(result); } -createADatabase().catch(console.error); +async function main() { + createADatabase(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/databasesDeleteSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/databasesDeleteSample.ts index 852bd5869b05..4b549e840a8a 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/databasesDeleteSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/databasesDeleteSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Deletes a database. @@ -18,8 +21,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/DatabaseDelete.json */ async function deleteADatabase() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "TestGroup"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "TestGroup"; const serverName = "testserver"; const databaseName = "db1"; const credential = new DefaultAzureCredential(); @@ -35,4 +41,8 @@ async function deleteADatabase() { console.log(result); } -deleteADatabase().catch(console.error); +async function main() { + deleteADatabase(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/databasesGetSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/databasesGetSample.ts index 7219b4f615cb..803492bd1629 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/databasesGetSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/databasesGetSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Gets information about a database. @@ -18,8 +21,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/DatabaseGet.json */ async function getADatabase() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "TestGroup"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "TestGroup"; const serverName = "testserver"; const databaseName = "db1"; const credential = new DefaultAzureCredential(); @@ -35,4 +41,8 @@ async function getADatabase() { console.log(result); } -getADatabase().catch(console.error); +async function main() { + getADatabase(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/databasesListByServerSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/databasesListByServerSample.ts index 67933bbf1c7d..245e78b91a66 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/databasesListByServerSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/databasesListByServerSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to List all the databases in a given server. @@ -18,8 +21,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/DatabasesListByServer.json */ async function listDatabasesInAServer() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "TestGroup"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "TestGroup"; const serverName = "testserver"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( @@ -36,4 +42,8 @@ async function listDatabasesInAServer() { console.log(resArray); } -listDatabasesInAServer().catch(console.error); +async function main() { + listDatabasesInAServer(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/firewallRulesCreateOrUpdateSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/firewallRulesCreateOrUpdateSample.ts index 23a026163e3a..3fdeeecd07af 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/firewallRulesCreateOrUpdateSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/firewallRulesCreateOrUpdateSample.ts @@ -13,6 +13,9 @@ import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Creates a new firewall rule or updates an existing firewall rule. @@ -21,8 +24,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/FirewallRuleCreate.json */ async function firewallRuleCreate() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const firewallRuleName = "rule1"; const parameters: FirewallRule = { @@ -43,4 +49,8 @@ async function firewallRuleCreate() { console.log(result); } -firewallRuleCreate().catch(console.error); +async function main() { + firewallRuleCreate(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/firewallRulesDeleteSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/firewallRulesDeleteSample.ts index 3579768cd7c7..72f2c2c03713 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/firewallRulesDeleteSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/firewallRulesDeleteSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Deletes a PostgreSQL server firewall rule. @@ -18,8 +21,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/FirewallRuleDelete.json */ async function firewallRuleDelete() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const firewallRuleName = "rule1"; const credential = new DefaultAzureCredential(); @@ -35,4 +41,8 @@ async function firewallRuleDelete() { console.log(result); } -firewallRuleDelete().catch(console.error); +async function main() { + firewallRuleDelete(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/firewallRulesGetSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/firewallRulesGetSample.ts index 976320b82321..fd7b03e630a7 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/firewallRulesGetSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/firewallRulesGetSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to List all the firewall rules in a given server. @@ -18,8 +21,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/FirewallRuleGet.json */ async function firewallRuleList() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const firewallRuleName = "rule1"; const credential = new DefaultAzureCredential(); @@ -35,4 +41,8 @@ async function firewallRuleList() { console.log(result); } -firewallRuleList().catch(console.error); +async function main() { + firewallRuleList(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/firewallRulesListByServerSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/firewallRulesListByServerSample.ts index f411a15db1d0..b3d9639cbaca 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/firewallRulesListByServerSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/firewallRulesListByServerSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to List all the firewall rules in a given PostgreSQL server. @@ -18,8 +21,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/FirewallRuleListByServer.json */ async function firewallRuleList() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( @@ -36,4 +42,8 @@ async function firewallRuleList() { console.log(resArray); } -firewallRuleList().catch(console.error); +async function main() { + firewallRuleList(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/getPrivateDnsZoneSuffixExecuteSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/getPrivateDnsZoneSuffixExecuteSample.ts index 934ea52bf7df..bcb2d2869084 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/getPrivateDnsZoneSuffixExecuteSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/getPrivateDnsZoneSuffixExecuteSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Get private DNS zone suffix in the cloud @@ -18,7 +21,9 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/GetPrivateDnsZoneSuffix.json */ async function getPrivateDnsZoneSuffix() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( credential, @@ -28,4 +33,8 @@ async function getPrivateDnsZoneSuffix() { console.log(result); } -getPrivateDnsZoneSuffix().catch(console.error); +async function main() { + getPrivateDnsZoneSuffix(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/locationBasedCapabilitiesExecuteSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/locationBasedCapabilitiesExecuteSample.ts index e8d6f53f68c9..baadcbbb5efc 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/locationBasedCapabilitiesExecuteSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/locationBasedCapabilitiesExecuteSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Get capabilities at specified location in a given subscription. @@ -18,7 +21,9 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/CapabilitiesByLocation.json */ async function capabilitiesList() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; const locationName = "westus"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( @@ -34,4 +39,8 @@ async function capabilitiesList() { console.log(resArray); } -capabilitiesList().catch(console.error); +async function main() { + capabilitiesList(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/operationsListSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/operationsListSample.ts index bec6e21bf320..41d50797bdfd 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/operationsListSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/operationsListSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Lists all of the available REST API operations. @@ -18,7 +21,9 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/OperationList.json */ async function operationList() { - const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( credential, @@ -28,4 +33,8 @@ async function operationList() { console.log(result); } -operationList().catch(console.error); +async function main() { + operationList(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversCreateSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversCreateSample.ts index 39de05f88c04..0876c991d441 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversCreateSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversCreateSample.ts @@ -13,6 +13,9 @@ import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Creates a new server. @@ -21,8 +24,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerCreatePointInTimeRestore.json */ async function createADatabaseAsAPointInTimeRestore() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "pgtestsvc5"; const parameters: Server = { createMode: "PointInTimeRestore", @@ -44,8 +50,6 @@ async function createADatabaseAsAPointInTimeRestore() { console.log(result); } -createADatabaseAsAPointInTimeRestore().catch(console.error); - /** * This sample demonstrates how to Creates a new server. * @@ -53,8 +57,11 @@ createADatabaseAsAPointInTimeRestore().catch(console.error); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerCreate.json */ async function createANewServer() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "pgtestsvc4"; const parameters: Server = { administratorLogin: "cloudsa", @@ -88,4 +95,9 @@ async function createANewServer() { console.log(result); } -createANewServer().catch(console.error); +async function main() { + createADatabaseAsAPointInTimeRestore(); + createANewServer(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversDeleteSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversDeleteSample.ts index 9ae9a4b50b5b..8e70766051c3 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversDeleteSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversDeleteSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Deletes a server. @@ -18,8 +21,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerDelete.json */ async function serverDelete() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( @@ -33,4 +39,8 @@ async function serverDelete() { console.log(result); } -serverDelete().catch(console.error); +async function main() { + serverDelete(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversGetSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversGetSample.ts index c84447eaa048..140bb59ab82c 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversGetSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversGetSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Gets information about a server. @@ -18,8 +21,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerGet.json */ async function serverGet() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "pgtestsvc1"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( @@ -30,8 +36,6 @@ async function serverGet() { console.log(result); } -serverGet().catch(console.error); - /** * This sample demonstrates how to Gets information about a server. * @@ -39,8 +43,11 @@ serverGet().catch(console.error); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerGetWithVnet.json */ async function serverGetWithVnet() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "pgtestsvc4"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( @@ -51,4 +58,9 @@ async function serverGetWithVnet() { console.log(result); } -serverGetWithVnet().catch(console.error); +async function main() { + serverGet(); + serverGetWithVnet(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversListByResourceGroupSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversListByResourceGroupSample.ts index 6c984bdf3476..915e850a8f63 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversListByResourceGroupSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversListByResourceGroupSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to List all the servers in a given resource group. @@ -18,8 +21,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerListByResourceGroup.json */ async function serverListByResourceGroup() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( credential, @@ -34,4 +40,8 @@ async function serverListByResourceGroup() { console.log(resArray); } -serverListByResourceGroup().catch(console.error); +async function main() { + serverListByResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversListSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversListSample.ts index 02a4c3561ba4..5b40e473d774 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversListSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversListSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to List all the servers in a given subscription. @@ -18,7 +21,9 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerList.json */ async function serverList() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( credential, @@ -31,4 +36,8 @@ async function serverList() { console.log(resArray); } -serverList().catch(console.error); +async function main() { + serverList(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversRestartSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversRestartSample.ts index 1650a45d6720..71956c32463b 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversRestartSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversRestartSample.ts @@ -14,6 +14,9 @@ import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Restarts a server. @@ -22,8 +25,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerRestart.json */ async function serverRestart() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( @@ -37,8 +43,6 @@ async function serverRestart() { console.log(result); } -serverRestart().catch(console.error); - /** * This sample demonstrates how to Restarts a server. * @@ -46,8 +50,11 @@ serverRestart().catch(console.error); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerRestartWithFailover.json */ async function serverRestartWithFailover() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const parameters: RestartParameter = { failoverMode: "ForcedFailover", @@ -67,4 +74,9 @@ async function serverRestartWithFailover() { console.log(result); } -serverRestartWithFailover().catch(console.error); +async function main() { + serverRestart(); + serverRestartWithFailover(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversStartSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversStartSample.ts index 11272131c64d..89967735ba05 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversStartSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversStartSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Starts a server. @@ -18,8 +21,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerStart.json */ async function serverStart() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( @@ -33,4 +39,8 @@ async function serverStart() { console.log(result); } -serverStart().catch(console.error); +async function main() { + serverStart(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversStopSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversStopSample.ts index 6739c9fb51cc..ceb103200f60 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversStopSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversStopSample.ts @@ -10,6 +10,9 @@ // Licensed under the MIT License. import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Stops a server. @@ -18,8 +21,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerStop.json */ async function serverStop() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "testserver"; const credential = new DefaultAzureCredential(); const client = new PostgreSQLManagementFlexibleServerClient( @@ -33,4 +39,8 @@ async function serverStop() { console.log(result); } -serverStop().catch(console.error); +async function main() { + serverStop(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversUpdateSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversUpdateSample.ts index f86249acc561..4dac0a63ae86 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversUpdateSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/serversUpdateSample.ts @@ -13,6 +13,9 @@ import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Updates an existing server. The request body can contain one to many of the properties present in the normal server definition. @@ -21,8 +24,11 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerUpdate.json */ async function serverUpdate() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "TestGroup"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "TestGroup"; const serverName = "pgtestsvc4"; const parameters: ServerForUpdate = { administratorLoginPassword: "newpassword", @@ -45,8 +51,6 @@ async function serverUpdate() { console.log(result); } -serverUpdate().catch(console.error); - /** * This sample demonstrates how to Updates an existing server. The request body can contain one to many of the properties present in the normal server definition. * @@ -54,8 +58,11 @@ serverUpdate().catch(console.error); * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/ServerUpdateWithCustomerMaintenanceWindow.json */ async function serverUpdateWithCustomerMaintenanceWindow() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - const resourceGroupName = "testrg"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const resourceGroupName = + process.env["POSTGRESQL_RESOURCE_GROUP"] || "testrg"; const serverName = "pgtestsvc4"; const parameters: ServerForUpdate = { createMode: "Update", @@ -80,4 +87,9 @@ async function serverUpdateWithCustomerMaintenanceWindow() { console.log(result); } -serverUpdateWithCustomerMaintenanceWindow().catch(console.error); +async function main() { + serverUpdate(); + serverUpdateWithCustomerMaintenanceWindow(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/virtualNetworkSubnetUsageExecuteSample.ts b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/virtualNetworkSubnetUsageExecuteSample.ts index d0a2307bcd2e..a98d0b4ce9d5 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/virtualNetworkSubnetUsageExecuteSample.ts +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/src/virtualNetworkSubnetUsageExecuteSample.ts @@ -13,6 +13,9 @@ import { PostgreSQLManagementFlexibleServerClient } from "@azure/arm-postgresql-flexible"; import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); /** * This sample demonstrates how to Get virtual network subnet usage for a given vNet resource id. @@ -21,7 +24,9 @@ import { DefaultAzureCredential } from "@azure/identity"; * x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2021-06-01/examples/VirtualNetworkSubnetUsage.json */ async function virtualNetworkSubnetUsageList() { - const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + const subscriptionId = + process.env["POSTGRESQL_SUBSCRIPTION_ID"] || + "ffffffff-ffff-ffff-ffff-ffffffffffff"; const locationName = "westus"; const parameters: VirtualNetworkSubnetUsageParameter = { virtualNetworkArmResourceId: @@ -39,4 +44,8 @@ async function virtualNetworkSubnetUsageList() { console.log(result); } -virtualNetworkSubnetUsageList().catch(console.error); +async function main() { + virtualNetworkSubnetUsageList(); +} + +main().catch(console.error); diff --git a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/tsconfig.json b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/tsconfig.json index 416c2dd82e00..e26ce2a6d8f7 100644 --- a/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/tsconfig.json +++ b/sdk/postgresql/arm-postgresql-flexible/samples/v6/typescript/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "ES2018", + "target": "ES2020", "module": "commonjs", "moduleResolution": "node", "resolveJsonModule": true, diff --git a/sdk/postgresql/arm-postgresql-flexible/src/index.ts b/sdk/postgresql/arm-postgresql-flexible/src/index.ts index f077f9b33bea..135211a7f2b2 100644 --- a/sdk/postgresql/arm-postgresql-flexible/src/index.ts +++ b/sdk/postgresql/arm-postgresql-flexible/src/index.ts @@ -7,6 +7,7 @@ */ /// +export { getContinuationToken } from "./pagingHelper"; export * from "./models"; export { PostgreSQLManagementFlexibleServerClient } from "./postgreSQLManagementFlexibleServerClient"; export * from "./operationsInterfaces"; diff --git a/sdk/postgresql/arm-postgresql-flexible/src/models/index.ts b/sdk/postgresql/arm-postgresql-flexible/src/models/index.ts index d3f77f48b01a..e4d9b9886d7a 100644 --- a/sdk/postgresql/arm-postgresql-flexible/src/models/index.ts +++ b/sdk/postgresql/arm-postgresql-flexible/src/models/index.ts @@ -551,18 +551,18 @@ export interface DatabaseListResult { } /** The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' */ -export type TrackedResource = Resource & { +export interface TrackedResource extends Resource { /** Resource tags. */ tags?: { [propertyName: string]: string }; /** The geo-location where the resource lives */ location: string; -}; +} /** The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location */ -export type ProxyResource = Resource & {}; +export interface ProxyResource extends Resource {} /** Represents a server. */ -export type Server = TrackedResource & { +export interface Server extends TrackedResource { /** The SKU (pricing tier) of the server. */ sku?: Sku; /** @@ -612,10 +612,10 @@ export type Server = TrackedResource & { availabilityZone?: string; /** The mode to create a new PostgreSQL server. */ createMode?: CreateMode; -}; +} /** Represents a server firewall rule. */ -export type FirewallRule = ProxyResource & { +export interface FirewallRule extends ProxyResource { /** * The system metadata relating to this resource. * NOTE: This property will not be serialized. It can only be populated by the server. @@ -625,10 +625,10 @@ export type FirewallRule = ProxyResource & { startIpAddress: string; /** The end IP address of the server firewall rule. Must be IPv4 format. */ endIpAddress: string; -}; +} /** Represents a Configuration. */ -export type Configuration = ProxyResource & { +export interface Configuration extends ProxyResource { /** * The system metadata relating to this resource. * NOTE: This property will not be serialized. It can only be populated by the server. @@ -683,10 +683,10 @@ export type Configuration = ProxyResource & { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly documentationLink?: string; -}; +} /** Represents a Database. */ -export type Database = ProxyResource & { +export interface Database extends ProxyResource { /** * The system metadata relating to this resource. * NOTE: This property will not be serialized. It can only be populated by the server. @@ -696,12 +696,15 @@ export type Database = ProxyResource & { charset?: string; /** The collation of the database. */ collation?: string; -}; +} /** Known values of {@link SkuTier} that the service accepts. */ export enum KnownSkuTier { + /** Burstable */ Burstable = "Burstable", + /** GeneralPurpose */ GeneralPurpose = "GeneralPurpose", + /** MemoryOptimized */ MemoryOptimized = "MemoryOptimized" } @@ -718,8 +721,11 @@ export type SkuTier = string; /** Known values of {@link ServerVersion} that the service accepts. */ export enum KnownServerVersion { + /** Thirteen */ Thirteen = "13", + /** Twelve */ Twelve = "12", + /** Eleven */ Eleven = "11" } @@ -736,12 +742,19 @@ export type ServerVersion = string; /** Known values of {@link ServerState} that the service accepts. */ export enum KnownServerState { + /** Ready */ Ready = "Ready", + /** Dropping */ Dropping = "Dropping", + /** Disabled */ Disabled = "Disabled", + /** Starting */ Starting = "Starting", + /** Stopping */ Stopping = "Stopping", + /** Stopped */ Stopped = "Stopped", + /** Updating */ Updating = "Updating" } @@ -762,7 +775,9 @@ export type ServerState = string; /** Known values of {@link GeoRedundantBackupEnum} that the service accepts. */ export enum KnownGeoRedundantBackupEnum { + /** Enabled */ Enabled = "Enabled", + /** Disabled */ Disabled = "Disabled" } @@ -778,7 +793,9 @@ export type GeoRedundantBackupEnum = string; /** Known values of {@link ServerPublicNetworkAccessState} that the service accepts. */ export enum KnownServerPublicNetworkAccessState { + /** Enabled */ Enabled = "Enabled", + /** Disabled */ Disabled = "Disabled" } @@ -794,7 +811,9 @@ export type ServerPublicNetworkAccessState = string; /** Known values of {@link HighAvailabilityMode} that the service accepts. */ export enum KnownHighAvailabilityMode { + /** Disabled */ Disabled = "Disabled", + /** ZoneRedundant */ ZoneRedundant = "ZoneRedundant" } @@ -810,11 +829,17 @@ export type HighAvailabilityMode = string; /** Known values of {@link ServerHAState} that the service accepts. */ export enum KnownServerHAState { + /** NotEnabled */ NotEnabled = "NotEnabled", + /** CreatingStandby */ CreatingStandby = "CreatingStandby", + /** ReplicatingData */ ReplicatingData = "ReplicatingData", + /** FailingOver */ FailingOver = "FailingOver", + /** Healthy */ Healthy = "Healthy", + /** RemovingStandby */ RemovingStandby = "RemovingStandby" } @@ -834,9 +859,13 @@ export type ServerHAState = string; /** Known values of {@link CreateMode} that the service accepts. */ export enum KnownCreateMode { + /** Default */ Default = "Default", + /** Create */ Create = "Create", + /** Update */ Update = "Update", + /** PointInTimeRestore */ PointInTimeRestore = "PointInTimeRestore" } @@ -854,9 +883,13 @@ export type CreateMode = string; /** Known values of {@link CreatedByType} that the service accepts. */ export enum KnownCreatedByType { + /** User */ User = "User", + /** Application */ Application = "Application", + /** ManagedIdentity */ ManagedIdentity = "ManagedIdentity", + /** Key */ Key = "Key" } @@ -874,7 +907,9 @@ export type CreatedByType = string; /** Known values of {@link CreateModeForUpdate} that the service accepts. */ export enum KnownCreateModeForUpdate { + /** Default */ Default = "Default", + /** Update */ Update = "Update" } @@ -890,9 +925,13 @@ export type CreateModeForUpdate = string; /** Known values of {@link FailoverMode} that the service accepts. */ export enum KnownFailoverMode { + /** PlannedFailover */ PlannedFailover = "PlannedFailover", + /** ForcedFailover */ ForcedFailover = "ForcedFailover", + /** PlannedSwitchover */ PlannedSwitchover = "PlannedSwitchover", + /** ForcedSwitchover */ ForcedSwitchover = "ForcedSwitchover" } @@ -910,9 +949,13 @@ export type FailoverMode = string; /** Known values of {@link ConfigurationDataType} that the service accepts. */ export enum KnownConfigurationDataType { + /** Boolean */ Boolean = "Boolean", + /** Numeric */ Numeric = "Numeric", + /** Integer */ Integer = "Integer", + /** Enumeration */ Enumeration = "Enumeration" } @@ -930,7 +973,9 @@ export type ConfigurationDataType = string; /** Known values of {@link Reason} that the service accepts. */ export enum KnownReason { + /** Invalid */ Invalid = "Invalid", + /** AlreadyExists */ AlreadyExists = "AlreadyExists" } @@ -946,8 +991,11 @@ export type Reason = string; /** Known values of {@link OperationOrigin} that the service accepts. */ export enum KnownOperationOrigin { + /** NotSpecified */ NotSpecified = "NotSpecified", + /** User */ User = "user", + /** System */ System = "system" } diff --git a/sdk/postgresql/arm-postgresql-flexible/src/operations/configurations.ts b/sdk/postgresql/arm-postgresql-flexible/src/operations/configurations.ts index 4813f22745a0..6b5aa8ee9953 100644 --- a/sdk/postgresql/arm-postgresql-flexible/src/operations/configurations.ts +++ b/sdk/postgresql/arm-postgresql-flexible/src/operations/configurations.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { Configurations } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -64,11 +65,15 @@ export class ConfigurationsImpl implements Configurations { [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listByServerPagingPage( resourceGroupName, serverName, - options + options, + settings ); } }; @@ -77,15 +82,18 @@ export class ConfigurationsImpl implements Configurations { private async *listByServerPagingPage( resourceGroupName: string, serverName: string, - options?: ConfigurationsListByServerOptionalParams + options?: ConfigurationsListByServerOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listByServer( - resourceGroupName, - serverName, - options - ); - yield result.value || []; - let continuationToken = result.nextLink; + let result: ConfigurationsListByServerResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listByServer(resourceGroupName, serverName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listByServerNext( resourceGroupName, @@ -94,7 +102,9 @@ export class ConfigurationsImpl implements Configurations { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -488,7 +498,6 @@ const listByServerNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, diff --git a/sdk/postgresql/arm-postgresql-flexible/src/operations/databases.ts b/sdk/postgresql/arm-postgresql-flexible/src/operations/databases.ts index 194969427168..2dfb33feef4d 100644 --- a/sdk/postgresql/arm-postgresql-flexible/src/operations/databases.ts +++ b/sdk/postgresql/arm-postgresql-flexible/src/operations/databases.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { Databases } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -18,12 +19,12 @@ import { Database, DatabasesListByServerNextOptionalParams, DatabasesListByServerOptionalParams, + DatabasesListByServerResponse, DatabasesCreateOptionalParams, DatabasesCreateResponse, DatabasesDeleteOptionalParams, DatabasesGetOptionalParams, DatabasesGetResponse, - DatabasesListByServerResponse, DatabasesListByServerNextResponse } from "../models"; @@ -63,11 +64,15 @@ export class DatabasesImpl implements Databases { [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listByServerPagingPage( resourceGroupName, serverName, - options + options, + settings ); } }; @@ -76,15 +81,18 @@ export class DatabasesImpl implements Databases { private async *listByServerPagingPage( resourceGroupName: string, serverName: string, - options?: DatabasesListByServerOptionalParams + options?: DatabasesListByServerOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listByServer( - resourceGroupName, - serverName, - options - ); - yield result.value || []; - let continuationToken = result.nextLink; + let result: DatabasesListByServerResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listByServer(resourceGroupName, serverName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listByServerNext( resourceGroupName, @@ -93,7 +101,9 @@ export class DatabasesImpl implements Databases { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -467,7 +477,6 @@ const listByServerNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, diff --git a/sdk/postgresql/arm-postgresql-flexible/src/operations/firewallRules.ts b/sdk/postgresql/arm-postgresql-flexible/src/operations/firewallRules.ts index f81070d751ba..90a1c8daae8b 100644 --- a/sdk/postgresql/arm-postgresql-flexible/src/operations/firewallRules.ts +++ b/sdk/postgresql/arm-postgresql-flexible/src/operations/firewallRules.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { FirewallRules } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -18,12 +19,12 @@ import { FirewallRule, FirewallRulesListByServerNextOptionalParams, FirewallRulesListByServerOptionalParams, + FirewallRulesListByServerResponse, FirewallRulesCreateOrUpdateOptionalParams, FirewallRulesCreateOrUpdateResponse, FirewallRulesDeleteOptionalParams, FirewallRulesGetOptionalParams, FirewallRulesGetResponse, - FirewallRulesListByServerResponse, FirewallRulesListByServerNextResponse } from "../models"; @@ -63,11 +64,15 @@ export class FirewallRulesImpl implements FirewallRules { [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listByServerPagingPage( resourceGroupName, serverName, - options + options, + settings ); } }; @@ -76,15 +81,18 @@ export class FirewallRulesImpl implements FirewallRules { private async *listByServerPagingPage( resourceGroupName: string, serverName: string, - options?: FirewallRulesListByServerOptionalParams + options?: FirewallRulesListByServerOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listByServer( - resourceGroupName, - serverName, - options - ); - yield result.value || []; - let continuationToken = result.nextLink; + let result: FirewallRulesListByServerResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listByServer(resourceGroupName, serverName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listByServerNext( resourceGroupName, @@ -93,7 +101,9 @@ export class FirewallRulesImpl implements FirewallRules { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -467,7 +477,6 @@ const listByServerNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, diff --git a/sdk/postgresql/arm-postgresql-flexible/src/operations/locationBasedCapabilities.ts b/sdk/postgresql/arm-postgresql-flexible/src/operations/locationBasedCapabilities.ts index f906b16c5e67..47ba8177ae3d 100644 --- a/sdk/postgresql/arm-postgresql-flexible/src/operations/locationBasedCapabilities.ts +++ b/sdk/postgresql/arm-postgresql-flexible/src/operations/locationBasedCapabilities.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { LocationBasedCapabilities } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -51,19 +52,29 @@ export class LocationBasedCapabilitiesImpl [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.executePagingPage(locationName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.executePagingPage(locationName, options, settings); } }; } private async *executePagingPage( locationName: string, - options?: LocationBasedCapabilitiesExecuteOptionalParams + options?: LocationBasedCapabilitiesExecuteOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._execute(locationName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: LocationBasedCapabilitiesExecuteResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._execute(locationName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._executeNext( locationName, @@ -71,7 +82,9 @@ export class LocationBasedCapabilitiesImpl options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -151,7 +164,6 @@ const executeNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, diff --git a/sdk/postgresql/arm-postgresql-flexible/src/operations/servers.ts b/sdk/postgresql/arm-postgresql-flexible/src/operations/servers.ts index 8d1e8808ef93..31daaf0db871 100644 --- a/sdk/postgresql/arm-postgresql-flexible/src/operations/servers.ts +++ b/sdk/postgresql/arm-postgresql-flexible/src/operations/servers.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { Servers } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -18,8 +19,10 @@ import { Server, ServersListByResourceGroupNextOptionalParams, ServersListByResourceGroupOptionalParams, + ServersListByResourceGroupResponse, ServersListNextOptionalParams, ServersListOptionalParams, + ServersListResponse, ServersCreateOptionalParams, ServersCreateResponse, ServerForUpdate, @@ -28,8 +31,6 @@ import { ServersDeleteOptionalParams, ServersGetOptionalParams, ServersGetResponse, - ServersListByResourceGroupResponse, - ServersListResponse, ServersRestartOptionalParams, ServersStartOptionalParams, ServersStopOptionalParams, @@ -67,19 +68,33 @@ export class ServersImpl implements Servers { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listByResourceGroupPagingPage(resourceGroupName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listByResourceGroupPagingPage( + resourceGroupName, + options, + settings + ); } }; } private async *listByResourceGroupPagingPage( resourceGroupName: string, - options?: ServersListByResourceGroupOptionalParams + options?: ServersListByResourceGroupOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listByResourceGroup(resourceGroupName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: ServersListByResourceGroupResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listByResourceGroup(resourceGroupName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listByResourceGroupNext( resourceGroupName, @@ -87,7 +102,9 @@ export class ServersImpl implements Servers { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -118,22 +135,34 @@ export class ServersImpl implements Servers { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); } }; } private async *listPagingPage( - options?: ServersListOptionalParams + options?: ServersListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: ServersListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -957,7 +986,6 @@ const listByResourceGroupNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, @@ -978,7 +1006,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, diff --git a/sdk/postgresql/arm-postgresql-flexible/src/pagingHelper.ts b/sdk/postgresql/arm-postgresql-flexible/src/pagingHelper.ts new file mode 100644 index 000000000000..269a2b9814b5 --- /dev/null +++ b/sdk/postgresql/arm-postgresql-flexible/src/pagingHelper.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export interface PageInfo { + continuationToken?: string; +} + +const pageMap = new WeakMap(); + +/** + * Given the last `.value` produced by the `byPage` iterator, + * returns a continuation token that can be used to begin paging from + * that point later. + * @param page An object from accessing `value` on the IteratorResult from a `byPage` iterator. + * @returns The continuation token that can be passed into byPage() during future calls. + */ +export function getContinuationToken(page: unknown): string | undefined { + if (typeof page !== "object" || page === null) { + return undefined; + } + return pageMap.get(page)?.continuationToken; +} + +export function setContinuationToken( + page: unknown, + continuationToken: string | undefined +): void { + if (typeof page !== "object" || page === null || !continuationToken) { + return; + } + const pageInfo = pageMap.get(page) ?? {}; + pageInfo.continuationToken = continuationToken; + pageMap.set(page, pageInfo); +} diff --git a/sdk/postgresql/arm-postgresql-flexible/src/postgreSQLManagementFlexibleServerClient.ts b/sdk/postgresql/arm-postgresql-flexible/src/postgreSQLManagementFlexibleServerClient.ts index 11e99549de60..f4de2d4562ce 100644 --- a/sdk/postgresql/arm-postgresql-flexible/src/postgreSQLManagementFlexibleServerClient.ts +++ b/sdk/postgresql/arm-postgresql-flexible/src/postgreSQLManagementFlexibleServerClient.ts @@ -8,6 +8,11 @@ import * as coreClient from "@azure/core-client"; import * as coreRestPipeline from "@azure/core-rest-pipeline"; +import { + PipelineRequest, + PipelineResponse, + SendRequest +} from "@azure/core-rest-pipeline"; import * as coreAuth from "@azure/core-auth"; import { ServersImpl, @@ -65,47 +70,53 @@ export class PostgreSQLManagementFlexibleServerClient extends coreClient.Service credential: credentials }; - const packageDetails = `azsdk-js-arm-postgresql-flexible/6.0.1`; + const packageDetails = `azsdk-js-arm-postgresql-flexible/6.1.0`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` : `${packageDetails}`; - if (!options.credentialScopes) { - options.credentialScopes = ["https://management.azure.com/.default"]; - } const optionsWithDefaults = { ...defaults, ...options, userAgentOptions: { userAgentPrefix }, - baseUri: + endpoint: options.endpoint ?? options.baseUri ?? "https://management.azure.com" }; super(optionsWithDefaults); + let bearerTokenAuthenticationPolicyFound: boolean = false; if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies(); - const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( + 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 - } - }) - ); - } + } + if ( + !options || + !options.pipeline || + options.pipeline.getOrderedPolicies().length == 0 || + !bearerTokenAuthenticationPolicyFound + ) { + this.pipeline.removePolicy({ + name: coreRestPipeline.bearerTokenAuthenticationPolicyName + }); + this.pipeline.addPolicy( + coreRestPipeline.bearerTokenAuthenticationPolicy({ + credential: credentials, + scopes: + optionsWithDefaults.credentialScopes ?? + `${optionsWithDefaults.endpoint}/.default`, + challengeCallbacks: { + authorizeRequestOnChallenge: + coreClient.authorizeRequestOnClaimChallenge + } + }) + ); } // Parameter assignments this.subscriptionId = subscriptionId; @@ -122,6 +133,35 @@ export class PostgreSQLManagementFlexibleServerClient extends coreClient.Service this.operations = new OperationsImpl(this); this.databases = new DatabasesImpl(this); this.getPrivateDnsZoneSuffix = new GetPrivateDnsZoneSuffixImpl(this); + this.addCustomApiVersionPolicy(options.apiVersion); + } + + /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */ + private addCustomApiVersionPolicy(apiVersion?: string) { + if (!apiVersion) { + return; + } + const apiVersionPolicy = { + name: "CustomApiVersionPolicy", + async sendRequest( + request: PipelineRequest, + next: SendRequest + ): Promise { + const param = request.url.split("?"); + if (param.length > 1) { + const newParams = param[1].split("&").map((item) => { + if (item.indexOf("api-version") > -1) { + return "api-version=" + apiVersion; + } else { + return item; + } + }); + request.url = param[0] + "?" + newParams.join("&"); + } + return next(request); + } + }; + this.pipeline.addPolicy(apiVersionPolicy); } servers: Servers; diff --git a/sdk/postgresql/arm-postgresql-flexible/test/sampleTest.ts b/sdk/postgresql/arm-postgresql-flexible/test/sampleTest.ts index 7ed89b043e1b..25aeb3ebcc36 100644 --- a/sdk/postgresql/arm-postgresql-flexible/test/sampleTest.ts +++ b/sdk/postgresql/arm-postgresql-flexible/test/sampleTest.ts @@ -7,35 +7,30 @@ */ import { - env, - record, - RecorderEnvironmentSetup, - Recorder + Recorder, + RecorderStartOptions, + env } from "@azure-tools/test-recorder"; -import * as assert from "assert"; +import { assert } from "chai"; +import { Context } from "mocha"; -const recorderEnvSetup: RecorderEnvironmentSetup = { - replaceableVariables: { - AZURE_CLIENT_ID: "azure_client_id", - AZURE_CLIENT_SECRET: "azure_client_secret", - AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", - SUBSCRIPTION_ID: "azure_subscription_id" - }, - customizationsOnRecordings: [ - (recording: any): any => - recording.replace( - /"access_token":"[^"]*"/g, - `"access_token":"access_token"` - ) - ], - queryParametersToSkip: [] +const replaceableVariables: Record = { + AZURE_CLIENT_ID: "azure_client_id", + AZURE_CLIENT_SECRET: "azure_client_secret", + AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", + SUBSCRIPTION_ID: "azure_subscription_id" +}; + +const recorderOptions: RecorderStartOptions = { + envSetupForPlayback: replaceableVariables }; describe("My test", () => { let recorder: Recorder; - beforeEach(async function() { - recorder = record(this, recorderEnvSetup); + beforeEach(async function(this: Context) { + recorder = new Recorder(this.currentTest); + await recorder.start(recorderOptions); }); afterEach(async function() { diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/CHANGELOG.md b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/CHANGELOG.md index f80e10b25e31..e5ca0f5ee618 100644 --- a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/CHANGELOG.md +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/CHANGELOG.md @@ -1,15 +1,42 @@ # Release History - -## 2.0.1 (Unreleased) - -### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes - + +## 2.1.0 (2022-12-22) + +**Features** + + - Added Interface DeploymentWhatIfProperties + - Added Interface GenericResource + - Added Interface GenericResourceExpanded + - Added function getContinuationToken + - Interface DeploymentOperationsListAtManagementGroupScopeNextOptionalParams no longer has parameter top + - Interface DeploymentOperationsListAtScopeNextOptionalParams no longer has parameter top + - Interface DeploymentOperationsListAtSubscriptionScopeNextOptionalParams no longer has parameter top + - Interface DeploymentOperationsListAtTenantScopeNextOptionalParams no longer has parameter top + - Interface DeploymentOperationsListNextOptionalParams no longer has parameter top + - Interface DeploymentsListAtManagementGroupScopeNextOptionalParams no longer has parameter filter + - Interface DeploymentsListAtManagementGroupScopeNextOptionalParams no longer has parameter top + - Interface DeploymentsListAtScopeNextOptionalParams no longer has parameter filter + - Interface DeploymentsListAtScopeNextOptionalParams no longer has parameter top + - Interface DeploymentsListAtSubscriptionScopeNextOptionalParams no longer has parameter filter + - Interface DeploymentsListAtSubscriptionScopeNextOptionalParams no longer has parameter top + - Interface DeploymentsListAtTenantScopeNextOptionalParams no longer has parameter filter + - Interface DeploymentsListAtTenantScopeNextOptionalParams no longer has parameter top + - Interface DeploymentsListByResourceGroupNextOptionalParams no longer has parameter filter + - Interface DeploymentsListByResourceGroupNextOptionalParams no longer has parameter top + - Interface ProvidersListAtTenantScopeNextOptionalParams no longer has parameter expand + - Interface ProvidersListAtTenantScopeNextOptionalParams no longer has parameter top + - Interface ProvidersListNextOptionalParams no longer has parameter expand + - Interface ProvidersListNextOptionalParams no longer has parameter top + - Interface ResourceGroupsListNextOptionalParams no longer has parameter filter + - Interface ResourceGroupsListNextOptionalParams no longer has parameter top + - Interface ResourcesListByResourceGroupNextOptionalParams no longer has parameter expand + - Interface ResourcesListByResourceGroupNextOptionalParams no longer has parameter filter + - Interface ResourcesListByResourceGroupNextOptionalParams no longer has parameter top + - Interface ResourcesListNextOptionalParams no longer has parameter expand + - Interface ResourcesListNextOptionalParams no longer has parameter filter + - Interface ResourcesListNextOptionalParams no longer has parameter top + + ## 2.0.0 (2022-03-08) The package of @azure/arm-resources-profile-2020-09-01-hybrid is using our next generation design principles since version 2.0.0, which contains breaking changes. diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/_meta.json b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/_meta.json index f9a9845ed297..d361d5556240 100644 --- a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/_meta.json +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/_meta.json @@ -1,7 +1,8 @@ { "commit": "989a7d0e47a71a77d9a8e56f2a3eee0d366b6909", "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:\\mydev\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\resources\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-beta.16 --tag=package-resources-2019-10 --profile-content=profile-hybrid-2020-09-01", + "autorest_command": "autorest --version=3.9.3 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=F:\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\resources\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-rc.5.20221215.1 --generate-sample=true --profile-content=profile-hybrid-2020-09-01 --tag=package-resources-2019-10", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "use": "@autorest/typescript@6.0.0-beta.16" + "release_tool": "@azure-tools/js-sdk-release-tools@2.5.4", + "use": "@autorest/typescript@6.0.0-rc.5.20221215.1" } \ No newline at end of file diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/package.json b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/package.json index 6a3655083327..ed5c233a4de7 100644 --- a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/package.json +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/package.json @@ -3,7 +3,7 @@ "sdk-type": "mgmt", "author": "Microsoft Corporation", "description": "A generated SDK for ResourceManagementClient.", - "version": "2.0.1", + "version": "2.1.0", "engines": { "node": ">=14.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.6.1", "@azure/core-auth": "^1.3.0", - "@azure/core-rest-pipeline": "^1.1.0", + "@azure/core-rest-pipeline": "^1.8.0", "tslib": "^2.2.0" }, "keywords": [ @@ -36,15 +36,20 @@ "mkdirp": "^1.0.4", "rollup": "^2.66.1", "rollup-plugin-sourcemaps": "^0.6.3", - "typescript": "~4.2.0", + "typescript": "~4.8.0", "uglify-js": "^3.4.9", "rimraf": "^3.0.0", + "dotenv": "^8.2.0", "@azure/identity": "^2.0.1", - "@azure-tools/test-recorder": "^1.0.0", + "@azure-tools/test-recorder": "^2.0.0", + "@azure-tools/test-credential": "^1.0.0", "mocha": "^7.1.1", - "cross-env": "^7.0.2" + "@types/chai": "^4.2.8", + "chai": "^4.2.0", + "cross-env": "^7.0.2", + "@types/node": "^14.0.0", + "@azure/dev-tool": "^1.0.0" }, - "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/resources/arm-resources-profile-2020-09-01-hybrid", "repository": { "type": "git", "url": "https://github.com/Azure/azure-sdk-for-js.git" @@ -93,9 +98,8 @@ "unit-test:node": "cross-env TEST_MODE=playback npm run integration-test:node", "unit-test:browser": "echo skipped", "integration-test": "npm run integration-test:node && npm run integration-test:browser", - "integration-test:node": "mocha -r esm --require ts-node/register --timeout 1200000 --full-trace test/*.ts --reporter ../../../common/tools/mocha-multi-reporter.js", - "integration-test:browser": "echo skipped", - "docs": "echo skipped" + "integration-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 'test/*.ts'", + "integration-test:browser": "echo skipped" }, "sideEffects": false, "//metadata": { @@ -106,5 +110,14 @@ } ] }, - "autoPublish": true + "autoPublish": true, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/resources/arm-resources-profile-2020-09-01-hybrid", + "//sampleConfiguration": { + "productName": "", + "productSlugs": [ + "azure" + ], + "disableDocsMs": true, + "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-resources-profile-2020-09-01-hybrid?view=azure-node-preview" + } } diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/recordings/node/my_test/recording_sample_test.json b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/recordings/node/my_test/recording_sample_test.json new file mode 100644 index 000000000000..f721723386d8 --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/recordings/node/my_test/recording_sample_test.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/review/arm-resources-profile-2020-09-01-hybrid.api.md b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/review/arm-resources-profile-2020-09-01-hybrid.api.md index 3faadec3411c..b5f1a07be9ef 100644 --- a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/review/arm-resources-profile-2020-09-01-hybrid.api.md +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/review/arm-resources-profile-2020-09-01-hybrid.api.md @@ -179,7 +179,6 @@ export type DeploymentOperationsGetResponse = DeploymentOperation; // @public export interface DeploymentOperationsListAtManagementGroupScopeNextOptionalParams extends coreClient.OperationOptions { - top?: number; } // @public @@ -195,7 +194,6 @@ export type DeploymentOperationsListAtManagementGroupScopeResponse = DeploymentO // @public export interface DeploymentOperationsListAtScopeNextOptionalParams extends coreClient.OperationOptions { - top?: number; } // @public @@ -211,7 +209,6 @@ export type DeploymentOperationsListAtScopeResponse = DeploymentOperationsListRe // @public export interface DeploymentOperationsListAtSubscriptionScopeNextOptionalParams extends coreClient.OperationOptions { - top?: number; } // @public @@ -227,7 +224,6 @@ export type DeploymentOperationsListAtSubscriptionScopeResponse = DeploymentOper // @public export interface DeploymentOperationsListAtTenantScopeNextOptionalParams extends coreClient.OperationOptions { - top?: number; } // @public @@ -243,7 +239,6 @@ export type DeploymentOperationsListAtTenantScopeResponse = DeploymentOperations // @public export interface DeploymentOperationsListNextOptionalParams extends coreClient.OperationOptions { - top?: number; } // @public @@ -582,8 +577,6 @@ export type DeploymentsGetResponse = DeploymentExtended; // @public export interface DeploymentsListAtManagementGroupScopeNextOptionalParams extends coreClient.OperationOptions { - filter?: string; - top?: number; } // @public @@ -600,8 +593,6 @@ export type DeploymentsListAtManagementGroupScopeResponse = DeploymentListResult // @public export interface DeploymentsListAtScopeNextOptionalParams extends coreClient.OperationOptions { - filter?: string; - top?: number; } // @public @@ -618,8 +609,6 @@ export type DeploymentsListAtScopeResponse = DeploymentListResult; // @public export interface DeploymentsListAtSubscriptionScopeNextOptionalParams extends coreClient.OperationOptions { - filter?: string; - top?: number; } // @public @@ -636,8 +625,6 @@ export type DeploymentsListAtSubscriptionScopeResponse = DeploymentListResult; // @public export interface DeploymentsListAtTenantScopeNextOptionalParams extends coreClient.OperationOptions { - filter?: string; - top?: number; } // @public @@ -654,8 +641,6 @@ export type DeploymentsListAtTenantScopeResponse = DeploymentListResult; // @public export interface DeploymentsListByResourceGroupNextOptionalParams extends coreClient.OperationOptions { - filter?: string; - top?: number; } // @public @@ -788,9 +773,9 @@ export interface DeploymentWhatIf { } // @public -export type DeploymentWhatIfProperties = DeploymentProperties & { +export interface DeploymentWhatIfProperties extends DeploymentProperties { whatIfSettings?: DeploymentWhatIfSettings; -}; +} // @public export interface DeploymentWhatIfSettings { @@ -819,21 +804,21 @@ export interface ExportTemplateRequest { } // @public -export type GenericResource = Resource & { - plan?: Plan; - properties?: Record; +export interface GenericResource extends Resource { + identity?: Identity; kind?: string; managedBy?: string; + plan?: Plan; + properties?: Record; sku?: Sku; - identity?: Identity; -}; +} // @public -export type GenericResourceExpanded = GenericResource & { - readonly createdTime?: Date; +export interface GenericResourceExpanded extends GenericResource { readonly changedTime?: Date; + readonly createdTime?: Date; readonly provisioningState?: string; -}; +} // @public export interface GenericResourceFilter { @@ -842,6 +827,9 @@ export interface GenericResourceFilter { tagvalue?: string; } +// @public +export function getContinuationToken(page: unknown): string | undefined; + // @public export interface HttpMessage { content?: Record; @@ -1000,8 +988,6 @@ export type ProvidersGetResponse = Provider; // @public export interface ProvidersListAtTenantScopeNextOptionalParams extends coreClient.OperationOptions { - expand?: string; - top?: number; } // @public @@ -1018,8 +1004,6 @@ export type ProvidersListAtTenantScopeResponse = ProviderListResult; // @public export interface ProvidersListNextOptionalParams extends coreClient.OperationOptions { - expand?: string; - top?: number; } // @public @@ -1161,8 +1145,6 @@ export type ResourceGroupsGetResponse = ResourceGroup; // @public export interface ResourceGroupsListNextOptionalParams extends coreClient.OperationOptions { - filter?: string; - top?: number; } // @public @@ -1329,9 +1311,6 @@ export type ResourcesGetResponse = GenericResource; // @public export interface ResourcesListByResourceGroupNextOptionalParams extends coreClient.OperationOptions { - expand?: string; - filter?: string; - top?: number; } // @public @@ -1349,9 +1328,6 @@ export type ResourcesListByResourceGroupResponse = ResourceListResult; // @public export interface ResourcesListNextOptionalParams extends coreClient.OperationOptions { - expand?: string; - filter?: string; - top?: number; } // @public diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/sample.env b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/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-profile-2020-09-01-hybrid/samples-dev/deploymentsCalculateTemplateHashSample.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/deploymentsCalculateTemplateHashSample.ts new file mode 100644 index 000000000000..78a94cc6a46f --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/deploymentsCalculateTemplateHashSample.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { ResourceManagementClient } from "@azure/arm-resources-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2019-10-01/examples/CalculateTemplateHash.json + */ +async function calculateTemplateHash() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "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); +} + +async function main() { + calculateTemplateHash(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/deploymentsCreateOrUpdateAtManagementGroupScopeSample.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/deploymentsCreateOrUpdateAtManagementGroupScopeSample.ts new file mode 100644 index 000000000000..2d71a6abef2c --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/deploymentsCreateOrUpdateAtManagementGroupScopeSample.ts @@ -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. +import { + ScopedDeployment, + ResourceManagementClient +} from "@azure/arm-resources-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2019-10-01/examples/PutDeploymentAtManagementGroup.json + */ +async function createDeploymentAtManagementGroupScope() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const groupId = "tiano-group1"; + const deploymentName = "mg-dep01"; + const parameters: ScopedDeployment = { + location: "eastus", + properties: { + mode: "Incremental", + parameters: {}, + templateLink: { uri: "{templateUri}" } + } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAtManagementGroupScopeAndWait( + groupId, + deploymentName, + parameters + ); + console.log(result); +} + +async function main() { + createDeploymentAtManagementGroupScope(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/deploymentsCreateOrUpdateAtScopeSample.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/deploymentsCreateOrUpdateAtScopeSample.ts new file mode 100644 index 000000000000..40e310f68498 --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/deploymentsCreateOrUpdateAtScopeSample.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 { + Deployment, + ResourceManagementClient +} from "@azure/arm-resources-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2019-10-01/examples/PutDeploymentAtScope.json + */ +async function createDeploymentAtAGivenScope() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = "providers/Microsoft.Management/managementGroups/tiano-group1"; + const deploymentName = "mg-dep01"; + const parameters: Deployment = { + location: "eastus", + properties: { + mode: "Incremental", + parameters: {}, + templateLink: { uri: "{templateUri}" } + }, + tags: { tagKey1: "tagValue1", tagKey2: "tagValue2" } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAtScopeAndWait( + scope, + deploymentName, + parameters + ); + console.log(result); +} + +async function main() { + createDeploymentAtAGivenScope(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/deploymentsCreateOrUpdateAtTenantScopeSample.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/deploymentsCreateOrUpdateAtTenantScopeSample.ts new file mode 100644 index 000000000000..d29490630b0a --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/deploymentsCreateOrUpdateAtTenantScopeSample.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 { + ScopedDeployment, + ResourceManagementClient +} from "@azure/arm-resources-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2019-10-01/examples/PutDeploymentAtTenant.json + */ +async function createDeploymentAtTenantScope() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const deploymentName = "tenant-dep01"; + const parameters: ScopedDeployment = { + location: "eastus", + properties: { + mode: "Incremental", + parameters: {}, + templateLink: { uri: "{templateUri}" } + }, + tags: { tagKey1: "tagValue1", tagKey2: "tagValue2" } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAtTenantScopeAndWait( + deploymentName, + parameters + ); + console.log(result); +} + +async function main() { + createDeploymentAtTenantScope(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/deploymentsCreateOrUpdateSample.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/deploymentsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..709e55c4a3cc --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/deploymentsCreateOrUpdateSample.ts @@ -0,0 +1,88 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * 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-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2019-10-01/examples/PutDeploymentWithOnErrorDeploymentSpecificDeployment.json + */ +async function createADeploymentThatWillRedeployAnotherDeploymentOnFailure() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || "{subscriptionId}"; + const resourceGroupName = + process.env["RESOURCES_RESOURCE_GROUP"] || "myResourceGroup"; + const deploymentName = "exampleDeploymentName"; + const parameters: Deployment = { + properties: { + mode: "Complete", + onErrorDeployment: { + type: "SpecificDeployment", + deploymentName: "{nameOfDeploymentToUse}" + }, + parameters: {}, + templateLink: { uri: "{templateUri}" } + } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAndWait( + resourceGroupName, + deploymentName, + parameters + ); + console.log(result); +} + +/** + * 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/2019-10-01/examples/PutDeploymentWithOnErrorDeploymentLastSuccessful.json + */ +async function createADeploymentThatWillRedeployTheLastSuccessfulDeploymentOnFailure() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || "{subscriptionId}"; + const resourceGroupName = + process.env["RESOURCES_RESOURCE_GROUP"] || "myResourceGroup"; + const deploymentName = "exampleDeploymentName"; + const parameters: Deployment = { + properties: { + mode: "Complete", + onErrorDeployment: { type: "LastSuccessful" }, + parameters: {}, + templateLink: { uri: "{templateUri}" } + } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAndWait( + resourceGroupName, + deploymentName, + parameters + ); + console.log(result); +} + +async function main() { + createADeploymentThatWillRedeployAnotherDeploymentOnFailure(); + createADeploymentThatWillRedeployTheLastSuccessfulDeploymentOnFailure(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/deploymentsWhatIfAtManagementGroupScopeSample.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/deploymentsWhatIfAtManagementGroupScopeSample.ts new file mode 100644 index 000000000000..933e9a3a9fb4 --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/deploymentsWhatIfAtManagementGroupScopeSample.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 { + ScopedDeploymentWhatIf, + ResourceManagementClient +} from "@azure/arm-resources-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2019-10-01/examples/PostDeploymentWhatIfOnManagementGroup.json + */ +async function predictTemplateChangesAtManagementGroupScope() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const groupId = "myManagementGruop"; + const deploymentName = "exampleDeploymentName"; + const parameters: ScopedDeploymentWhatIf = { + 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.beginWhatIfAtManagementGroupScopeAndWait( + groupId, + deploymentName, + parameters + ); + console.log(result); +} + +async function main() { + predictTemplateChangesAtManagementGroupScope(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/deploymentsWhatIfAtSubscriptionScopeSample.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/deploymentsWhatIfAtSubscriptionScopeSample.ts new file mode 100644 index 000000000000..642d678bc436 --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/deploymentsWhatIfAtSubscriptionScopeSample.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 { + DeploymentWhatIf, + ResourceManagementClient +} from "@azure/arm-resources-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2019-10-01/examples/PostDeploymentWhatIfOnSubscription.json + */ +async function predictTemplateChangesAtSubscriptionScope() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000001"; + const deploymentName = "exampleDeploymentName"; + const parameters: DeploymentWhatIf = { + location: "westus", + 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.beginWhatIfAtSubscriptionScopeAndWait( + deploymentName, + parameters + ); + console.log(result); +} + +async function main() { + predictTemplateChangesAtSubscriptionScope(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/deploymentsWhatIfAtTenantScopeSample.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/deploymentsWhatIfAtTenantScopeSample.ts new file mode 100644 index 000000000000..8062cb1a1614 --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/deploymentsWhatIfAtTenantScopeSample.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 { + ScopedDeploymentWhatIf, + ResourceManagementClient +} from "@azure/arm-resources-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2019-10-01/examples/PostDeploymentWhatIfOnTenant.json + */ +async function predictTemplateChangesAtManagementGroupScope() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const deploymentName = "exampleDeploymentName"; + const parameters: ScopedDeploymentWhatIf = { + 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.beginWhatIfAtTenantScopeAndWait( + deploymentName, + parameters + ); + console.log(result); +} + +async function main() { + predictTemplateChangesAtManagementGroupScope(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/deploymentsWhatIfSample.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/deploymentsWhatIfSample.ts new file mode 100644 index 000000000000..f78da703330d --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/deploymentsWhatIfSample.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 { + DeploymentWhatIf, + ResourceManagementClient +} from "@azure/arm-resources-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2019-10-01/examples/PostDeploymentWhatIfOnResourceGroup.json + */ +async function predictTemplateChangesAtResourceGroupScope() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000001"; + const resourceGroupName = + process.env["RESOURCES_RESOURCE_GROUP"] || "myResourceGroup"; + const deploymentName = "exampleDeploymentName"; + const parameters: DeploymentWhatIf = { + 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.beginWhatIfAndWait( + resourceGroupName, + deploymentName, + parameters + ); + console.log(result); +} + +async function main() { + predictTemplateChangesAtResourceGroupScope(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/resourceGroupsCreateOrUpdateSample.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/resourceGroupsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..7ea72f1d4ec1 --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/resourceGroupsCreateOrUpdateSample.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 { + ResourceGroup, + ResourceManagementClient +} from "@azure/arm-resources-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2019-10-01/examples/CreateResourceGroup.json + */ +async function createOrUpdateAResourceGroup() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = + process.env["RESOURCES_RESOURCE_GROUP"] || "myResourceGroup"; + 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); +} + +async function main() { + createOrUpdateAResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/resourceGroupsExportTemplateSample.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/resourceGroupsExportTemplateSample.ts new file mode 100644 index 000000000000..14479017351a --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/resourceGroupsExportTemplateSample.ts @@ -0,0 +1,77 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * 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-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2019-10-01/examples/ExportResourceGroup.json + */ +async function exportAResourceGroup() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "eaee6a92-e973-4922-9471-3a0a6abf81cd"; + const resourceGroupName = + process.env["RESOURCES_RESOURCE_GROUP"] || "myResourceGroup"; + 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); +} + +/** + * 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/2019-10-01/examples/ExportResourceGroupWithFiltering.json + */ +async function exportAResourceGroupWithFiltering() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "eaee6a92-e973-4922-9471-3a0a6abf81cd"; + const resourceGroupName = + process.env["RESOURCES_RESOURCE_GROUP"] || "myResourceGroup"; + const parameters: ExportTemplateRequest = { + options: "SkipResourceNameParameterization", + resources: [ + "/subscriptions/eaee6a92-e973-4922-9471-3a0a6abf81cd/resourceGroups/myResourceGroup/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); +} + +async function main() { + exportAResourceGroup(); + exportAResourceGroupWithFiltering(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/tagsCreateOrUpdateAtScopeSample.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/tagsCreateOrUpdateAtScopeSample.ts new file mode 100644 index 000000000000..5f52bbcd7455 --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/tagsCreateOrUpdateAtScopeSample.ts @@ -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. +import { + TagsResource, + ResourceManagementClient +} from "@azure/arm-resources-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2019-10-01/examples/PutTagsResource.json + */ +async function updateTagsOnAResource() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "subscriptions/eaee6a92-e973-4922-9471-3a0a6abf81cd/resourcegroups/myResourceGroup/providers/myPRNameSpace/VM/myVm"; + const parameters: TagsResource = { + properties: { tags: { tagKey1: "tagValue1", tagKey2: "tagValue2" } } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.tagsOperations.createOrUpdateAtScope( + scope, + parameters + ); + console.log(result); +} + +/** + * 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/2019-10-01/examples/PutTagsSubscription.json + */ +async function updateTagsOnASubscription() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/eaee6a92-e973-4922-9471-3a0a6abf81cd"; + const parameters: TagsResource = { + properties: { tags: { tagKey1: "tagValue1", tagKey2: "tagValue2" } } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.tagsOperations.createOrUpdateAtScope( + scope, + parameters + ); + console.log(result); +} + +async function main() { + updateTagsOnAResource(); + updateTagsOnASubscription(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/tagsGetAtScopeSample.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/tagsGetAtScopeSample.ts new file mode 100644 index 000000000000..1b5b6d4a1f53 --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples-dev/tagsGetAtScopeSample.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * 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-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2019-10-01/examples/GetTagsResource.json + */ +async function getTagsOnAResource() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "subscriptions/eaee6a92-e973-4922-9471-3a0a6abf81cd/resourcegroups/myResourceGroup/providers/myPRNameSpace/VM/myVm"; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.tagsOperations.getAtScope(scope); + console.log(result); +} + +/** + * 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/2019-10-01/examples/GetTagsSubscription.json + */ +async function getTagsOnASubscription() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/eaee6a92-e973-4922-9471-3a0a6abf81cd"; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.tagsOperations.getAtScope(scope); + console.log(result); +} + +async function main() { + getTagsOnAResource(); + getTagsOnASubscription(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/README.md b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/README.md new file mode 100644 index 000000000000..63fac1abc9a2 --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/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** | +| ----------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| [deploymentsCalculateTemplateHashSample.js][deploymentscalculatetemplatehashsample] | Calculate the hash of the given template. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2019-10-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/2019-10-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/2019-10-01/examples/PutDeploymentAtScope.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/2019-10-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/2019-10-01/examples/PutDeploymentWithOnErrorDeploymentSpecificDeployment.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/2019-10-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/2019-10-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/2019-10-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/2019-10-01/examples/PostDeploymentWhatIfOnResourceGroup.json | +| [resourceGroupsCreateOrUpdateSample.js][resourcegroupscreateorupdatesample] | Creates or updates a resource group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2019-10-01/examples/CreateResourceGroup.json | +| [resourceGroupsExportTemplateSample.js][resourcegroupsexporttemplatesample] | Captures the specified resource group as a template. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2019-10-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/2019-10-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/2019-10-01/examples/GetTagsResource.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). + +You need [an Azure subscription][freesub] to run these sample programs. + +Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. + +Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. + +## Setup + +To run the samples using the published version of the package: + +1. Install the dependencies using `npm`: + +```bash +npm install +``` + +2. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. + +3. Run whichever samples you like (note that some samples may require additional setup, see the table above): + +```bash +node 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 RESOURCES_SUBSCRIPTION_ID="" 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-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsCalculateTemplateHashSample.js +[deploymentscreateorupdateatmanagementgroupscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsCreateOrUpdateAtManagementGroupScopeSample.js +[deploymentscreateorupdateatscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsCreateOrUpdateAtScopeSample.js +[deploymentscreateorupdateattenantscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsCreateOrUpdateAtTenantScopeSample.js +[deploymentscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsCreateOrUpdateSample.js +[deploymentswhatifatmanagementgroupscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsWhatIfAtManagementGroupScopeSample.js +[deploymentswhatifatsubscriptionscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsWhatIfAtSubscriptionScopeSample.js +[deploymentswhatifattenantscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsWhatIfAtTenantScopeSample.js +[deploymentswhatifsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsWhatIfSample.js +[resourcegroupscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/resourceGroupsCreateOrUpdateSample.js +[resourcegroupsexporttemplatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/resourceGroupsExportTemplateSample.js +[tagscreateorupdateatscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/tagsCreateOrUpdateAtScopeSample.js +[tagsgetatscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/tagsGetAtScopeSample.js +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-resources-profile-2020-09-01-hybrid?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-profile-2020-09-01-hybrid/README.md diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsCalculateTemplateHashSample.js b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsCalculateTemplateHashSample.js new file mode 100644 index 000000000000..8a4c6fe0eedb --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsCalculateTemplateHashSample.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 { ResourceManagementClient } = require("@azure/arm-resources-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * 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/2019-10-01/examples/CalculateTemplateHash.json + */ +async function calculateTemplateHash() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || "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); +} + +async function main() { + calculateTemplateHash(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsCreateOrUpdateAtManagementGroupScopeSample.js b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsCreateOrUpdateAtManagementGroupScopeSample.js new file mode 100644 index 000000000000..757bd4c2422b --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsCreateOrUpdateAtManagementGroupScopeSample.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 { ResourceManagementClient } = require("@azure/arm-resources-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * 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/2019-10-01/examples/PutDeploymentAtManagementGroup.json + */ +async function createDeploymentAtManagementGroupScope() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const groupId = "tiano-group1"; + const deploymentName = "mg-dep01"; + const parameters = { + location: "eastus", + properties: { + mode: "Incremental", + parameters: {}, + templateLink: { uri: "{templateUri}" }, + }, + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAtManagementGroupScopeAndWait( + groupId, + deploymentName, + parameters + ); + console.log(result); +} + +async function main() { + createDeploymentAtManagementGroupScope(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsCreateOrUpdateAtScopeSample.js b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsCreateOrUpdateAtScopeSample.js new file mode 100644 index 000000000000..d8d3f1faa79e --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsCreateOrUpdateAtScopeSample.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 { ResourceManagementClient } = require("@azure/arm-resources-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * 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/2019-10-01/examples/PutDeploymentAtScope.json + */ +async function createDeploymentAtAGivenScope() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = "providers/Microsoft.Management/managementGroups/tiano-group1"; + const deploymentName = "mg-dep01"; + const parameters = { + location: "eastus", + properties: { + mode: "Incremental", + parameters: {}, + templateLink: { uri: "{templateUri}" }, + }, + tags: { tagKey1: "tagValue1", tagKey2: "tagValue2" }, + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAtScopeAndWait( + scope, + deploymentName, + parameters + ); + console.log(result); +} + +async function main() { + createDeploymentAtAGivenScope(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsCreateOrUpdateAtTenantScopeSample.js b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsCreateOrUpdateAtTenantScopeSample.js new file mode 100644 index 000000000000..3b79a3231ef3 --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsCreateOrUpdateAtTenantScopeSample.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-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * 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/2019-10-01/examples/PutDeploymentAtTenant.json + */ +async function createDeploymentAtTenantScope() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const deploymentName = "tenant-dep01"; + const parameters = { + location: "eastus", + properties: { + mode: "Incremental", + parameters: {}, + templateLink: { uri: "{templateUri}" }, + }, + tags: { tagKey1: "tagValue1", tagKey2: "tagValue2" }, + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAtTenantScopeAndWait( + deploymentName, + parameters + ); + console.log(result); +} + +async function main() { + createDeploymentAtTenantScope(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsCreateOrUpdateSample.js b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsCreateOrUpdateSample.js new file mode 100644 index 000000000000..72e2e95befde --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsCreateOrUpdateSample.js @@ -0,0 +1,79 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { ResourceManagementClient } = require("@azure/arm-resources-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * 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/2019-10-01/examples/PutDeploymentWithOnErrorDeploymentSpecificDeployment.json + */ +async function createADeploymentThatWillRedeployAnotherDeploymentOnFailure() { + const subscriptionId = process.env["RESOURCES_SUBSCRIPTION_ID"] || "{subscriptionId}"; + const resourceGroupName = process.env["RESOURCES_RESOURCE_GROUP"] || "myResourceGroup"; + const deploymentName = "exampleDeploymentName"; + const parameters = { + properties: { + mode: "Complete", + onErrorDeployment: { + type: "SpecificDeployment", + deploymentName: "{nameOfDeploymentToUse}", + }, + parameters: {}, + templateLink: { uri: "{templateUri}" }, + }, + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAndWait( + resourceGroupName, + deploymentName, + parameters + ); + console.log(result); +} + +/** + * 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/2019-10-01/examples/PutDeploymentWithOnErrorDeploymentLastSuccessful.json + */ +async function createADeploymentThatWillRedeployTheLastSuccessfulDeploymentOnFailure() { + const subscriptionId = process.env["RESOURCES_SUBSCRIPTION_ID"] || "{subscriptionId}"; + const resourceGroupName = process.env["RESOURCES_RESOURCE_GROUP"] || "myResourceGroup"; + const deploymentName = "exampleDeploymentName"; + const parameters = { + properties: { + mode: "Complete", + onErrorDeployment: { type: "LastSuccessful" }, + parameters: {}, + templateLink: { uri: "{templateUri}" }, + }, + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAndWait( + resourceGroupName, + deploymentName, + parameters + ); + console.log(result); +} + +async function main() { + createADeploymentThatWillRedeployAnotherDeploymentOnFailure(); + createADeploymentThatWillRedeployTheLastSuccessfulDeploymentOnFailure(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsWhatIfAtManagementGroupScopeSample.js b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsWhatIfAtManagementGroupScopeSample.js new file mode 100644 index 000000000000..69e2d9e74ed9 --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsWhatIfAtManagementGroupScopeSample.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 { ResourceManagementClient } = require("@azure/arm-resources-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * 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/2019-10-01/examples/PostDeploymentWhatIfOnManagementGroup.json + */ +async function predictTemplateChangesAtManagementGroupScope() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const groupId = "myManagementGruop"; + const deploymentName = "exampleDeploymentName"; + 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.beginWhatIfAtManagementGroupScopeAndWait( + groupId, + deploymentName, + parameters + ); + console.log(result); +} + +async function main() { + predictTemplateChangesAtManagementGroupScope(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsWhatIfAtSubscriptionScopeSample.js b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsWhatIfAtSubscriptionScopeSample.js new file mode 100644 index 000000000000..ada15aa09e5a --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsWhatIfAtSubscriptionScopeSample.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 { ResourceManagementClient } = require("@azure/arm-resources-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * 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/2019-10-01/examples/PostDeploymentWhatIfOnSubscription.json + */ +async function predictTemplateChangesAtSubscriptionScope() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000001"; + const deploymentName = "exampleDeploymentName"; + const parameters = { + location: "westus", + 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.beginWhatIfAtSubscriptionScopeAndWait( + deploymentName, + parameters + ); + console.log(result); +} + +async function main() { + predictTemplateChangesAtSubscriptionScope(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsWhatIfAtTenantScopeSample.js b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsWhatIfAtTenantScopeSample.js new file mode 100644 index 000000000000..1336690f9fc2 --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsWhatIfAtTenantScopeSample.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 { ResourceManagementClient } = require("@azure/arm-resources-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * 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/2019-10-01/examples/PostDeploymentWhatIfOnTenant.json + */ +async function predictTemplateChangesAtManagementGroupScope() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const deploymentName = "exampleDeploymentName"; + 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.beginWhatIfAtTenantScopeAndWait( + deploymentName, + parameters + ); + console.log(result); +} + +async function main() { + predictTemplateChangesAtManagementGroupScope(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsWhatIfSample.js b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsWhatIfSample.js new file mode 100644 index 000000000000..64f23830c3b3 --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/deploymentsWhatIfSample.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-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * 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/2019-10-01/examples/PostDeploymentWhatIfOnResourceGroup.json + */ +async function predictTemplateChangesAtResourceGroupScope() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000001"; + const resourceGroupName = process.env["RESOURCES_RESOURCE_GROUP"] || "myResourceGroup"; + const deploymentName = "exampleDeploymentName"; + const parameters = { + 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.beginWhatIfAndWait( + resourceGroupName, + deploymentName, + parameters + ); + console.log(result); +} + +async function main() { + predictTemplateChangesAtResourceGroupScope(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/package.json b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/package.json new file mode 100644 index 000000000000..8d09c1ab57bf --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/package.json @@ -0,0 +1,32 @@ +{ + "name": "@azure-samples/arm-resources-profile-2020-09-01-hybrid-js", + "private": true, + "version": "1.0.0", + "description": " client library samples for JavaScript", + "engines": { + "node": ">=14.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/resources/arm-resources-profile-2020-09-01-hybrid" + }, + "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-profile-2020-09-01-hybrid", + "dependencies": { + "@azure/arm-resources-profile-2020-09-01-hybrid": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + } +} diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/resourceGroupsCreateOrUpdateSample.js b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/resourceGroupsCreateOrUpdateSample.js new file mode 100644 index 000000000000..d5e9cb26e8fa --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/resourceGroupsCreateOrUpdateSample.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 { ResourceManagementClient } = require("@azure/arm-resources-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * 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/2019-10-01/examples/CreateResourceGroup.json + */ +async function createOrUpdateAResourceGroup() { + const subscriptionId = process.env["RESOURCES_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["RESOURCES_RESOURCE_GROUP"] || "myResourceGroup"; + 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); +} + +async function main() { + createOrUpdateAResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/resourceGroupsExportTemplateSample.js b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/resourceGroupsExportTemplateSample.js new file mode 100644 index 000000000000..34382050fafe --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/resourceGroupsExportTemplateSample.js @@ -0,0 +1,68 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * 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-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * 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/2019-10-01/examples/ExportResourceGroup.json + */ +async function exportAResourceGroup() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || "eaee6a92-e973-4922-9471-3a0a6abf81cd"; + const resourceGroupName = process.env["RESOURCES_RESOURCE_GROUP"] || "myResourceGroup"; + 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); +} + +/** + * 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/2019-10-01/examples/ExportResourceGroupWithFiltering.json + */ +async function exportAResourceGroupWithFiltering() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || "eaee6a92-e973-4922-9471-3a0a6abf81cd"; + const resourceGroupName = process.env["RESOURCES_RESOURCE_GROUP"] || "myResourceGroup"; + const parameters = { + options: "SkipResourceNameParameterization", + resources: [ + "/subscriptions/eaee6a92-e973-4922-9471-3a0a6abf81cd/resourceGroups/myResourceGroup/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); +} + +async function main() { + exportAResourceGroup(); + exportAResourceGroupWithFiltering(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/sample.env b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/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/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/tagsCreateOrUpdateAtScopeSample.js b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/tagsCreateOrUpdateAtScopeSample.js new file mode 100644 index 000000000000..db4e05fcc49a --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/tagsCreateOrUpdateAtScopeSample.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 { ResourceManagementClient } = require("@azure/arm-resources-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * 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/2019-10-01/examples/PutTagsResource.json + */ +async function updateTagsOnAResource() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "subscriptions/eaee6a92-e973-4922-9471-3a0a6abf81cd/resourcegroups/myResourceGroup/providers/myPRNameSpace/VM/myVm"; + const parameters = { + properties: { tags: { tagKey1: "tagValue1", tagKey2: "tagValue2" } }, + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.tagsOperations.createOrUpdateAtScope(scope, parameters); + console.log(result); +} + +/** + * 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/2019-10-01/examples/PutTagsSubscription.json + */ +async function updateTagsOnASubscription() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/eaee6a92-e973-4922-9471-3a0a6abf81cd"; + const parameters = { + properties: { tags: { tagKey1: "tagValue1", tagKey2: "tagValue2" } }, + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.tagsOperations.createOrUpdateAtScope(scope, parameters); + console.log(result); +} + +async function main() { + updateTagsOnAResource(); + updateTagsOnASubscription(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/tagsGetAtScopeSample.js b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/tagsGetAtScopeSample.js new file mode 100644 index 000000000000..25164217ff2b --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/javascript/tagsGetAtScopeSample.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-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * 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/2019-10-01/examples/GetTagsResource.json + */ +async function getTagsOnAResource() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = + "subscriptions/eaee6a92-e973-4922-9471-3a0a6abf81cd/resourcegroups/myResourceGroup/providers/myPRNameSpace/VM/myVm"; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.tagsOperations.getAtScope(scope); + console.log(result); +} + +/** + * 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/2019-10-01/examples/GetTagsSubscription.json + */ +async function getTagsOnASubscription() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/eaee6a92-e973-4922-9471-3a0a6abf81cd"; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.tagsOperations.getAtScope(scope); + console.log(result); +} + +async function main() { + getTagsOnAResource(); + getTagsOnASubscription(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/README.md b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/README.md new file mode 100644 index 000000000000..f2d3b96e25d6 --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/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** | +| ----------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| [deploymentsCalculateTemplateHashSample.ts][deploymentscalculatetemplatehashsample] | Calculate the hash of the given template. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2019-10-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/2019-10-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/2019-10-01/examples/PutDeploymentAtScope.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/2019-10-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/2019-10-01/examples/PutDeploymentWithOnErrorDeploymentSpecificDeployment.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/2019-10-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/2019-10-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/2019-10-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/2019-10-01/examples/PostDeploymentWhatIfOnResourceGroup.json | +| [resourceGroupsCreateOrUpdateSample.ts][resourcegroupscreateorupdatesample] | Creates or updates a resource group. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2019-10-01/examples/CreateResourceGroup.json | +| [resourceGroupsExportTemplateSample.ts][resourcegroupsexporttemplatesample] | Captures the specified resource group as a template. x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2019-10-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/2019-10-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/2019-10-01/examples/GetTagsResource.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). + +Before running the samples in Node, they must be compiled to JavaScript using the TypeScript compiler. For more information on TypeScript, see the [TypeScript documentation][typescript]. Install the TypeScript compiler using: + +```bash +npm install -g typescript +``` + +You need [an Azure subscription][freesub] to run these sample programs. + +Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. + +Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. + +## Setup + +To run the samples using the published version of the package: + +1. Install the dependencies using `npm`: + +```bash +npm install +``` + +2. Compile the samples: + +```bash +npm run build +``` + +3. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. + +4. Run whichever samples you like (note that some samples may require additional setup, see the table above): + +```bash +node dist/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 RESOURCES_SUBSCRIPTION_ID="" 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-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsCalculateTemplateHashSample.ts +[deploymentscreateorupdateatmanagementgroupscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsCreateOrUpdateAtManagementGroupScopeSample.ts +[deploymentscreateorupdateatscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsCreateOrUpdateAtScopeSample.ts +[deploymentscreateorupdateattenantscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsCreateOrUpdateAtTenantScopeSample.ts +[deploymentscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsCreateOrUpdateSample.ts +[deploymentswhatifatmanagementgroupscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsWhatIfAtManagementGroupScopeSample.ts +[deploymentswhatifatsubscriptionscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsWhatIfAtSubscriptionScopeSample.ts +[deploymentswhatifattenantscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsWhatIfAtTenantScopeSample.ts +[deploymentswhatifsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsWhatIfSample.ts +[resourcegroupscreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/resourceGroupsCreateOrUpdateSample.ts +[resourcegroupsexporttemplatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/resourceGroupsExportTemplateSample.ts +[tagscreateorupdateatscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/tagsCreateOrUpdateAtScopeSample.ts +[tagsgetatscopesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/tagsGetAtScopeSample.ts +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-resources-profile-2020-09-01-hybrid?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-profile-2020-09-01-hybrid/README.md +[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/package.json b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/package.json new file mode 100644 index 000000000000..eb9cb30ed92a --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/package.json @@ -0,0 +1,41 @@ +{ + "name": "@azure-samples/arm-resources-profile-2020-09-01-hybrid-ts", + "private": true, + "version": "1.0.0", + "description": " client library samples for TypeScript", + "engines": { + "node": ">=14.0.0" + }, + "scripts": { + "build": "tsc", + "prebuild": "rimraf dist/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/resources/arm-resources-profile-2020-09-01-hybrid" + }, + "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-profile-2020-09-01-hybrid", + "dependencies": { + "@azure/arm-resources-profile-2020-09-01-hybrid": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + }, + "devDependencies": { + "@types/node": "^14.0.0", + "typescript": "~4.8.0", + "rimraf": "latest" + } +} diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/sample.env b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/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/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsCalculateTemplateHashSample.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsCalculateTemplateHashSample.ts new file mode 100644 index 000000000000..78a94cc6a46f --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsCalculateTemplateHashSample.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { ResourceManagementClient } from "@azure/arm-resources-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2019-10-01/examples/CalculateTemplateHash.json + */ +async function calculateTemplateHash() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "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); +} + +async function main() { + calculateTemplateHash(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsCreateOrUpdateAtManagementGroupScopeSample.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsCreateOrUpdateAtManagementGroupScopeSample.ts new file mode 100644 index 000000000000..2d71a6abef2c --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsCreateOrUpdateAtManagementGroupScopeSample.ts @@ -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. +import { + ScopedDeployment, + ResourceManagementClient +} from "@azure/arm-resources-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2019-10-01/examples/PutDeploymentAtManagementGroup.json + */ +async function createDeploymentAtManagementGroupScope() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const groupId = "tiano-group1"; + const deploymentName = "mg-dep01"; + const parameters: ScopedDeployment = { + location: "eastus", + properties: { + mode: "Incremental", + parameters: {}, + templateLink: { uri: "{templateUri}" } + } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAtManagementGroupScopeAndWait( + groupId, + deploymentName, + parameters + ); + console.log(result); +} + +async function main() { + createDeploymentAtManagementGroupScope(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsCreateOrUpdateAtScopeSample.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsCreateOrUpdateAtScopeSample.ts new file mode 100644 index 000000000000..40e310f68498 --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsCreateOrUpdateAtScopeSample.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 { + Deployment, + ResourceManagementClient +} from "@azure/arm-resources-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2019-10-01/examples/PutDeploymentAtScope.json + */ +async function createDeploymentAtAGivenScope() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = "providers/Microsoft.Management/managementGroups/tiano-group1"; + const deploymentName = "mg-dep01"; + const parameters: Deployment = { + location: "eastus", + properties: { + mode: "Incremental", + parameters: {}, + templateLink: { uri: "{templateUri}" } + }, + tags: { tagKey1: "tagValue1", tagKey2: "tagValue2" } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAtScopeAndWait( + scope, + deploymentName, + parameters + ); + console.log(result); +} + +async function main() { + createDeploymentAtAGivenScope(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsCreateOrUpdateAtTenantScopeSample.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsCreateOrUpdateAtTenantScopeSample.ts new file mode 100644 index 000000000000..d29490630b0a --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsCreateOrUpdateAtTenantScopeSample.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 { + ScopedDeployment, + ResourceManagementClient +} from "@azure/arm-resources-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2019-10-01/examples/PutDeploymentAtTenant.json + */ +async function createDeploymentAtTenantScope() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const deploymentName = "tenant-dep01"; + const parameters: ScopedDeployment = { + location: "eastus", + properties: { + mode: "Incremental", + parameters: {}, + templateLink: { uri: "{templateUri}" } + }, + tags: { tagKey1: "tagValue1", tagKey2: "tagValue2" } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAtTenantScopeAndWait( + deploymentName, + parameters + ); + console.log(result); +} + +async function main() { + createDeploymentAtTenantScope(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsCreateOrUpdateSample.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..709e55c4a3cc --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsCreateOrUpdateSample.ts @@ -0,0 +1,88 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * 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-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2019-10-01/examples/PutDeploymentWithOnErrorDeploymentSpecificDeployment.json + */ +async function createADeploymentThatWillRedeployAnotherDeploymentOnFailure() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || "{subscriptionId}"; + const resourceGroupName = + process.env["RESOURCES_RESOURCE_GROUP"] || "myResourceGroup"; + const deploymentName = "exampleDeploymentName"; + const parameters: Deployment = { + properties: { + mode: "Complete", + onErrorDeployment: { + type: "SpecificDeployment", + deploymentName: "{nameOfDeploymentToUse}" + }, + parameters: {}, + templateLink: { uri: "{templateUri}" } + } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAndWait( + resourceGroupName, + deploymentName, + parameters + ); + console.log(result); +} + +/** + * 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/2019-10-01/examples/PutDeploymentWithOnErrorDeploymentLastSuccessful.json + */ +async function createADeploymentThatWillRedeployTheLastSuccessfulDeploymentOnFailure() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || "{subscriptionId}"; + const resourceGroupName = + process.env["RESOURCES_RESOURCE_GROUP"] || "myResourceGroup"; + const deploymentName = "exampleDeploymentName"; + const parameters: Deployment = { + properties: { + mode: "Complete", + onErrorDeployment: { type: "LastSuccessful" }, + parameters: {}, + templateLink: { uri: "{templateUri}" } + } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.deployments.beginCreateOrUpdateAndWait( + resourceGroupName, + deploymentName, + parameters + ); + console.log(result); +} + +async function main() { + createADeploymentThatWillRedeployAnotherDeploymentOnFailure(); + createADeploymentThatWillRedeployTheLastSuccessfulDeploymentOnFailure(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsWhatIfAtManagementGroupScopeSample.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsWhatIfAtManagementGroupScopeSample.ts new file mode 100644 index 000000000000..933e9a3a9fb4 --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsWhatIfAtManagementGroupScopeSample.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 { + ScopedDeploymentWhatIf, + ResourceManagementClient +} from "@azure/arm-resources-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2019-10-01/examples/PostDeploymentWhatIfOnManagementGroup.json + */ +async function predictTemplateChangesAtManagementGroupScope() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const groupId = "myManagementGruop"; + const deploymentName = "exampleDeploymentName"; + const parameters: ScopedDeploymentWhatIf = { + 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.beginWhatIfAtManagementGroupScopeAndWait( + groupId, + deploymentName, + parameters + ); + console.log(result); +} + +async function main() { + predictTemplateChangesAtManagementGroupScope(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsWhatIfAtSubscriptionScopeSample.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsWhatIfAtSubscriptionScopeSample.ts new file mode 100644 index 000000000000..642d678bc436 --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsWhatIfAtSubscriptionScopeSample.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 { + DeploymentWhatIf, + ResourceManagementClient +} from "@azure/arm-resources-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2019-10-01/examples/PostDeploymentWhatIfOnSubscription.json + */ +async function predictTemplateChangesAtSubscriptionScope() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000001"; + const deploymentName = "exampleDeploymentName"; + const parameters: DeploymentWhatIf = { + location: "westus", + 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.beginWhatIfAtSubscriptionScopeAndWait( + deploymentName, + parameters + ); + console.log(result); +} + +async function main() { + predictTemplateChangesAtSubscriptionScope(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsWhatIfAtTenantScopeSample.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsWhatIfAtTenantScopeSample.ts new file mode 100644 index 000000000000..8062cb1a1614 --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsWhatIfAtTenantScopeSample.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 { + ScopedDeploymentWhatIf, + ResourceManagementClient +} from "@azure/arm-resources-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2019-10-01/examples/PostDeploymentWhatIfOnTenant.json + */ +async function predictTemplateChangesAtManagementGroupScope() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const deploymentName = "exampleDeploymentName"; + const parameters: ScopedDeploymentWhatIf = { + 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.beginWhatIfAtTenantScopeAndWait( + deploymentName, + parameters + ); + console.log(result); +} + +async function main() { + predictTemplateChangesAtManagementGroupScope(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsWhatIfSample.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsWhatIfSample.ts new file mode 100644 index 000000000000..f78da703330d --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/deploymentsWhatIfSample.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 { + DeploymentWhatIf, + ResourceManagementClient +} from "@azure/arm-resources-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2019-10-01/examples/PostDeploymentWhatIfOnResourceGroup.json + */ +async function predictTemplateChangesAtResourceGroupScope() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000001"; + const resourceGroupName = + process.env["RESOURCES_RESOURCE_GROUP"] || "myResourceGroup"; + const deploymentName = "exampleDeploymentName"; + const parameters: DeploymentWhatIf = { + 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.beginWhatIfAndWait( + resourceGroupName, + deploymentName, + parameters + ); + console.log(result); +} + +async function main() { + predictTemplateChangesAtResourceGroupScope(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/resourceGroupsCreateOrUpdateSample.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/resourceGroupsCreateOrUpdateSample.ts new file mode 100644 index 000000000000..7ea72f1d4ec1 --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/resourceGroupsCreateOrUpdateSample.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 { + ResourceGroup, + ResourceManagementClient +} from "@azure/arm-resources-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2019-10-01/examples/CreateResourceGroup.json + */ +async function createOrUpdateAResourceGroup() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = + process.env["RESOURCES_RESOURCE_GROUP"] || "myResourceGroup"; + 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); +} + +async function main() { + createOrUpdateAResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/resourceGroupsExportTemplateSample.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/resourceGroupsExportTemplateSample.ts new file mode 100644 index 000000000000..14479017351a --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/resourceGroupsExportTemplateSample.ts @@ -0,0 +1,77 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * 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-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2019-10-01/examples/ExportResourceGroup.json + */ +async function exportAResourceGroup() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "eaee6a92-e973-4922-9471-3a0a6abf81cd"; + const resourceGroupName = + process.env["RESOURCES_RESOURCE_GROUP"] || "myResourceGroup"; + 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); +} + +/** + * 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/2019-10-01/examples/ExportResourceGroupWithFiltering.json + */ +async function exportAResourceGroupWithFiltering() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "eaee6a92-e973-4922-9471-3a0a6abf81cd"; + const resourceGroupName = + process.env["RESOURCES_RESOURCE_GROUP"] || "myResourceGroup"; + const parameters: ExportTemplateRequest = { + options: "SkipResourceNameParameterization", + resources: [ + "/subscriptions/eaee6a92-e973-4922-9471-3a0a6abf81cd/resourceGroups/myResourceGroup/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); +} + +async function main() { + exportAResourceGroup(); + exportAResourceGroupWithFiltering(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/tagsCreateOrUpdateAtScopeSample.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/tagsCreateOrUpdateAtScopeSample.ts new file mode 100644 index 000000000000..5f52bbcd7455 --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/tagsCreateOrUpdateAtScopeSample.ts @@ -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. +import { + TagsResource, + ResourceManagementClient +} from "@azure/arm-resources-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2019-10-01/examples/PutTagsResource.json + */ +async function updateTagsOnAResource() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "subscriptions/eaee6a92-e973-4922-9471-3a0a6abf81cd/resourcegroups/myResourceGroup/providers/myPRNameSpace/VM/myVm"; + const parameters: TagsResource = { + properties: { tags: { tagKey1: "tagValue1", tagKey2: "tagValue2" } } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.tagsOperations.createOrUpdateAtScope( + scope, + parameters + ); + console.log(result); +} + +/** + * 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/2019-10-01/examples/PutTagsSubscription.json + */ +async function updateTagsOnASubscription() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/eaee6a92-e973-4922-9471-3a0a6abf81cd"; + const parameters: TagsResource = { + properties: { tags: { tagKey1: "tagValue1", tagKey2: "tagValue2" } } + }; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.tagsOperations.createOrUpdateAtScope( + scope, + parameters + ); + console.log(result); +} + +async function main() { + updateTagsOnAResource(); + updateTagsOnASubscription(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/tagsGetAtScopeSample.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/tagsGetAtScopeSample.ts new file mode 100644 index 000000000000..1b5b6d4a1f53 --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/src/tagsGetAtScopeSample.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * 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-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2019-10-01/examples/GetTagsResource.json + */ +async function getTagsOnAResource() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = + "subscriptions/eaee6a92-e973-4922-9471-3a0a6abf81cd/resourcegroups/myResourceGroup/providers/myPRNameSpace/VM/myVm"; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.tagsOperations.getAtScope(scope); + console.log(result); +} + +/** + * 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/2019-10-01/examples/GetTagsSubscription.json + */ +async function getTagsOnASubscription() { + const subscriptionId = + process.env["RESOURCES_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const scope = "subscriptions/eaee6a92-e973-4922-9471-3a0a6abf81cd"; + const credential = new DefaultAzureCredential(); + const client = new ResourceManagementClient(credential, subscriptionId); + const result = await client.tagsOperations.getAtScope(scope); + console.log(result); +} + +async function main() { + getTagsOnAResource(); + getTagsOnASubscription(); +} + +main().catch(console.error); diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/tsconfig.json b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/tsconfig.json new file mode 100644 index 000000000000..e26ce2a6d8f7 --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/samples/v2/typescript/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "commonjs", + "moduleResolution": "node", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "alwaysStrict": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": [ + "src/**.ts" + ] +} diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/index.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/index.ts index 3af4903c75a2..bc3b6b9ec381 100644 --- a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/index.ts +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/index.ts @@ -7,6 +7,7 @@ */ /// +export { getContinuationToken } from "./pagingHelper"; export * from "./models"; export { ResourceManagementClient } from "./resourceManagementClient"; export * from "./operationsInterfaces"; diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/models/index.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/models/index.ts index bfadf97950c1..a8a3b3fccf32 100644 --- a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/models/index.ts +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/models/index.ts @@ -905,13 +905,13 @@ export interface SubResource { } /** Deployment What-if properties. */ -export type DeploymentWhatIfProperties = DeploymentProperties & { +export interface DeploymentWhatIfProperties extends DeploymentProperties { /** Optional What-If operation settings. */ whatIfSettings?: DeploymentWhatIfSettings; -}; +} /** Resource information. */ -export type GenericResource = Resource & { +export interface GenericResource extends Resource { /** The plan of the resource. */ plan?: Plan; /** The resource properties. */ @@ -924,10 +924,10 @@ export type GenericResource = Resource & { sku?: Sku; /** The identity of the resource. */ identity?: Identity; -}; +} /** Resource information. */ -export type GenericResourceExpanded = GenericResource & { +export interface GenericResourceExpanded extends GenericResource { /** * The created time of the resource. This is only present if requested via the $expand query parameter. * NOTE: This property will not be serialized. It can only be populated by the server. @@ -943,7 +943,7 @@ export type GenericResourceExpanded = GenericResource & { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly provisioningState?: string; -}; +} /** Defines headers for Deployments_whatIfAtTenantScope operation. */ export interface DeploymentsWhatIfAtTenantScopeHeaders { @@ -1467,60 +1467,35 @@ export type DeploymentsCalculateTemplateHashResponse = TemplateHashResult; /** Optional parameters. */ export interface DeploymentsListAtScopeNextOptionalParams - extends coreClient.OperationOptions { - /** The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. */ - filter?: string; - /** The number of results to get. If null is passed, returns all deployments. */ - top?: number; -} + extends coreClient.OperationOptions {} /** Contains response data for the listAtScopeNext operation. */ export type DeploymentsListAtScopeNextResponse = DeploymentListResult; /** Optional parameters. */ export interface DeploymentsListAtTenantScopeNextOptionalParams - extends coreClient.OperationOptions { - /** The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. */ - filter?: string; - /** The number of results to get. If null is passed, returns all deployments. */ - top?: number; -} + extends coreClient.OperationOptions {} /** Contains response data for the listAtTenantScopeNext operation. */ export type DeploymentsListAtTenantScopeNextResponse = DeploymentListResult; /** Optional parameters. */ export interface DeploymentsListAtManagementGroupScopeNextOptionalParams - extends coreClient.OperationOptions { - /** The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. */ - filter?: string; - /** The number of results to get. If null is passed, returns all deployments. */ - top?: number; -} + extends coreClient.OperationOptions {} /** Contains response data for the listAtManagementGroupScopeNext operation. */ export type DeploymentsListAtManagementGroupScopeNextResponse = DeploymentListResult; /** Optional parameters. */ export interface DeploymentsListAtSubscriptionScopeNextOptionalParams - extends coreClient.OperationOptions { - /** The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. */ - filter?: string; - /** The number of results to get. If null is passed, returns all deployments. */ - top?: number; -} + extends coreClient.OperationOptions {} /** Contains response data for the listAtSubscriptionScopeNext operation. */ export type DeploymentsListAtSubscriptionScopeNextResponse = DeploymentListResult; /** Optional parameters. */ export interface DeploymentsListByResourceGroupNextOptionalParams - extends coreClient.OperationOptions { - /** The filter to apply on the operation. For example, you can use $filter=provisioningState eq '{state}'. */ - filter?: string; - /** The number of results to get. If null is passed, returns all deployments. */ - top?: number; -} + extends coreClient.OperationOptions {} /** Contains response data for the listByResourceGroupNext operation. */ export type DeploymentsListByResourceGroupNextResponse = DeploymentListResult; @@ -1585,24 +1560,14 @@ export type ProvidersGetAtTenantScopeResponse = Provider; /** Optional parameters. */ export interface ProvidersListNextOptionalParams - extends coreClient.OperationOptions { - /** The number of results to return. If null is passed returns all deployments. */ - top?: number; - /** The properties to include in the results. For example, use &$expand=metadata in the query string to retrieve resource provider metadata. To include property aliases in response, use $expand=resourceTypes/aliases. */ - expand?: string; -} + extends coreClient.OperationOptions {} /** Contains response data for the listNext operation. */ export type ProvidersListNextResponse = ProviderListResult; /** Optional parameters. */ export interface ProvidersListAtTenantScopeNextOptionalParams - extends coreClient.OperationOptions { - /** The number of results to return. If null is passed returns all providers. */ - top?: number; - /** The properties to include in the results. For example, use &$expand=metadata in the query string to retrieve resource provider metadata. To include property aliases in response, use $expand=resourceTypes/aliases. */ - expand?: string; -} + extends coreClient.OperationOptions {} /** Contains response data for the listAtTenantScopeNext operation. */ export type ProvidersListAtTenantScopeNextResponse = ProviderListResult; @@ -1753,28 +1718,14 @@ export type ResourcesGetByIdResponse = GenericResource; /** Optional parameters. */ export interface ResourcesListByResourceGroupNextOptionalParams - extends coreClient.OperationOptions { - /** The filter to apply on the operation.

The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, and plan/promotionCode.

For example, to filter by a resource type, use: $filter=resourceType eq 'Microsoft.Network/virtualNetworks'

You can use substringof(value, property) in the filter. The properties you can use for substring are: name and resourceGroup.

For example, to get all resources with 'demo' anywhere in the name, use: $filter=substringof('demo', name)

You can link more than one substringof together by adding and/or operators.

You can filter by tag names and values. For example, to filter for a tag name and value, use $filter=tagName eq 'tag1' and tagValue eq 'Value1'. When you filter by a tag name and value, the tags for each resource are not returned in the results.

You can use some properties together when filtering. The combinations you can use are: substringof and/or resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. */ - filter?: string; - /** The number of results to return. If null is passed, returns all resources. */ - top?: number; - /** Comma-separated list of additional properties to be included in the response. Valid values include `createdTime`, `changedTime` and `provisioningState`. For example, `$expand=createdTime,changedTime`. */ - expand?: string; -} + extends coreClient.OperationOptions {} /** Contains response data for the listByResourceGroupNext operation. */ export type ResourcesListByResourceGroupNextResponse = ResourceListResult; /** Optional parameters. */ export interface ResourcesListNextOptionalParams - extends coreClient.OperationOptions { - /** The filter to apply on the operation.

The properties you can use for eq (equals) or ne (not equals) are: location, resourceType, name, resourceGroup, identity, identity/principalId, plan, plan/publisher, plan/product, plan/name, plan/version, and plan/promotionCode.

For example, to filter by a resource type, use: $filter=resourceType eq 'Microsoft.Network/virtualNetworks'

You can use substringof(value, property) in the filter. The properties you can use for substring are: name and resourceGroup.

For example, to get all resources with 'demo' anywhere in the name, use: $filter=substringof('demo', name)

You can link more than one substringof together by adding and/or operators.

You can filter by tag names and values. For example, to filter for a tag name and value, use $filter=tagName eq 'tag1' and tagValue eq 'Value1'. When you filter by a tag name and value, the tags for each resource are not returned in the results.

You can use some properties together when filtering. The combinations you can use are: substringof and/or resourceType, plan and plan/publisher and plan/name, identity and identity/principalId. */ - filter?: string; - /** The number of results to return. If null is passed, returns all resources. */ - top?: number; - /** Comma-separated list of additional properties to be included in the response. Valid values include `createdTime`, `changedTime` and `provisioningState`. For example, `$expand=createdTime,changedTime`. */ - expand?: string; -} + extends coreClient.OperationOptions {} /** Contains response data for the listNext operation. */ export type ResourcesListNextResponse = ResourceListResult; @@ -1844,12 +1795,7 @@ export type ResourceGroupsListResponse = ResourceGroupListResult; /** Optional parameters. */ export interface ResourceGroupsListNextOptionalParams - extends coreClient.OperationOptions { - /** The filter to apply on the operation.

You can filter by tag names and values. For example, to filter for a tag name and value, use $filter=tagName eq 'tag1' and tagValue eq 'Value1' */ - filter?: string; - /** The number of results to return. If null is passed, returns all resource groups. */ - top?: number; -} + extends coreClient.OperationOptions {} /** Contains response data for the listNext operation. */ export type ResourceGroupsListNextResponse = ResourceGroupListResult; @@ -2000,50 +1946,35 @@ export type DeploymentOperationsListResponse = DeploymentOperationsListResult; /** Optional parameters. */ export interface DeploymentOperationsListAtScopeNextOptionalParams - extends coreClient.OperationOptions { - /** The number of results to return. */ - top?: number; -} + extends coreClient.OperationOptions {} /** Contains response data for the listAtScopeNext operation. */ export type DeploymentOperationsListAtScopeNextResponse = DeploymentOperationsListResult; /** Optional parameters. */ export interface DeploymentOperationsListAtTenantScopeNextOptionalParams - extends coreClient.OperationOptions { - /** The number of results to return. */ - top?: number; -} + extends coreClient.OperationOptions {} /** Contains response data for the listAtTenantScopeNext operation. */ export type DeploymentOperationsListAtTenantScopeNextResponse = DeploymentOperationsListResult; /** Optional parameters. */ export interface DeploymentOperationsListAtManagementGroupScopeNextOptionalParams - extends coreClient.OperationOptions { - /** The number of results to return. */ - top?: number; -} + extends coreClient.OperationOptions {} /** Contains response data for the listAtManagementGroupScopeNext operation. */ export type DeploymentOperationsListAtManagementGroupScopeNextResponse = DeploymentOperationsListResult; /** Optional parameters. */ export interface DeploymentOperationsListAtSubscriptionScopeNextOptionalParams - extends coreClient.OperationOptions { - /** The number of results to return. */ - top?: number; -} + extends coreClient.OperationOptions {} /** Contains response data for the listAtSubscriptionScopeNext operation. */ export type DeploymentOperationsListAtSubscriptionScopeNextResponse = DeploymentOperationsListResult; /** Optional parameters. */ export interface DeploymentOperationsListNextOptionalParams - extends coreClient.OperationOptions { - /** The number of results to return. */ - top?: number; -} + extends coreClient.OperationOptions {} /** Contains response data for the listNext operation. */ export type DeploymentOperationsListNextResponse = DeploymentOperationsListResult; diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/deploymentOperations.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/deploymentOperations.ts index 705dbf7ffd1c..ac58be548913 100644 --- a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/deploymentOperations.ts +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/deploymentOperations.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { DeploymentOperations } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -16,29 +17,29 @@ import { DeploymentOperation, DeploymentOperationsListAtScopeNextOptionalParams, DeploymentOperationsListAtScopeOptionalParams, + DeploymentOperationsListAtScopeResponse, DeploymentOperationsListAtTenantScopeNextOptionalParams, DeploymentOperationsListAtTenantScopeOptionalParams, + DeploymentOperationsListAtTenantScopeResponse, DeploymentOperationsListAtManagementGroupScopeNextOptionalParams, DeploymentOperationsListAtManagementGroupScopeOptionalParams, + DeploymentOperationsListAtManagementGroupScopeResponse, DeploymentOperationsListAtSubscriptionScopeNextOptionalParams, DeploymentOperationsListAtSubscriptionScopeOptionalParams, + DeploymentOperationsListAtSubscriptionScopeResponse, DeploymentOperationsListNextOptionalParams, DeploymentOperationsListOptionalParams, + DeploymentOperationsListResponse, DeploymentOperationsGetAtScopeOptionalParams, DeploymentOperationsGetAtScopeResponse, - DeploymentOperationsListAtScopeResponse, DeploymentOperationsGetAtTenantScopeOptionalParams, DeploymentOperationsGetAtTenantScopeResponse, - DeploymentOperationsListAtTenantScopeResponse, DeploymentOperationsGetAtManagementGroupScopeOptionalParams, DeploymentOperationsGetAtManagementGroupScopeResponse, - DeploymentOperationsListAtManagementGroupScopeResponse, DeploymentOperationsGetAtSubscriptionScopeOptionalParams, DeploymentOperationsGetAtSubscriptionScopeResponse, - DeploymentOperationsListAtSubscriptionScopeResponse, DeploymentOperationsGetOptionalParams, DeploymentOperationsGetResponse, - DeploymentOperationsListResponse, DeploymentOperationsListAtScopeNextResponse, DeploymentOperationsListAtTenantScopeNextResponse, DeploymentOperationsListAtManagementGroupScopeNextResponse, @@ -78,8 +79,16 @@ export class DeploymentOperationsImpl implements DeploymentOperations { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listAtScopePagingPage(scope, deploymentName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listAtScopePagingPage( + scope, + deploymentName, + options, + settings + ); } }; } @@ -87,11 +96,18 @@ export class DeploymentOperationsImpl implements DeploymentOperations { private async *listAtScopePagingPage( scope: string, deploymentName: string, - options?: DeploymentOperationsListAtScopeOptionalParams + options?: DeploymentOperationsListAtScopeOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listAtScope(scope, deploymentName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: DeploymentOperationsListAtScopeResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listAtScope(scope, deploymentName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listAtScopeNext( scope, @@ -100,7 +116,9 @@ export class DeploymentOperationsImpl implements DeploymentOperations { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -135,19 +153,33 @@ export class DeploymentOperationsImpl implements DeploymentOperations { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listAtTenantScopePagingPage(deploymentName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listAtTenantScopePagingPage( + deploymentName, + options, + settings + ); } }; } private async *listAtTenantScopePagingPage( deploymentName: string, - options?: DeploymentOperationsListAtTenantScopeOptionalParams + options?: DeploymentOperationsListAtTenantScopeOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listAtTenantScope(deploymentName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: DeploymentOperationsListAtTenantScopeResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listAtTenantScope(deploymentName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listAtTenantScopeNext( deploymentName, @@ -155,7 +187,9 @@ export class DeploymentOperationsImpl implements DeploymentOperations { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -194,11 +228,15 @@ export class DeploymentOperationsImpl implements DeploymentOperations { [Symbol.asyncIterator]() { return this; }, - byPage: () => { + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } return this.listAtManagementGroupScopePagingPage( groupId, deploymentName, - options + options, + settings ); } }; @@ -207,15 +245,22 @@ export class DeploymentOperationsImpl implements DeploymentOperations { private async *listAtManagementGroupScopePagingPage( groupId: string, deploymentName: string, - options?: DeploymentOperationsListAtManagementGroupScopeOptionalParams + options?: DeploymentOperationsListAtManagementGroupScopeOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listAtManagementGroupScope( - groupId, - deploymentName, - options - ); - yield result.value || []; - let continuationToken = result.nextLink; + let result: DeploymentOperationsListAtManagementGroupScopeResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listAtManagementGroupScope( + groupId, + deploymentName, + options + ); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listAtManagementGroupScopeNext( groupId, @@ -224,7 +269,9 @@ export class DeploymentOperationsImpl implements DeploymentOperations { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -259,19 +306,33 @@ export class DeploymentOperationsImpl implements DeploymentOperations { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listAtSubscriptionScopePagingPage(deploymentName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listAtSubscriptionScopePagingPage( + deploymentName, + options, + settings + ); } }; } private async *listAtSubscriptionScopePagingPage( deploymentName: string, - options?: DeploymentOperationsListAtSubscriptionScopeOptionalParams + options?: DeploymentOperationsListAtSubscriptionScopeOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listAtSubscriptionScope(deploymentName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: DeploymentOperationsListAtSubscriptionScopeResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listAtSubscriptionScope(deploymentName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listAtSubscriptionScopeNext( deploymentName, @@ -279,7 +340,9 @@ export class DeploymentOperationsImpl implements DeploymentOperations { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -314,8 +377,16 @@ export class DeploymentOperationsImpl implements DeploymentOperations { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(resourceGroupName, deploymentName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage( + resourceGroupName, + deploymentName, + options, + settings + ); } }; } @@ -323,11 +394,18 @@ export class DeploymentOperationsImpl implements DeploymentOperations { private async *listPagingPage( resourceGroupName: string, deploymentName: string, - options?: DeploymentOperationsListOptionalParams + options?: DeploymentOperationsListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(resourceGroupName, deploymentName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: DeploymentOperationsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(resourceGroupName, deploymentName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext( resourceGroupName, @@ -336,7 +414,9 @@ export class DeploymentOperationsImpl implements DeploymentOperations { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -845,7 +925,6 @@ const listAtScopeNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion, Parameters.top], urlParameters: [ Parameters.$host, Parameters.nextLink, @@ -866,7 +945,6 @@ const listAtTenantScopeNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion, Parameters.top], urlParameters: [ Parameters.$host, Parameters.nextLink, @@ -886,7 +964,6 @@ const listAtManagementGroupScopeNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion, Parameters.top], urlParameters: [ Parameters.$host, Parameters.nextLink, @@ -907,7 +984,6 @@ const listAtSubscriptionScopeNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion, Parameters.top], urlParameters: [ Parameters.$host, Parameters.nextLink, @@ -928,7 +1004,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion, Parameters.top], urlParameters: [ Parameters.$host, Parameters.nextLink, diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/deployments.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/deployments.ts index a4d92e6a9e98..f08fcac3d023 100644 --- a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/deployments.ts +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/deployments.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { Deployments } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -18,14 +19,19 @@ import { DeploymentExtended, DeploymentsListAtScopeNextOptionalParams, DeploymentsListAtScopeOptionalParams, + DeploymentsListAtScopeResponse, DeploymentsListAtTenantScopeNextOptionalParams, DeploymentsListAtTenantScopeOptionalParams, + DeploymentsListAtTenantScopeResponse, DeploymentsListAtManagementGroupScopeNextOptionalParams, DeploymentsListAtManagementGroupScopeOptionalParams, + DeploymentsListAtManagementGroupScopeResponse, DeploymentsListAtSubscriptionScopeNextOptionalParams, DeploymentsListAtSubscriptionScopeOptionalParams, + DeploymentsListAtSubscriptionScopeResponse, DeploymentsListByResourceGroupNextOptionalParams, DeploymentsListByResourceGroupOptionalParams, + DeploymentsListByResourceGroupResponse, DeploymentsDeleteAtScopeOptionalParams, DeploymentsCheckExistenceAtScopeOptionalParams, DeploymentsCheckExistenceAtScopeResponse, @@ -39,7 +45,6 @@ import { DeploymentsValidateAtScopeResponse, DeploymentsExportTemplateAtScopeOptionalParams, DeploymentsExportTemplateAtScopeResponse, - DeploymentsListAtScopeResponse, DeploymentsDeleteAtTenantScopeOptionalParams, DeploymentsCheckExistenceAtTenantScopeOptionalParams, DeploymentsCheckExistenceAtTenantScopeResponse, @@ -56,7 +61,6 @@ import { DeploymentsWhatIfAtTenantScopeResponse, DeploymentsExportTemplateAtTenantScopeOptionalParams, DeploymentsExportTemplateAtTenantScopeResponse, - DeploymentsListAtTenantScopeResponse, DeploymentsDeleteAtManagementGroupScopeOptionalParams, DeploymentsCheckExistenceAtManagementGroupScopeOptionalParams, DeploymentsCheckExistenceAtManagementGroupScopeResponse, @@ -71,7 +75,6 @@ import { DeploymentsWhatIfAtManagementGroupScopeResponse, DeploymentsExportTemplateAtManagementGroupScopeOptionalParams, DeploymentsExportTemplateAtManagementGroupScopeResponse, - DeploymentsListAtManagementGroupScopeResponse, DeploymentsDeleteAtSubscriptionScopeOptionalParams, DeploymentsCheckExistenceAtSubscriptionScopeOptionalParams, DeploymentsCheckExistenceAtSubscriptionScopeResponse, @@ -87,7 +90,6 @@ import { DeploymentsWhatIfAtSubscriptionScopeResponse, DeploymentsExportTemplateAtSubscriptionScopeOptionalParams, DeploymentsExportTemplateAtSubscriptionScopeResponse, - DeploymentsListAtSubscriptionScopeResponse, DeploymentsDeleteOptionalParams, DeploymentsCheckExistenceOptionalParams, DeploymentsCheckExistenceResponse, @@ -102,7 +104,6 @@ import { DeploymentsWhatIfResponse, DeploymentsExportTemplateOptionalParams, DeploymentsExportTemplateResponse, - DeploymentsListByResourceGroupResponse, DeploymentsCalculateTemplateHashOptionalParams, DeploymentsCalculateTemplateHashResponse, DeploymentsListAtScopeNextResponse, @@ -142,23 +143,35 @@ export class DeploymentsImpl implements Deployments { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listAtScopePagingPage(scope, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listAtScopePagingPage(scope, options, settings); } }; } private async *listAtScopePagingPage( scope: string, - options?: DeploymentsListAtScopeOptionalParams + options?: DeploymentsListAtScopeOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listAtScope(scope, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: DeploymentsListAtScopeResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listAtScope(scope, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listAtScopeNext(scope, continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -186,22 +199,34 @@ export class DeploymentsImpl implements Deployments { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listAtTenantScopePagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listAtTenantScopePagingPage(options, settings); } }; } private async *listAtTenantScopePagingPage( - options?: DeploymentsListAtTenantScopeOptionalParams + options?: DeploymentsListAtTenantScopeOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listAtTenantScope(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: DeploymentsListAtTenantScopeResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listAtTenantScope(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listAtTenantScopeNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -230,19 +255,33 @@ export class DeploymentsImpl implements Deployments { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listAtManagementGroupScopePagingPage(groupId, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listAtManagementGroupScopePagingPage( + groupId, + options, + settings + ); } }; } private async *listAtManagementGroupScopePagingPage( groupId: string, - options?: DeploymentsListAtManagementGroupScopeOptionalParams + options?: DeploymentsListAtManagementGroupScopeOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listAtManagementGroupScope(groupId, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: DeploymentsListAtManagementGroupScopeResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listAtManagementGroupScope(groupId, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listAtManagementGroupScopeNext( groupId, @@ -250,7 +289,9 @@ export class DeploymentsImpl implements Deployments { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -281,25 +322,37 @@ export class DeploymentsImpl implements Deployments { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listAtSubscriptionScopePagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listAtSubscriptionScopePagingPage(options, settings); } }; } private async *listAtSubscriptionScopePagingPage( - options?: DeploymentsListAtSubscriptionScopeOptionalParams + options?: DeploymentsListAtSubscriptionScopeOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listAtSubscriptionScope(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: DeploymentsListAtSubscriptionScopeResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listAtSubscriptionScope(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listAtSubscriptionScopeNext( continuationToken, options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -329,19 +382,33 @@ export class DeploymentsImpl implements Deployments { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listByResourceGroupPagingPage(resourceGroupName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listByResourceGroupPagingPage( + resourceGroupName, + options, + settings + ); } }; } private async *listByResourceGroupPagingPage( resourceGroupName: string, - options?: DeploymentsListByResourceGroupOptionalParams + options?: DeploymentsListByResourceGroupOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listByResourceGroup(resourceGroupName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: DeploymentsListByResourceGroupResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listByResourceGroup(resourceGroupName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listByResourceGroupNext( resourceGroupName, @@ -349,7 +416,9 @@ export class DeploymentsImpl implements Deployments { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -426,10 +495,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 +607,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 +736,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 +858,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 +960,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 +1080,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 +1168,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 +1285,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 +1399,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 +1528,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 +1622,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 +1745,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 +1850,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 +1970,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 +2058,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 +2177,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 +2293,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 +2424,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 +2519,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; } /** @@ -3623,7 +3730,6 @@ const listAtScopeNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion, Parameters.filter, Parameters.top], urlParameters: [Parameters.$host, Parameters.nextLink, Parameters.scope], headerParameters: [Parameters.accept], serializer @@ -3639,7 +3745,6 @@ const listAtTenantScopeNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion, Parameters.filter, Parameters.top], urlParameters: [Parameters.$host, Parameters.nextLink], headerParameters: [Parameters.accept], serializer @@ -3655,7 +3760,6 @@ const listAtManagementGroupScopeNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion, Parameters.filter, Parameters.top], urlParameters: [Parameters.$host, Parameters.nextLink, Parameters.groupId], headerParameters: [Parameters.accept], serializer @@ -3671,7 +3775,6 @@ const listAtSubscriptionScopeNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion, Parameters.filter, Parameters.top], urlParameters: [ Parameters.$host, Parameters.nextLink, @@ -3691,7 +3794,6 @@ const listByResourceGroupNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion, Parameters.filter, Parameters.top], urlParameters: [ Parameters.$host, Parameters.nextLink, diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/operations.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/operations.ts index 498f072ab75b..e218ad6bc0b6 100644 --- a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/operations.ts +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/operations.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { Operations } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -48,22 +49,34 @@ export class OperationsImpl implements Operations { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); } }; } private async *listPagingPage( - options?: OperationsListOptionalParams + options?: OperationsListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: OperationsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -130,7 +143,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.$host, Parameters.nextLink], headerParameters: [Parameters.accept], serializer diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/providers.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/providers.ts index 92110ade704f..2017ebfede4f 100644 --- a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/providers.ts +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/providers.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { Providers } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -16,14 +17,14 @@ import { Provider, ProvidersListNextOptionalParams, ProvidersListOptionalParams, + ProvidersListResponse, ProvidersListAtTenantScopeNextOptionalParams, ProvidersListAtTenantScopeOptionalParams, + ProvidersListAtTenantScopeResponse, ProvidersUnregisterOptionalParams, ProvidersUnregisterResponse, ProvidersRegisterOptionalParams, ProvidersRegisterResponse, - ProvidersListResponse, - ProvidersListAtTenantScopeResponse, ProvidersGetOptionalParams, ProvidersGetResponse, ProvidersGetAtTenantScopeOptionalParams, @@ -60,22 +61,34 @@ export class ProvidersImpl implements Providers { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); } }; } private async *listPagingPage( - options?: ProvidersListOptionalParams + options?: ProvidersListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: ProvidersListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -102,22 +115,34 @@ export class ProvidersImpl implements Providers { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listAtTenantScopePagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listAtTenantScopePagingPage(options, settings); } }; } private async *listAtTenantScopePagingPage( - options?: ProvidersListAtTenantScopeOptionalParams + options?: ProvidersListAtTenantScopeOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listAtTenantScope(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: ProvidersListAtTenantScopeResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listAtTenantScope(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listAtTenantScopeNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -366,7 +391,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion, Parameters.top, Parameters.expand], urlParameters: [ Parameters.$host, Parameters.nextLink, @@ -386,7 +410,6 @@ const listAtTenantScopeNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion, Parameters.top, Parameters.expand], urlParameters: [Parameters.$host, Parameters.nextLink], headerParameters: [Parameters.accept], serializer diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/resourceGroups.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/resourceGroups.ts index a4cd6ca9f85b..631f0731d097 100644 --- a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/resourceGroups.ts +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/resourceGroups.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { ResourceGroups } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -18,6 +19,7 @@ import { ResourceGroup, ResourceGroupsListNextOptionalParams, ResourceGroupsListOptionalParams, + ResourceGroupsListResponse, ResourceGroupsCheckExistenceOptionalParams, ResourceGroupsCheckExistenceResponse, ResourceGroupsCreateOrUpdateOptionalParams, @@ -31,7 +33,6 @@ import { ExportTemplateRequest, ResourceGroupsExportTemplateOptionalParams, ResourceGroupsExportTemplateResponse, - ResourceGroupsListResponse, ResourceGroupsListNextResponse } from "../models"; @@ -63,22 +64,34 @@ export class ResourceGroupsImpl implements ResourceGroups { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); } }; } private async *listPagingPage( - options?: ResourceGroupsListOptionalParams + options?: ResourceGroupsListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: ResourceGroupsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -178,10 +191,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 +307,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; } /** @@ -512,7 +529,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion, Parameters.filter, Parameters.top], urlParameters: [ Parameters.$host, Parameters.nextLink, diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/resources.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/resources.ts index bf49624f9ee4..33eda3f41f7c 100644 --- a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/resources.ts +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/resources.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { Resources } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -18,13 +19,13 @@ import { GenericResourceExpanded, ResourcesListByResourceGroupNextOptionalParams, ResourcesListByResourceGroupOptionalParams, + ResourcesListByResourceGroupResponse, ResourcesListNextOptionalParams, ResourcesListOptionalParams, - ResourcesListByResourceGroupResponse, + ResourcesListResponse, ResourcesMoveInfo, ResourcesMoveResourcesOptionalParams, ResourcesValidateMoveResourcesOptionalParams, - ResourcesListResponse, ResourcesCheckExistenceOptionalParams, ResourcesCheckExistenceResponse, ResourcesDeleteOptionalParams, @@ -78,19 +79,33 @@ export class ResourcesImpl implements Resources { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listByResourceGroupPagingPage(resourceGroupName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listByResourceGroupPagingPage( + resourceGroupName, + options, + settings + ); } }; } private async *listByResourceGroupPagingPage( resourceGroupName: string, - options?: ResourcesListByResourceGroupOptionalParams + options?: ResourcesListByResourceGroupOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listByResourceGroup(resourceGroupName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: ResourcesListByResourceGroupResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._listByResourceGroup(resourceGroupName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listByResourceGroupNext( resourceGroupName, @@ -98,7 +113,9 @@ export class ResourcesImpl implements Resources { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -129,22 +146,34 @@ export class ResourcesImpl implements Resources { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); } }; } private async *listPagingPage( - options?: ResourcesListOptionalParams + options?: ResourcesListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: ResourcesListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -229,10 +258,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; } /** @@ -317,10 +348,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; } /** @@ -463,10 +496,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; } /** @@ -581,10 +616,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; } /** @@ -702,10 +739,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; } /** @@ -853,10 +892,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; } /** @@ -940,10 +981,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; } /** @@ -1034,10 +1077,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; } /** @@ -1473,12 +1518,6 @@ const listByResourceGroupNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [ - Parameters.apiVersion, - Parameters.filter, - Parameters.top, - Parameters.expand - ], urlParameters: [ Parameters.$host, Parameters.nextLink, @@ -1499,12 +1538,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [ - Parameters.apiVersion, - Parameters.filter, - Parameters.top, - Parameters.expand - ], urlParameters: [ Parameters.$host, Parameters.nextLink, diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/tagsOperations.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/tagsOperations.ts index c993a0f6df0b..121ce4e824ec 100644 --- a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/tagsOperations.ts +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/operations/tagsOperations.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { TagsOperations } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -16,13 +17,13 @@ import { TagDetails, TagsListNextOptionalParams, TagsListOptionalParams, + TagsListResponse, TagsDeleteValueOptionalParams, TagsCreateOrUpdateValueOptionalParams, TagsCreateOrUpdateValueResponse, TagsCreateOrUpdateOptionalParams, TagsCreateOrUpdateResponse, TagsDeleteOptionalParams, - TagsListResponse, TagsResource, TagsCreateOrUpdateAtScopeOptionalParams, TagsCreateOrUpdateAtScopeResponse, @@ -66,22 +67,34 @@ export class TagsOperationsImpl implements TagsOperations { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); } }; } private async *listPagingPage( - options?: TagsListOptionalParams + options?: TagsListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: TagsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -440,7 +453,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.CloudError } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.nextLink, diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/pagingHelper.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/pagingHelper.ts new file mode 100644 index 000000000000..269a2b9814b5 --- /dev/null +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/pagingHelper.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export interface PageInfo { + continuationToken?: string; +} + +const pageMap = new WeakMap(); + +/** + * Given the last `.value` produced by the `byPage` iterator, + * returns a continuation token that can be used to begin paging from + * that point later. + * @param page An object from accessing `value` on the IteratorResult from a `byPage` iterator. + * @returns The continuation token that can be passed into byPage() during future calls. + */ +export function getContinuationToken(page: unknown): string | undefined { + if (typeof page !== "object" || page === null) { + return undefined; + } + return pageMap.get(page)?.continuationToken; +} + +export function setContinuationToken( + page: unknown, + continuationToken: string | undefined +): void { + if (typeof page !== "object" || page === null || !continuationToken) { + return; + } + const pageInfo = pageMap.get(page) ?? {}; + pageInfo.continuationToken = continuationToken; + pageMap.set(page, pageInfo); +} diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/resourceManagementClient.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/resourceManagementClient.ts index 6c2ce87cb769..6d3cc4248d68 100644 --- a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/resourceManagementClient.ts +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/src/resourceManagementClient.ts @@ -7,6 +7,12 @@ */ import * as coreClient from "@azure/core-client"; +import * as coreRestPipeline from "@azure/core-rest-pipeline"; +import { + PipelineRequest, + PipelineResponse, + SendRequest +} from "@azure/core-rest-pipeline"; import * as coreAuth from "@azure/core-auth"; import { OperationsImpl, @@ -60,24 +66,54 @@ export class ResourceManagementClient extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-resources-profile-2020-09-01-hybrid/2.0.1`; + const packageDetails = `azsdk-js-arm-resources-profile-2020-09-01-hybrid/2.1.0`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` : `${packageDetails}`; - if (!options.credentialScopes) { - options.credentialScopes = ["https://management.azure.com/.default"]; - } const optionsWithDefaults = { ...defaults, ...options, userAgentOptions: { userAgentPrefix }, - baseUri: options.endpoint || "https://management.azure.com" + endpoint: + options.endpoint ?? options.baseUri ?? "https://management.azure.com" }; super(optionsWithDefaults); + + let bearerTokenAuthenticationPolicyFound: boolean = false; + if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { + const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies(); + bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( + (pipelinePolicy) => + pipelinePolicy.name === + coreRestPipeline.bearerTokenAuthenticationPolicyName + ); + } + if ( + !options || + !options.pipeline || + options.pipeline.getOrderedPolicies().length == 0 || + !bearerTokenAuthenticationPolicyFound + ) { + this.pipeline.removePolicy({ + name: coreRestPipeline.bearerTokenAuthenticationPolicyName + }); + this.pipeline.addPolicy( + coreRestPipeline.bearerTokenAuthenticationPolicy({ + credential: credentials, + scopes: + optionsWithDefaults.credentialScopes ?? + `${optionsWithDefaults.endpoint}/.default`, + challengeCallbacks: { + authorizeRequestOnChallenge: + coreClient.authorizeRequestOnClaimChallenge + } + }) + ); + } // Parameter assignments this.subscriptionId = subscriptionId; @@ -91,6 +127,35 @@ export class ResourceManagementClient extends coreClient.ServiceClient { this.resourceGroups = new ResourceGroupsImpl(this); this.tagsOperations = new TagsOperationsImpl(this); this.deploymentOperations = new DeploymentOperationsImpl(this); + this.addCustomApiVersionPolicy(options.apiVersion); + } + + /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */ + private addCustomApiVersionPolicy(apiVersion?: string) { + if (!apiVersion) { + return; + } + const apiVersionPolicy = { + name: "CustomApiVersionPolicy", + async sendRequest( + request: PipelineRequest, + next: SendRequest + ): Promise { + const param = request.url.split("?"); + if (param.length > 1) { + const newParams = param[1].split("&").map((item) => { + if (item.indexOf("api-version") > -1) { + return "api-version=" + apiVersion; + } else { + return item; + } + }); + request.url = param[0] + "?" + newParams.join("&"); + } + return next(request); + } + }; + this.pipeline.addPolicy(apiVersionPolicy); } operations: Operations; diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/test/sampleTest.ts b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/test/sampleTest.ts index 7ed89b043e1b..25aeb3ebcc36 100644 --- a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/test/sampleTest.ts +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/test/sampleTest.ts @@ -7,35 +7,30 @@ */ import { - env, - record, - RecorderEnvironmentSetup, - Recorder + Recorder, + RecorderStartOptions, + env } from "@azure-tools/test-recorder"; -import * as assert from "assert"; +import { assert } from "chai"; +import { Context } from "mocha"; -const recorderEnvSetup: RecorderEnvironmentSetup = { - replaceableVariables: { - AZURE_CLIENT_ID: "azure_client_id", - AZURE_CLIENT_SECRET: "azure_client_secret", - AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", - SUBSCRIPTION_ID: "azure_subscription_id" - }, - customizationsOnRecordings: [ - (recording: any): any => - recording.replace( - /"access_token":"[^"]*"/g, - `"access_token":"access_token"` - ) - ], - queryParametersToSkip: [] +const replaceableVariables: Record = { + AZURE_CLIENT_ID: "azure_client_id", + AZURE_CLIENT_SECRET: "azure_client_secret", + AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", + SUBSCRIPTION_ID: "azure_subscription_id" +}; + +const recorderOptions: RecorderStartOptions = { + envSetupForPlayback: replaceableVariables }; describe("My test", () => { let recorder: Recorder; - beforeEach(async function() { - recorder = record(this, recorderEnvSetup); + beforeEach(async function(this: Context) { + recorder = new Recorder(this.currentTest); + await recorder.start(recorderOptions); }); afterEach(async function() { diff --git a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/tsconfig.json b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/tsconfig.json index 3e6ae96443f3..e079fd516ad4 100644 --- a/sdk/resources/arm-resources-profile-2020-09-01-hybrid/tsconfig.json +++ b/sdk/resources/arm-resources-profile-2020-09-01-hybrid/tsconfig.json @@ -15,11 +15,17 @@ ], "declaration": true, "outDir": "./dist-esm", - "importHelpers": true + "importHelpers": true, + "paths": { + "@azure/arm-resources-profile-2020-09-01-hybrid": [ + "./src/index" + ] + } }, "include": [ "./src/**/*.ts", - "./test/**/*.ts" + "./test/**/*.ts", + "samples-dev/**/*.ts" ], "exclude": [ "node_modules" diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/CHANGELOG.md b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/CHANGELOG.md index 72e1c30fce37..4e7c92443ed6 100644 --- a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/CHANGELOG.md +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/CHANGELOG.md @@ -1,15 +1,20 @@ # Release History - -## 2.0.1 (Unreleased) - -### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes - + +## 2.1.0 (2022-12-22) + +**Features** + + - Added Interface BlobInventoryPolicy + - Added Interface EncryptionScope + - Added Interface ManagementPolicy + - Added Interface ObjectReplicationPolicy + - Added Interface PrivateEndpointConnection + - Added Interface PrivateLinkResource + - Added Interface StorageAccount + - Added Interface TrackedResource + - Added function getContinuationToken + + ## 2.0.0 (2022-03-09) The package of @azure/arm-storage-profile-2020-09-01-hybrid is using our next generation design principles since version 2.0.0, which contains breaking changes. diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/_meta.json b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/_meta.json index 8b655c5a9c71..f231b8b888c1 100644 --- a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/_meta.json +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/_meta.json @@ -1,7 +1,8 @@ { "commit": "989a7d0e47a71a77d9a8e56f2a3eee0d366b6909", "readme": "specification/storage/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\\storage\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-beta.16 --tag=profile-hybrid-2020-09-01 --profile-content=profile-hybrid-2020-09-01", + "autorest_command": "autorest --version=3.9.3 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=F:\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\storage\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-rc.5.20221215.1 --generate-sample=true --profile-content=profile-hybrid-2020-09-01", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "use": "@autorest/typescript@6.0.0-beta.16" + "release_tool": "@azure-tools/js-sdk-release-tools@2.5.4", + "use": "@autorest/typescript@6.0.0-rc.5.20221215.1" } \ No newline at end of file diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/package.json b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/package.json index 0eb845775aad..e570e85f2f7a 100644 --- a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/package.json +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/package.json @@ -3,7 +3,7 @@ "sdk-type": "mgmt", "author": "Microsoft Corporation", "description": "A generated SDK for StorageManagementClient.", - "version": "2.0.1", + "version": "2.1.0", "engines": { "node": ">=14.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.6.1", "@azure/core-auth": "^1.3.0", - "@azure/core-rest-pipeline": "^1.1.0", + "@azure/core-rest-pipeline": "^1.8.0", "tslib": "^2.2.0" }, "keywords": [ @@ -36,15 +36,20 @@ "mkdirp": "^1.0.4", "rollup": "^2.66.1", "rollup-plugin-sourcemaps": "^0.6.3", - "typescript": "~4.2.0", + "typescript": "~4.8.0", "uglify-js": "^3.4.9", "rimraf": "^3.0.0", + "dotenv": "^8.2.0", "@azure/identity": "^2.0.1", - "@azure-tools/test-recorder": "^1.0.0", + "@azure-tools/test-recorder": "^2.0.0", + "@azure-tools/test-credential": "^1.0.0", "mocha": "^7.1.1", - "cross-env": "^7.0.2" + "@types/chai": "^4.2.8", + "chai": "^4.2.0", + "cross-env": "^7.0.2", + "@types/node": "^14.0.0", + "@azure/dev-tool": "^1.0.0" }, - "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid", "repository": { "type": "git", "url": "https://github.com/Azure/azure-sdk-for-js.git" @@ -93,9 +98,8 @@ "unit-test:node": "cross-env TEST_MODE=playback npm run integration-test:node", "unit-test:browser": "echo skipped", "integration-test": "npm run integration-test:node && npm run integration-test:browser", - "integration-test:node": "mocha -r esm --require ts-node/register --timeout 1200000 --full-trace test/*.ts --reporter ../../../common/tools/mocha-multi-reporter.js", - "integration-test:browser": "echo skipped", - "docs": "echo skipped" + "integration-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 'test/*.ts'", + "integration-test:browser": "echo skipped" }, "sideEffects": false, "//metadata": { @@ -106,5 +110,14 @@ } ] }, - "autoPublish": true -} + "autoPublish": true, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid", + "//sampleConfiguration": { + "productName": "", + "productSlugs": [ + "azure" + ], + "disableDocsMs": true, + "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-storage-profile-2020-09-01-hybrid?view=azure-node-preview" + } +} \ No newline at end of file diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/recordings/node/my_test/recording_sample_test.json b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/recordings/node/my_test/recording_sample_test.json new file mode 100644 index 000000000000..f721723386d8 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/recordings/node/my_test/recording_sample_test.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/review/arm-storage-profile-2020-09-01-hybrid.api.md b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/review/arm-storage-profile-2020-09-01-hybrid.api.md index 3a12d4da774d..3be9345c1589 100644 --- a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/review/arm-storage-profile-2020-09-01-hybrid.api.md +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/review/arm-storage-profile-2020-09-01-hybrid.api.md @@ -78,11 +78,11 @@ export interface BlobInventoryPoliciesListOptionalParams extends coreClient.Oper export type BlobInventoryPoliciesListResponse = ListBlobInventoryPolicy; // @public -export type BlobInventoryPolicy = Resource & { - readonly systemData?: SystemData; +export interface BlobInventoryPolicy extends Resource { readonly lastModifiedTime?: Date; policy?: BlobInventoryPolicySchema; -}; + readonly systemData?: SystemData; +} // @public export interface BlobInventoryPolicyDefinition { @@ -189,13 +189,13 @@ export interface Encryption { } // @public -export type EncryptionScope = Resource & { - source?: EncryptionScopeSource; - state?: EncryptionScopeState; +export interface EncryptionScope extends Resource { readonly creationTime?: Date; - readonly lastModifiedTime?: Date; keyVaultProperties?: EncryptionScopeKeyVaultProperties; -}; + readonly lastModifiedTime?: Date; + source?: EncryptionScopeSource; + state?: EncryptionScopeState; +} // @public export interface EncryptionScopeKeyVaultProperties { @@ -305,6 +305,9 @@ export interface GeoReplicationStats { // @public export type GeoReplicationStatus = string; +// @public +export function getContinuationToken(page: unknown): string | undefined; + // @public export type HttpProtocol = "https,http" | "https"; @@ -348,137 +351,99 @@ export type Kind = string; // @public export enum KnownBlobInventoryPolicyName { - // (undocumented) Default = "default" } // @public export enum KnownBlobRestoreProgressStatus { - // (undocumented) Complete = "Complete", - // (undocumented) Failed = "Failed", - // (undocumented) InProgress = "InProgress" } // @public export enum KnownBypass { - // (undocumented) AzureServices = "AzureServices", - // (undocumented) Logging = "Logging", - // (undocumented) Metrics = "Metrics", - // (undocumented) None = "None" } // @public export enum KnownCreatedByType { - // (undocumented) Application = "Application", - // (undocumented) Key = "Key", - // (undocumented) ManagedIdentity = "ManagedIdentity", - // (undocumented) User = "User" } // @public export enum KnownDirectoryServiceOptions { - // (undocumented) Aadds = "AADDS", - // (undocumented) AD = "AD", - // (undocumented) None = "None" } // @public export enum KnownEncryptionScopeSource { - // (undocumented) MicrosoftKeyVault = "Microsoft.KeyVault", - // (undocumented) MicrosoftStorage = "Microsoft.Storage" } // @public export enum KnownEncryptionScopeState { - // (undocumented) Disabled = "Disabled", - // (undocumented) Enabled = "Enabled" } // @public export enum KnownGeoReplicationStatus { - // (undocumented) Bootstrap = "Bootstrap", - // (undocumented) Live = "Live", - // (undocumented) Unavailable = "Unavailable" } // @public export enum KnownInventoryRuleType { - // (undocumented) Inventory = "Inventory" } // @public export enum KnownKeySource { - // (undocumented) MicrosoftKeyvault = "Microsoft.Keyvault", - // (undocumented) MicrosoftStorage = "Microsoft.Storage" } // @public export enum KnownKeyType { - // (undocumented) Account = "Account", - // (undocumented) Service = "Service" } // @public export enum KnownKind { - // (undocumented) BlobStorage = "BlobStorage", - // (undocumented) BlockBlobStorage = "BlockBlobStorage", - // (undocumented) FileStorage = "FileStorage", - // (undocumented) Storage = "Storage", - // (undocumented) StorageV2 = "StorageV2" } // @public export enum KnownLargeFileSharesState { - // (undocumented) Disabled = "Disabled", - // (undocumented) Enabled = "Enabled" } // @public export enum KnownManagementPolicyName { - // (undocumented) Default = "default" } // @public export enum KnownMinimumTlsVersion { - // (undocumented) TLS10 = "TLS1_0", - // (undocumented) TLS11 = "TLS1_1", - // (undocumented) TLS12 = "TLS1_2" } @@ -504,45 +469,33 @@ export enum KnownPermissions { // @public export enum KnownPrivateEndpointConnectionProvisioningState { - // (undocumented) Creating = "Creating", - // (undocumented) Deleting = "Deleting", - // (undocumented) Failed = "Failed", - // (undocumented) Succeeded = "Succeeded" } // @public export enum KnownPrivateEndpointServiceConnectionStatus { - // (undocumented) Approved = "Approved", - // (undocumented) Pending = "Pending", - // (undocumented) Rejected = "Rejected" } // @public export enum KnownReasonCode { - // (undocumented) NotAvailableForSubscription = "NotAvailableForSubscription", - // (undocumented) QuotaId = "QuotaId" } // @public export enum KnownRoutingChoice { - // (undocumented) InternetRouting = "InternetRouting", - // (undocumented) MicrosoftRouting = "MicrosoftRouting" } // @public export enum KnownRuleType { - // (undocumented) Lifecycle = "Lifecycle" } @@ -582,21 +535,13 @@ export enum KnownSignedResourceTypes { // @public export enum KnownSkuName { - // (undocumented) PremiumLRS = "Premium_LRS", - // (undocumented) PremiumZRS = "Premium_ZRS", - // (undocumented) StandardGRS = "Standard_GRS", - // (undocumented) StandardGzrs = "Standard_GZRS", - // (undocumented) StandardLRS = "Standard_LRS", - // (undocumented) StandardRagrs = "Standard_RAGRS", - // (undocumented) StandardRagzrs = "Standard_RAGZRS", - // (undocumented) StandardZRS = "Standard_ZRS" } @@ -644,10 +589,10 @@ export interface ManagementPoliciesGetOptionalParams extends coreClient.Operatio export type ManagementPoliciesGetResponse = ManagementPolicy; // @public -export type ManagementPolicy = Resource & { +export interface ManagementPolicy extends Resource { readonly lastModifiedTime?: Date; policy?: ManagementPolicySchema; -}; +} // @public export interface ManagementPolicyAction { @@ -770,13 +715,13 @@ export interface ObjectReplicationPoliciesOperations { } // @public -export type ObjectReplicationPolicy = Resource & { - readonly policyId?: string; - readonly enabledTime?: Date; - sourceAccount?: string; +export interface ObjectReplicationPolicy extends Resource { destinationAccount?: string; + readonly enabledTime?: Date; + readonly policyId?: string; rules?: ObjectReplicationPolicyRule[]; -}; + sourceAccount?: string; +} // @public export interface ObjectReplicationPolicyFilter { @@ -835,11 +780,11 @@ export interface PrivateEndpoint { } // @public -export type PrivateEndpointConnection = Resource & { +export interface PrivateEndpointConnection extends Resource { privateEndpoint?: PrivateEndpoint; privateLinkServiceConnectionState?: PrivateLinkServiceConnectionState; readonly provisioningState?: PrivateEndpointConnectionProvisioningState; -}; +} // @public export interface PrivateEndpointConnectionListResult { @@ -886,11 +831,11 @@ export type PrivateEndpointConnectionsPutResponse = PrivateEndpointConnection; export type PrivateEndpointServiceConnectionStatus = string; // @public -export type PrivateLinkResource = Resource & { +export interface PrivateLinkResource extends Resource { readonly groupId?: string; readonly requiredMembers?: string[]; requiredZoneNames?: string[]; -}; +} // @public export interface PrivateLinkResourceListResult { @@ -1033,36 +978,36 @@ export type SkuTier = "Standard" | "Premium"; export type State = "provisioning" | "deprovisioning" | "succeeded" | "failed" | "networkSourceDeleted"; // @public -export type StorageAccount = TrackedResource & { - readonly sku?: Sku; - readonly kind?: Kind; - identity?: Identity; - readonly provisioningState?: ProvisioningState; - readonly primaryEndpoints?: Endpoints; - readonly primaryLocation?: string; - readonly statusOfPrimary?: AccountStatus; - readonly lastGeoFailoverTime?: Date; - readonly secondaryLocation?: string; - readonly statusOfSecondary?: AccountStatus; - readonly creationTime?: Date; - readonly customDomain?: CustomDomain; - readonly secondaryEndpoints?: Endpoints; - readonly encryption?: Encryption; +export interface StorageAccount extends TrackedResource { readonly accessTier?: AccessTier; + allowBlobPublicAccess?: boolean; + allowSharedKeyAccess?: boolean; azureFilesIdentityBasedAuthentication?: AzureFilesIdentityBasedAuthentication; + readonly blobRestoreStatus?: BlobRestoreStatus; + readonly creationTime?: Date; + readonly customDomain?: CustomDomain; enableHttpsTrafficOnly?: boolean; - readonly networkRuleSet?: NetworkRuleSet; - isHnsEnabled?: boolean; - readonly geoReplicationStats?: GeoReplicationStats; + readonly encryption?: Encryption; readonly failoverInProgress?: boolean; + readonly geoReplicationStats?: GeoReplicationStats; + identity?: Identity; + isHnsEnabled?: boolean; + readonly kind?: Kind; largeFileSharesState?: LargeFileSharesState; + readonly lastGeoFailoverTime?: Date; + minimumTlsVersion?: MinimumTlsVersion; + readonly networkRuleSet?: NetworkRuleSet; + readonly primaryEndpoints?: Endpoints; + readonly primaryLocation?: string; readonly privateEndpointConnections?: PrivateEndpointConnection[]; + readonly provisioningState?: ProvisioningState; routingPreference?: RoutingPreference; - readonly blobRestoreStatus?: BlobRestoreStatus; - allowBlobPublicAccess?: boolean; - minimumTlsVersion?: MinimumTlsVersion; - allowSharedKeyAccess?: boolean; -}; + readonly secondaryEndpoints?: Endpoints; + readonly secondaryLocation?: string; + readonly sku?: Sku; + readonly statusOfPrimary?: AccountStatus; + readonly statusOfSecondary?: AccountStatus; +} // @public export interface StorageAccountCheckNameAvailabilityParameters { @@ -1343,12 +1288,12 @@ export interface TagFilter { } // @public -export type TrackedResource = Resource & { +export interface TrackedResource extends Resource { + location: string; tags?: { [propertyName: string]: string; }; - location: string; -}; +} // @public export interface Usage { diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/sample.env b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/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/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/blobInventoryPoliciesCreateOrUpdateSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/blobInventoryPoliciesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..e2a054728ee3 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/blobInventoryPoliciesCreateOrUpdateSample.ts @@ -0,0 +1,68 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + BlobInventoryPolicy, + StorageManagementClient +} from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Sets the blob inventory policy to the specified storage account. + * + * @summary Sets the blob inventory policy to the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountSetBlobInventoryPolicy.json + */ +async function storageAccountSetBlobInventoryPolicy() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "sto9699"; + const blobInventoryPolicyName = "default"; + const properties: BlobInventoryPolicy = { + policy: { + type: "Inventory", + destination: "containerName", + enabled: true, + rules: [ + { + name: "inventoryPolicyRule1", + definition: { + filters: { + blobTypes: ["blockBlob", "appendBlob", "pageBlob"], + includeBlobVersions: true, + includeSnapshots: true, + prefixMatch: ["inventoryprefix1", "inventoryprefix2"] + } + }, + enabled: true + } + ] + } + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.blobInventoryPolicies.createOrUpdate( + resourceGroupName, + accountName, + blobInventoryPolicyName, + properties + ); + console.log(result); +} + +async function main() { + storageAccountSetBlobInventoryPolicy(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/blobInventoryPoliciesDeleteSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/blobInventoryPoliciesDeleteSample.ts new file mode 100644 index 000000000000..a64197dea431 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/blobInventoryPoliciesDeleteSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the blob inventory policy associated with the specified storage account. + * + * @summary Deletes the blob inventory policy associated with the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountDeleteBlobInventoryPolicy.json + */ +async function storageAccountDeleteBlobInventoryPolicy() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const blobInventoryPolicyName = "default"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.blobInventoryPolicies.delete( + resourceGroupName, + accountName, + blobInventoryPolicyName + ); + console.log(result); +} + +async function main() { + storageAccountDeleteBlobInventoryPolicy(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/blobInventoryPoliciesGetSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/blobInventoryPoliciesGetSample.ts new file mode 100644 index 000000000000..e00f75d4931d --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/blobInventoryPoliciesGetSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the blob inventory policy associated with the specified storage account. + * + * @summary Gets the blob inventory policy associated with the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetBlobInventoryPolicy.json + */ +async function storageAccountGetBlobInventoryPolicy() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "sto9699"; + const blobInventoryPolicyName = "default"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.blobInventoryPolicies.get( + resourceGroupName, + accountName, + blobInventoryPolicyName + ); + console.log(result); +} + +async function main() { + storageAccountGetBlobInventoryPolicy(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/blobInventoryPoliciesListSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/blobInventoryPoliciesListSample.ts new file mode 100644 index 000000000000..5d48e77c6396 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/blobInventoryPoliciesListSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the blob inventory policy associated with the specified storage account. + * + * @summary Gets the blob inventory policy associated with the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListBlobInventoryPolicy.json + */ +async function storageAccountGetBlobInventoryPolicy() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "sto9699"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.blobInventoryPolicies.list( + resourceGroupName, + accountName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + storageAccountGetBlobInventoryPolicy(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/encryptionScopesGetSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/encryptionScopesGetSample.ts new file mode 100644 index 000000000000..d0d408092206 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/encryptionScopesGetSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Returns the properties for the specified encryption scope. + * + * @summary Returns the properties for the specified encryption scope. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetEncryptionScope.json + */ +async function storageAccountGetEncryptionScope() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = + process.env["STORAGE_RESOURCE_GROUP"] || "resource-group-name"; + const accountName = "{storage-account-name}"; + const encryptionScopeName = "{encryption-scope-name}"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.encryptionScopes.get( + resourceGroupName, + accountName, + encryptionScopeName + ); + console.log(result); +} + +async function main() { + storageAccountGetEncryptionScope(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/encryptionScopesListSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/encryptionScopesListSample.ts new file mode 100644 index 000000000000..1cf8b51fe7e9 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/encryptionScopesListSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Lists all the encryption scopes available under the specified storage account. + * + * @summary Lists all the encryption scopes available under the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountEncryptionScopeList.json + */ +async function storageAccountEncryptionScopeList() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = + process.env["STORAGE_RESOURCE_GROUP"] || "resource-group-name"; + const accountName = "{storage-account-name}"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.encryptionScopes.list( + resourceGroupName, + accountName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + storageAccountEncryptionScopeList(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/encryptionScopesPatchSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/encryptionScopesPatchSample.ts new file mode 100644 index 000000000000..48130658c033 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/encryptionScopesPatchSample.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 { + EncryptionScope, + StorageManagementClient +} from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. + * + * @summary Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountPatchEncryptionScope.json + */ +async function storageAccountPatchEncryptionScope() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = + process.env["STORAGE_RESOURCE_GROUP"] || "resource-group-name"; + const accountName = "{storage-account-name}"; + const encryptionScopeName = "{encryption-scope-name}"; + const encryptionScope: EncryptionScope = { + keyVaultProperties: { + keyUri: + "https://testvault.vault.core.windows.net/keys/key1/863425f1358359c" + }, + source: "Microsoft.KeyVault" + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.encryptionScopes.patch( + resourceGroupName, + accountName, + encryptionScopeName, + encryptionScope + ); + console.log(result); +} + +async function main() { + storageAccountPatchEncryptionScope(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/encryptionScopesPutSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/encryptionScopesPutSample.ts new file mode 100644 index 000000000000..a7535e101cd1 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/encryptionScopesPutSample.ts @@ -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. +import { + EncryptionScope, + StorageManagementClient +} from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Synchronously creates or updates an encryption scope under the specified storage account. If an encryption scope is already created and a subsequent request is issued with different properties, the encryption scope properties will be updated per the specified request. + * + * @summary Synchronously creates or updates an encryption scope under the specified storage account. If an encryption scope is already created and a subsequent request is issued with different properties, the encryption scope properties will be updated per the specified request. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountPutEncryptionScope.json + */ +async function storageAccountPutEncryptionScope() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = + process.env["STORAGE_RESOURCE_GROUP"] || "resource-group-name"; + const accountName = "{storage-account-name}"; + const encryptionScopeName = "{encryption-scope-name}"; + const encryptionScope: EncryptionScope = {}; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.encryptionScopes.put( + resourceGroupName, + accountName, + encryptionScopeName, + encryptionScope + ); + console.log(result); +} + +async function main() { + storageAccountPutEncryptionScope(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/managementPoliciesCreateOrUpdateSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/managementPoliciesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..aa9e14a37ea8 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/managementPoliciesCreateOrUpdateSample.ts @@ -0,0 +1,248 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + ManagementPolicy, + StorageManagementClient +} from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Sets the managementpolicy to the specified storage account. + * + * @summary Sets the managementpolicy to the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountSetManagementPolicy.json + */ +async function storageAccountSetManagementPolicies() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "sto9699"; + const managementPolicyName = "default"; + const properties: ManagementPolicy = { + policy: { + rules: [ + { + name: "olcmtest1", + type: "Lifecycle", + definition: { + actions: { + baseBlob: { + delete: { daysAfterModificationGreaterThan: 1000 }, + tierToArchive: { daysAfterModificationGreaterThan: 90 }, + tierToCool: { daysAfterModificationGreaterThan: 30 } + }, + snapshot: { delete: { daysAfterCreationGreaterThan: 30 } } + }, + filters: { + blobTypes: ["blockBlob"], + prefixMatch: ["olcmtestcontainer1"] + } + }, + enabled: true + }, + { + name: "olcmtest2", + type: "Lifecycle", + definition: { + actions: { + baseBlob: { + delete: { daysAfterModificationGreaterThan: 1000 }, + tierToArchive: { daysAfterModificationGreaterThan: 90 }, + tierToCool: { daysAfterModificationGreaterThan: 30 } + } + }, + filters: { + blobIndexMatch: [ + { name: "tag1", op: "==", value: "val1" }, + { name: "tag2", op: "==", value: "val2" } + ], + blobTypes: ["blockBlob"], + prefixMatch: ["olcmtestcontainer2"] + } + }, + enabled: true + } + ] + } + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.managementPolicies.createOrUpdate( + resourceGroupName, + accountName, + managementPolicyName, + properties + ); + console.log(result); +} + +/** + * This sample demonstrates how to Sets the managementpolicy to the specified storage account. + * + * @summary Sets the managementpolicy to the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountSetManagementPolicyForBlockAndAppendBlobs.json + */ +async function storageAccountSetManagementPolicyForBlockAndAppendBlobs() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "sto9699"; + const managementPolicyName = "default"; + const properties: ManagementPolicy = { + policy: { + rules: [ + { + name: "olcmtest1", + type: "Lifecycle", + definition: { + actions: { + baseBlob: { delete: { daysAfterModificationGreaterThan: 90 } }, + snapshot: { delete: { daysAfterCreationGreaterThan: 90 } }, + version: { delete: { daysAfterCreationGreaterThan: 90 } } + }, + filters: { + blobTypes: ["blockBlob", "appendBlob"], + prefixMatch: ["olcmtestcontainer1"] + } + }, + enabled: true + } + ] + } + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.managementPolicies.createOrUpdate( + resourceGroupName, + accountName, + managementPolicyName, + properties + ); + console.log(result); +} + +/** + * This sample demonstrates how to Sets the managementpolicy to the specified storage account. + * + * @summary Sets the managementpolicy to the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountSetManagementPolicyWithSnapshotAndVersion.json + */ +async function storageAccountSetManagementPolicyWithSnapshotAndVersion() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "sto9699"; + const managementPolicyName = "default"; + const properties: ManagementPolicy = { + policy: { + rules: [ + { + name: "olcmtest1", + type: "Lifecycle", + definition: { + actions: { + baseBlob: { + delete: { daysAfterModificationGreaterThan: 1000 }, + tierToArchive: { daysAfterModificationGreaterThan: 90 }, + tierToCool: { daysAfterModificationGreaterThan: 30 } + }, + snapshot: { + delete: { daysAfterCreationGreaterThan: 1000 }, + tierToArchive: { daysAfterCreationGreaterThan: 90 }, + tierToCool: { daysAfterCreationGreaterThan: 30 } + }, + version: { + delete: { daysAfterCreationGreaterThan: 1000 }, + tierToArchive: { daysAfterCreationGreaterThan: 90 }, + tierToCool: { daysAfterCreationGreaterThan: 30 } + } + }, + filters: { + blobTypes: ["blockBlob"], + prefixMatch: ["olcmtestcontainer1"] + } + }, + enabled: true + } + ] + } + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.managementPolicies.createOrUpdate( + resourceGroupName, + accountName, + managementPolicyName, + properties + ); + console.log(result); +} + +/** + * This sample demonstrates how to Sets the managementpolicy to the specified storage account. + * + * @summary Sets the managementpolicy to the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountSetManagementPolicy_LastAccessTimeBasedBlobActions.json + */ +async function storageAccountSetManagementPolicyLastAccessTimeBasedBlobActions() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "sto9699"; + const managementPolicyName = "default"; + const properties: ManagementPolicy = { + policy: { + rules: [ + { + name: "olcmtest", + type: "Lifecycle", + definition: { + actions: { + baseBlob: { + delete: { daysAfterLastAccessTimeGreaterThan: 1000 }, + enableAutoTierToHotFromCool: true, + tierToArchive: { daysAfterLastAccessTimeGreaterThan: 90 }, + tierToCool: { daysAfterLastAccessTimeGreaterThan: 30 } + }, + snapshot: { delete: { daysAfterCreationGreaterThan: 30 } } + }, + filters: { + blobTypes: ["blockBlob"], + prefixMatch: ["olcmtestcontainer"] + } + }, + enabled: true + } + ] + } + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.managementPolicies.createOrUpdate( + resourceGroupName, + accountName, + managementPolicyName, + properties + ); + console.log(result); +} + +async function main() { + storageAccountSetManagementPolicies(); + storageAccountSetManagementPolicyForBlockAndAppendBlobs(); + storageAccountSetManagementPolicyWithSnapshotAndVersion(); + storageAccountSetManagementPolicyLastAccessTimeBasedBlobActions(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/managementPoliciesDeleteSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/managementPoliciesDeleteSample.ts new file mode 100644 index 000000000000..85052c069aec --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/managementPoliciesDeleteSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the managementpolicy associated with the specified storage account. + * + * @summary Deletes the managementpolicy associated with the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountDeleteManagementPolicy.json + */ +async function storageAccountDeleteManagementPolicies() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const managementPolicyName = "default"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.managementPolicies.delete( + resourceGroupName, + accountName, + managementPolicyName + ); + console.log(result); +} + +async function main() { + storageAccountDeleteManagementPolicies(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/managementPoliciesGetSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/managementPoliciesGetSample.ts new file mode 100644 index 000000000000..6a7d29fb1a88 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/managementPoliciesGetSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the managementpolicy associated with the specified storage account. + * + * @summary Gets the managementpolicy associated with the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetManagementPolicy.json + */ +async function storageAccountGetManagementPolicies() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const managementPolicyName = "default"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.managementPolicies.get( + resourceGroupName, + accountName, + managementPolicyName + ); + console.log(result); +} + +async function main() { + storageAccountGetManagementPolicies(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/objectReplicationPoliciesCreateOrUpdateSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/objectReplicationPoliciesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..116f2aac0ad7 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/objectReplicationPoliciesCreateOrUpdateSample.ts @@ -0,0 +1,175 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + ObjectReplicationPolicy, + StorageManagementClient +} from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Create or update the object replication policy of the storage account. + * + * @summary Create or update the object replication policy of the storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountCreateObjectReplicationPolicyOnDestination.json + */ +async function storageAccountCreateObjectReplicationPolicyOnDestination() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "dst112"; + const objectReplicationPolicyId = "default"; + const properties: ObjectReplicationPolicy = { + destinationAccount: "dst112", + rules: [ + { + destinationContainer: "dcont139", + filters: { prefixMatch: ["blobA", "blobB"] }, + sourceContainer: "scont139" + } + ], + sourceAccount: "src1122" + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.objectReplicationPoliciesOperations.createOrUpdate( + resourceGroupName, + accountName, + objectReplicationPolicyId, + properties + ); + console.log(result); +} + +/** + * This sample demonstrates how to Create or update the object replication policy of the storage account. + * + * @summary Create or update the object replication policy of the storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountCreateObjectReplicationPolicyOnSource.json + */ +async function storageAccountCreateObjectReplicationPolicyOnSource() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "src1122"; + const objectReplicationPolicyId = "2a20bb73-5717-4635-985a-5d4cf777438f"; + const properties: ObjectReplicationPolicy = { + destinationAccount: "dst112", + rules: [ + { + destinationContainer: "dcont139", + filters: { + minCreationTime: "2020-02-19T16:05:00Z", + prefixMatch: ["blobA", "blobB"] + }, + ruleId: "d5d18a48-8801-4554-aeaa-74faf65f5ef9", + sourceContainer: "scont139" + } + ], + sourceAccount: "src1122" + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.objectReplicationPoliciesOperations.createOrUpdate( + resourceGroupName, + accountName, + objectReplicationPolicyId, + properties + ); + console.log(result); +} + +/** + * This sample demonstrates how to Create or update the object replication policy of the storage account. + * + * @summary Create or update the object replication policy of the storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountUpdateObjectReplicationPolicyOnDestination.json + */ +async function storageAccountUpdateObjectReplicationPolicyOnDestination() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "dst112"; + const objectReplicationPolicyId = "2a20bb73-5717-4635-985a-5d4cf777438f"; + const properties: ObjectReplicationPolicy = { + destinationAccount: "dst112", + rules: [ + { + destinationContainer: "dcont139", + filters: { prefixMatch: ["blobA", "blobB"] }, + ruleId: "d5d18a48-8801-4554-aeaa-74faf65f5ef9", + sourceContainer: "scont139" + }, + { destinationContainer: "dcont179", sourceContainer: "scont179" } + ], + sourceAccount: "src1122" + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.objectReplicationPoliciesOperations.createOrUpdate( + resourceGroupName, + accountName, + objectReplicationPolicyId, + properties + ); + console.log(result); +} + +/** + * This sample demonstrates how to Create or update the object replication policy of the storage account. + * + * @summary Create or update the object replication policy of the storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountUpdateObjectReplicationPolicyOnSource.json + */ +async function storageAccountUpdateObjectReplicationPolicyOnSource() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "src1122"; + const objectReplicationPolicyId = "2a20bb73-5717-4635-985a-5d4cf777438f"; + const properties: ObjectReplicationPolicy = { + destinationAccount: "dst112", + rules: [ + { + destinationContainer: "dcont139", + filters: { prefixMatch: ["blobA", "blobB"] }, + ruleId: "d5d18a48-8801-4554-aeaa-74faf65f5ef9", + sourceContainer: "scont139" + }, + { + destinationContainer: "dcont179", + ruleId: "cfbb4bc2-8b60-429f-b05a-d1e0942b33b2", + sourceContainer: "scont179" + } + ], + sourceAccount: "src1122" + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.objectReplicationPoliciesOperations.createOrUpdate( + resourceGroupName, + accountName, + objectReplicationPolicyId, + properties + ); + console.log(result); +} + +async function main() { + storageAccountCreateObjectReplicationPolicyOnDestination(); + storageAccountCreateObjectReplicationPolicyOnSource(); + storageAccountUpdateObjectReplicationPolicyOnDestination(); + storageAccountUpdateObjectReplicationPolicyOnSource(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/objectReplicationPoliciesDeleteSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/objectReplicationPoliciesDeleteSample.ts new file mode 100644 index 000000000000..4f172e81dad9 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/objectReplicationPoliciesDeleteSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the object replication policy associated with the specified storage account. + * + * @summary Deletes the object replication policy associated with the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountDeleteObjectReplicationPolicy.json + */ +async function storageAccountDeleteObjectReplicationPolicies() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const objectReplicationPolicyId = "{objectReplicationPolicy-Id}"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.objectReplicationPoliciesOperations.delete( + resourceGroupName, + accountName, + objectReplicationPolicyId + ); + console.log(result); +} + +async function main() { + storageAccountDeleteObjectReplicationPolicies(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/objectReplicationPoliciesGetSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/objectReplicationPoliciesGetSample.ts new file mode 100644 index 000000000000..48d2e0e5f279 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/objectReplicationPoliciesGetSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get the object replication policy of the storage account by policy ID. + * + * @summary Get the object replication policy of the storage account by policy ID. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetObjectReplicationPolicy.json + */ +async function storageAccountGetObjectReplicationPolicies() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const objectReplicationPolicyId = "{objectReplicationPolicy-Id}"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.objectReplicationPoliciesOperations.get( + resourceGroupName, + accountName, + objectReplicationPolicyId + ); + console.log(result); +} + +async function main() { + storageAccountGetObjectReplicationPolicies(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/objectReplicationPoliciesListSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/objectReplicationPoliciesListSample.ts new file mode 100644 index 000000000000..29d06ab5c714 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/objectReplicationPoliciesListSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List the object replication policies associated with the storage account. + * + * @summary List the object replication policies associated with the storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListObjectReplicationPolicies.json + */ +async function storageAccountListObjectReplicationPolicies() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.objectReplicationPoliciesOperations.list( + resourceGroupName, + accountName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + storageAccountListObjectReplicationPolicies(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/operationsListSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/operationsListSample.ts new file mode 100644 index 000000000000..667b9b0e5f52 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/operationsListSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Lists all of the available Storage Rest API operations. + * + * @summary Lists all of the available Storage Rest API operations. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/OperationsList.json + */ +async function operationsList() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + operationsList(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/privateEndpointConnectionsDeleteSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/privateEndpointConnectionsDeleteSample.ts new file mode 100644 index 000000000000..b11de18e4b3e --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/privateEndpointConnectionsDeleteSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified private endpoint connection associated with the storage account. + * + * @summary Deletes the specified private endpoint connection associated with the storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountDeletePrivateEndpointConnection.json + */ +async function storageAccountDeletePrivateEndpointConnection() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const privateEndpointConnectionName = "{privateEndpointConnectionName}"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.delete( + resourceGroupName, + accountName, + privateEndpointConnectionName + ); + console.log(result); +} + +async function main() { + storageAccountDeletePrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/privateEndpointConnectionsGetSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/privateEndpointConnectionsGetSample.ts new file mode 100644 index 000000000000..9c398fc3f3bc --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/privateEndpointConnectionsGetSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified private endpoint connection associated with the storage account. + * + * @summary Gets the specified private endpoint connection associated with the storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetPrivateEndpointConnection.json + */ +async function storageAccountGetPrivateEndpointConnection() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const privateEndpointConnectionName = "{privateEndpointConnectionName}"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.get( + resourceGroupName, + accountName, + privateEndpointConnectionName + ); + console.log(result); +} + +async function main() { + storageAccountGetPrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/privateEndpointConnectionsListSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/privateEndpointConnectionsListSample.ts new file mode 100644 index 000000000000..f0de0974655f --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/privateEndpointConnectionsListSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List all the private endpoint connections associated with the storage account. + * + * @summary List all the private endpoint connections associated with the storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListPrivateEndpointConnections.json + */ +async function storageAccountListPrivateEndpointConnections() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.privateEndpointConnections.list( + resourceGroupName, + accountName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + storageAccountListPrivateEndpointConnections(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/privateEndpointConnectionsPutSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/privateEndpointConnectionsPutSample.ts new file mode 100644 index 000000000000..f12a79ad79b2 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/privateEndpointConnectionsPutSample.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 { + PrivateEndpointConnection, + StorageManagementClient +} from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Update the state of specified private endpoint connection associated with the storage account. + * + * @summary Update the state of specified private endpoint connection associated with the storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountPutPrivateEndpointConnection.json + */ +async function storageAccountPutPrivateEndpointConnection() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "sto9699"; + const privateEndpointConnectionName = "{privateEndpointConnectionName}"; + const properties: PrivateEndpointConnection = { + privateLinkServiceConnectionState: { + description: "Auto-Approved", + status: "Approved" + } + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.put( + resourceGroupName, + accountName, + privateEndpointConnectionName, + properties + ); + console.log(result); +} + +async function main() { + storageAccountPutPrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/privateLinkResourcesListByStorageAccountSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/privateLinkResourcesListByStorageAccountSample.ts new file mode 100644 index 000000000000..70672ca23760 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/privateLinkResourcesListByStorageAccountSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the private link resources that need to be created for a storage account. + * + * @summary Gets the private link resources that need to be created for a storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListPrivateLinkResources.json + */ +async function storageAccountListPrivateLinkResources() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.privateLinkResources.listByStorageAccount( + resourceGroupName, + accountName + ); + console.log(result); +} + +async function main() { + storageAccountListPrivateLinkResources(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/skusListSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/skusListSample.ts new file mode 100644 index 000000000000..8fe8ed8a43a8 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/skusListSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Lists the available SKUs supported by Microsoft.Storage for given subscription. + * + * @summary Lists the available SKUs supported by Microsoft.Storage for given subscription. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/SKUList.json + */ +async function skuList() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.skus.list()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + skuList(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsCheckNameAvailabilitySample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsCheckNameAvailabilitySample.ts new file mode 100644 index 000000000000..d84584c2b004 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsCheckNameAvailabilitySample.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 { + StorageAccountCheckNameAvailabilityParameters, + StorageManagementClient +} from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Checks that the storage account name is valid and is not already in use. + * + * @summary Checks that the storage account name is valid and is not already in use. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountCheckNameAvailability.json + */ +async function storageAccountCheckNameAvailability() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const accountName: StorageAccountCheckNameAvailabilityParameters = { + name: "sto3363", + type: "Microsoft.Storage/storageAccounts" + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.checkNameAvailability( + accountName + ); + console.log(result); +} + +async function main() { + storageAccountCheckNameAvailability(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsCreateSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsCreateSample.ts new file mode 100644 index 000000000000..bd442a504800 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsCreateSample.ts @@ -0,0 +1,68 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + StorageAccountCreateParameters, + StorageManagementClient +} from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or update request is issued with the exact same set of properties, the request will succeed. + * + * @summary Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or update request is issued with the exact same set of properties, the request will succeed. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountCreate.json + */ +async function storageAccountCreate() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res9101"; + const accountName = "sto4445"; + const parameters: StorageAccountCreateParameters = { + allowBlobPublicAccess: false, + allowSharedKeyAccess: true, + encryption: { + keySource: "Microsoft.Storage", + requireInfrastructureEncryption: false, + services: { + blob: { enabled: true, keyType: "Account" }, + file: { enabled: true, keyType: "Account" } + } + }, + isHnsEnabled: true, + kind: "Storage", + location: "eastus", + minimumTlsVersion: "TLS1_2", + routingPreference: { + publishInternetEndpoints: true, + publishMicrosoftEndpoints: true, + routingChoice: "MicrosoftRouting" + }, + sku: { name: "Standard_GRS" }, + tags: { key1: "value1", key2: "value2" } + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.beginCreateAndWait( + resourceGroupName, + accountName, + parameters + ); + console.log(result); +} + +async function main() { + storageAccountCreate(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsDeleteSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsDeleteSample.ts new file mode 100644 index 000000000000..0bb0ea25ac05 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsDeleteSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes a storage account in Microsoft Azure. + * + * @summary Deletes a storage account in Microsoft Azure. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountDelete.json + */ +async function storageAccountDelete() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res4228"; + const accountName = "sto2434"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.delete( + resourceGroupName, + accountName + ); + console.log(result); +} + +async function main() { + storageAccountDelete(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsFailoverSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsFailoverSample.ts new file mode 100644 index 000000000000..9339d2919fb0 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsFailoverSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. + * + * @summary Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountFailover.json + */ +async function storageAccountFailover() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res4228"; + const accountName = "sto2434"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.beginFailoverAndWait( + resourceGroupName, + accountName + ); + console.log(result); +} + +async function main() { + storageAccountFailover(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsGetPropertiesSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsGetPropertiesSample.ts new file mode 100644 index 000000000000..b0e31236a2e9 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsGetPropertiesSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. + * + * @summary Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetProperties.json + */ +async function storageAccountGetProperties() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res9407"; + const accountName = "sto8596"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.getProperties( + resourceGroupName, + accountName + ); + console.log(result); +} + +/** + * This sample demonstrates how to Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. + * + * @summary Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetPropertiesCMKEnabled.json + */ +async function storageAccountGetPropertiesCmkEnabled() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res9407"; + const accountName = "sto8596"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.getProperties( + resourceGroupName, + accountName + ); + console.log(result); +} + +async function main() { + storageAccountGetProperties(); + storageAccountGetPropertiesCmkEnabled(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsListAccountSasSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsListAccountSasSample.ts new file mode 100644 index 000000000000..1d591cdc034c --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsListAccountSasSample.ts @@ -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. +import { + AccountSasParameters, + StorageManagementClient +} from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List SAS credentials of a storage account. + * + * @summary List SAS credentials of a storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListAccountSAS.json + */ +async function storageAccountListAccountSas() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7985"; + const accountName = "sto8588"; + const parameters: AccountSasParameters = { + keyToSign: "key1", + sharedAccessExpiryTime: new Date("2017-05-24T11:42:03.1567373Z"), + permissions: "r", + protocols: "https,http", + resourceTypes: "s", + services: "b", + sharedAccessStartTime: new Date("2017-05-24T10:42:03.1567373Z") + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.listAccountSAS( + resourceGroupName, + accountName, + parameters + ); + console.log(result); +} + +async function main() { + storageAccountListAccountSas(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsListByResourceGroupSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsListByResourceGroupSample.ts new file mode 100644 index 000000000000..5486237cee03 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsListByResourceGroupSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. + * + * @summary Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListByResourceGroup.json + */ +async function storageAccountListByResourceGroup() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6117"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.storageAccounts.listByResourceGroup( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + storageAccountListByResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsListKeysSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsListKeysSample.ts new file mode 100644 index 000000000000..b353f6dd962f --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsListKeysSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. + * + * @summary Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListKeys.json + */ +async function storageAccountListKeys() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res418"; + const accountName = "sto2220"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.listKeys( + resourceGroupName, + accountName + ); + console.log(result); +} + +async function main() { + storageAccountListKeys(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsListSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsListSample.ts new file mode 100644 index 000000000000..d5db0af11bd4 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsListSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. + * + * @summary Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountList.json + */ +async function storageAccountList() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.storageAccounts.list()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + storageAccountList(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsListServiceSasSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsListServiceSasSample.ts new file mode 100644 index 000000000000..2245b646d3da --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsListServiceSasSample.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 { + ServiceSasParameters, + StorageManagementClient +} from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List service SAS credentials of a specific resource. + * + * @summary List service SAS credentials of a specific resource. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListServiceSAS.json + */ +async function storageAccountListServiceSas() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7439"; + const accountName = "sto1299"; + const parameters: ServiceSasParameters = { + canonicalizedResource: "/blob/sto1299/music", + sharedAccessExpiryTime: new Date("2017-05-24T11:32:48.8457197Z"), + permissions: "l", + resource: "c" + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.listServiceSAS( + resourceGroupName, + accountName, + parameters + ); + console.log(result); +} + +async function main() { + storageAccountListServiceSas(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsRegenerateKeySample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsRegenerateKeySample.ts new file mode 100644 index 000000000000..0c853fdac121 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsRegenerateKeySample.ts @@ -0,0 +1,73 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + StorageAccountRegenerateKeyParameters, + StorageManagementClient +} from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Regenerates one of the access keys or Kerberos keys for the specified storage account. + * + * @summary Regenerates one of the access keys or Kerberos keys for the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountRegenerateKerbKey.json + */ +async function storageAccountRegenerateKerbKey() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res4167"; + const accountName = "sto3539"; + const regenerateKey: StorageAccountRegenerateKeyParameters = { + keyName: "kerb1" + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.regenerateKey( + resourceGroupName, + accountName, + regenerateKey + ); + console.log(result); +} + +/** + * This sample demonstrates how to Regenerates one of the access keys or Kerberos keys for the specified storage account. + * + * @summary Regenerates one of the access keys or Kerberos keys for the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountRegenerateKey.json + */ +async function storageAccountRegenerateKey() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res4167"; + const accountName = "sto3539"; + const regenerateKey: StorageAccountRegenerateKeyParameters = { + keyName: "key2" + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.regenerateKey( + resourceGroupName, + accountName, + regenerateKey + ); + console.log(result); +} + +async function main() { + storageAccountRegenerateKerbKey(); + storageAccountRegenerateKey(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsRestoreBlobRangesSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsRestoreBlobRangesSample.ts new file mode 100644 index 000000000000..7669cd727294 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsRestoreBlobRangesSample.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + BlobRestoreParameters, + StorageManagementClient +} from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Restore blobs in the specified blob ranges + * + * @summary Restore blobs in the specified blob ranges + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/BlobRangesRestore.json + */ +async function blobRangesRestore() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res9101"; + const accountName = "sto4445"; + const parameters: BlobRestoreParameters = { + blobRanges: [ + { endRange: "container/blobpath2", startRange: "container/blobpath1" }, + { endRange: "", startRange: "container2/blobpath3" } + ], + timeToRestore: new Date("2019-04-20T15:30:00.0000000Z") + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.beginRestoreBlobRangesAndWait( + resourceGroupName, + accountName, + parameters + ); + console.log(result); +} + +async function main() { + blobRangesRestore(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsRevokeUserDelegationKeysSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsRevokeUserDelegationKeysSample.ts new file mode 100644 index 000000000000..bcb4f7fe3fd4 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsRevokeUserDelegationKeysSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Revoke user delegation keys. + * + * @summary Revoke user delegation keys. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountRevokeUserDelegationKeys.json + */ +async function storageAccountRevokeUserDelegationKeys() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res4167"; + const accountName = "sto3539"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.revokeUserDelegationKeys( + resourceGroupName, + accountName + ); + console.log(result); +} + +async function main() { + storageAccountRevokeUserDelegationKeys(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsUpdateSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsUpdateSample.ts new file mode 100644 index 000000000000..cf8bc525659a --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/storageAccountsUpdateSample.ts @@ -0,0 +1,134 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + StorageAccountUpdateParameters, + StorageManagementClient +} from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not supported. In order to replace an old custom domain, the old value must be cleared/unregistered before a new value can be set. The update of multiple properties is supported. This call does not change the storage keys for the account. If you want to change the storage account keys, use the regenerate keys operation. The location and name of the storage account cannot be changed after creation. + * + * @summary The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not supported. In order to replace an old custom domain, the old value must be cleared/unregistered before a new value can be set. The update of multiple properties is supported. This call does not change the storage keys for the account. If you want to change the storage account keys, use the regenerate keys operation. The location and name of the storage account cannot be changed after creation. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountEnableAD.json + */ +async function storageAccountEnableAd() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res9407"; + const accountName = "sto8596"; + const parameters: StorageAccountUpdateParameters = { + azureFilesIdentityBasedAuthentication: { + activeDirectoryProperties: { + azureStorageSid: "S-1-5-21-2400535526-2334094090-2402026252-0012", + domainGuid: "aebfc118-9fa9-4732-a21f-d98e41a77ae1", + domainName: "adtest.com", + domainSid: "S-1-5-21-2400535526-2334094090-2402026252", + forestName: "adtest.com", + netBiosDomainName: "adtest.com" + }, + directoryServiceOptions: "AD" + } + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.update( + resourceGroupName, + accountName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not supported. In order to replace an old custom domain, the old value must be cleared/unregistered before a new value can be set. The update of multiple properties is supported. This call does not change the storage keys for the account. If you want to change the storage account keys, use the regenerate keys operation. The location and name of the storage account cannot be changed after creation. + * + * @summary The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not supported. In order to replace an old custom domain, the old value must be cleared/unregistered before a new value can be set. The update of multiple properties is supported. This call does not change the storage keys for the account. If you want to change the storage account keys, use the regenerate keys operation. The location and name of the storage account cannot be changed after creation. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountEnableCMK.json + */ +async function storageAccountEnableCmk() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res9407"; + const accountName = "sto8596"; + const parameters: StorageAccountUpdateParameters = { + encryption: { + keySource: "Microsoft.Keyvault", + keyVaultProperties: { + keyName: "wrappingKey", + keyVaultUri: "https://myvault8569.vault.azure.net", + keyVersion: "" + }, + services: { + blob: { enabled: true, keyType: "Account" }, + file: { enabled: true, keyType: "Account" } + } + } + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.update( + resourceGroupName, + accountName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not supported. In order to replace an old custom domain, the old value must be cleared/unregistered before a new value can be set. The update of multiple properties is supported. This call does not change the storage keys for the account. If you want to change the storage account keys, use the regenerate keys operation. The location and name of the storage account cannot be changed after creation. + * + * @summary The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not supported. In order to replace an old custom domain, the old value must be cleared/unregistered before a new value can be set. The update of multiple properties is supported. This call does not change the storage keys for the account. If you want to change the storage account keys, use the regenerate keys operation. The location and name of the storage account cannot be changed after creation. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountUpdate.json + */ +async function storageAccountUpdate() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res9407"; + const accountName = "sto8596"; + const parameters: StorageAccountUpdateParameters = { + allowBlobPublicAccess: false, + allowSharedKeyAccess: true, + encryption: { + keySource: "Microsoft.Storage", + services: { + blob: { enabled: true, keyType: "Account" }, + file: { enabled: true, keyType: "Account" } + } + }, + minimumTlsVersion: "TLS1_2", + networkRuleSet: { defaultAction: "Allow" }, + routingPreference: { + publishInternetEndpoints: true, + publishMicrosoftEndpoints: true, + routingChoice: "MicrosoftRouting" + } + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.update( + resourceGroupName, + accountName, + parameters + ); + console.log(result); +} + +async function main() { + storageAccountEnableAd(); + storageAccountEnableCmk(); + storageAccountUpdate(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/usagesListByLocationSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/usagesListByLocationSample.ts new file mode 100644 index 000000000000..d674d608d0f4 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples-dev/usagesListByLocationSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the current usage count and the limit for the resources of the location under the subscription. + * + * @summary Gets the current usage count and the limit for the resources of the location under the subscription. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListLocationUsage.json + */ +async function usageList() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const location = "eastus2(stage)"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.usages.listByLocation(location)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + usageList(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/README.md b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/README.md new file mode 100644 index 000000000000..2d06518cf503 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/README.md @@ -0,0 +1,122 @@ +# client library samples for JavaScript + +These sample programs show how to use the JavaScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [blobInventoryPoliciesCreateOrUpdateSample.js][blobinventorypoliciescreateorupdatesample] | Sets the blob inventory policy to the specified storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountSetBlobInventoryPolicy.json | +| [blobInventoryPoliciesDeleteSample.js][blobinventorypoliciesdeletesample] | Deletes the blob inventory policy associated with the specified storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountDeleteBlobInventoryPolicy.json | +| [blobInventoryPoliciesGetSample.js][blobinventorypoliciesgetsample] | Gets the blob inventory policy associated with the specified storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetBlobInventoryPolicy.json | +| [blobInventoryPoliciesListSample.js][blobinventorypolicieslistsample] | Gets the blob inventory policy associated with the specified storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListBlobInventoryPolicy.json | +| [encryptionScopesGetSample.js][encryptionscopesgetsample] | Returns the properties for the specified encryption scope. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetEncryptionScope.json | +| [encryptionScopesListSample.js][encryptionscopeslistsample] | Lists all the encryption scopes available under the specified storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountEncryptionScopeList.json | +| [encryptionScopesPatchSample.js][encryptionscopespatchsample] | Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountPatchEncryptionScope.json | +| [encryptionScopesPutSample.js][encryptionscopesputsample] | Synchronously creates or updates an encryption scope under the specified storage account. If an encryption scope is already created and a subsequent request is issued with different properties, the encryption scope properties will be updated per the specified request. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountPutEncryptionScope.json | +| [managementPoliciesCreateOrUpdateSample.js][managementpoliciescreateorupdatesample] | Sets the managementpolicy to the specified storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountSetManagementPolicy.json | +| [managementPoliciesDeleteSample.js][managementpoliciesdeletesample] | Deletes the managementpolicy associated with the specified storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountDeleteManagementPolicy.json | +| [managementPoliciesGetSample.js][managementpoliciesgetsample] | Gets the managementpolicy associated with the specified storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetManagementPolicy.json | +| [objectReplicationPoliciesCreateOrUpdateSample.js][objectreplicationpoliciescreateorupdatesample] | Create or update the object replication policy of the storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountCreateObjectReplicationPolicyOnDestination.json | +| [objectReplicationPoliciesDeleteSample.js][objectreplicationpoliciesdeletesample] | Deletes the object replication policy associated with the specified storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountDeleteObjectReplicationPolicy.json | +| [objectReplicationPoliciesGetSample.js][objectreplicationpoliciesgetsample] | Get the object replication policy of the storage account by policy ID. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetObjectReplicationPolicy.json | +| [objectReplicationPoliciesListSample.js][objectreplicationpolicieslistsample] | List the object replication policies associated with the storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListObjectReplicationPolicies.json | +| [operationsListSample.js][operationslistsample] | Lists all of the available Storage Rest API operations. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/OperationsList.json | +| [privateEndpointConnectionsDeleteSample.js][privateendpointconnectionsdeletesample] | Deletes the specified private endpoint connection associated with the storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountDeletePrivateEndpointConnection.json | +| [privateEndpointConnectionsGetSample.js][privateendpointconnectionsgetsample] | Gets the specified private endpoint connection associated with the storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetPrivateEndpointConnection.json | +| [privateEndpointConnectionsListSample.js][privateendpointconnectionslistsample] | List all the private endpoint connections associated with the storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListPrivateEndpointConnections.json | +| [privateEndpointConnectionsPutSample.js][privateendpointconnectionsputsample] | Update the state of specified private endpoint connection associated with the storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountPutPrivateEndpointConnection.json | +| [privateLinkResourcesListByStorageAccountSample.js][privatelinkresourceslistbystorageaccountsample] | Gets the private link resources that need to be created for a storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListPrivateLinkResources.json | +| [skusListSample.js][skuslistsample] | Lists the available SKUs supported by Microsoft.Storage for given subscription. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/SKUList.json | +| [storageAccountsCheckNameAvailabilitySample.js][storageaccountschecknameavailabilitysample] | Checks that the storage account name is valid and is not already in use. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountCheckNameAvailability.json | +| [storageAccountsCreateSample.js][storageaccountscreatesample] | Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or update request is issued with the exact same set of properties, the request will succeed. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountCreate.json | +| [storageAccountsDeleteSample.js][storageaccountsdeletesample] | Deletes a storage account in Microsoft Azure. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountDelete.json | +| [storageAccountsFailoverSample.js][storageaccountsfailoversample] | Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountFailover.json | +| [storageAccountsGetPropertiesSample.js][storageaccountsgetpropertiessample] | Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetProperties.json | +| [storageAccountsListAccountSasSample.js][storageaccountslistaccountsassample] | List SAS credentials of a storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListAccountSAS.json | +| [storageAccountsListByResourceGroupSample.js][storageaccountslistbyresourcegroupsample] | Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListByResourceGroup.json | +| [storageAccountsListKeysSample.js][storageaccountslistkeyssample] | Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListKeys.json | +| [storageAccountsListSample.js][storageaccountslistsample] | Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountList.json | +| [storageAccountsListServiceSasSample.js][storageaccountslistservicesassample] | List service SAS credentials of a specific resource. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListServiceSAS.json | +| [storageAccountsRegenerateKeySample.js][storageaccountsregeneratekeysample] | Regenerates one of the access keys or Kerberos keys for the specified storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountRegenerateKerbKey.json | +| [storageAccountsRestoreBlobRangesSample.js][storageaccountsrestoreblobrangessample] | Restore blobs in the specified blob ranges x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/BlobRangesRestore.json | +| [storageAccountsRevokeUserDelegationKeysSample.js][storageaccountsrevokeuserdelegationkeyssample] | Revoke user delegation keys. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountRevokeUserDelegationKeys.json | +| [storageAccountsUpdateSample.js][storageaccountsupdatesample] | The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not supported. In order to replace an old custom domain, the old value must be cleared/unregistered before a new value can be set. The update of multiple properties is supported. This call does not change the storage keys for the account. If you want to change the storage account keys, use the regenerate keys operation. The location and name of the storage account cannot be changed after creation. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountEnableAD.json | +| [usagesListByLocationSample.js][usageslistbylocationsample] | Gets the current usage count and the limit for the resources of the location under the subscription. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListLocationUsage.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). + +You need [an Azure subscription][freesub] to run these sample programs. + +Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. + +Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. + +## Setup + +To run the samples using the published version of the package: + +1. Install the dependencies using `npm`: + +```bash +npm install +``` + +2. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. + +3. Run whichever samples you like (note that some samples may require additional setup, see the table above): + +```bash +node blobInventoryPoliciesCreateOrUpdateSample.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 STORAGE_SUBSCRIPTION_ID="" STORAGE_RESOURCE_GROUP="" node blobInventoryPoliciesCreateOrUpdateSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[blobinventorypoliciescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/blobInventoryPoliciesCreateOrUpdateSample.js +[blobinventorypoliciesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/blobInventoryPoliciesDeleteSample.js +[blobinventorypoliciesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/blobInventoryPoliciesGetSample.js +[blobinventorypolicieslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/blobInventoryPoliciesListSample.js +[encryptionscopesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/encryptionScopesGetSample.js +[encryptionscopeslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/encryptionScopesListSample.js +[encryptionscopespatchsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/encryptionScopesPatchSample.js +[encryptionscopesputsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/encryptionScopesPutSample.js +[managementpoliciescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/managementPoliciesCreateOrUpdateSample.js +[managementpoliciesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/managementPoliciesDeleteSample.js +[managementpoliciesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/managementPoliciesGetSample.js +[objectreplicationpoliciescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/objectReplicationPoliciesCreateOrUpdateSample.js +[objectreplicationpoliciesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/objectReplicationPoliciesDeleteSample.js +[objectreplicationpoliciesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/objectReplicationPoliciesGetSample.js +[objectreplicationpolicieslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/objectReplicationPoliciesListSample.js +[operationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/operationsListSample.js +[privateendpointconnectionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/privateEndpointConnectionsDeleteSample.js +[privateendpointconnectionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/privateEndpointConnectionsGetSample.js +[privateendpointconnectionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/privateEndpointConnectionsListSample.js +[privateendpointconnectionsputsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/privateEndpointConnectionsPutSample.js +[privatelinkresourceslistbystorageaccountsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/privateLinkResourcesListByStorageAccountSample.js +[skuslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/skusListSample.js +[storageaccountschecknameavailabilitysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsCheckNameAvailabilitySample.js +[storageaccountscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsCreateSample.js +[storageaccountsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsDeleteSample.js +[storageaccountsfailoversample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsFailoverSample.js +[storageaccountsgetpropertiessample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsGetPropertiesSample.js +[storageaccountslistaccountsassample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsListAccountSasSample.js +[storageaccountslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsListByResourceGroupSample.js +[storageaccountslistkeyssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsListKeysSample.js +[storageaccountslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsListSample.js +[storageaccountslistservicesassample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsListServiceSasSample.js +[storageaccountsregeneratekeysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsRegenerateKeySample.js +[storageaccountsrestoreblobrangessample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsRestoreBlobRangesSample.js +[storageaccountsrevokeuserdelegationkeyssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsRevokeUserDelegationKeysSample.js +[storageaccountsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsUpdateSample.js +[usageslistbylocationsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/usagesListByLocationSample.js +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-storage-profile-2020-09-01-hybrid?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/README.md diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/blobInventoryPoliciesCreateOrUpdateSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/blobInventoryPoliciesCreateOrUpdateSample.js new file mode 100644 index 000000000000..6977fd2ef28f --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/blobInventoryPoliciesCreateOrUpdateSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Sets the blob inventory policy to the specified storage account. + * + * @summary Sets the blob inventory policy to the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountSetBlobInventoryPolicy.json + */ +async function storageAccountSetBlobInventoryPolicy() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "sto9699"; + const blobInventoryPolicyName = "default"; + const properties = { + policy: { + type: "Inventory", + destination: "containerName", + enabled: true, + rules: [ + { + name: "inventoryPolicyRule1", + definition: { + filters: { + blobTypes: ["blockBlob", "appendBlob", "pageBlob"], + includeBlobVersions: true, + includeSnapshots: true, + prefixMatch: ["inventoryprefix1", "inventoryprefix2"], + }, + }, + enabled: true, + }, + ], + }, + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.blobInventoryPolicies.createOrUpdate( + resourceGroupName, + accountName, + blobInventoryPolicyName, + properties + ); + console.log(result); +} + +async function main() { + storageAccountSetBlobInventoryPolicy(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/blobInventoryPoliciesDeleteSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/blobInventoryPoliciesDeleteSample.js new file mode 100644 index 000000000000..f75abf3332a7 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/blobInventoryPoliciesDeleteSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Deletes the blob inventory policy associated with the specified storage account. + * + * @summary Deletes the blob inventory policy associated with the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountDeleteBlobInventoryPolicy.json + */ +async function storageAccountDeleteBlobInventoryPolicy() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const blobInventoryPolicyName = "default"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.blobInventoryPolicies.delete( + resourceGroupName, + accountName, + blobInventoryPolicyName + ); + console.log(result); +} + +async function main() { + storageAccountDeleteBlobInventoryPolicy(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/blobInventoryPoliciesGetSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/blobInventoryPoliciesGetSample.js new file mode 100644 index 000000000000..1feccbfdf56c --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/blobInventoryPoliciesGetSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the blob inventory policy associated with the specified storage account. + * + * @summary Gets the blob inventory policy associated with the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetBlobInventoryPolicy.json + */ +async function storageAccountGetBlobInventoryPolicy() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "sto9699"; + const blobInventoryPolicyName = "default"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.blobInventoryPolicies.get( + resourceGroupName, + accountName, + blobInventoryPolicyName + ); + console.log(result); +} + +async function main() { + storageAccountGetBlobInventoryPolicy(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/blobInventoryPoliciesListSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/blobInventoryPoliciesListSample.js new file mode 100644 index 000000000000..6b9fdc5ee935 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/blobInventoryPoliciesListSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the blob inventory policy associated with the specified storage account. + * + * @summary Gets the blob inventory policy associated with the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListBlobInventoryPolicy.json + */ +async function storageAccountGetBlobInventoryPolicy() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "sto9699"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.blobInventoryPolicies.list(resourceGroupName, accountName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + storageAccountGetBlobInventoryPolicy(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/encryptionScopesGetSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/encryptionScopesGetSample.js new file mode 100644 index 000000000000..993e6bbcf923 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/encryptionScopesGetSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Returns the properties for the specified encryption scope. + * + * @summary Returns the properties for the specified encryption scope. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetEncryptionScope.json + */ +async function storageAccountGetEncryptionScope() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "resource-group-name"; + const accountName = "{storage-account-name}"; + const encryptionScopeName = "{encryption-scope-name}"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.encryptionScopes.get( + resourceGroupName, + accountName, + encryptionScopeName + ); + console.log(result); +} + +async function main() { + storageAccountGetEncryptionScope(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/encryptionScopesListSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/encryptionScopesListSample.js new file mode 100644 index 000000000000..3e69149db38a --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/encryptionScopesListSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Lists all the encryption scopes available under the specified storage account. + * + * @summary Lists all the encryption scopes available under the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountEncryptionScopeList.json + */ +async function storageAccountEncryptionScopeList() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "resource-group-name"; + const accountName = "{storage-account-name}"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.encryptionScopes.list(resourceGroupName, accountName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + storageAccountEncryptionScopeList(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/encryptionScopesPatchSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/encryptionScopesPatchSample.js new file mode 100644 index 000000000000..ed4b61aa6ea9 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/encryptionScopesPatchSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. + * + * @summary Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountPatchEncryptionScope.json + */ +async function storageAccountPatchEncryptionScope() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "resource-group-name"; + const accountName = "{storage-account-name}"; + const encryptionScopeName = "{encryption-scope-name}"; + const encryptionScope = { + keyVaultProperties: { + keyUri: "https://testvault.vault.core.windows.net/keys/key1/863425f1358359c", + }, + source: "Microsoft.KeyVault", + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.encryptionScopes.patch( + resourceGroupName, + accountName, + encryptionScopeName, + encryptionScope + ); + console.log(result); +} + +async function main() { + storageAccountPatchEncryptionScope(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/encryptionScopesPutSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/encryptionScopesPutSample.js new file mode 100644 index 000000000000..f6de6e48d32d --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/encryptionScopesPutSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Synchronously creates or updates an encryption scope under the specified storage account. If an encryption scope is already created and a subsequent request is issued with different properties, the encryption scope properties will be updated per the specified request. + * + * @summary Synchronously creates or updates an encryption scope under the specified storage account. If an encryption scope is already created and a subsequent request is issued with different properties, the encryption scope properties will be updated per the specified request. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountPutEncryptionScope.json + */ +async function storageAccountPutEncryptionScope() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "resource-group-name"; + const accountName = "{storage-account-name}"; + const encryptionScopeName = "{encryption-scope-name}"; + const encryptionScope = {}; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.encryptionScopes.put( + resourceGroupName, + accountName, + encryptionScopeName, + encryptionScope + ); + console.log(result); +} + +async function main() { + storageAccountPutEncryptionScope(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/managementPoliciesCreateOrUpdateSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/managementPoliciesCreateOrUpdateSample.js new file mode 100644 index 000000000000..8c59bba7e9d7 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/managementPoliciesCreateOrUpdateSample.js @@ -0,0 +1,239 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Sets the managementpolicy to the specified storage account. + * + * @summary Sets the managementpolicy to the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountSetManagementPolicy.json + */ +async function storageAccountSetManagementPolicies() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "sto9699"; + const managementPolicyName = "default"; + const properties = { + policy: { + rules: [ + { + name: "olcmtest1", + type: "Lifecycle", + definition: { + actions: { + baseBlob: { + delete: { daysAfterModificationGreaterThan: 1000 }, + tierToArchive: { daysAfterModificationGreaterThan: 90 }, + tierToCool: { daysAfterModificationGreaterThan: 30 }, + }, + snapshot: { delete: { daysAfterCreationGreaterThan: 30 } }, + }, + filters: { + blobTypes: ["blockBlob"], + prefixMatch: ["olcmtestcontainer1"], + }, + }, + enabled: true, + }, + { + name: "olcmtest2", + type: "Lifecycle", + definition: { + actions: { + baseBlob: { + delete: { daysAfterModificationGreaterThan: 1000 }, + tierToArchive: { daysAfterModificationGreaterThan: 90 }, + tierToCool: { daysAfterModificationGreaterThan: 30 }, + }, + }, + filters: { + blobIndexMatch: [ + { name: "tag1", op: "==", value: "val1" }, + { name: "tag2", op: "==", value: "val2" }, + ], + blobTypes: ["blockBlob"], + prefixMatch: ["olcmtestcontainer2"], + }, + }, + enabled: true, + }, + ], + }, + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.managementPolicies.createOrUpdate( + resourceGroupName, + accountName, + managementPolicyName, + properties + ); + console.log(result); +} + +/** + * This sample demonstrates how to Sets the managementpolicy to the specified storage account. + * + * @summary Sets the managementpolicy to the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountSetManagementPolicyForBlockAndAppendBlobs.json + */ +async function storageAccountSetManagementPolicyForBlockAndAppendBlobs() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "sto9699"; + const managementPolicyName = "default"; + const properties = { + policy: { + rules: [ + { + name: "olcmtest1", + type: "Lifecycle", + definition: { + actions: { + baseBlob: { delete: { daysAfterModificationGreaterThan: 90 } }, + snapshot: { delete: { daysAfterCreationGreaterThan: 90 } }, + version: { delete: { daysAfterCreationGreaterThan: 90 } }, + }, + filters: { + blobTypes: ["blockBlob", "appendBlob"], + prefixMatch: ["olcmtestcontainer1"], + }, + }, + enabled: true, + }, + ], + }, + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.managementPolicies.createOrUpdate( + resourceGroupName, + accountName, + managementPolicyName, + properties + ); + console.log(result); +} + +/** + * This sample demonstrates how to Sets the managementpolicy to the specified storage account. + * + * @summary Sets the managementpolicy to the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountSetManagementPolicyWithSnapshotAndVersion.json + */ +async function storageAccountSetManagementPolicyWithSnapshotAndVersion() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "sto9699"; + const managementPolicyName = "default"; + const properties = { + policy: { + rules: [ + { + name: "olcmtest1", + type: "Lifecycle", + definition: { + actions: { + baseBlob: { + delete: { daysAfterModificationGreaterThan: 1000 }, + tierToArchive: { daysAfterModificationGreaterThan: 90 }, + tierToCool: { daysAfterModificationGreaterThan: 30 }, + }, + snapshot: { + delete: { daysAfterCreationGreaterThan: 1000 }, + tierToArchive: { daysAfterCreationGreaterThan: 90 }, + tierToCool: { daysAfterCreationGreaterThan: 30 }, + }, + version: { + delete: { daysAfterCreationGreaterThan: 1000 }, + tierToArchive: { daysAfterCreationGreaterThan: 90 }, + tierToCool: { daysAfterCreationGreaterThan: 30 }, + }, + }, + filters: { + blobTypes: ["blockBlob"], + prefixMatch: ["olcmtestcontainer1"], + }, + }, + enabled: true, + }, + ], + }, + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.managementPolicies.createOrUpdate( + resourceGroupName, + accountName, + managementPolicyName, + properties + ); + console.log(result); +} + +/** + * This sample demonstrates how to Sets the managementpolicy to the specified storage account. + * + * @summary Sets the managementpolicy to the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountSetManagementPolicy_LastAccessTimeBasedBlobActions.json + */ +async function storageAccountSetManagementPolicyLastAccessTimeBasedBlobActions() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "sto9699"; + const managementPolicyName = "default"; + const properties = { + policy: { + rules: [ + { + name: "olcmtest", + type: "Lifecycle", + definition: { + actions: { + baseBlob: { + delete: { daysAfterLastAccessTimeGreaterThan: 1000 }, + enableAutoTierToHotFromCool: true, + tierToArchive: { daysAfterLastAccessTimeGreaterThan: 90 }, + tierToCool: { daysAfterLastAccessTimeGreaterThan: 30 }, + }, + snapshot: { delete: { daysAfterCreationGreaterThan: 30 } }, + }, + filters: { + blobTypes: ["blockBlob"], + prefixMatch: ["olcmtestcontainer"], + }, + }, + enabled: true, + }, + ], + }, + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.managementPolicies.createOrUpdate( + resourceGroupName, + accountName, + managementPolicyName, + properties + ); + console.log(result); +} + +async function main() { + storageAccountSetManagementPolicies(); + storageAccountSetManagementPolicyForBlockAndAppendBlobs(); + storageAccountSetManagementPolicyWithSnapshotAndVersion(); + storageAccountSetManagementPolicyLastAccessTimeBasedBlobActions(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/managementPoliciesDeleteSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/managementPoliciesDeleteSample.js new file mode 100644 index 000000000000..164e534e420b --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/managementPoliciesDeleteSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Deletes the managementpolicy associated with the specified storage account. + * + * @summary Deletes the managementpolicy associated with the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountDeleteManagementPolicy.json + */ +async function storageAccountDeleteManagementPolicies() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const managementPolicyName = "default"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.managementPolicies.delete( + resourceGroupName, + accountName, + managementPolicyName + ); + console.log(result); +} + +async function main() { + storageAccountDeleteManagementPolicies(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/managementPoliciesGetSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/managementPoliciesGetSample.js new file mode 100644 index 000000000000..ffce730aff94 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/managementPoliciesGetSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the managementpolicy associated with the specified storage account. + * + * @summary Gets the managementpolicy associated with the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetManagementPolicy.json + */ +async function storageAccountGetManagementPolicies() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const managementPolicyName = "default"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.managementPolicies.get( + resourceGroupName, + accountName, + managementPolicyName + ); + console.log(result); +} + +async function main() { + storageAccountGetManagementPolicies(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/objectReplicationPoliciesCreateOrUpdateSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/objectReplicationPoliciesCreateOrUpdateSample.js new file mode 100644 index 000000000000..04710d33e736 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/objectReplicationPoliciesCreateOrUpdateSample.js @@ -0,0 +1,166 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Create or update the object replication policy of the storage account. + * + * @summary Create or update the object replication policy of the storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountCreateObjectReplicationPolicyOnDestination.json + */ +async function storageAccountCreateObjectReplicationPolicyOnDestination() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "dst112"; + const objectReplicationPolicyId = "default"; + const properties = { + destinationAccount: "dst112", + rules: [ + { + destinationContainer: "dcont139", + filters: { prefixMatch: ["blobA", "blobB"] }, + sourceContainer: "scont139", + }, + ], + sourceAccount: "src1122", + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.objectReplicationPoliciesOperations.createOrUpdate( + resourceGroupName, + accountName, + objectReplicationPolicyId, + properties + ); + console.log(result); +} + +/** + * This sample demonstrates how to Create or update the object replication policy of the storage account. + * + * @summary Create or update the object replication policy of the storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountCreateObjectReplicationPolicyOnSource.json + */ +async function storageAccountCreateObjectReplicationPolicyOnSource() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "src1122"; + const objectReplicationPolicyId = "2a20bb73-5717-4635-985a-5d4cf777438f"; + const properties = { + destinationAccount: "dst112", + rules: [ + { + destinationContainer: "dcont139", + filters: { + minCreationTime: "2020-02-19T16:05:00Z", + prefixMatch: ["blobA", "blobB"], + }, + ruleId: "d5d18a48-8801-4554-aeaa-74faf65f5ef9", + sourceContainer: "scont139", + }, + ], + sourceAccount: "src1122", + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.objectReplicationPoliciesOperations.createOrUpdate( + resourceGroupName, + accountName, + objectReplicationPolicyId, + properties + ); + console.log(result); +} + +/** + * This sample demonstrates how to Create or update the object replication policy of the storage account. + * + * @summary Create or update the object replication policy of the storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountUpdateObjectReplicationPolicyOnDestination.json + */ +async function storageAccountUpdateObjectReplicationPolicyOnDestination() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "dst112"; + const objectReplicationPolicyId = "2a20bb73-5717-4635-985a-5d4cf777438f"; + const properties = { + destinationAccount: "dst112", + rules: [ + { + destinationContainer: "dcont139", + filters: { prefixMatch: ["blobA", "blobB"] }, + ruleId: "d5d18a48-8801-4554-aeaa-74faf65f5ef9", + sourceContainer: "scont139", + }, + { destinationContainer: "dcont179", sourceContainer: "scont179" }, + ], + sourceAccount: "src1122", + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.objectReplicationPoliciesOperations.createOrUpdate( + resourceGroupName, + accountName, + objectReplicationPolicyId, + properties + ); + console.log(result); +} + +/** + * This sample demonstrates how to Create or update the object replication policy of the storage account. + * + * @summary Create or update the object replication policy of the storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountUpdateObjectReplicationPolicyOnSource.json + */ +async function storageAccountUpdateObjectReplicationPolicyOnSource() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "src1122"; + const objectReplicationPolicyId = "2a20bb73-5717-4635-985a-5d4cf777438f"; + const properties = { + destinationAccount: "dst112", + rules: [ + { + destinationContainer: "dcont139", + filters: { prefixMatch: ["blobA", "blobB"] }, + ruleId: "d5d18a48-8801-4554-aeaa-74faf65f5ef9", + sourceContainer: "scont139", + }, + { + destinationContainer: "dcont179", + ruleId: "cfbb4bc2-8b60-429f-b05a-d1e0942b33b2", + sourceContainer: "scont179", + }, + ], + sourceAccount: "src1122", + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.objectReplicationPoliciesOperations.createOrUpdate( + resourceGroupName, + accountName, + objectReplicationPolicyId, + properties + ); + console.log(result); +} + +async function main() { + storageAccountCreateObjectReplicationPolicyOnDestination(); + storageAccountCreateObjectReplicationPolicyOnSource(); + storageAccountUpdateObjectReplicationPolicyOnDestination(); + storageAccountUpdateObjectReplicationPolicyOnSource(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/objectReplicationPoliciesDeleteSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/objectReplicationPoliciesDeleteSample.js new file mode 100644 index 000000000000..e1a927c8e201 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/objectReplicationPoliciesDeleteSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Deletes the object replication policy associated with the specified storage account. + * + * @summary Deletes the object replication policy associated with the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountDeleteObjectReplicationPolicy.json + */ +async function storageAccountDeleteObjectReplicationPolicies() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const objectReplicationPolicyId = "{objectReplicationPolicy-Id}"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.objectReplicationPoliciesOperations.delete( + resourceGroupName, + accountName, + objectReplicationPolicyId + ); + console.log(result); +} + +async function main() { + storageAccountDeleteObjectReplicationPolicies(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/objectReplicationPoliciesGetSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/objectReplicationPoliciesGetSample.js new file mode 100644 index 000000000000..6470222c1795 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/objectReplicationPoliciesGetSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Get the object replication policy of the storage account by policy ID. + * + * @summary Get the object replication policy of the storage account by policy ID. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetObjectReplicationPolicy.json + */ +async function storageAccountGetObjectReplicationPolicies() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const objectReplicationPolicyId = "{objectReplicationPolicy-Id}"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.objectReplicationPoliciesOperations.get( + resourceGroupName, + accountName, + objectReplicationPolicyId + ); + console.log(result); +} + +async function main() { + storageAccountGetObjectReplicationPolicies(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/objectReplicationPoliciesListSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/objectReplicationPoliciesListSample.js new file mode 100644 index 000000000000..f7c7201dab57 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/objectReplicationPoliciesListSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to List the object replication policies associated with the storage account. + * + * @summary List the object replication policies associated with the storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListObjectReplicationPolicies.json + */ +async function storageAccountListObjectReplicationPolicies() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.objectReplicationPoliciesOperations.list( + resourceGroupName, + accountName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + storageAccountListObjectReplicationPolicies(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/operationsListSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/operationsListSample.js new file mode 100644 index 000000000000..5bb1e49e6c24 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/operationsListSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Lists all of the available Storage Rest API operations. + * + * @summary Lists all of the available Storage Rest API operations. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/OperationsList.json + */ +async function operationsList() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + operationsList(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/package.json b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/package.json new file mode 100644 index 000000000000..c92964101759 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/package.json @@ -0,0 +1,32 @@ +{ + "name": "@azure-samples/arm-storage-profile-2020-09-01-hybrid-js", + "private": true, + "version": "1.0.0", + "description": " client library samples for JavaScript", + "engines": { + "node": ">=14.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/storage/arm-storage-profile-2020-09-01-hybrid" + }, + "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/storage/arm-storage-profile-2020-09-01-hybrid", + "dependencies": { + "@azure/arm-storage-profile-2020-09-01-hybrid": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + } +} diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/privateEndpointConnectionsDeleteSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/privateEndpointConnectionsDeleteSample.js new file mode 100644 index 000000000000..6403d4748e85 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/privateEndpointConnectionsDeleteSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Deletes the specified private endpoint connection associated with the storage account. + * + * @summary Deletes the specified private endpoint connection associated with the storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountDeletePrivateEndpointConnection.json + */ +async function storageAccountDeletePrivateEndpointConnection() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const privateEndpointConnectionName = "{privateEndpointConnectionName}"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.delete( + resourceGroupName, + accountName, + privateEndpointConnectionName + ); + console.log(result); +} + +async function main() { + storageAccountDeletePrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/privateEndpointConnectionsGetSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/privateEndpointConnectionsGetSample.js new file mode 100644 index 000000000000..a9f23b1750a5 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/privateEndpointConnectionsGetSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the specified private endpoint connection associated with the storage account. + * + * @summary Gets the specified private endpoint connection associated with the storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetPrivateEndpointConnection.json + */ +async function storageAccountGetPrivateEndpointConnection() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const privateEndpointConnectionName = "{privateEndpointConnectionName}"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.get( + resourceGroupName, + accountName, + privateEndpointConnectionName + ); + console.log(result); +} + +async function main() { + storageAccountGetPrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/privateEndpointConnectionsListSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/privateEndpointConnectionsListSample.js new file mode 100644 index 000000000000..9a9efbeb5771 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/privateEndpointConnectionsListSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to List all the private endpoint connections associated with the storage account. + * + * @summary List all the private endpoint connections associated with the storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListPrivateEndpointConnections.json + */ +async function storageAccountListPrivateEndpointConnections() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.privateEndpointConnections.list(resourceGroupName, accountName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + storageAccountListPrivateEndpointConnections(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/privateEndpointConnectionsPutSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/privateEndpointConnectionsPutSample.js new file mode 100644 index 000000000000..62760e7c1933 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/privateEndpointConnectionsPutSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Update the state of specified private endpoint connection associated with the storage account. + * + * @summary Update the state of specified private endpoint connection associated with the storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountPutPrivateEndpointConnection.json + */ +async function storageAccountPutPrivateEndpointConnection() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "sto9699"; + const privateEndpointConnectionName = "{privateEndpointConnectionName}"; + const properties = { + privateLinkServiceConnectionState: { + description: "Auto-Approved", + status: "Approved", + }, + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.put( + resourceGroupName, + accountName, + privateEndpointConnectionName, + properties + ); + console.log(result); +} + +async function main() { + storageAccountPutPrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/privateLinkResourcesListByStorageAccountSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/privateLinkResourcesListByStorageAccountSample.js new file mode 100644 index 000000000000..a00b42e87923 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/privateLinkResourcesListByStorageAccountSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the private link resources that need to be created for a storage account. + * + * @summary Gets the private link resources that need to be created for a storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListPrivateLinkResources.json + */ +async function storageAccountListPrivateLinkResources() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.privateLinkResources.listByStorageAccount( + resourceGroupName, + accountName + ); + console.log(result); +} + +async function main() { + storageAccountListPrivateLinkResources(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/sample.env b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/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/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/skusListSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/skusListSample.js new file mode 100644 index 000000000000..be2e1db7b0e8 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/skusListSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Lists the available SKUs supported by Microsoft.Storage for given subscription. + * + * @summary Lists the available SKUs supported by Microsoft.Storage for given subscription. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/SKUList.json + */ +async function skuList() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.skus.list()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + skuList(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsCheckNameAvailabilitySample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsCheckNameAvailabilitySample.js new file mode 100644 index 000000000000..8fa5ba7cb1f7 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsCheckNameAvailabilitySample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Checks that the storage account name is valid and is not already in use. + * + * @summary Checks that the storage account name is valid and is not already in use. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountCheckNameAvailability.json + */ +async function storageAccountCheckNameAvailability() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const accountName = { + name: "sto3363", + type: "Microsoft.Storage/storageAccounts", + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.checkNameAvailability(accountName); + console.log(result); +} + +async function main() { + storageAccountCheckNameAvailability(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsCreateSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsCreateSample.js new file mode 100644 index 000000000000..a46e72dd82e6 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsCreateSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or update request is issued with the exact same set of properties, the request will succeed. + * + * @summary Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or update request is issued with the exact same set of properties, the request will succeed. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountCreate.json + */ +async function storageAccountCreate() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res9101"; + const accountName = "sto4445"; + const parameters = { + allowBlobPublicAccess: false, + allowSharedKeyAccess: true, + encryption: { + keySource: "Microsoft.Storage", + requireInfrastructureEncryption: false, + services: { + blob: { enabled: true, keyType: "Account" }, + file: { enabled: true, keyType: "Account" }, + }, + }, + isHnsEnabled: true, + kind: "Storage", + location: "eastus", + minimumTlsVersion: "TLS1_2", + routingPreference: { + publishInternetEndpoints: true, + publishMicrosoftEndpoints: true, + routingChoice: "MicrosoftRouting", + }, + sku: { name: "Standard_GRS" }, + tags: { key1: "value1", key2: "value2" }, + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.beginCreateAndWait( + resourceGroupName, + accountName, + parameters + ); + console.log(result); +} + +async function main() { + storageAccountCreate(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsDeleteSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsDeleteSample.js new file mode 100644 index 000000000000..9d207bed40cc --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsDeleteSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Deletes a storage account in Microsoft Azure. + * + * @summary Deletes a storage account in Microsoft Azure. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountDelete.json + */ +async function storageAccountDelete() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res4228"; + const accountName = "sto2434"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.delete(resourceGroupName, accountName); + console.log(result); +} + +async function main() { + storageAccountDelete(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsFailoverSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsFailoverSample.js new file mode 100644 index 000000000000..d1a6dce2f29c --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsFailoverSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. + * + * @summary Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountFailover.json + */ +async function storageAccountFailover() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res4228"; + const accountName = "sto2434"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.beginFailoverAndWait(resourceGroupName, accountName); + console.log(result); +} + +async function main() { + storageAccountFailover(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsGetPropertiesSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsGetPropertiesSample.js new file mode 100644 index 000000000000..05931e6a7e0f --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsGetPropertiesSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. + * + * @summary Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetProperties.json + */ +async function storageAccountGetProperties() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res9407"; + const accountName = "sto8596"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.getProperties(resourceGroupName, accountName); + console.log(result); +} + +/** + * This sample demonstrates how to Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. + * + * @summary Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetPropertiesCMKEnabled.json + */ +async function storageAccountGetPropertiesCmkEnabled() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res9407"; + const accountName = "sto8596"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.getProperties(resourceGroupName, accountName); + console.log(result); +} + +async function main() { + storageAccountGetProperties(); + storageAccountGetPropertiesCmkEnabled(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsListAccountSasSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsListAccountSasSample.js new file mode 100644 index 000000000000..e9b04d51da2b --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsListAccountSasSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to List SAS credentials of a storage account. + * + * @summary List SAS credentials of a storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListAccountSAS.json + */ +async function storageAccountListAccountSas() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7985"; + const accountName = "sto8588"; + const parameters = { + keyToSign: "key1", + sharedAccessExpiryTime: new Date("2017-05-24T11:42:03.1567373Z"), + permissions: "r", + protocols: "https,http", + resourceTypes: "s", + services: "b", + sharedAccessStartTime: new Date("2017-05-24T10:42:03.1567373Z"), + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.listAccountSAS( + resourceGroupName, + accountName, + parameters + ); + console.log(result); +} + +async function main() { + storageAccountListAccountSas(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsListByResourceGroupSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsListByResourceGroupSample.js new file mode 100644 index 000000000000..5c0daa31e0bc --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsListByResourceGroupSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. + * + * @summary Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListByResourceGroup.json + */ +async function storageAccountListByResourceGroup() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6117"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.storageAccounts.listByResourceGroup(resourceGroupName)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + storageAccountListByResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsListKeysSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsListKeysSample.js new file mode 100644 index 000000000000..c3ee0873725a --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsListKeysSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. + * + * @summary Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListKeys.json + */ +async function storageAccountListKeys() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res418"; + const accountName = "sto2220"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.listKeys(resourceGroupName, accountName); + console.log(result); +} + +async function main() { + storageAccountListKeys(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsListSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsListSample.js new file mode 100644 index 000000000000..83e1614f3278 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsListSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. + * + * @summary Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountList.json + */ +async function storageAccountList() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.storageAccounts.list()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + storageAccountList(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsListServiceSasSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsListServiceSasSample.js new file mode 100644 index 000000000000..259f134578fd --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsListServiceSasSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to List service SAS credentials of a specific resource. + * + * @summary List service SAS credentials of a specific resource. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListServiceSAS.json + */ +async function storageAccountListServiceSas() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7439"; + const accountName = "sto1299"; + const parameters = { + canonicalizedResource: "/blob/sto1299/music", + sharedAccessExpiryTime: new Date("2017-05-24T11:32:48.8457197Z"), + permissions: "l", + resource: "c", + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.listServiceSAS( + resourceGroupName, + accountName, + parameters + ); + console.log(result); +} + +async function main() { + storageAccountListServiceSas(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsRegenerateKeySample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsRegenerateKeySample.js new file mode 100644 index 000000000000..d5b3a94a245f --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsRegenerateKeySample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Regenerates one of the access keys or Kerberos keys for the specified storage account. + * + * @summary Regenerates one of the access keys or Kerberos keys for the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountRegenerateKerbKey.json + */ +async function storageAccountRegenerateKerbKey() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res4167"; + const accountName = "sto3539"; + const regenerateKey = { + keyName: "kerb1", + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.regenerateKey( + resourceGroupName, + accountName, + regenerateKey + ); + console.log(result); +} + +/** + * This sample demonstrates how to Regenerates one of the access keys or Kerberos keys for the specified storage account. + * + * @summary Regenerates one of the access keys or Kerberos keys for the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountRegenerateKey.json + */ +async function storageAccountRegenerateKey() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res4167"; + const accountName = "sto3539"; + const regenerateKey = { + keyName: "key2", + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.regenerateKey( + resourceGroupName, + accountName, + regenerateKey + ); + console.log(result); +} + +async function main() { + storageAccountRegenerateKerbKey(); + storageAccountRegenerateKey(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsRestoreBlobRangesSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsRestoreBlobRangesSample.js new file mode 100644 index 000000000000..f34515b7c0b9 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsRestoreBlobRangesSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Restore blobs in the specified blob ranges + * + * @summary Restore blobs in the specified blob ranges + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/BlobRangesRestore.json + */ +async function blobRangesRestore() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res9101"; + const accountName = "sto4445"; + const parameters = { + blobRanges: [ + { endRange: "container/blobpath2", startRange: "container/blobpath1" }, + { endRange: "", startRange: "container2/blobpath3" }, + ], + timeToRestore: new Date("2019-04-20T15:30:00.0000000Z"), + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.beginRestoreBlobRangesAndWait( + resourceGroupName, + accountName, + parameters + ); + console.log(result); +} + +async function main() { + blobRangesRestore(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsRevokeUserDelegationKeysSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsRevokeUserDelegationKeysSample.js new file mode 100644 index 000000000000..0a1fa7958823 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsRevokeUserDelegationKeysSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Revoke user delegation keys. + * + * @summary Revoke user delegation keys. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountRevokeUserDelegationKeys.json + */ +async function storageAccountRevokeUserDelegationKeys() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res4167"; + const accountName = "sto3539"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.revokeUserDelegationKeys( + resourceGroupName, + accountName + ); + console.log(result); +} + +async function main() { + storageAccountRevokeUserDelegationKeys(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsUpdateSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsUpdateSample.js new file mode 100644 index 000000000000..5b489eff6579 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/storageAccountsUpdateSample.js @@ -0,0 +1,114 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +const { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not supported. In order to replace an old custom domain, the old value must be cleared/unregistered before a new value can be set. The update of multiple properties is supported. This call does not change the storage keys for the account. If you want to change the storage account keys, use the regenerate keys operation. The location and name of the storage account cannot be changed after creation. + * + * @summary The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not supported. In order to replace an old custom domain, the old value must be cleared/unregistered before a new value can be set. The update of multiple properties is supported. This call does not change the storage keys for the account. If you want to change the storage account keys, use the regenerate keys operation. The location and name of the storage account cannot be changed after creation. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountEnableAD.json + */ +async function storageAccountEnableAd() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res9407"; + const accountName = "sto8596"; + const parameters = { + azureFilesIdentityBasedAuthentication: { + activeDirectoryProperties: { + azureStorageSid: "S-1-5-21-2400535526-2334094090-2402026252-0012", + domainGuid: "aebfc118-9fa9-4732-a21f-d98e41a77ae1", + domainName: "adtest.com", + domainSid: "S-1-5-21-2400535526-2334094090-2402026252", + forestName: "adtest.com", + netBiosDomainName: "adtest.com", + }, + directoryServiceOptions: "AD", + }, + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.update(resourceGroupName, accountName, parameters); + console.log(result); +} + +/** + * This sample demonstrates how to The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not supported. In order to replace an old custom domain, the old value must be cleared/unregistered before a new value can be set. The update of multiple properties is supported. This call does not change the storage keys for the account. If you want to change the storage account keys, use the regenerate keys operation. The location and name of the storage account cannot be changed after creation. + * + * @summary The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not supported. In order to replace an old custom domain, the old value must be cleared/unregistered before a new value can be set. The update of multiple properties is supported. This call does not change the storage keys for the account. If you want to change the storage account keys, use the regenerate keys operation. The location and name of the storage account cannot be changed after creation. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountEnableCMK.json + */ +async function storageAccountEnableCmk() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res9407"; + const accountName = "sto8596"; + const parameters = { + encryption: { + keySource: "Microsoft.Keyvault", + keyVaultProperties: { + keyName: "wrappingKey", + keyVaultUri: "https://myvault8569.vault.azure.net", + keyVersion: "", + }, + services: { + blob: { enabled: true, keyType: "Account" }, + file: { enabled: true, keyType: "Account" }, + }, + }, + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.update(resourceGroupName, accountName, parameters); + console.log(result); +} + +/** + * This sample demonstrates how to The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not supported. In order to replace an old custom domain, the old value must be cleared/unregistered before a new value can be set. The update of multiple properties is supported. This call does not change the storage keys for the account. If you want to change the storage account keys, use the regenerate keys operation. The location and name of the storage account cannot be changed after creation. + * + * @summary The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not supported. In order to replace an old custom domain, the old value must be cleared/unregistered before a new value can be set. The update of multiple properties is supported. This call does not change the storage keys for the account. If you want to change the storage account keys, use the regenerate keys operation. The location and name of the storage account cannot be changed after creation. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountUpdate.json + */ +async function storageAccountUpdate() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res9407"; + const accountName = "sto8596"; + const parameters = { + allowBlobPublicAccess: false, + allowSharedKeyAccess: true, + encryption: { + keySource: "Microsoft.Storage", + services: { + blob: { enabled: true, keyType: "Account" }, + file: { enabled: true, keyType: "Account" }, + }, + }, + minimumTlsVersion: "TLS1_2", + networkRuleSet: { defaultAction: "Allow" }, + routingPreference: { + publishInternetEndpoints: true, + publishMicrosoftEndpoints: true, + routingChoice: "MicrosoftRouting", + }, + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.update(resourceGroupName, accountName, parameters); + console.log(result); +} + +async function main() { + storageAccountEnableAd(); + storageAccountEnableCmk(); + storageAccountUpdate(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/usagesListByLocationSample.js b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/usagesListByLocationSample.js new file mode 100644 index 000000000000..3f9a5f0679b3 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/javascript/usagesListByLocationSample.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 { StorageManagementClient } = require("@azure/arm-storage-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Gets the current usage count and the limit for the resources of the location under the subscription. + * + * @summary Gets the current usage count and the limit for the resources of the location under the subscription. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListLocationUsage.json + */ +async function usageList() { + const subscriptionId = process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const location = "eastus2(stage)"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.usages.listByLocation(location)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + usageList(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/README.md b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/README.md new file mode 100644 index 000000000000..19fd6c0c0943 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/README.md @@ -0,0 +1,135 @@ +# client library samples for TypeScript + +These sample programs show how to use the TypeScript client libraries for in some common scenarios. + +| **File Name** | **Description** | +| --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [blobInventoryPoliciesCreateOrUpdateSample.ts][blobinventorypoliciescreateorupdatesample] | Sets the blob inventory policy to the specified storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountSetBlobInventoryPolicy.json | +| [blobInventoryPoliciesDeleteSample.ts][blobinventorypoliciesdeletesample] | Deletes the blob inventory policy associated with the specified storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountDeleteBlobInventoryPolicy.json | +| [blobInventoryPoliciesGetSample.ts][blobinventorypoliciesgetsample] | Gets the blob inventory policy associated with the specified storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetBlobInventoryPolicy.json | +| [blobInventoryPoliciesListSample.ts][blobinventorypolicieslistsample] | Gets the blob inventory policy associated with the specified storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListBlobInventoryPolicy.json | +| [encryptionScopesGetSample.ts][encryptionscopesgetsample] | Returns the properties for the specified encryption scope. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetEncryptionScope.json | +| [encryptionScopesListSample.ts][encryptionscopeslistsample] | Lists all the encryption scopes available under the specified storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountEncryptionScopeList.json | +| [encryptionScopesPatchSample.ts][encryptionscopespatchsample] | Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountPatchEncryptionScope.json | +| [encryptionScopesPutSample.ts][encryptionscopesputsample] | Synchronously creates or updates an encryption scope under the specified storage account. If an encryption scope is already created and a subsequent request is issued with different properties, the encryption scope properties will be updated per the specified request. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountPutEncryptionScope.json | +| [managementPoliciesCreateOrUpdateSample.ts][managementpoliciescreateorupdatesample] | Sets the managementpolicy to the specified storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountSetManagementPolicy.json | +| [managementPoliciesDeleteSample.ts][managementpoliciesdeletesample] | Deletes the managementpolicy associated with the specified storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountDeleteManagementPolicy.json | +| [managementPoliciesGetSample.ts][managementpoliciesgetsample] | Gets the managementpolicy associated with the specified storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetManagementPolicy.json | +| [objectReplicationPoliciesCreateOrUpdateSample.ts][objectreplicationpoliciescreateorupdatesample] | Create or update the object replication policy of the storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountCreateObjectReplicationPolicyOnDestination.json | +| [objectReplicationPoliciesDeleteSample.ts][objectreplicationpoliciesdeletesample] | Deletes the object replication policy associated with the specified storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountDeleteObjectReplicationPolicy.json | +| [objectReplicationPoliciesGetSample.ts][objectreplicationpoliciesgetsample] | Get the object replication policy of the storage account by policy ID. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetObjectReplicationPolicy.json | +| [objectReplicationPoliciesListSample.ts][objectreplicationpolicieslistsample] | List the object replication policies associated with the storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListObjectReplicationPolicies.json | +| [operationsListSample.ts][operationslistsample] | Lists all of the available Storage Rest API operations. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/OperationsList.json | +| [privateEndpointConnectionsDeleteSample.ts][privateendpointconnectionsdeletesample] | Deletes the specified private endpoint connection associated with the storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountDeletePrivateEndpointConnection.json | +| [privateEndpointConnectionsGetSample.ts][privateendpointconnectionsgetsample] | Gets the specified private endpoint connection associated with the storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetPrivateEndpointConnection.json | +| [privateEndpointConnectionsListSample.ts][privateendpointconnectionslistsample] | List all the private endpoint connections associated with the storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListPrivateEndpointConnections.json | +| [privateEndpointConnectionsPutSample.ts][privateendpointconnectionsputsample] | Update the state of specified private endpoint connection associated with the storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountPutPrivateEndpointConnection.json | +| [privateLinkResourcesListByStorageAccountSample.ts][privatelinkresourceslistbystorageaccountsample] | Gets the private link resources that need to be created for a storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListPrivateLinkResources.json | +| [skusListSample.ts][skuslistsample] | Lists the available SKUs supported by Microsoft.Storage for given subscription. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/SKUList.json | +| [storageAccountsCheckNameAvailabilitySample.ts][storageaccountschecknameavailabilitysample] | Checks that the storage account name is valid and is not already in use. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountCheckNameAvailability.json | +| [storageAccountsCreateSample.ts][storageaccountscreatesample] | Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or update request is issued with the exact same set of properties, the request will succeed. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountCreate.json | +| [storageAccountsDeleteSample.ts][storageaccountsdeletesample] | Deletes a storage account in Microsoft Azure. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountDelete.json | +| [storageAccountsFailoverSample.ts][storageaccountsfailoversample] | Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountFailover.json | +| [storageAccountsGetPropertiesSample.ts][storageaccountsgetpropertiessample] | Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetProperties.json | +| [storageAccountsListAccountSasSample.ts][storageaccountslistaccountsassample] | List SAS credentials of a storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListAccountSAS.json | +| [storageAccountsListByResourceGroupSample.ts][storageaccountslistbyresourcegroupsample] | Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListByResourceGroup.json | +| [storageAccountsListKeysSample.ts][storageaccountslistkeyssample] | Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListKeys.json | +| [storageAccountsListSample.ts][storageaccountslistsample] | Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountList.json | +| [storageAccountsListServiceSasSample.ts][storageaccountslistservicesassample] | List service SAS credentials of a specific resource. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListServiceSAS.json | +| [storageAccountsRegenerateKeySample.ts][storageaccountsregeneratekeysample] | Regenerates one of the access keys or Kerberos keys for the specified storage account. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountRegenerateKerbKey.json | +| [storageAccountsRestoreBlobRangesSample.ts][storageaccountsrestoreblobrangessample] | Restore blobs in the specified blob ranges x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/BlobRangesRestore.json | +| [storageAccountsRevokeUserDelegationKeysSample.ts][storageaccountsrevokeuserdelegationkeyssample] | Revoke user delegation keys. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountRevokeUserDelegationKeys.json | +| [storageAccountsUpdateSample.ts][storageaccountsupdatesample] | The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not supported. In order to replace an old custom domain, the old value must be cleared/unregistered before a new value can be set. The update of multiple properties is supported. This call does not change the storage keys for the account. If you want to change the storage account keys, use the regenerate keys operation. The location and name of the storage account cannot be changed after creation. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountEnableAD.json | +| [usagesListByLocationSample.ts][usageslistbylocationsample] | Gets the current usage count and the limit for the resources of the location under the subscription. x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListLocationUsage.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). + +Before running the samples in Node, they must be compiled to JavaScript using the TypeScript compiler. For more information on TypeScript, see the [TypeScript documentation][typescript]. Install the TypeScript compiler using: + +```bash +npm install -g typescript +``` + +You need [an Azure subscription][freesub] to run these sample programs. + +Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. + +Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. + +## Setup + +To run the samples using the published version of the package: + +1. Install the dependencies using `npm`: + +```bash +npm install +``` + +2. Compile the samples: + +```bash +npm run build +``` + +3. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. + +4. Run whichever samples you like (note that some samples may require additional setup, see the table above): + +```bash +node dist/blobInventoryPoliciesCreateOrUpdateSample.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 STORAGE_SUBSCRIPTION_ID="" STORAGE_RESOURCE_GROUP="" node dist/blobInventoryPoliciesCreateOrUpdateSample.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[blobinventorypoliciescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/blobInventoryPoliciesCreateOrUpdateSample.ts +[blobinventorypoliciesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/blobInventoryPoliciesDeleteSample.ts +[blobinventorypoliciesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/blobInventoryPoliciesGetSample.ts +[blobinventorypolicieslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/blobInventoryPoliciesListSample.ts +[encryptionscopesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/encryptionScopesGetSample.ts +[encryptionscopeslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/encryptionScopesListSample.ts +[encryptionscopespatchsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/encryptionScopesPatchSample.ts +[encryptionscopesputsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/encryptionScopesPutSample.ts +[managementpoliciescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/managementPoliciesCreateOrUpdateSample.ts +[managementpoliciesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/managementPoliciesDeleteSample.ts +[managementpoliciesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/managementPoliciesGetSample.ts +[objectreplicationpoliciescreateorupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/objectReplicationPoliciesCreateOrUpdateSample.ts +[objectreplicationpoliciesdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/objectReplicationPoliciesDeleteSample.ts +[objectreplicationpoliciesgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/objectReplicationPoliciesGetSample.ts +[objectreplicationpolicieslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/objectReplicationPoliciesListSample.ts +[operationslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/operationsListSample.ts +[privateendpointconnectionsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/privateEndpointConnectionsDeleteSample.ts +[privateendpointconnectionsgetsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/privateEndpointConnectionsGetSample.ts +[privateendpointconnectionslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/privateEndpointConnectionsListSample.ts +[privateendpointconnectionsputsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/privateEndpointConnectionsPutSample.ts +[privatelinkresourceslistbystorageaccountsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/privateLinkResourcesListByStorageAccountSample.ts +[skuslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/skusListSample.ts +[storageaccountschecknameavailabilitysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsCheckNameAvailabilitySample.ts +[storageaccountscreatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsCreateSample.ts +[storageaccountsdeletesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsDeleteSample.ts +[storageaccountsfailoversample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsFailoverSample.ts +[storageaccountsgetpropertiessample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsGetPropertiesSample.ts +[storageaccountslistaccountsassample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsListAccountSasSample.ts +[storageaccountslistbyresourcegroupsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsListByResourceGroupSample.ts +[storageaccountslistkeyssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsListKeysSample.ts +[storageaccountslistsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsListSample.ts +[storageaccountslistservicesassample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsListServiceSasSample.ts +[storageaccountsregeneratekeysample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsRegenerateKeySample.ts +[storageaccountsrestoreblobrangessample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsRestoreBlobRangesSample.ts +[storageaccountsrevokeuserdelegationkeyssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsRevokeUserDelegationKeysSample.ts +[storageaccountsupdatesample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsUpdateSample.ts +[usageslistbylocationsample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/usagesListByLocationSample.ts +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-storage-profile-2020-09-01-hybrid?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/storage/arm-storage-profile-2020-09-01-hybrid/README.md +[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/package.json b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/package.json new file mode 100644 index 000000000000..83ba47fb9d00 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/package.json @@ -0,0 +1,41 @@ +{ + "name": "@azure-samples/arm-storage-profile-2020-09-01-hybrid-ts", + "private": true, + "version": "1.0.0", + "description": " client library samples for TypeScript", + "engines": { + "node": ">=14.0.0" + }, + "scripts": { + "build": "tsc", + "prebuild": "rimraf dist/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/storage/arm-storage-profile-2020-09-01-hybrid" + }, + "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/storage/arm-storage-profile-2020-09-01-hybrid", + "dependencies": { + "@azure/arm-storage-profile-2020-09-01-hybrid": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + }, + "devDependencies": { + "@types/node": "^14.0.0", + "typescript": "~4.8.0", + "rimraf": "latest" + } +} diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/sample.env b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/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/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/blobInventoryPoliciesCreateOrUpdateSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/blobInventoryPoliciesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..e2a054728ee3 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/blobInventoryPoliciesCreateOrUpdateSample.ts @@ -0,0 +1,68 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + BlobInventoryPolicy, + StorageManagementClient +} from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Sets the blob inventory policy to the specified storage account. + * + * @summary Sets the blob inventory policy to the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountSetBlobInventoryPolicy.json + */ +async function storageAccountSetBlobInventoryPolicy() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "sto9699"; + const blobInventoryPolicyName = "default"; + const properties: BlobInventoryPolicy = { + policy: { + type: "Inventory", + destination: "containerName", + enabled: true, + rules: [ + { + name: "inventoryPolicyRule1", + definition: { + filters: { + blobTypes: ["blockBlob", "appendBlob", "pageBlob"], + includeBlobVersions: true, + includeSnapshots: true, + prefixMatch: ["inventoryprefix1", "inventoryprefix2"] + } + }, + enabled: true + } + ] + } + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.blobInventoryPolicies.createOrUpdate( + resourceGroupName, + accountName, + blobInventoryPolicyName, + properties + ); + console.log(result); +} + +async function main() { + storageAccountSetBlobInventoryPolicy(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/blobInventoryPoliciesDeleteSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/blobInventoryPoliciesDeleteSample.ts new file mode 100644 index 000000000000..a64197dea431 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/blobInventoryPoliciesDeleteSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the blob inventory policy associated with the specified storage account. + * + * @summary Deletes the blob inventory policy associated with the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountDeleteBlobInventoryPolicy.json + */ +async function storageAccountDeleteBlobInventoryPolicy() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const blobInventoryPolicyName = "default"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.blobInventoryPolicies.delete( + resourceGroupName, + accountName, + blobInventoryPolicyName + ); + console.log(result); +} + +async function main() { + storageAccountDeleteBlobInventoryPolicy(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/blobInventoryPoliciesGetSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/blobInventoryPoliciesGetSample.ts new file mode 100644 index 000000000000..e00f75d4931d --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/blobInventoryPoliciesGetSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the blob inventory policy associated with the specified storage account. + * + * @summary Gets the blob inventory policy associated with the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetBlobInventoryPolicy.json + */ +async function storageAccountGetBlobInventoryPolicy() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "sto9699"; + const blobInventoryPolicyName = "default"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.blobInventoryPolicies.get( + resourceGroupName, + accountName, + blobInventoryPolicyName + ); + console.log(result); +} + +async function main() { + storageAccountGetBlobInventoryPolicy(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/blobInventoryPoliciesListSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/blobInventoryPoliciesListSample.ts new file mode 100644 index 000000000000..5d48e77c6396 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/blobInventoryPoliciesListSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the blob inventory policy associated with the specified storage account. + * + * @summary Gets the blob inventory policy associated with the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListBlobInventoryPolicy.json + */ +async function storageAccountGetBlobInventoryPolicy() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "sto9699"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.blobInventoryPolicies.list( + resourceGroupName, + accountName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + storageAccountGetBlobInventoryPolicy(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/encryptionScopesGetSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/encryptionScopesGetSample.ts new file mode 100644 index 000000000000..d0d408092206 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/encryptionScopesGetSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Returns the properties for the specified encryption scope. + * + * @summary Returns the properties for the specified encryption scope. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetEncryptionScope.json + */ +async function storageAccountGetEncryptionScope() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = + process.env["STORAGE_RESOURCE_GROUP"] || "resource-group-name"; + const accountName = "{storage-account-name}"; + const encryptionScopeName = "{encryption-scope-name}"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.encryptionScopes.get( + resourceGroupName, + accountName, + encryptionScopeName + ); + console.log(result); +} + +async function main() { + storageAccountGetEncryptionScope(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/encryptionScopesListSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/encryptionScopesListSample.ts new file mode 100644 index 000000000000..1cf8b51fe7e9 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/encryptionScopesListSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Lists all the encryption scopes available under the specified storage account. + * + * @summary Lists all the encryption scopes available under the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountEncryptionScopeList.json + */ +async function storageAccountEncryptionScopeList() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = + process.env["STORAGE_RESOURCE_GROUP"] || "resource-group-name"; + const accountName = "{storage-account-name}"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.encryptionScopes.list( + resourceGroupName, + accountName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + storageAccountEncryptionScopeList(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/encryptionScopesPatchSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/encryptionScopesPatchSample.ts new file mode 100644 index 000000000000..48130658c033 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/encryptionScopesPatchSample.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 { + EncryptionScope, + StorageManagementClient +} from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. + * + * @summary Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountPatchEncryptionScope.json + */ +async function storageAccountPatchEncryptionScope() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = + process.env["STORAGE_RESOURCE_GROUP"] || "resource-group-name"; + const accountName = "{storage-account-name}"; + const encryptionScopeName = "{encryption-scope-name}"; + const encryptionScope: EncryptionScope = { + keyVaultProperties: { + keyUri: + "https://testvault.vault.core.windows.net/keys/key1/863425f1358359c" + }, + source: "Microsoft.KeyVault" + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.encryptionScopes.patch( + resourceGroupName, + accountName, + encryptionScopeName, + encryptionScope + ); + console.log(result); +} + +async function main() { + storageAccountPatchEncryptionScope(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/encryptionScopesPutSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/encryptionScopesPutSample.ts new file mode 100644 index 000000000000..a7535e101cd1 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/encryptionScopesPutSample.ts @@ -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. +import { + EncryptionScope, + StorageManagementClient +} from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Synchronously creates or updates an encryption scope under the specified storage account. If an encryption scope is already created and a subsequent request is issued with different properties, the encryption scope properties will be updated per the specified request. + * + * @summary Synchronously creates or updates an encryption scope under the specified storage account. If an encryption scope is already created and a subsequent request is issued with different properties, the encryption scope properties will be updated per the specified request. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountPutEncryptionScope.json + */ +async function storageAccountPutEncryptionScope() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = + process.env["STORAGE_RESOURCE_GROUP"] || "resource-group-name"; + const accountName = "{storage-account-name}"; + const encryptionScopeName = "{encryption-scope-name}"; + const encryptionScope: EncryptionScope = {}; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.encryptionScopes.put( + resourceGroupName, + accountName, + encryptionScopeName, + encryptionScope + ); + console.log(result); +} + +async function main() { + storageAccountPutEncryptionScope(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/managementPoliciesCreateOrUpdateSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/managementPoliciesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..aa9e14a37ea8 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/managementPoliciesCreateOrUpdateSample.ts @@ -0,0 +1,248 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + ManagementPolicy, + StorageManagementClient +} from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Sets the managementpolicy to the specified storage account. + * + * @summary Sets the managementpolicy to the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountSetManagementPolicy.json + */ +async function storageAccountSetManagementPolicies() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "sto9699"; + const managementPolicyName = "default"; + const properties: ManagementPolicy = { + policy: { + rules: [ + { + name: "olcmtest1", + type: "Lifecycle", + definition: { + actions: { + baseBlob: { + delete: { daysAfterModificationGreaterThan: 1000 }, + tierToArchive: { daysAfterModificationGreaterThan: 90 }, + tierToCool: { daysAfterModificationGreaterThan: 30 } + }, + snapshot: { delete: { daysAfterCreationGreaterThan: 30 } } + }, + filters: { + blobTypes: ["blockBlob"], + prefixMatch: ["olcmtestcontainer1"] + } + }, + enabled: true + }, + { + name: "olcmtest2", + type: "Lifecycle", + definition: { + actions: { + baseBlob: { + delete: { daysAfterModificationGreaterThan: 1000 }, + tierToArchive: { daysAfterModificationGreaterThan: 90 }, + tierToCool: { daysAfterModificationGreaterThan: 30 } + } + }, + filters: { + blobIndexMatch: [ + { name: "tag1", op: "==", value: "val1" }, + { name: "tag2", op: "==", value: "val2" } + ], + blobTypes: ["blockBlob"], + prefixMatch: ["olcmtestcontainer2"] + } + }, + enabled: true + } + ] + } + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.managementPolicies.createOrUpdate( + resourceGroupName, + accountName, + managementPolicyName, + properties + ); + console.log(result); +} + +/** + * This sample demonstrates how to Sets the managementpolicy to the specified storage account. + * + * @summary Sets the managementpolicy to the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountSetManagementPolicyForBlockAndAppendBlobs.json + */ +async function storageAccountSetManagementPolicyForBlockAndAppendBlobs() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "sto9699"; + const managementPolicyName = "default"; + const properties: ManagementPolicy = { + policy: { + rules: [ + { + name: "olcmtest1", + type: "Lifecycle", + definition: { + actions: { + baseBlob: { delete: { daysAfterModificationGreaterThan: 90 } }, + snapshot: { delete: { daysAfterCreationGreaterThan: 90 } }, + version: { delete: { daysAfterCreationGreaterThan: 90 } } + }, + filters: { + blobTypes: ["blockBlob", "appendBlob"], + prefixMatch: ["olcmtestcontainer1"] + } + }, + enabled: true + } + ] + } + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.managementPolicies.createOrUpdate( + resourceGroupName, + accountName, + managementPolicyName, + properties + ); + console.log(result); +} + +/** + * This sample demonstrates how to Sets the managementpolicy to the specified storage account. + * + * @summary Sets the managementpolicy to the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountSetManagementPolicyWithSnapshotAndVersion.json + */ +async function storageAccountSetManagementPolicyWithSnapshotAndVersion() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "sto9699"; + const managementPolicyName = "default"; + const properties: ManagementPolicy = { + policy: { + rules: [ + { + name: "olcmtest1", + type: "Lifecycle", + definition: { + actions: { + baseBlob: { + delete: { daysAfterModificationGreaterThan: 1000 }, + tierToArchive: { daysAfterModificationGreaterThan: 90 }, + tierToCool: { daysAfterModificationGreaterThan: 30 } + }, + snapshot: { + delete: { daysAfterCreationGreaterThan: 1000 }, + tierToArchive: { daysAfterCreationGreaterThan: 90 }, + tierToCool: { daysAfterCreationGreaterThan: 30 } + }, + version: { + delete: { daysAfterCreationGreaterThan: 1000 }, + tierToArchive: { daysAfterCreationGreaterThan: 90 }, + tierToCool: { daysAfterCreationGreaterThan: 30 } + } + }, + filters: { + blobTypes: ["blockBlob"], + prefixMatch: ["olcmtestcontainer1"] + } + }, + enabled: true + } + ] + } + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.managementPolicies.createOrUpdate( + resourceGroupName, + accountName, + managementPolicyName, + properties + ); + console.log(result); +} + +/** + * This sample demonstrates how to Sets the managementpolicy to the specified storage account. + * + * @summary Sets the managementpolicy to the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountSetManagementPolicy_LastAccessTimeBasedBlobActions.json + */ +async function storageAccountSetManagementPolicyLastAccessTimeBasedBlobActions() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "sto9699"; + const managementPolicyName = "default"; + const properties: ManagementPolicy = { + policy: { + rules: [ + { + name: "olcmtest", + type: "Lifecycle", + definition: { + actions: { + baseBlob: { + delete: { daysAfterLastAccessTimeGreaterThan: 1000 }, + enableAutoTierToHotFromCool: true, + tierToArchive: { daysAfterLastAccessTimeGreaterThan: 90 }, + tierToCool: { daysAfterLastAccessTimeGreaterThan: 30 } + }, + snapshot: { delete: { daysAfterCreationGreaterThan: 30 } } + }, + filters: { + blobTypes: ["blockBlob"], + prefixMatch: ["olcmtestcontainer"] + } + }, + enabled: true + } + ] + } + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.managementPolicies.createOrUpdate( + resourceGroupName, + accountName, + managementPolicyName, + properties + ); + console.log(result); +} + +async function main() { + storageAccountSetManagementPolicies(); + storageAccountSetManagementPolicyForBlockAndAppendBlobs(); + storageAccountSetManagementPolicyWithSnapshotAndVersion(); + storageAccountSetManagementPolicyLastAccessTimeBasedBlobActions(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/managementPoliciesDeleteSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/managementPoliciesDeleteSample.ts new file mode 100644 index 000000000000..85052c069aec --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/managementPoliciesDeleteSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the managementpolicy associated with the specified storage account. + * + * @summary Deletes the managementpolicy associated with the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountDeleteManagementPolicy.json + */ +async function storageAccountDeleteManagementPolicies() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const managementPolicyName = "default"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.managementPolicies.delete( + resourceGroupName, + accountName, + managementPolicyName + ); + console.log(result); +} + +async function main() { + storageAccountDeleteManagementPolicies(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/managementPoliciesGetSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/managementPoliciesGetSample.ts new file mode 100644 index 000000000000..6a7d29fb1a88 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/managementPoliciesGetSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the managementpolicy associated with the specified storage account. + * + * @summary Gets the managementpolicy associated with the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetManagementPolicy.json + */ +async function storageAccountGetManagementPolicies() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const managementPolicyName = "default"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.managementPolicies.get( + resourceGroupName, + accountName, + managementPolicyName + ); + console.log(result); +} + +async function main() { + storageAccountGetManagementPolicies(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/objectReplicationPoliciesCreateOrUpdateSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/objectReplicationPoliciesCreateOrUpdateSample.ts new file mode 100644 index 000000000000..116f2aac0ad7 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/objectReplicationPoliciesCreateOrUpdateSample.ts @@ -0,0 +1,175 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + ObjectReplicationPolicy, + StorageManagementClient +} from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Create or update the object replication policy of the storage account. + * + * @summary Create or update the object replication policy of the storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountCreateObjectReplicationPolicyOnDestination.json + */ +async function storageAccountCreateObjectReplicationPolicyOnDestination() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "dst112"; + const objectReplicationPolicyId = "default"; + const properties: ObjectReplicationPolicy = { + destinationAccount: "dst112", + rules: [ + { + destinationContainer: "dcont139", + filters: { prefixMatch: ["blobA", "blobB"] }, + sourceContainer: "scont139" + } + ], + sourceAccount: "src1122" + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.objectReplicationPoliciesOperations.createOrUpdate( + resourceGroupName, + accountName, + objectReplicationPolicyId, + properties + ); + console.log(result); +} + +/** + * This sample demonstrates how to Create or update the object replication policy of the storage account. + * + * @summary Create or update the object replication policy of the storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountCreateObjectReplicationPolicyOnSource.json + */ +async function storageAccountCreateObjectReplicationPolicyOnSource() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "src1122"; + const objectReplicationPolicyId = "2a20bb73-5717-4635-985a-5d4cf777438f"; + const properties: ObjectReplicationPolicy = { + destinationAccount: "dst112", + rules: [ + { + destinationContainer: "dcont139", + filters: { + minCreationTime: "2020-02-19T16:05:00Z", + prefixMatch: ["blobA", "blobB"] + }, + ruleId: "d5d18a48-8801-4554-aeaa-74faf65f5ef9", + sourceContainer: "scont139" + } + ], + sourceAccount: "src1122" + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.objectReplicationPoliciesOperations.createOrUpdate( + resourceGroupName, + accountName, + objectReplicationPolicyId, + properties + ); + console.log(result); +} + +/** + * This sample demonstrates how to Create or update the object replication policy of the storage account. + * + * @summary Create or update the object replication policy of the storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountUpdateObjectReplicationPolicyOnDestination.json + */ +async function storageAccountUpdateObjectReplicationPolicyOnDestination() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "dst112"; + const objectReplicationPolicyId = "2a20bb73-5717-4635-985a-5d4cf777438f"; + const properties: ObjectReplicationPolicy = { + destinationAccount: "dst112", + rules: [ + { + destinationContainer: "dcont139", + filters: { prefixMatch: ["blobA", "blobB"] }, + ruleId: "d5d18a48-8801-4554-aeaa-74faf65f5ef9", + sourceContainer: "scont139" + }, + { destinationContainer: "dcont179", sourceContainer: "scont179" } + ], + sourceAccount: "src1122" + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.objectReplicationPoliciesOperations.createOrUpdate( + resourceGroupName, + accountName, + objectReplicationPolicyId, + properties + ); + console.log(result); +} + +/** + * This sample demonstrates how to Create or update the object replication policy of the storage account. + * + * @summary Create or update the object replication policy of the storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountUpdateObjectReplicationPolicyOnSource.json + */ +async function storageAccountUpdateObjectReplicationPolicyOnSource() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "src1122"; + const objectReplicationPolicyId = "2a20bb73-5717-4635-985a-5d4cf777438f"; + const properties: ObjectReplicationPolicy = { + destinationAccount: "dst112", + rules: [ + { + destinationContainer: "dcont139", + filters: { prefixMatch: ["blobA", "blobB"] }, + ruleId: "d5d18a48-8801-4554-aeaa-74faf65f5ef9", + sourceContainer: "scont139" + }, + { + destinationContainer: "dcont179", + ruleId: "cfbb4bc2-8b60-429f-b05a-d1e0942b33b2", + sourceContainer: "scont179" + } + ], + sourceAccount: "src1122" + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.objectReplicationPoliciesOperations.createOrUpdate( + resourceGroupName, + accountName, + objectReplicationPolicyId, + properties + ); + console.log(result); +} + +async function main() { + storageAccountCreateObjectReplicationPolicyOnDestination(); + storageAccountCreateObjectReplicationPolicyOnSource(); + storageAccountUpdateObjectReplicationPolicyOnDestination(); + storageAccountUpdateObjectReplicationPolicyOnSource(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/objectReplicationPoliciesDeleteSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/objectReplicationPoliciesDeleteSample.ts new file mode 100644 index 000000000000..4f172e81dad9 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/objectReplicationPoliciesDeleteSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the object replication policy associated with the specified storage account. + * + * @summary Deletes the object replication policy associated with the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountDeleteObjectReplicationPolicy.json + */ +async function storageAccountDeleteObjectReplicationPolicies() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const objectReplicationPolicyId = "{objectReplicationPolicy-Id}"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.objectReplicationPoliciesOperations.delete( + resourceGroupName, + accountName, + objectReplicationPolicyId + ); + console.log(result); +} + +async function main() { + storageAccountDeleteObjectReplicationPolicies(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/objectReplicationPoliciesGetSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/objectReplicationPoliciesGetSample.ts new file mode 100644 index 000000000000..48d2e0e5f279 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/objectReplicationPoliciesGetSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Get the object replication policy of the storage account by policy ID. + * + * @summary Get the object replication policy of the storage account by policy ID. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetObjectReplicationPolicy.json + */ +async function storageAccountGetObjectReplicationPolicies() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const objectReplicationPolicyId = "{objectReplicationPolicy-Id}"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.objectReplicationPoliciesOperations.get( + resourceGroupName, + accountName, + objectReplicationPolicyId + ); + console.log(result); +} + +async function main() { + storageAccountGetObjectReplicationPolicies(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/objectReplicationPoliciesListSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/objectReplicationPoliciesListSample.ts new file mode 100644 index 000000000000..29d06ab5c714 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/objectReplicationPoliciesListSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List the object replication policies associated with the storage account. + * + * @summary List the object replication policies associated with the storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListObjectReplicationPolicies.json + */ +async function storageAccountListObjectReplicationPolicies() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.objectReplicationPoliciesOperations.list( + resourceGroupName, + accountName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + storageAccountListObjectReplicationPolicies(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/operationsListSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/operationsListSample.ts new file mode 100644 index 000000000000..667b9b0e5f52 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/operationsListSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Lists all of the available Storage Rest API operations. + * + * @summary Lists all of the available Storage Rest API operations. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/OperationsList.json + */ +async function operationsList() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || + "00000000-0000-0000-0000-000000000000"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.operations.list()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + operationsList(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/privateEndpointConnectionsDeleteSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/privateEndpointConnectionsDeleteSample.ts new file mode 100644 index 000000000000..b11de18e4b3e --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/privateEndpointConnectionsDeleteSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes the specified private endpoint connection associated with the storage account. + * + * @summary Deletes the specified private endpoint connection associated with the storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountDeletePrivateEndpointConnection.json + */ +async function storageAccountDeletePrivateEndpointConnection() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const privateEndpointConnectionName = "{privateEndpointConnectionName}"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.delete( + resourceGroupName, + accountName, + privateEndpointConnectionName + ); + console.log(result); +} + +async function main() { + storageAccountDeletePrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/privateEndpointConnectionsGetSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/privateEndpointConnectionsGetSample.ts new file mode 100644 index 000000000000..9c398fc3f3bc --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/privateEndpointConnectionsGetSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the specified private endpoint connection associated with the storage account. + * + * @summary Gets the specified private endpoint connection associated with the storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetPrivateEndpointConnection.json + */ +async function storageAccountGetPrivateEndpointConnection() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const privateEndpointConnectionName = "{privateEndpointConnectionName}"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.get( + resourceGroupName, + accountName, + privateEndpointConnectionName + ); + console.log(result); +} + +async function main() { + storageAccountGetPrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/privateEndpointConnectionsListSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/privateEndpointConnectionsListSample.ts new file mode 100644 index 000000000000..f0de0974655f --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/privateEndpointConnectionsListSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List all the private endpoint connections associated with the storage account. + * + * @summary List all the private endpoint connections associated with the storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListPrivateEndpointConnections.json + */ +async function storageAccountListPrivateEndpointConnections() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.privateEndpointConnections.list( + resourceGroupName, + accountName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + storageAccountListPrivateEndpointConnections(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/privateEndpointConnectionsPutSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/privateEndpointConnectionsPutSample.ts new file mode 100644 index 000000000000..f12a79ad79b2 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/privateEndpointConnectionsPutSample.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 { + PrivateEndpointConnection, + StorageManagementClient +} from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Update the state of specified private endpoint connection associated with the storage account. + * + * @summary Update the state of specified private endpoint connection associated with the storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountPutPrivateEndpointConnection.json + */ +async function storageAccountPutPrivateEndpointConnection() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7687"; + const accountName = "sto9699"; + const privateEndpointConnectionName = "{privateEndpointConnectionName}"; + const properties: PrivateEndpointConnection = { + privateLinkServiceConnectionState: { + description: "Auto-Approved", + status: "Approved" + } + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.privateEndpointConnections.put( + resourceGroupName, + accountName, + privateEndpointConnectionName, + properties + ); + console.log(result); +} + +async function main() { + storageAccountPutPrivateEndpointConnection(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/privateLinkResourcesListByStorageAccountSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/privateLinkResourcesListByStorageAccountSample.ts new file mode 100644 index 000000000000..70672ca23760 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/privateLinkResourcesListByStorageAccountSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the private link resources that need to be created for a storage account. + * + * @summary Gets the private link resources that need to be created for a storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListPrivateLinkResources.json + */ +async function storageAccountListPrivateLinkResources() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6977"; + const accountName = "sto2527"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.privateLinkResources.listByStorageAccount( + resourceGroupName, + accountName + ); + console.log(result); +} + +async function main() { + storageAccountListPrivateLinkResources(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/skusListSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/skusListSample.ts new file mode 100644 index 000000000000..8fe8ed8a43a8 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/skusListSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Lists the available SKUs supported by Microsoft.Storage for given subscription. + * + * @summary Lists the available SKUs supported by Microsoft.Storage for given subscription. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/SKUList.json + */ +async function skuList() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.skus.list()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + skuList(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsCheckNameAvailabilitySample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsCheckNameAvailabilitySample.ts new file mode 100644 index 000000000000..d84584c2b004 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsCheckNameAvailabilitySample.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 { + StorageAccountCheckNameAvailabilityParameters, + StorageManagementClient +} from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Checks that the storage account name is valid and is not already in use. + * + * @summary Checks that the storage account name is valid and is not already in use. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountCheckNameAvailability.json + */ +async function storageAccountCheckNameAvailability() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const accountName: StorageAccountCheckNameAvailabilityParameters = { + name: "sto3363", + type: "Microsoft.Storage/storageAccounts" + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.checkNameAvailability( + accountName + ); + console.log(result); +} + +async function main() { + storageAccountCheckNameAvailability(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsCreateSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsCreateSample.ts new file mode 100644 index 000000000000..bd442a504800 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsCreateSample.ts @@ -0,0 +1,68 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + StorageAccountCreateParameters, + StorageManagementClient +} from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or update request is issued with the exact same set of properties, the request will succeed. + * + * @summary Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request is issued with different properties, the account properties will be updated. If an account is already created and a subsequent create or update request is issued with the exact same set of properties, the request will succeed. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountCreate.json + */ +async function storageAccountCreate() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res9101"; + const accountName = "sto4445"; + const parameters: StorageAccountCreateParameters = { + allowBlobPublicAccess: false, + allowSharedKeyAccess: true, + encryption: { + keySource: "Microsoft.Storage", + requireInfrastructureEncryption: false, + services: { + blob: { enabled: true, keyType: "Account" }, + file: { enabled: true, keyType: "Account" } + } + }, + isHnsEnabled: true, + kind: "Storage", + location: "eastus", + minimumTlsVersion: "TLS1_2", + routingPreference: { + publishInternetEndpoints: true, + publishMicrosoftEndpoints: true, + routingChoice: "MicrosoftRouting" + }, + sku: { name: "Standard_GRS" }, + tags: { key1: "value1", key2: "value2" } + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.beginCreateAndWait( + resourceGroupName, + accountName, + parameters + ); + console.log(result); +} + +async function main() { + storageAccountCreate(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsDeleteSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsDeleteSample.ts new file mode 100644 index 000000000000..0bb0ea25ac05 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsDeleteSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Deletes a storage account in Microsoft Azure. + * + * @summary Deletes a storage account in Microsoft Azure. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountDelete.json + */ +async function storageAccountDelete() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res4228"; + const accountName = "sto2434"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.delete( + resourceGroupName, + accountName + ); + console.log(result); +} + +async function main() { + storageAccountDelete(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsFailoverSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsFailoverSample.ts new file mode 100644 index 000000000000..9339d2919fb0 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsFailoverSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. + * + * @summary Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountFailover.json + */ +async function storageAccountFailover() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res4228"; + const accountName = "sto2434"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.beginFailoverAndWait( + resourceGroupName, + accountName + ); + console.log(result); +} + +async function main() { + storageAccountFailover(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsGetPropertiesSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsGetPropertiesSample.ts new file mode 100644 index 000000000000..b0e31236a2e9 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsGetPropertiesSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. + * + * @summary Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetProperties.json + */ +async function storageAccountGetProperties() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res9407"; + const accountName = "sto8596"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.getProperties( + resourceGroupName, + accountName + ); + console.log(result); +} + +/** + * This sample demonstrates how to Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. + * + * @summary Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountGetPropertiesCMKEnabled.json + */ +async function storageAccountGetPropertiesCmkEnabled() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res9407"; + const accountName = "sto8596"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.getProperties( + resourceGroupName, + accountName + ); + console.log(result); +} + +async function main() { + storageAccountGetProperties(); + storageAccountGetPropertiesCmkEnabled(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsListAccountSasSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsListAccountSasSample.ts new file mode 100644 index 000000000000..1d591cdc034c --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsListAccountSasSample.ts @@ -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. +import { + AccountSasParameters, + StorageManagementClient +} from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List SAS credentials of a storage account. + * + * @summary List SAS credentials of a storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListAccountSAS.json + */ +async function storageAccountListAccountSas() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7985"; + const accountName = "sto8588"; + const parameters: AccountSasParameters = { + keyToSign: "key1", + sharedAccessExpiryTime: new Date("2017-05-24T11:42:03.1567373Z"), + permissions: "r", + protocols: "https,http", + resourceTypes: "s", + services: "b", + sharedAccessStartTime: new Date("2017-05-24T10:42:03.1567373Z") + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.listAccountSAS( + resourceGroupName, + accountName, + parameters + ); + console.log(result); +} + +async function main() { + storageAccountListAccountSas(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsListByResourceGroupSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsListByResourceGroupSample.ts new file mode 100644 index 000000000000..5486237cee03 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsListByResourceGroupSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. + * + * @summary Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListByResourceGroup.json + */ +async function storageAccountListByResourceGroup() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res6117"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.storageAccounts.listByResourceGroup( + resourceGroupName + )) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + storageAccountListByResourceGroup(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsListKeysSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsListKeysSample.ts new file mode 100644 index 000000000000..b353f6dd962f --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsListKeysSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. + * + * @summary Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListKeys.json + */ +async function storageAccountListKeys() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res418"; + const accountName = "sto2220"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.listKeys( + resourceGroupName, + accountName + ); + console.log(result); +} + +async function main() { + storageAccountListKeys(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsListSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsListSample.ts new file mode 100644 index 000000000000..d5db0af11bd4 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsListSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. + * + * @summary Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountList.json + */ +async function storageAccountList() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.storageAccounts.list()) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + storageAccountList(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsListServiceSasSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsListServiceSasSample.ts new file mode 100644 index 000000000000..2245b646d3da --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsListServiceSasSample.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 { + ServiceSasParameters, + StorageManagementClient +} from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to List service SAS credentials of a specific resource. + * + * @summary List service SAS credentials of a specific resource. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListServiceSAS.json + */ +async function storageAccountListServiceSas() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res7439"; + const accountName = "sto1299"; + const parameters: ServiceSasParameters = { + canonicalizedResource: "/blob/sto1299/music", + sharedAccessExpiryTime: new Date("2017-05-24T11:32:48.8457197Z"), + permissions: "l", + resource: "c" + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.listServiceSAS( + resourceGroupName, + accountName, + parameters + ); + console.log(result); +} + +async function main() { + storageAccountListServiceSas(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsRegenerateKeySample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsRegenerateKeySample.ts new file mode 100644 index 000000000000..0c853fdac121 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsRegenerateKeySample.ts @@ -0,0 +1,73 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + StorageAccountRegenerateKeyParameters, + StorageManagementClient +} from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Regenerates one of the access keys or Kerberos keys for the specified storage account. + * + * @summary Regenerates one of the access keys or Kerberos keys for the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountRegenerateKerbKey.json + */ +async function storageAccountRegenerateKerbKey() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res4167"; + const accountName = "sto3539"; + const regenerateKey: StorageAccountRegenerateKeyParameters = { + keyName: "kerb1" + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.regenerateKey( + resourceGroupName, + accountName, + regenerateKey + ); + console.log(result); +} + +/** + * This sample demonstrates how to Regenerates one of the access keys or Kerberos keys for the specified storage account. + * + * @summary Regenerates one of the access keys or Kerberos keys for the specified storage account. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountRegenerateKey.json + */ +async function storageAccountRegenerateKey() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res4167"; + const accountName = "sto3539"; + const regenerateKey: StorageAccountRegenerateKeyParameters = { + keyName: "key2" + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.regenerateKey( + resourceGroupName, + accountName, + regenerateKey + ); + console.log(result); +} + +async function main() { + storageAccountRegenerateKerbKey(); + storageAccountRegenerateKey(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsRestoreBlobRangesSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsRestoreBlobRangesSample.ts new file mode 100644 index 000000000000..7669cd727294 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsRestoreBlobRangesSample.ts @@ -0,0 +1,52 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + BlobRestoreParameters, + StorageManagementClient +} from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Restore blobs in the specified blob ranges + * + * @summary Restore blobs in the specified blob ranges + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/BlobRangesRestore.json + */ +async function blobRangesRestore() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res9101"; + const accountName = "sto4445"; + const parameters: BlobRestoreParameters = { + blobRanges: [ + { endRange: "container/blobpath2", startRange: "container/blobpath1" }, + { endRange: "", startRange: "container2/blobpath3" } + ], + timeToRestore: new Date("2019-04-20T15:30:00.0000000Z") + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.beginRestoreBlobRangesAndWait( + resourceGroupName, + accountName, + parameters + ); + console.log(result); +} + +async function main() { + blobRangesRestore(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsRevokeUserDelegationKeysSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsRevokeUserDelegationKeysSample.ts new file mode 100644 index 000000000000..bcb4f7fe3fd4 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsRevokeUserDelegationKeysSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Revoke user delegation keys. + * + * @summary Revoke user delegation keys. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountRevokeUserDelegationKeys.json + */ +async function storageAccountRevokeUserDelegationKeys() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res4167"; + const accountName = "sto3539"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.revokeUserDelegationKeys( + resourceGroupName, + accountName + ); + console.log(result); +} + +async function main() { + storageAccountRevokeUserDelegationKeys(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsUpdateSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsUpdateSample.ts new file mode 100644 index 000000000000..cf8bc525659a --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/storageAccountsUpdateSample.ts @@ -0,0 +1,134 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +import { + StorageAccountUpdateParameters, + StorageManagementClient +} from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not supported. In order to replace an old custom domain, the old value must be cleared/unregistered before a new value can be set. The update of multiple properties is supported. This call does not change the storage keys for the account. If you want to change the storage account keys, use the regenerate keys operation. The location and name of the storage account cannot be changed after creation. + * + * @summary The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not supported. In order to replace an old custom domain, the old value must be cleared/unregistered before a new value can be set. The update of multiple properties is supported. This call does not change the storage keys for the account. If you want to change the storage account keys, use the regenerate keys operation. The location and name of the storage account cannot be changed after creation. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountEnableAD.json + */ +async function storageAccountEnableAd() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res9407"; + const accountName = "sto8596"; + const parameters: StorageAccountUpdateParameters = { + azureFilesIdentityBasedAuthentication: { + activeDirectoryProperties: { + azureStorageSid: "S-1-5-21-2400535526-2334094090-2402026252-0012", + domainGuid: "aebfc118-9fa9-4732-a21f-d98e41a77ae1", + domainName: "adtest.com", + domainSid: "S-1-5-21-2400535526-2334094090-2402026252", + forestName: "adtest.com", + netBiosDomainName: "adtest.com" + }, + directoryServiceOptions: "AD" + } + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.update( + resourceGroupName, + accountName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not supported. In order to replace an old custom domain, the old value must be cleared/unregistered before a new value can be set. The update of multiple properties is supported. This call does not change the storage keys for the account. If you want to change the storage account keys, use the regenerate keys operation. The location and name of the storage account cannot be changed after creation. + * + * @summary The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not supported. In order to replace an old custom domain, the old value must be cleared/unregistered before a new value can be set. The update of multiple properties is supported. This call does not change the storage keys for the account. If you want to change the storage account keys, use the regenerate keys operation. The location and name of the storage account cannot be changed after creation. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountEnableCMK.json + */ +async function storageAccountEnableCmk() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res9407"; + const accountName = "sto8596"; + const parameters: StorageAccountUpdateParameters = { + encryption: { + keySource: "Microsoft.Keyvault", + keyVaultProperties: { + keyName: "wrappingKey", + keyVaultUri: "https://myvault8569.vault.azure.net", + keyVersion: "" + }, + services: { + blob: { enabled: true, keyType: "Account" }, + file: { enabled: true, keyType: "Account" } + } + } + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.update( + resourceGroupName, + accountName, + parameters + ); + console.log(result); +} + +/** + * This sample demonstrates how to The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not supported. In order to replace an old custom domain, the old value must be cleared/unregistered before a new value can be set. The update of multiple properties is supported. This call does not change the storage keys for the account. If you want to change the storage account keys, use the regenerate keys operation. The location and name of the storage account cannot be changed after creation. + * + * @summary The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account to a custom domain. Only one custom domain is supported per storage account; the replacement/change of custom domain is not supported. In order to replace an old custom domain, the old value must be cleared/unregistered before a new value can be set. The update of multiple properties is supported. This call does not change the storage keys for the account. If you want to change the storage account keys, use the regenerate keys operation. The location and name of the storage account cannot be changed after creation. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountUpdate.json + */ +async function storageAccountUpdate() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const resourceGroupName = process.env["STORAGE_RESOURCE_GROUP"] || "res9407"; + const accountName = "sto8596"; + const parameters: StorageAccountUpdateParameters = { + allowBlobPublicAccess: false, + allowSharedKeyAccess: true, + encryption: { + keySource: "Microsoft.Storage", + services: { + blob: { enabled: true, keyType: "Account" }, + file: { enabled: true, keyType: "Account" } + } + }, + minimumTlsVersion: "TLS1_2", + networkRuleSet: { defaultAction: "Allow" }, + routingPreference: { + publishInternetEndpoints: true, + publishMicrosoftEndpoints: true, + routingChoice: "MicrosoftRouting" + } + }; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const result = await client.storageAccounts.update( + resourceGroupName, + accountName, + parameters + ); + console.log(result); +} + +async function main() { + storageAccountEnableAd(); + storageAccountEnableCmk(); + storageAccountUpdate(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/usagesListByLocationSample.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/usagesListByLocationSample.ts new file mode 100644 index 000000000000..d674d608d0f4 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/src/usagesListByLocationSample.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 { StorageManagementClient } from "@azure/arm-storage-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Gets the current usage count and the limit for the resources of the location under the subscription. + * + * @summary Gets the current usage count and the limit for the resources of the location under the subscription. + * x-ms-original-file: specification/storage/resource-manager/Microsoft.Storage/stable/2019-06-01/examples/StorageAccountListLocationUsage.json + */ +async function usageList() { + const subscriptionId = + process.env["STORAGE_SUBSCRIPTION_ID"] || "{subscription-id}"; + const location = "eastus2(stage)"; + const credential = new DefaultAzureCredential(); + const client = new StorageManagementClient(credential, subscriptionId); + const resArray = new Array(); + for await (let item of client.usages.listByLocation(location)) { + resArray.push(item); + } + console.log(resArray); +} + +async function main() { + usageList(); +} + +main().catch(console.error); diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/tsconfig.json b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/tsconfig.json new file mode 100644 index 000000000000..e26ce2a6d8f7 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/samples/v2/typescript/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "commonjs", + "moduleResolution": "node", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "alwaysStrict": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": [ + "src/**.ts" + ] +} diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/index.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/index.ts index 73d50acefbed..2eec2f06be99 100644 --- a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/index.ts +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/index.ts @@ -7,6 +7,7 @@ */ /// +export { getContinuationToken } from "./pagingHelper"; export * from "./models"; export { StorageManagementClient } from "./storageManagementClient"; export * from "./operationsInterfaces"; diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/models/index.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/models/index.ts index cbc57c1dbde5..c2b424ea8eb4 100644 --- a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/models/index.ts +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/models/index.ts @@ -1004,7 +1004,7 @@ export interface EncryptionScopeListResult { } /** The Private Endpoint Connection resource. */ -export type PrivateEndpointConnection = Resource & { +export interface PrivateEndpointConnection extends Resource { /** The resource of private end point. */ privateEndpoint?: PrivateEndpoint; /** A collection of information about the state of the connection between service consumer and provider. */ @@ -1014,18 +1014,18 @@ export type PrivateEndpointConnection = Resource & { * NOTE: This property will not be serialized. It can only be populated by the server. */ readonly provisioningState?: PrivateEndpointConnectionProvisioningState; -}; +} /** The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' */ -export type TrackedResource = Resource & { +export interface TrackedResource extends Resource { /** Resource tags. */ tags?: { [propertyName: string]: string }; /** The geo-location where the resource lives */ location: string; -}; +} /** The Get Storage Account ManagementPolicies operation response. */ -export type ManagementPolicy = Resource & { +export interface ManagementPolicy extends Resource { /** * Returns the date and time the ManagementPolicies was last modified. * NOTE: This property will not be serialized. It can only be populated by the server. @@ -1033,10 +1033,10 @@ export type ManagementPolicy = Resource & { readonly lastModifiedTime?: Date; /** The Storage Account ManagementPolicy, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. */ policy?: ManagementPolicySchema; -}; +} /** The storage account blob inventory policy. */ -export type BlobInventoryPolicy = Resource & { +export interface BlobInventoryPolicy extends Resource { /** * 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. @@ -1049,10 +1049,10 @@ export type BlobInventoryPolicy = Resource & { readonly lastModifiedTime?: Date; /** The storage account blob inventory policy object. It is composed of policy rules. */ policy?: BlobInventoryPolicySchema; -}; +} /** A private link resource */ -export type PrivateLinkResource = Resource & { +export interface PrivateLinkResource extends Resource { /** * The private link resource group id. * NOTE: This property will not be serialized. It can only be populated by the server. @@ -1065,10 +1065,10 @@ export type PrivateLinkResource = Resource & { readonly requiredMembers?: string[]; /** The private link resource Private link DNS zone name. */ requiredZoneNames?: string[]; -}; +} /** The replication policy between two storage accounts. Multiple rules can be defined in one policy. */ -export type ObjectReplicationPolicy = Resource & { +export interface ObjectReplicationPolicy extends Resource { /** * A unique id for object replication policy. * NOTE: This property will not be serialized. It can only be populated by the server. @@ -1085,10 +1085,10 @@ export type ObjectReplicationPolicy = Resource & { destinationAccount?: string; /** The storage account object replication rules. */ rules?: ObjectReplicationPolicyRule[]; -}; +} /** The Encryption Scope resource. */ -export type EncryptionScope = Resource & { +export interface EncryptionScope extends Resource { /** The provider for the encryption scope. Possible values (case-insensitive): Microsoft.Storage, Microsoft.KeyVault. */ source?: EncryptionScopeSource; /** The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled. */ @@ -1105,10 +1105,10 @@ export type EncryptionScope = Resource & { readonly lastModifiedTime?: Date; /** The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. */ keyVaultProperties?: EncryptionScopeKeyVaultProperties; -}; +} /** The storage account. */ -export type StorageAccount = TrackedResource & { +export interface StorageAccount extends TrackedResource { /** * Gets the SKU. * NOTE: This property will not be serialized. It can only be populated by the server. @@ -1222,17 +1222,25 @@ export type StorageAccount = TrackedResource & { minimumTlsVersion?: MinimumTlsVersion; /** Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including shared access signatures, must be authorized with Azure Active Directory (Azure AD). The default value is null, which is equivalent to true. */ allowSharedKeyAccess?: boolean; -}; +} /** Known values of {@link SkuName} that the service accepts. */ export enum KnownSkuName { + /** StandardLRS */ StandardLRS = "Standard_LRS", + /** StandardGRS */ StandardGRS = "Standard_GRS", + /** StandardRagrs */ StandardRagrs = "Standard_RAGRS", + /** StandardZRS */ StandardZRS = "Standard_ZRS", + /** PremiumLRS */ PremiumLRS = "Premium_LRS", + /** PremiumZRS */ PremiumZRS = "Premium_ZRS", + /** StandardGzrs */ StandardGzrs = "Standard_GZRS", + /** StandardRagzrs */ StandardRagzrs = "Standard_RAGZRS" } @@ -1254,10 +1262,15 @@ export type SkuName = string; /** Known values of {@link Kind} that the service accepts. */ export enum KnownKind { + /** Storage */ Storage = "Storage", + /** StorageV2 */ StorageV2 = "StorageV2", + /** BlobStorage */ BlobStorage = "BlobStorage", + /** FileStorage */ FileStorage = "FileStorage", + /** BlockBlobStorage */ BlockBlobStorage = "BlockBlobStorage" } @@ -1276,7 +1289,9 @@ export type Kind = string; /** Known values of {@link ReasonCode} that the service accepts. */ export enum KnownReasonCode { + /** QuotaId */ QuotaId = "QuotaId", + /** NotAvailableForSubscription */ NotAvailableForSubscription = "NotAvailableForSubscription" } @@ -1292,7 +1307,9 @@ export type ReasonCode = string; /** Known values of {@link KeyType} that the service accepts. */ export enum KnownKeyType { + /** Service */ Service = "Service", + /** Account */ Account = "Account" } @@ -1308,7 +1325,9 @@ export type KeyType = string; /** Known values of {@link KeySource} that the service accepts. */ export enum KnownKeySource { + /** MicrosoftStorage */ MicrosoftStorage = "Microsoft.Storage", + /** MicrosoftKeyvault */ MicrosoftKeyvault = "Microsoft.Keyvault" } @@ -1324,9 +1343,13 @@ export type KeySource = string; /** Known values of {@link Bypass} that the service accepts. */ export enum KnownBypass { + /** None */ None = "None", + /** Logging */ Logging = "Logging", + /** Metrics */ Metrics = "Metrics", + /** AzureServices */ AzureServices = "AzureServices" } @@ -1344,8 +1367,11 @@ export type Bypass = string; /** Known values of {@link DirectoryServiceOptions} that the service accepts. */ export enum KnownDirectoryServiceOptions { + /** None */ None = "None", + /** Aadds */ Aadds = "AADDS", + /** AD */ AD = "AD" } @@ -1362,7 +1388,9 @@ export type DirectoryServiceOptions = string; /** Known values of {@link LargeFileSharesState} that the service accepts. */ export enum KnownLargeFileSharesState { + /** Disabled */ Disabled = "Disabled", + /** Enabled */ Enabled = "Enabled" } @@ -1378,7 +1406,9 @@ export type LargeFileSharesState = string; /** Known values of {@link RoutingChoice} that the service accepts. */ export enum KnownRoutingChoice { + /** MicrosoftRouting */ MicrosoftRouting = "MicrosoftRouting", + /** InternetRouting */ InternetRouting = "InternetRouting" } @@ -1394,8 +1424,11 @@ export type RoutingChoice = string; /** Known values of {@link MinimumTlsVersion} that the service accepts. */ export enum KnownMinimumTlsVersion { + /** TLS10 */ TLS10 = "TLS1_0", + /** TLS11 */ TLS11 = "TLS1_1", + /** TLS12 */ TLS12 = "TLS1_2" } @@ -1412,8 +1445,11 @@ export type MinimumTlsVersion = string; /** Known values of {@link GeoReplicationStatus} that the service accepts. */ export enum KnownGeoReplicationStatus { + /** Live */ Live = "Live", + /** Bootstrap */ Bootstrap = "Bootstrap", + /** Unavailable */ Unavailable = "Unavailable" } @@ -1430,8 +1466,11 @@ export type GeoReplicationStatus = string; /** Known values of {@link PrivateEndpointServiceConnectionStatus} that the service accepts. */ export enum KnownPrivateEndpointServiceConnectionStatus { + /** Pending */ Pending = "Pending", + /** Approved */ Approved = "Approved", + /** Rejected */ Rejected = "Rejected" } @@ -1448,9 +1487,13 @@ export type PrivateEndpointServiceConnectionStatus = string; /** Known values of {@link PrivateEndpointConnectionProvisioningState} that the service accepts. */ export enum KnownPrivateEndpointConnectionProvisioningState { + /** Succeeded */ Succeeded = "Succeeded", + /** Creating */ Creating = "Creating", + /** Deleting */ Deleting = "Deleting", + /** Failed */ Failed = "Failed" } @@ -1468,8 +1511,11 @@ export type PrivateEndpointConnectionProvisioningState = string; /** Known values of {@link BlobRestoreProgressStatus} that the service accepts. */ export enum KnownBlobRestoreProgressStatus { + /** InProgress */ InProgress = "InProgress", + /** Complete */ Complete = "Complete", + /** Failed */ Failed = "Failed" } @@ -1486,9 +1532,13 @@ export type BlobRestoreProgressStatus = string; /** Known values of {@link Services} that the service accepts. */ export enum KnownServices { + /** B */ B = "b", + /** Q */ Q = "q", + /** T */ T = "t", + /** F */ F = "f" } @@ -1506,8 +1556,11 @@ export type Services = string; /** Known values of {@link SignedResourceTypes} that the service accepts. */ export enum KnownSignedResourceTypes { + /** S */ S = "s", + /** C */ C = "c", + /** O */ O = "o" } @@ -1524,13 +1577,21 @@ export type SignedResourceTypes = string; /** Known values of {@link Permissions} that the service accepts. */ export enum KnownPermissions { + /** R */ R = "r", + /** D */ D = "d", + /** W */ W = "w", + /** L */ L = "l", + /** A */ A = "a", + /** C */ C = "c", + /** U */ U = "u", + /** P */ P = "p" } @@ -1552,9 +1613,13 @@ export type Permissions = string; /** Known values of {@link SignedResource} that the service accepts. */ export enum KnownSignedResource { + /** B */ B = "b", + /** C */ C = "c", + /** F */ F = "f", + /** S */ S = "s" } @@ -1572,6 +1637,7 @@ export type SignedResource = string; /** Known values of {@link ManagementPolicyName} that the service accepts. */ export enum KnownManagementPolicyName { + /** Default */ Default = "default" } @@ -1586,6 +1652,7 @@ export type ManagementPolicyName = string; /** Known values of {@link RuleType} that the service accepts. */ export enum KnownRuleType { + /** Lifecycle */ Lifecycle = "Lifecycle" } @@ -1600,6 +1667,7 @@ export type RuleType = string; /** Known values of {@link BlobInventoryPolicyName} that the service accepts. */ export enum KnownBlobInventoryPolicyName { + /** Default */ Default = "default" } @@ -1614,6 +1682,7 @@ export type BlobInventoryPolicyName = string; /** Known values of {@link InventoryRuleType} that the service accepts. */ export enum KnownInventoryRuleType { + /** Inventory */ Inventory = "Inventory" } @@ -1628,9 +1697,13 @@ export type InventoryRuleType = string; /** Known values of {@link CreatedByType} that the service accepts. */ export enum KnownCreatedByType { + /** User */ User = "User", + /** Application */ Application = "Application", + /** ManagedIdentity */ ManagedIdentity = "ManagedIdentity", + /** Key */ Key = "Key" } @@ -1648,7 +1721,9 @@ export type CreatedByType = string; /** Known values of {@link EncryptionScopeSource} that the service accepts. */ export enum KnownEncryptionScopeSource { + /** MicrosoftStorage */ MicrosoftStorage = "Microsoft.Storage", + /** MicrosoftKeyVault */ MicrosoftKeyVault = "Microsoft.KeyVault" } @@ -1664,7 +1739,9 @@ export type EncryptionScopeSource = string; /** Known values of {@link EncryptionScopeState} that the service accepts. */ export enum KnownEncryptionScopeState { + /** Enabled */ Enabled = "Enabled", + /** Disabled */ Disabled = "Disabled" } diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/blobInventoryPolicies.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/blobInventoryPolicies.ts index 4c5e6ef5fb7a..258a6221a59c 100644 --- a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/blobInventoryPolicies.ts +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/blobInventoryPolicies.ts @@ -6,7 +6,7 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; import { BlobInventoryPolicies } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -15,13 +15,13 @@ import { StorageManagementClient } from "../storageManagementClient"; import { BlobInventoryPolicy, BlobInventoryPoliciesListOptionalParams, + BlobInventoryPoliciesListResponse, BlobInventoryPolicyName, BlobInventoryPoliciesGetOptionalParams, BlobInventoryPoliciesGetResponse, BlobInventoryPoliciesCreateOrUpdateOptionalParams, BlobInventoryPoliciesCreateOrUpdateResponse, - BlobInventoryPoliciesDeleteOptionalParams, - BlobInventoryPoliciesListResponse + BlobInventoryPoliciesDeleteOptionalParams } from "../models"; /// @@ -59,8 +59,16 @@ export class BlobInventoryPoliciesImpl implements BlobInventoryPolicies { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(resourceGroupName, accountName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage( + resourceGroupName, + accountName, + options, + settings + ); } }; } @@ -68,9 +76,11 @@ export class BlobInventoryPoliciesImpl implements BlobInventoryPolicies { private async *listPagingPage( resourceGroupName: string, accountName: string, - options?: BlobInventoryPoliciesListOptionalParams + options?: BlobInventoryPoliciesListOptionalParams, + _settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(resourceGroupName, accountName, options); + let result: BlobInventoryPoliciesListResponse; + result = await this._list(resourceGroupName, accountName, options); yield result.value || []; } diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/encryptionScopes.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/encryptionScopes.ts index d2157321d555..aa03d6438a9b 100644 --- a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/encryptionScopes.ts +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/encryptionScopes.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { EncryptionScopes } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -16,13 +17,13 @@ import { EncryptionScope, EncryptionScopesListNextOptionalParams, EncryptionScopesListOptionalParams, + EncryptionScopesListResponse, EncryptionScopesPutOptionalParams, EncryptionScopesPutResponse, EncryptionScopesPatchOptionalParams, EncryptionScopesPatchResponse, EncryptionScopesGetOptionalParams, EncryptionScopesGetResponse, - EncryptionScopesListResponse, EncryptionScopesListNextResponse } from "../models"; @@ -61,8 +62,16 @@ export class EncryptionScopesImpl implements EncryptionScopes { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(resourceGroupName, accountName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage( + resourceGroupName, + accountName, + options, + settings + ); } }; } @@ -70,11 +79,18 @@ export class EncryptionScopesImpl implements EncryptionScopes { private async *listPagingPage( resourceGroupName: string, accountName: string, - options?: EncryptionScopesListOptionalParams + options?: EncryptionScopesListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(resourceGroupName, accountName, options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: EncryptionScopesListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(resourceGroupName, accountName, options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext( resourceGroupName, @@ -83,7 +99,9 @@ export class EncryptionScopesImpl implements EncryptionScopes { options ); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -343,7 +361,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.EncryptionScopeListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/objectReplicationPoliciesOperations.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/objectReplicationPoliciesOperations.ts index 143ba357a4fc..4871c670a12c 100644 --- a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/objectReplicationPoliciesOperations.ts +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/objectReplicationPoliciesOperations.ts @@ -6,7 +6,7 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; import { ObjectReplicationPoliciesOperations } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -59,8 +59,16 @@ export class ObjectReplicationPoliciesOperationsImpl [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(resourceGroupName, accountName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage( + resourceGroupName, + accountName, + options, + settings + ); } }; } @@ -68,9 +76,11 @@ export class ObjectReplicationPoliciesOperationsImpl private async *listPagingPage( resourceGroupName: string, accountName: string, - options?: ObjectReplicationPoliciesListOptionalParams + options?: ObjectReplicationPoliciesListOptionalParams, + _settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(resourceGroupName, accountName, options); + let result: ObjectReplicationPoliciesListResponse; + result = await this._list(resourceGroupName, accountName, options); yield result.value || []; } diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/operations.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/operations.ts index eabf0465c804..ef8c47c41dab 100644 --- a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/operations.ts +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/operations.ts @@ -6,7 +6,7 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; import { Operations } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -46,16 +46,21 @@ export class OperationsImpl implements Operations { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); } }; } private async *listPagingPage( - options?: OperationsListOptionalParams + options?: OperationsListOptionalParams, + _settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(options); + let result: OperationsListResponse; + result = await this._list(options); yield result.value || []; } diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/privateEndpointConnections.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/privateEndpointConnections.ts index 6a3e7b946143..0ec566cf65c6 100644 --- a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/privateEndpointConnections.ts +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/privateEndpointConnections.ts @@ -6,7 +6,7 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; import { PrivateEndpointConnections } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -59,8 +59,16 @@ export class PrivateEndpointConnectionsImpl [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(resourceGroupName, accountName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage( + resourceGroupName, + accountName, + options, + settings + ); } }; } @@ -68,9 +76,11 @@ export class PrivateEndpointConnectionsImpl private async *listPagingPage( resourceGroupName: string, accountName: string, - options?: PrivateEndpointConnectionsListOptionalParams + options?: PrivateEndpointConnectionsListOptionalParams, + _settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(resourceGroupName, accountName, options); + let result: PrivateEndpointConnectionsListResponse; + result = await this._list(resourceGroupName, accountName, options); yield result.value || []; } diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/skus.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/skus.ts index 5b7d5185aeec..35d62080c282 100644 --- a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/skus.ts +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/skus.ts @@ -6,7 +6,7 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; import { Skus } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -46,16 +46,21 @@ export class SkusImpl implements Skus { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); } }; } private async *listPagingPage( - options?: SkusListOptionalParams + options?: SkusListOptionalParams, + _settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(options); + let result: SkusListResponse; + result = await this._list(options); yield result.value || []; } diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/storageAccounts.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/storageAccounts.ts index 27e04bd5b6ae..697dd1e90d31 100644 --- a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/storageAccounts.ts +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/storageAccounts.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { StorageAccounts } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -18,7 +19,9 @@ import { StorageAccount, StorageAccountsListNextOptionalParams, StorageAccountsListOptionalParams, + StorageAccountsListResponse, StorageAccountsListByResourceGroupOptionalParams, + StorageAccountsListByResourceGroupResponse, StorageAccountCheckNameAvailabilityParameters, StorageAccountsCheckNameAvailabilityOptionalParams, StorageAccountsCheckNameAvailabilityResponse, @@ -31,8 +34,6 @@ import { StorageAccountUpdateParameters, StorageAccountsUpdateOptionalParams, StorageAccountsUpdateResponse, - StorageAccountsListResponse, - StorageAccountsListByResourceGroupResponse, StorageAccountsListKeysOptionalParams, StorageAccountsListKeysResponse, StorageAccountRegenerateKeyParameters, @@ -81,22 +82,34 @@ export class StorageAccountsImpl implements StorageAccounts { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); } }; } private async *listPagingPage( - options?: StorageAccountsListOptionalParams + options?: StorageAccountsListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: StorageAccountsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -127,17 +140,26 @@ export class StorageAccountsImpl implements StorageAccounts { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listByResourceGroupPagingPage(resourceGroupName, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listByResourceGroupPagingPage( + resourceGroupName, + options, + settings + ); } }; } private async *listByResourceGroupPagingPage( resourceGroupName: string, - options?: StorageAccountsListByResourceGroupOptionalParams + options?: StorageAccountsListByResourceGroupOptionalParams, + _settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listByResourceGroup(resourceGroupName, options); + let result: StorageAccountsListByResourceGroupResponse; + result = await this._listByResourceGroup(resourceGroupName, options); yield result.value || []; } @@ -238,10 +260,12 @@ export class StorageAccountsImpl implements StorageAccounts { { resourceGroupName, accountName, parameters, options }, createOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); + await poller.poll(); + return poller; } /** @@ -517,11 +541,13 @@ export class StorageAccountsImpl implements StorageAccounts { { resourceGroupName, accountName, options }, failoverOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, lroResourceLocationConfig: "location" }); + await poller.poll(); + return poller; } /** @@ -613,11 +639,13 @@ export class StorageAccountsImpl implements StorageAccounts { { resourceGroupName, accountName, parameters, options }, restoreBlobRangesOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, lroResourceLocationConfig: "location" }); + await poller.poll(); + return poller; } /** @@ -963,7 +991,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.StorageAccountListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/usages.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/usages.ts index dcfd7980abb0..d8ca359c45db 100644 --- a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/usages.ts +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/operations/usages.ts @@ -6,7 +6,7 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; import { Usages } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -48,17 +48,22 @@ export class UsagesImpl implements Usages { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listByLocationPagingPage(location, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listByLocationPagingPage(location, options, settings); } }; } private async *listByLocationPagingPage( location: string, - options?: UsagesListByLocationOptionalParams + options?: UsagesListByLocationOptionalParams, + _settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listByLocation(location, options); + let result: UsagesListByLocationResponse; + result = await this._listByLocation(location, options); yield result.value || []; } diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/pagingHelper.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/pagingHelper.ts new file mode 100644 index 000000000000..269a2b9814b5 --- /dev/null +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/pagingHelper.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export interface PageInfo { + continuationToken?: string; +} + +const pageMap = new WeakMap(); + +/** + * Given the last `.value` produced by the `byPage` iterator, + * returns a continuation token that can be used to begin paging from + * that point later. + * @param page An object from accessing `value` on the IteratorResult from a `byPage` iterator. + * @returns The continuation token that can be passed into byPage() during future calls. + */ +export function getContinuationToken(page: unknown): string | undefined { + if (typeof page !== "object" || page === null) { + return undefined; + } + return pageMap.get(page)?.continuationToken; +} + +export function setContinuationToken( + page: unknown, + continuationToken: string | undefined +): void { + if (typeof page !== "object" || page === null || !continuationToken) { + return; + } + const pageInfo = pageMap.get(page) ?? {}; + pageInfo.continuationToken = continuationToken; + pageMap.set(page, pageInfo); +} diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/storageManagementClient.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/storageManagementClient.ts index b0186a067a60..a869291db274 100644 --- a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/storageManagementClient.ts +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/src/storageManagementClient.ts @@ -7,6 +7,12 @@ */ import * as coreClient from "@azure/core-client"; +import * as coreRestPipeline from "@azure/core-rest-pipeline"; +import { + PipelineRequest, + PipelineResponse, + SendRequest +} from "@azure/core-rest-pipeline"; import * as coreAuth from "@azure/core-auth"; import { OperationsImpl, @@ -66,24 +72,54 @@ export class StorageManagementClient extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-storage-profile-2020-09-01-hybrid/2.0.1`; + const packageDetails = `azsdk-js-arm-storage-profile-2020-09-01-hybrid/2.1.0`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` : `${packageDetails}`; - if (!options.credentialScopes) { - options.credentialScopes = ["https://management.azure.com/.default"]; - } const optionsWithDefaults = { ...defaults, ...options, userAgentOptions: { userAgentPrefix }, - baseUri: options.endpoint || "https://management.azure.com" + endpoint: + options.endpoint ?? options.baseUri ?? "https://management.azure.com" }; super(optionsWithDefaults); + + let bearerTokenAuthenticationPolicyFound: boolean = false; + if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { + const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies(); + bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( + (pipelinePolicy) => + pipelinePolicy.name === + coreRestPipeline.bearerTokenAuthenticationPolicyName + ); + } + if ( + !options || + !options.pipeline || + options.pipeline.getOrderedPolicies().length == 0 || + !bearerTokenAuthenticationPolicyFound + ) { + this.pipeline.removePolicy({ + name: coreRestPipeline.bearerTokenAuthenticationPolicyName + }); + this.pipeline.addPolicy( + coreRestPipeline.bearerTokenAuthenticationPolicy({ + credential: credentials, + scopes: + optionsWithDefaults.credentialScopes ?? + `${optionsWithDefaults.endpoint}/.default`, + challengeCallbacks: { + authorizeRequestOnChallenge: + coreClient.authorizeRequestOnClaimChallenge + } + }) + ); + } // Parameter assignments this.subscriptionId = subscriptionId; @@ -102,6 +138,35 @@ export class StorageManagementClient extends coreClient.ServiceClient { this ); this.encryptionScopes = new EncryptionScopesImpl(this); + this.addCustomApiVersionPolicy(options.apiVersion); + } + + /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */ + private addCustomApiVersionPolicy(apiVersion?: string) { + if (!apiVersion) { + return; + } + const apiVersionPolicy = { + name: "CustomApiVersionPolicy", + async sendRequest( + request: PipelineRequest, + next: SendRequest + ): Promise { + const param = request.url.split("?"); + if (param.length > 1) { + const newParams = param[1].split("&").map((item) => { + if (item.indexOf("api-version") > -1) { + return "api-version=" + apiVersion; + } else { + return item; + } + }); + request.url = param[0] + "?" + newParams.join("&"); + } + return next(request); + } + }; + this.pipeline.addPolicy(apiVersionPolicy); } operations: Operations; diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/test/sampleTest.ts b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/test/sampleTest.ts index 7ed89b043e1b..25aeb3ebcc36 100644 --- a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/test/sampleTest.ts +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/test/sampleTest.ts @@ -7,35 +7,30 @@ */ import { - env, - record, - RecorderEnvironmentSetup, - Recorder + Recorder, + RecorderStartOptions, + env } from "@azure-tools/test-recorder"; -import * as assert from "assert"; +import { assert } from "chai"; +import { Context } from "mocha"; -const recorderEnvSetup: RecorderEnvironmentSetup = { - replaceableVariables: { - AZURE_CLIENT_ID: "azure_client_id", - AZURE_CLIENT_SECRET: "azure_client_secret", - AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", - SUBSCRIPTION_ID: "azure_subscription_id" - }, - customizationsOnRecordings: [ - (recording: any): any => - recording.replace( - /"access_token":"[^"]*"/g, - `"access_token":"access_token"` - ) - ], - queryParametersToSkip: [] +const replaceableVariables: Record = { + AZURE_CLIENT_ID: "azure_client_id", + AZURE_CLIENT_SECRET: "azure_client_secret", + AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", + SUBSCRIPTION_ID: "azure_subscription_id" +}; + +const recorderOptions: RecorderStartOptions = { + envSetupForPlayback: replaceableVariables }; describe("My test", () => { let recorder: Recorder; - beforeEach(async function() { - recorder = record(this, recorderEnvSetup); + beforeEach(async function(this: Context) { + recorder = new Recorder(this.currentTest); + await recorder.start(recorderOptions); }); afterEach(async function() { diff --git a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/tsconfig.json b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/tsconfig.json index 3e6ae96443f3..98359facc830 100644 --- a/sdk/storage/arm-storage-profile-2020-09-01-hybrid/tsconfig.json +++ b/sdk/storage/arm-storage-profile-2020-09-01-hybrid/tsconfig.json @@ -15,11 +15,17 @@ ], "declaration": true, "outDir": "./dist-esm", - "importHelpers": true + "importHelpers": true, + "paths": { + "@azure/arm-storage-profile-2020-09-01-hybrid": [ + "./src/index" + ] + } }, "include": [ "./src/**/*.ts", - "./test/**/*.ts" + "./test/**/*.ts", + "samples-dev/**/*.ts" ], "exclude": [ "node_modules" diff --git a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/CHANGELOG.md b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/CHANGELOG.md index b206be24b10d..cd9b0c9ea34e 100644 --- a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/CHANGELOG.md +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/CHANGELOG.md @@ -1,14 +1,14 @@ # Release History -## 2.0.1 (Unreleased) +## 2.1.0 (2022-12-22) -### Features Added +**Features** -### Breaking Changes +- Exposes `getContinuationToken` helper function to extract continuation token -### Bugs Fixed +**Bugs Fixed** -### Other Changes + - A series of small bug fixs relevant to authentication and apiVersion policy ## 2.0.0 (2022-03-09) diff --git a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/README.md b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/README.md index e7605dc7b14d..059970b8dbcd 100644 --- a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/README.md +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/README.md @@ -53,7 +53,8 @@ const { SubscriptionClient } = require("@azure/arm-subscriptions-profile-2020-09 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 client = new SubscriptionClient(new DefaultAzureCredential()); +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({ diff --git a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/_meta.json b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/_meta.json index 7955ae92a6c5..1e33d24149ce 100644 --- a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/_meta.json +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/_meta.json @@ -1,7 +1,8 @@ { "commit": "989a7d0e47a71a77d9a8e56f2a3eee0d366b6909", "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:\\mydev\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\resources\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-beta.16 --tag=package-subscriptions-2016-06 --profile-content=profile-hybrid-2020-09-01", + "autorest_command": "autorest --version=3.9.3 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=F:\\azure-sdk-for-js ..\\azure-rest-api-specs\\specification\\resources\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-rc.5.20221215.1 --generate-sample=true --profile-content=profile-hybrid-2020-09-01 --tag=package-subscriptions-2016-06", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "use": "@autorest/typescript@6.0.0-beta.16" + "release_tool": "@azure-tools/js-sdk-release-tools@2.5.4", + "use": "@autorest/typescript@6.0.0-rc.5.20221215.1" } \ No newline at end of file diff --git a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/package.json b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/package.json index a25de02b86a3..0a2e28946778 100644 --- a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/package.json +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/package.json @@ -3,15 +3,15 @@ "sdk-type": "mgmt", "author": "Microsoft Corporation", "description": "A generated SDK for SubscriptionClient.", - "version": "2.0.1", + "version": "2.1.0", "engines": { "node": ">=14.0.0" }, "dependencies": { "@azure/core-paging": "^1.2.0", - "@azure/core-client": "^1.0.0", + "@azure/core-client": "^1.6.1", "@azure/core-auth": "^1.3.0", - "@azure/core-rest-pipeline": "^1.1.0", + "@azure/core-rest-pipeline": "^1.8.0", "tslib": "^2.2.0" }, "keywords": [ @@ -34,15 +34,20 @@ "mkdirp": "^1.0.4", "rollup": "^2.66.1", "rollup-plugin-sourcemaps": "^0.6.3", - "typescript": "~4.2.0", + "typescript": "~4.8.0", "uglify-js": "^3.4.9", "rimraf": "^3.0.0", + "dotenv": "^8.2.0", "@azure/identity": "^2.0.1", - "@azure-tools/test-recorder": "^1.0.0", + "@azure-tools/test-recorder": "^2.0.0", + "@azure-tools/test-credential": "^1.0.0", "mocha": "^7.1.1", - "cross-env": "^7.0.2" + "@types/chai": "^4.2.8", + "chai": "^4.2.0", + "cross-env": "^7.0.2", + "@types/node": "^14.0.0", + "@azure/dev-tool": "^1.0.0" }, - "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid", "repository": { "type": "git", "url": "https://github.com/Azure/azure-sdk-for-js.git" @@ -91,9 +96,8 @@ "unit-test:node": "cross-env TEST_MODE=playback npm run integration-test:node", "unit-test:browser": "echo skipped", "integration-test": "npm run integration-test:node && npm run integration-test:browser", - "integration-test:node": "mocha -r esm --require ts-node/register --timeout 1200000 --full-trace test/*.ts --reporter ../../../common/tools/mocha-multi-reporter.js", - "integration-test:browser": "echo skipped", - "docs": "echo skipped" + "integration-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 'test/*.ts'", + "integration-test:browser": "echo skipped" }, "sideEffects": false, "//metadata": { @@ -104,5 +108,14 @@ } ] }, - "autoPublish": true + "autoPublish": true, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid", + "//sampleConfiguration": { + "productName": "", + "productSlugs": [ + "azure" + ], + "disableDocsMs": true, + "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-subscriptions-profile-2020-09-01-hybrid?view=azure-node-preview" + } } diff --git a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/recordings/node/my_test/recording_sample_test.json b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/recordings/node/my_test/recording_sample_test.json new file mode 100644 index 000000000000..f721723386d8 --- /dev/null +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/recordings/node/my_test/recording_sample_test.json @@ -0,0 +1,4 @@ +{ + "Entries": [], + "Variables": {} +} diff --git a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/review/arm-subscriptions-profile-2020-09-01-hybrid.api.md b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/review/arm-subscriptions-profile-2020-09-01-hybrid.api.md index 370cd6770bc4..f1e9f393799b 100644 --- a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/review/arm-subscriptions-profile-2020-09-01-hybrid.api.md +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/review/arm-subscriptions-profile-2020-09-01-hybrid.api.md @@ -73,11 +73,12 @@ export interface ErrorResponseAutoGenerated { error?: ErrorDefinition; } +// @public +export function getContinuationToken(page: unknown): string | undefined; + // @public export enum KnownResourceNameStatus { - // (undocumented) Allowed = "Allowed", - // (undocumented) Reserved = "Reserved" } diff --git a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/sample.env b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/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/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples-dev/checkResourceNameSample.ts b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples-dev/checkResourceNameSample.ts new file mode 100644 index 000000000000..8f2dae1f7a21 --- /dev/null +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples-dev/checkResourceNameSample.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 { SubscriptionClient } from "@azure/arm-subscriptions-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2016-06-01/examples/CheckResourceName.json + */ +async function checkValidityForAResourceName() { + const credential = new DefaultAzureCredential(); + const client = new SubscriptionClient(credential); + const result = await client.checkResourceName(); + console.log(result); +} + +async function main() { + checkValidityForAResourceName(); +} + +main().catch(console.error); diff --git a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples-dev/subscriptionsCheckZonePeersSample.ts b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples-dev/subscriptionsCheckZonePeersSample.ts new file mode 100644 index 000000000000..49510dbc7627 --- /dev/null +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples-dev/subscriptionsCheckZonePeersSample.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 { + CheckZonePeersRequest, + SubscriptionClient +} from "@azure/arm-subscriptions-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Compares a subscriptions logical zone mapping + * + * @summary Compares a subscriptions logical zone mapping + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2016-06-01/examples/PostCheckZonePeers.json + */ +async function getLogicalZoneMapping() { + const subscriptionId = "00000000-0000-0000-0000-00000000000000"; + const parameters: CheckZonePeersRequest = { + location: "eastus", + subscriptionIds: ["subscriptions/11111111-1111-1111-1111-111111111111"] + }; + const credential = new DefaultAzureCredential(); + const client = new SubscriptionClient(credential); + const result = await client.subscriptions.checkZonePeers( + subscriptionId, + parameters + ); + console.log(result); +} + +async function main() { + getLogicalZoneMapping(); +} + +main().catch(console.error); diff --git a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/javascript/README.md b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/javascript/README.md new file mode 100644 index 000000000000..d83b0cab6859 --- /dev/null +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/javascript/README.md @@ -0,0 +1,52 @@ +# 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/2016-06-01/examples/CheckResourceName.json | +| [subscriptionsCheckZonePeersSample.js][subscriptionscheckzonepeerssample] | Compares a subscriptions logical zone mapping x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2016-06-01/examples/PostCheckZonePeers.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). + +You need [an Azure subscription][freesub] to run these sample programs. + +Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. + +Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. + +## Setup + +To run the samples using the published version of the package: + +1. Install the dependencies using `npm`: + +```bash +npm install +``` + +2. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. + +3. Run whichever samples you like (note that some samples may require additional setup, see the table above): + +```bash +node 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/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/javascript/checkResourceNameSample.js +[subscriptionscheckzonepeerssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/javascript/subscriptionsCheckZonePeersSample.js +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-subscriptions-profile-2020-09-01-hybrid?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/README.md diff --git a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/javascript/checkResourceNameSample.js b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/javascript/checkResourceNameSample.js new file mode 100644 index 000000000000..66e2daad3560 --- /dev/null +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/javascript/checkResourceNameSample.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 { SubscriptionClient } = require("@azure/arm-subscriptions-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * 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/2016-06-01/examples/CheckResourceName.json + */ +async function checkValidityForAResourceName() { + const credential = new DefaultAzureCredential(); + const client = new SubscriptionClient(credential); + const result = await client.checkResourceName(); + console.log(result); +} + +async function main() { + checkValidityForAResourceName(); +} + +main().catch(console.error); diff --git a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/javascript/package.json b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/javascript/package.json new file mode 100644 index 000000000000..ae7d664fef0c --- /dev/null +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/javascript/package.json @@ -0,0 +1,32 @@ +{ + "name": "@azure-samples/arm-subscriptions-profile-2020-09-01-hybrid-js", + "private": true, + "version": "1.0.0", + "description": " client library samples for JavaScript", + "engines": { + "node": ">=14.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid" + }, + "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/subscription/arm-subscriptions-profile-2020-09-01-hybrid", + "dependencies": { + "@azure/arm-subscriptions-profile-2020-09-01-hybrid": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + } +} diff --git a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/javascript/sample.env b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/javascript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/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/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/javascript/subscriptionsCheckZonePeersSample.js b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/javascript/subscriptionsCheckZonePeersSample.js new file mode 100644 index 000000000000..6d5fd1899c21 --- /dev/null +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/javascript/subscriptionsCheckZonePeersSample.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 { SubscriptionClient } = require("@azure/arm-subscriptions-profile-2020-09-01-hybrid"); +const { DefaultAzureCredential } = require("@azure/identity"); +require("dotenv").config(); + +/** + * This sample demonstrates how to Compares a subscriptions logical zone mapping + * + * @summary Compares a subscriptions logical zone mapping + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2016-06-01/examples/PostCheckZonePeers.json + */ +async function getLogicalZoneMapping() { + const subscriptionId = "00000000-0000-0000-0000-00000000000000"; + const parameters = { + location: "eastus", + subscriptionIds: ["subscriptions/11111111-1111-1111-1111-111111111111"], + }; + const credential = new DefaultAzureCredential(); + const client = new SubscriptionClient(credential); + const result = await client.subscriptions.checkZonePeers(subscriptionId, parameters); + console.log(result); +} + +async function main() { + getLogicalZoneMapping(); +} + +main().catch(console.error); diff --git a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/typescript/README.md b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/typescript/README.md new file mode 100644 index 000000000000..ac188a0fa5fd --- /dev/null +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/typescript/README.md @@ -0,0 +1,65 @@ +# 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/2016-06-01/examples/CheckResourceName.json | +| [subscriptionsCheckZonePeersSample.ts][subscriptionscheckzonepeerssample] | Compares a subscriptions logical zone mapping x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2016-06-01/examples/PostCheckZonePeers.json | + +## Prerequisites + +The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). + +Before running the samples in Node, they must be compiled to JavaScript using the TypeScript compiler. For more information on TypeScript, see the [TypeScript documentation][typescript]. Install the TypeScript compiler using: + +```bash +npm install -g typescript +``` + +You need [an Azure subscription][freesub] to run these sample programs. + +Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. + +Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. + +## Setup + +To run the samples using the published version of the package: + +1. Install the dependencies using `npm`: + +```bash +npm install +``` + +2. Compile the samples: + +```bash +npm run build +``` + +3. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. + +4. Run whichever samples you like (note that some samples may require additional setup, see the table above): + +```bash +node dist/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/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/typescript/src/checkResourceNameSample.ts +[subscriptionscheckzonepeerssample]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/typescript/src/subscriptionsCheckZonePeersSample.ts +[apiref]: https://docs.microsoft.com/javascript/api/@azure/arm-subscriptions-profile-2020-09-01-hybrid?view=azure-node-preview +[freesub]: https://azure.microsoft.com/free/ +[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/README.md +[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/typescript/package.json b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/typescript/package.json new file mode 100644 index 000000000000..3d71f88d224c --- /dev/null +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/typescript/package.json @@ -0,0 +1,41 @@ +{ + "name": "@azure-samples/arm-subscriptions-profile-2020-09-01-hybrid-ts", + "private": true, + "version": "1.0.0", + "description": " client library samples for TypeScript", + "engines": { + "node": ">=14.0.0" + }, + "scripts": { + "build": "tsc", + "prebuild": "rimraf dist/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid" + }, + "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/subscription/arm-subscriptions-profile-2020-09-01-hybrid", + "dependencies": { + "@azure/arm-subscriptions-profile-2020-09-01-hybrid": "latest", + "dotenv": "latest", + "@azure/identity": "^2.0.1" + }, + "devDependencies": { + "@types/node": "^14.0.0", + "typescript": "~4.8.0", + "rimraf": "latest" + } +} diff --git a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/typescript/sample.env b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/typescript/sample.env new file mode 100644 index 000000000000..672847a3fea0 --- /dev/null +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/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/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/typescript/src/checkResourceNameSample.ts b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/typescript/src/checkResourceNameSample.ts new file mode 100644 index 000000000000..8f2dae1f7a21 --- /dev/null +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/typescript/src/checkResourceNameSample.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 { SubscriptionClient } from "@azure/arm-subscriptions-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * 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/2016-06-01/examples/CheckResourceName.json + */ +async function checkValidityForAResourceName() { + const credential = new DefaultAzureCredential(); + const client = new SubscriptionClient(credential); + const result = await client.checkResourceName(); + console.log(result); +} + +async function main() { + checkValidityForAResourceName(); +} + +main().catch(console.error); diff --git a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/typescript/src/subscriptionsCheckZonePeersSample.ts b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/typescript/src/subscriptionsCheckZonePeersSample.ts new file mode 100644 index 000000000000..49510dbc7627 --- /dev/null +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/typescript/src/subscriptionsCheckZonePeersSample.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 { + CheckZonePeersRequest, + SubscriptionClient +} from "@azure/arm-subscriptions-profile-2020-09-01-hybrid"; +import { DefaultAzureCredential } from "@azure/identity"; +import * as dotenv from "dotenv"; + +dotenv.config(); + +/** + * This sample demonstrates how to Compares a subscriptions logical zone mapping + * + * @summary Compares a subscriptions logical zone mapping + * x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2016-06-01/examples/PostCheckZonePeers.json + */ +async function getLogicalZoneMapping() { + const subscriptionId = "00000000-0000-0000-0000-00000000000000"; + const parameters: CheckZonePeersRequest = { + location: "eastus", + subscriptionIds: ["subscriptions/11111111-1111-1111-1111-111111111111"] + }; + const credential = new DefaultAzureCredential(); + const client = new SubscriptionClient(credential); + const result = await client.subscriptions.checkZonePeers( + subscriptionId, + parameters + ); + console.log(result); +} + +async function main() { + getLogicalZoneMapping(); +} + +main().catch(console.error); diff --git a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/typescript/tsconfig.json b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/typescript/tsconfig.json new file mode 100644 index 000000000000..e26ce2a6d8f7 --- /dev/null +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/samples/v2/typescript/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "commonjs", + "moduleResolution": "node", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "alwaysStrict": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": [ + "src/**.ts" + ] +} diff --git a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/src/index.ts b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/src/index.ts index e21d9f74104f..1947e4feb076 100644 --- a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/src/index.ts +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/src/index.ts @@ -7,6 +7,7 @@ */ /// +export { getContinuationToken } from "./pagingHelper"; export * from "./models"; export { SubscriptionClient } from "./subscriptionClient"; export * from "./operationsInterfaces"; diff --git a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/src/models/index.ts b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/src/models/index.ts index 781774dea146..fe301392b731 100644 --- a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/src/models/index.ts +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/src/models/index.ts @@ -282,7 +282,9 @@ export interface ErrorDefinition { /** Known values of {@link ResourceNameStatus} that the service accepts. */ export enum KnownResourceNameStatus { + /** Allowed */ Allowed = "Allowed", + /** Reserved */ Reserved = "Reserved" } diff --git a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/src/operations/operations.ts b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/src/operations/operations.ts index c3d9219e2420..332d74658805 100644 --- a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/src/operations/operations.ts +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/src/operations/operations.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { Operations } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -48,22 +49,34 @@ export class OperationsImpl implements Operations { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); } }; } private async *listPagingPage( - options?: OperationsListOptionalParams + options?: OperationsListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: OperationsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -124,7 +137,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.OperationListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.$host, Parameters.nextLink], headerParameters: [Parameters.accept], serializer diff --git a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/src/operations/subscriptions.ts b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/src/operations/subscriptions.ts index 4878b1e40cfd..2f8b6fccba5c 100644 --- a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/src/operations/subscriptions.ts +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/src/operations/subscriptions.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { Subscriptions } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -15,13 +16,13 @@ import { SubscriptionClient } from "../subscriptionClient"; import { Location, SubscriptionsListLocationsOptionalParams, + SubscriptionsListLocationsResponse, Subscription, SubscriptionsListNextOptionalParams, SubscriptionsListOptionalParams, - SubscriptionsListLocationsResponse, + SubscriptionsListResponse, SubscriptionsGetOptionalParams, SubscriptionsGetResponse, - SubscriptionsListResponse, CheckZonePeersRequest, SubscriptionsCheckZonePeersOptionalParams, SubscriptionsCheckZonePeersResponse, @@ -59,17 +60,22 @@ export class SubscriptionsImpl implements Subscriptions { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listLocationsPagingPage(subscriptionId, options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listLocationsPagingPage(subscriptionId, options, settings); } }; } private async *listLocationsPagingPage( subscriptionId: string, - options?: SubscriptionsListLocationsOptionalParams + options?: SubscriptionsListLocationsOptionalParams, + _settings?: PageSettings ): AsyncIterableIterator { - let result = await this._listLocations(subscriptionId, options); + let result: SubscriptionsListLocationsResponse; + result = await this._listLocations(subscriptionId, options); yield result.value || []; } @@ -100,22 +106,34 @@ export class SubscriptionsImpl implements Subscriptions { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); } }; } private async *listPagingPage( - options?: SubscriptionsListOptionalParams + options?: SubscriptionsListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: SubscriptionsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -269,7 +287,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.SubscriptionListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.$host, Parameters.nextLink], headerParameters: [Parameters.accept], serializer diff --git a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/src/operations/tenants.ts b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/src/operations/tenants.ts index 2c55e1cd3aac..58a0293f575d 100644 --- a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/src/operations/tenants.ts +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/src/operations/tenants.ts @@ -6,7 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; import { Tenants } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; @@ -48,22 +49,34 @@ export class TenantsImpl implements Tenants { [Symbol.asyncIterator]() { return this; }, - byPage: () => { - return this.listPagingPage(options); + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); } }; } private async *listPagingPage( - options?: TenantsListOptionalParams + options?: TenantsListOptionalParams, + settings?: PageSettings ): AsyncIterableIterator { - let result = await this._list(options); - yield result.value || []; - let continuationToken = result.nextLink; + let result: TenantsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } while (continuationToken) { result = await this._listNext(continuationToken, options); continuationToken = result.nextLink; - yield result.value || []; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; } } @@ -124,7 +137,6 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.TenantListResult } }, - queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.$host, Parameters.nextLink], headerParameters: [Parameters.accept], serializer diff --git a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/src/pagingHelper.ts b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/src/pagingHelper.ts new file mode 100644 index 000000000000..269a2b9814b5 --- /dev/null +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/src/pagingHelper.ts @@ -0,0 +1,39 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +export interface PageInfo { + continuationToken?: string; +} + +const pageMap = new WeakMap(); + +/** + * Given the last `.value` produced by the `byPage` iterator, + * returns a continuation token that can be used to begin paging from + * that point later. + * @param page An object from accessing `value` on the IteratorResult from a `byPage` iterator. + * @returns The continuation token that can be passed into byPage() during future calls. + */ +export function getContinuationToken(page: unknown): string | undefined { + if (typeof page !== "object" || page === null) { + return undefined; + } + return pageMap.get(page)?.continuationToken; +} + +export function setContinuationToken( + page: unknown, + continuationToken: string | undefined +): void { + if (typeof page !== "object" || page === null || !continuationToken) { + return; + } + const pageInfo = pageMap.get(page) ?? {}; + pageInfo.continuationToken = continuationToken; + pageMap.set(page, pageInfo); +} diff --git a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/src/subscriptionClient.ts b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/src/subscriptionClient.ts index 6eb705740603..6283ba881d83 100644 --- a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/src/subscriptionClient.ts +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/src/subscriptionClient.ts @@ -7,6 +7,12 @@ */ import * as coreClient from "@azure/core-client"; +import * as coreRestPipeline from "@azure/core-rest-pipeline"; +import { + PipelineRequest, + PipelineResponse, + SendRequest +} from "@azure/core-rest-pipeline"; import * as coreAuth from "@azure/core-auth"; import { OperationsImpl, SubscriptionsImpl, TenantsImpl } from "./operations"; import { Operations, Subscriptions, Tenants } from "./operationsInterfaces"; @@ -44,31 +50,90 @@ export class SubscriptionClient extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-subscriptions-profile-2020-09-01-hybrid/2.0.1`; + const packageDetails = `azsdk-js-arm-subscriptions-profile-2020-09-01-hybrid/2.1.0`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` : `${packageDetails}`; - if (!options.credentialScopes) { - options.credentialScopes = ["https://management.azure.com/.default"]; - } const optionsWithDefaults = { ...defaults, ...options, userAgentOptions: { userAgentPrefix }, - baseUri: options.endpoint || "https://management.azure.com" + endpoint: + options.endpoint ?? options.baseUri ?? "https://management.azure.com" }; super(optionsWithDefaults); + let bearerTokenAuthenticationPolicyFound: boolean = false; + if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { + const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies(); + bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( + (pipelinePolicy) => + pipelinePolicy.name === + coreRestPipeline.bearerTokenAuthenticationPolicyName + ); + } + if ( + !options || + !options.pipeline || + options.pipeline.getOrderedPolicies().length == 0 || + !bearerTokenAuthenticationPolicyFound + ) { + this.pipeline.removePolicy({ + name: coreRestPipeline.bearerTokenAuthenticationPolicyName + }); + this.pipeline.addPolicy( + coreRestPipeline.bearerTokenAuthenticationPolicy({ + credential: credentials, + scopes: + optionsWithDefaults.credentialScopes ?? + `${optionsWithDefaults.endpoint}/.default`, + challengeCallbacks: { + authorizeRequestOnChallenge: + coreClient.authorizeRequestOnClaimChallenge + } + }) + ); + } + // Assigning values to Constant parameters this.$host = options.$host || "https://management.azure.com"; this.apiVersion = options.apiVersion || "2016-06-01"; this.operations = new OperationsImpl(this); this.subscriptions = new SubscriptionsImpl(this); this.tenants = new TenantsImpl(this); + this.addCustomApiVersionPolicy(options.apiVersion); + } + + /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */ + private addCustomApiVersionPolicy(apiVersion?: string) { + if (!apiVersion) { + return; + } + const apiVersionPolicy = { + name: "CustomApiVersionPolicy", + async sendRequest( + request: PipelineRequest, + next: SendRequest + ): Promise { + const param = request.url.split("?"); + if (param.length > 1) { + const newParams = param[1].split("&").map((item) => { + if (item.indexOf("api-version") > -1) { + return "api-version=" + apiVersion; + } else { + return item; + } + }); + request.url = param[0] + "?" + newParams.join("&"); + } + return next(request); + } + }; + this.pipeline.addPolicy(apiVersionPolicy); } /** diff --git a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/test/sampleTest.ts b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/test/sampleTest.ts index 7ed89b043e1b..25aeb3ebcc36 100644 --- a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/test/sampleTest.ts +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/test/sampleTest.ts @@ -7,35 +7,30 @@ */ import { - env, - record, - RecorderEnvironmentSetup, - Recorder + Recorder, + RecorderStartOptions, + env } from "@azure-tools/test-recorder"; -import * as assert from "assert"; +import { assert } from "chai"; +import { Context } from "mocha"; -const recorderEnvSetup: RecorderEnvironmentSetup = { - replaceableVariables: { - AZURE_CLIENT_ID: "azure_client_id", - AZURE_CLIENT_SECRET: "azure_client_secret", - AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", - SUBSCRIPTION_ID: "azure_subscription_id" - }, - customizationsOnRecordings: [ - (recording: any): any => - recording.replace( - /"access_token":"[^"]*"/g, - `"access_token":"access_token"` - ) - ], - queryParametersToSkip: [] +const replaceableVariables: Record = { + AZURE_CLIENT_ID: "azure_client_id", + AZURE_CLIENT_SECRET: "azure_client_secret", + AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", + SUBSCRIPTION_ID: "azure_subscription_id" +}; + +const recorderOptions: RecorderStartOptions = { + envSetupForPlayback: replaceableVariables }; describe("My test", () => { let recorder: Recorder; - beforeEach(async function() { - recorder = record(this, recorderEnvSetup); + beforeEach(async function(this: Context) { + recorder = new Recorder(this.currentTest); + await recorder.start(recorderOptions); }); afterEach(async function() { diff --git a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/tsconfig.json b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/tsconfig.json index 3e6ae96443f3..c97597dcd0ec 100644 --- a/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/tsconfig.json +++ b/sdk/subscription/arm-subscriptions-profile-2020-09-01-hybrid/tsconfig.json @@ -15,11 +15,17 @@ ], "declaration": true, "outDir": "./dist-esm", - "importHelpers": true + "importHelpers": true, + "paths": { + "@azure/arm-subscriptions-profile-2020-09-01-hybrid": [ + "./src/index" + ] + } }, "include": [ "./src/**/*.ts", - "./test/**/*.ts" + "./test/**/*.ts", + "samples-dev/**/*.ts" ], "exclude": [ "node_modules"