diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 32ea130587bf..c3163f2e7c00 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -3855,7 +3855,7 @@ packages: dependencies: semver: 7.3.7 shelljs: 0.8.5 - typescript: 4.8.0-dev.20220713 + typescript: 4.8.0-dev.20220714 dev: false /downlevel-dts/0.4.0: @@ -8665,8 +8665,8 @@ packages: hasBin: true dev: false - /typescript/4.8.0-dev.20220713: - resolution: {integrity: sha512-bgvBy+eVzJfxLvylV2rp4wK8+UO38/LJXjKZ95F0pOQZU/9BfGEaXmTk0Ar2gsTmq7ewzZ6iTeIbQuumR4jZLA==} + /typescript/4.8.0-dev.20220714: + resolution: {integrity: sha512-wKK9FMpdvwI68PZiQdNTNmX4rpVXJBDOG9aylV9O6nJUO5YX8yv3bQNcyLc5tbI7J3+u7AU48LVY9SF9lYwy5g==} engines: {node: '>=4.2.0'} hasBin: true dev: false @@ -11330,7 +11330,7 @@ packages: dev: false file:projects/arm-extendedlocation.tgz: - resolution: {integrity: sha512-qh8KGDnbqoUV6UbWCbFhWA3nCJ0WIhdO4VjeozivtHaTzV9lYUjn5gRIomUnuD/yIJXyKds2jCqOTAXMPxQiRQ==, tarball: file:projects/arm-extendedlocation.tgz} + resolution: {integrity: sha512-8tTdmurcnnlFetKjKW3KCjwGcoeOraE/ak8Vri/4RAl+fdusg+f4BsgzH7PxumTTQtLdYFuf+xjj5KLq6JuTEQ==, tarball: file:projects/arm-extendedlocation.tgz} name: '@rush-temp/arm-extendedlocation' version: 0.0.0 dependencies: @@ -11339,19 +11339,19 @@ packages: '@microsoft/api-extractor': 7.18.11 '@rollup/plugin-commonjs': 21.1.0_rollup@2.76.0 '@rollup/plugin-json': 4.1.0_rollup@2.76.0 - '@rollup/plugin-multi-entry': 3.0.1_rollup@2.76.0 - '@rollup/plugin-node-resolve': 8.4.0_rollup@2.76.0 + '@rollup/plugin-multi-entry': 4.1.0_rollup@2.76.0 + '@rollup/plugin-node-resolve': 13.3.0_rollup@2.76.0 cross-env: 7.0.3 mkdirp: 1.0.4 mocha: 7.2.0 + rimraf: 3.0.2 rollup: 2.76.0 - rollup-plugin-sourcemaps: 0.4.2_rollup@2.76.0 + rollup-plugin-sourcemaps: 0.6.3_rollup@2.76.0 tslib: 2.4.0 typescript: 4.2.4 uglify-js: 3.16.2 transitivePeerDependencies: - - encoding - - supports-color + - '@types/node' dev: false file:projects/arm-features.tgz: diff --git a/sdk/extendedlocation/arm-extendedlocation/CHANGELOG.md b/sdk/extendedlocation/arm-extendedlocation/CHANGELOG.md index 5c48ad8e64aa..511ca546ab18 100644 --- a/sdk/extendedlocation/arm-extendedlocation/CHANGELOG.md +++ b/sdk/extendedlocation/arm-extendedlocation/CHANGELOG.md @@ -1,15 +1,40 @@ -## Release History +# Release History + +## 1.0.0-beta.2 (2022-07-14) + +**Features** -### 1.0.0-beta.2 (Unreleased) + - Added operation group ResourceSyncRules + - Added operation CustomLocations.findTargetResourceGroup + - Added Interface CustomLocationFindTargetResourceGroupProperties + - Added Interface CustomLocationFindTargetResourceGroupResult + - Added Interface CustomLocationsFindTargetResourceGroupOptionalParams + - Added Interface MatchExpressionsProperties + - Added Interface PatchableResourceSyncRule + - Added Interface ResourceSyncRuleListResult + - Added Interface ResourceSyncRulePropertiesSelector + - Added Interface ResourceSyncRulesCreateOrUpdateOptionalParams + - Added Interface ResourceSyncRulesDeleteOptionalParams + - Added Interface ResourceSyncRulesGetOptionalParams + - Added Interface ResourceSyncRulesListByCustomLocationIDNextOptionalParams + - Added Interface ResourceSyncRulesListByCustomLocationIDOptionalParams + - Added Interface ResourceSyncRulesUpdateOptionalParams + - Added Type Alias CustomLocationsFindTargetResourceGroupResponse + - Added Type Alias ResourceSyncRule + - Added Type Alias ResourceSyncRulesCreateOrUpdateResponse + - Added Type Alias ResourceSyncRulesGetResponse + - Added Type Alias ResourceSyncRulesListByCustomLocationIDNextResponse + - Added Type Alias ResourceSyncRulesListByCustomLocationIDResponse + - Added Type Alias ResourceSyncRulesUpdateResponse + - Class CustomLocationsManagementClient has a new parameter $host + - Class CustomLocationsManagementClient has a new parameter apiVersion + - Class CustomLocationsManagementClient has a new parameter resourceSyncRules + - Class CustomLocationsManagementClient has a new parameter subscriptionId -#### Features Added +**Breaking Changes** -#### Breaking Changes - -#### Bugs Fixed - -#### Other Changes - -### 1.0.0-beta.1 (2021-10-08) + - Deleted Class CustomLocationsManagementClientContext + +## 1.0.0-beta.1 (2021-10-08) - Initial Release diff --git a/sdk/extendedlocation/arm-extendedlocation/LICENSE b/sdk/extendedlocation/arm-extendedlocation/LICENSE index ccb63b166732..5d1d36e0af80 100644 --- a/sdk/extendedlocation/arm-extendedlocation/LICENSE +++ b/sdk/extendedlocation/arm-extendedlocation/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2021 Microsoft +Copyright (c) 2022 Microsoft Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/sdk/extendedlocation/arm-extendedlocation/README.md b/sdk/extendedlocation/arm-extendedlocation/README.md index d456bf3db43b..3255bcc18fd3 100644 --- a/sdk/extendedlocation/arm-extendedlocation/README.md +++ b/sdk/extendedlocation/arm-extendedlocation/README.md @@ -1,12 +1,12 @@ -# Azure customLocationsManagement client library for JavaScript +# Azure CustomLocationsManagement client library for JavaScript -This package contains an isomorphic SDK (runs both in Node.js and in browsers) for Azure customLocationsManagement client. +This package contains an isomorphic SDK (runs both in Node.js and in browsers) for Azure CustomLocationsManagement client. The customLocations Rest API spec. [Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/extendedlocation/arm-extendedlocation) | [Package (NPM)](https://www.npmjs.com/package/@azure/arm-extendedlocation) | -[API reference documentation](https://docs.microsoft.com/javascript/api/@azure/arm-extendedlocation) | +[API reference documentation](https://docs.microsoft.com/javascript/api/@azure/arm-extendedlocation?view=azure-node-preview) | [Samples](https://github.com/Azure-Samples/azure-samples-js-management) ## Getting started @@ -16,13 +16,15 @@ The customLocations Rest API spec. - [LTS versions of Node.js](https://nodejs.org/about/releases/) - Latest versions of Safari, Chrome, Edge and Firefox. +See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details. + ### Prerequisites - An [Azure subscription][azure_sub]. ### Install the `@azure/arm-extendedlocation` package -Install the Azure customLocationsManagement client library for JavaScript with `npm`: +Install the Azure CustomLocationsManagement client library for JavaScript with `npm`: ```bash npm install @azure/arm-extendedlocation @@ -30,8 +32,8 @@ npm install @azure/arm-extendedlocation ### Create and authenticate a `CustomLocationsManagementClient` -To create a client object to access the Azure customLocationsManagement API, you will need the `endpoint` of your Azure customLocationsManagement resource and a `credential`. The Azure customLocationsManagement client can use Azure Active Directory credentials to authenticate. -You can find the endpoint for your Azure customLocationsManagement resource in the [Azure Portal][azure_portal]. +To create a client object to access the Azure CustomLocationsManagement API, you will need the `endpoint` of your Azure CustomLocationsManagement resource and a `credential`. The Azure CustomLocationsManagement client can use Azure Active Directory credentials to authenticate. +You can find the endpoint for your Azure CustomLocationsManagement resource in the [Azure Portal][azure_portal]. You can authenticate with Azure Active Directory using a credential from the [@azure/identity][azure_identity] library or [an existing AAD Token](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token). @@ -41,7 +43,7 @@ To use the [DefaultAzureCredential][defaultazurecredential] provider shown below npm install @azure/identity ``` -You will also need to **register a new AAD application and grant access to Azure customLocationsManagement** by assigning the suitable role to your service principal (note: roles such as `"Owner"` will not grant the necessary permissions). +You will also need to **register a new AAD application and grant access to Azure CustomLocationsManagement** by assigning the suitable role to your service principal (note: roles such as `"Owner"` will not grant the necessary permissions). Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`. For more information about how to create an Azure AD Application check out [this guide](https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal). @@ -49,15 +51,28 @@ For more information about how to create an Azure AD Application check out [this ```javascript const { CustomLocationsManagementClient } = require("@azure/arm-extendedlocation"); const { DefaultAzureCredential } = require("@azure/identity"); +// For client-side applications running in the browser, use InteractiveBrowserCredential instead of DefaultAzureCredential. See https://aka.ms/azsdk/js/identity/examples for more details. + const subscriptionId = "00000000-0000-0000-0000-000000000000"; const client = new CustomLocationsManagementClient(new DefaultAzureCredential(), subscriptionId); + +// For client-side applications running in the browser, use this code instead: +// const credential = new InteractiveBrowserCredential({ +// tenantId: "", +// clientId: "" +// }); +// const client = new CustomLocationsManagementClient(credential, subscriptionId); ``` + +### JavaScript Bundle +To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling). + ## Key concepts ### CustomLocationsManagementClient -`CustomLocationsManagementClient` is the primary interface for developers using the Azure customLocationsManagement client library. Explore the methods on this client object to understand the different features of the Azure customLocationsManagement service that you can access. +`CustomLocationsManagementClient` is the primary interface for developers using the Azure CustomLocationsManagement client library. Explore the methods on this client object to understand the different features of the Azure CustomLocationsManagement service that you can access. ## Troubleshooting diff --git a/sdk/extendedlocation/arm-extendedlocation/_meta.json b/sdk/extendedlocation/arm-extendedlocation/_meta.json index 02b0295fadcf..5bcf05264e0f 100644 --- a/sdk/extendedlocation/arm-extendedlocation/_meta.json +++ b/sdk/extendedlocation/arm-extendedlocation/_meta.json @@ -1,7 +1,8 @@ { - "commit": "5cf3e4a0c30ad5167088ac839453578b2e8e9afc", + "commit": "08988617d900ebbe962a49b3bec764d57ee81305", "readme": "specification/extendedlocation/resource-manager/readme.md", - "autorest_command": "autorest --version=3.1.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=D:\\mydev\\azure-sdk-for-js ../azure-rest-api-specs/specification/extendedlocation/resource-manager/readme.md --use=@autorest/typescript@6.0.0-beta.13", + "autorest_command": "autorest --version=3.7.3 --typescript --modelerfour.lenient-model-deduplication --azure-arm --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-js ../azure-rest-api-specs/specification/extendedlocation/resource-manager/readme.md --use=@autorest/typescript@6.0.0-alpha.19.20220425.1", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "use": "@autorest/typescript@6.0.0-beta.13" + "release_tool": "@azure-tools/js-sdk-release-tools@2.4.0", + "use": "@autorest/typescript@6.0.0-alpha.19.20220425.1" } \ No newline at end of file diff --git a/sdk/extendedlocation/arm-extendedlocation/api-extractor.json b/sdk/extendedlocation/arm-extendedlocation/api-extractor.json index 8cc49dab445d..b8c5959ce3b5 100644 --- a/sdk/extendedlocation/arm-extendedlocation/api-extractor.json +++ b/sdk/extendedlocation/arm-extendedlocation/api-extractor.json @@ -1,18 +1,31 @@ { "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", "mainEntryPointFilePath": "./dist-esm/src/index.d.ts", - "docModel": { "enabled": true }, - "apiReport": { "enabled": true, "reportFolder": "./review" }, + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, "dtsRollup": { "enabled": true, "untrimmedFilePath": "", "publicTrimmedFilePath": "./types/arm-extendedlocation.d.ts" }, "messages": { - "tsdocMessageReporting": { "default": { "logLevel": "none" } }, + "tsdocMessageReporting": { + "default": { + "logLevel": "none" + } + }, "extractorMessageReporting": { - "ae-missing-release-tag": { "logLevel": "none" }, - "ae-unresolved-link": { "logLevel": "none" } + "ae-missing-release-tag": { + "logLevel": "none" + }, + "ae-unresolved-link": { + "logLevel": "none" + } } } -} +} \ No newline at end of file diff --git a/sdk/extendedlocation/arm-extendedlocation/package.json b/sdk/extendedlocation/arm-extendedlocation/package.json index fe60b068f313..456735c8ee5f 100644 --- a/sdk/extendedlocation/arm-extendedlocation/package.json +++ b/sdk/extendedlocation/arm-extendedlocation/package.json @@ -10,10 +10,10 @@ "dependencies": { "@azure/core-lro": "^2.2.0", "@azure/abort-controller": "^1.0.0", - "@azure/core-paging": "^1.1.1", - "@azure/core-client": "^1.0.0", + "@azure/core-paging": "^1.2.0", + "@azure/core-client": "^1.5.0", "@azure/core-auth": "^1.3.0", - "@azure/core-rest-pipeline": "^1.1.0", + "@azure/core-rest-pipeline": "^1.8.0", "tslib": "^2.2.0" }, "keywords": [ @@ -30,18 +30,21 @@ "devDependencies": { "@microsoft/api-extractor": "7.18.11", "@rollup/plugin-commonjs": "^21.0.1", - "@rollup/plugin-json": "^4.0.0", - "@rollup/plugin-multi-entry": "^3.0.0", - "@rollup/plugin-node-resolve": "^8.0.0", + "@rollup/plugin-json": "^4.1.0", + "@rollup/plugin-multi-entry": "^4.1.0", + "@rollup/plugin-node-resolve": "^13.1.3", "mkdirp": "^1.0.4", - "rollup": "^2.0.0", - "rollup-plugin-sourcemaps": "^0.4.2", + "rollup": "^2.66.1", + "rollup-plugin-sourcemaps": "^0.6.3", "typescript": "~4.2.0", "uglify-js": "^3.4.9", + "rimraf": "^3.0.0", "@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" + "cross-env": "^7.0.2", + "@azure/dev-tool": "^1.0.0" }, "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/extendedlocation/arm-extendedlocation", "repository": { @@ -70,14 +73,14 @@ "types/*" ], "scripts": { - "build": "tsc && rollup -c 2>&1 && npm run minify && mkdirp ./review && npm run extract-api", + "build": "npm run clean && tsc && rollup -c 2>&1 && npm run minify && mkdirp ./review && npm run extract-api", "minify": "uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js", "prepack": "npm run build", "pack": "npm pack 2>&1", "extract-api": "api-extractor run --local", "lint": "echo skipped", "audit": "echo skipped", - "clean": "echo skipped", + "clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log", "build:node": "echo skipped", "build:browser": "echo skipped", "build:test": "echo skipped", @@ -86,17 +89,24 @@ "execute:samples": "echo skipped", "format": "echo skipped", "test": "npm run integration-test", - "prebuild": "echo skipped", "test:node": "echo skipped", "test:browser": "echo skipped", "unit-test": "npm run unit-test:node && npm run unit-test:browser", "unit-test:node": "cross-env TEST_MODE=playback npm run integration-test:node", "unit-test:browser": "echo skipped", "integration-test": "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", + "integration-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 'test/*.ts'", "integration-test:browser": "echo skipped", "docs": "echo skipped" }, "sideEffects": false, + "//metadata": { + "constantPaths": [ + { + "path": "src/customLocationsManagementClient.ts", + "prefix": "packageDetails" + } + ] + }, "autoPublish": true -} +} \ No newline at end of file diff --git a/sdk/extendedlocation/arm-extendedlocation/review/arm-extendedlocation.api.md b/sdk/extendedlocation/arm-extendedlocation/review/arm-extendedlocation.api.md index 6cb1f216dbe1..1f2cf497ce17 100644 --- a/sdk/extendedlocation/arm-extendedlocation/review/arm-extendedlocation.api.md +++ b/sdk/extendedlocation/arm-extendedlocation/review/arm-extendedlocation.api.md @@ -26,6 +26,19 @@ export type CustomLocation = TrackedResource & { provisioningState?: string; }; +// @public +export interface CustomLocationFindTargetResourceGroupProperties { + labels?: { + [propertyName: string]: string; + }; +} + +// @public +export interface CustomLocationFindTargetResourceGroupResult { + readonly matchedResourceSyncRule?: string; + readonly targetResourceGroup?: string; +} + // @public export interface CustomLocationListResult { readonly nextLink?: string; @@ -61,6 +74,7 @@ export interface CustomLocations { beginCreateOrUpdateAndWait(resourceGroupName: string, resourceName: string, parameters: CustomLocation, options?: CustomLocationsCreateOrUpdateOptionalParams): Promise; beginDelete(resourceGroupName: string, resourceName: string, options?: CustomLocationsDeleteOptionalParams): Promise, void>>; beginDeleteAndWait(resourceGroupName: string, resourceName: string, options?: CustomLocationsDeleteOptionalParams): Promise; + findTargetResourceGroup(resourceGroupName: string, resourceName: string, parameters: CustomLocationFindTargetResourceGroupProperties, options?: CustomLocationsFindTargetResourceGroupOptionalParams): Promise; get(resourceGroupName: string, resourceName: string, options?: CustomLocationsGetOptionalParams): Promise; listByResourceGroup(resourceGroupName: string, options?: CustomLocationsListByResourceGroupOptionalParams): PagedAsyncIterableIterator; listBySubscription(options?: CustomLocationsListBySubscriptionOptionalParams): PagedAsyncIterableIterator; @@ -84,6 +98,13 @@ export interface CustomLocationsDeleteOptionalParams extends coreClient.Operatio updateIntervalInMs?: number; } +// @public +export interface CustomLocationsFindTargetResourceGroupOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type CustomLocationsFindTargetResourceGroupResponse = CustomLocationFindTargetResourceGroupResult; + // @public export interface CustomLocationsGetOptionalParams extends coreClient.OperationOptions { } @@ -148,20 +169,17 @@ export interface CustomLocationsListOperationsOptionalParams extends coreClient. export type CustomLocationsListOperationsResponse = CustomLocationOperationsList; // @public (undocumented) -export class CustomLocationsManagementClient extends CustomLocationsManagementClientContext { - constructor(credentials: coreAuth.TokenCredential, subscriptionId: string, options?: CustomLocationsManagementClientOptionalParams); - // (undocumented) - customLocations: CustomLocations; -} - -// @public (undocumented) -export class CustomLocationsManagementClientContext extends coreClient.ServiceClient { +export class CustomLocationsManagementClient extends coreClient.ServiceClient { // (undocumented) $host: string; constructor(credentials: coreAuth.TokenCredential, subscriptionId: string, options?: CustomLocationsManagementClientOptionalParams); // (undocumented) apiVersion: string; // (undocumented) + customLocations: CustomLocations; + // (undocumented) + resourceSyncRules: ResourceSyncRules; + // (undocumented) subscriptionId: string; } @@ -267,6 +285,13 @@ export enum KnownResourceIdentityType { SystemAssigned = "SystemAssigned" } +// @public +export interface MatchExpressionsProperties { + key?: string; + operator?: string; + values?: string[]; +} + // @public export interface PatchableCustomLocations { authentication?: CustomLocationPropertiesAuthentication; @@ -282,6 +307,17 @@ export interface PatchableCustomLocations { }; } +// @public +export interface PatchableResourceSyncRule { + priority?: number; + readonly provisioningState?: string; + selector?: ResourceSyncRulePropertiesSelector; + tags?: { + [propertyName: string]: string; + }; + targetResourceGroup?: string; +} + // @public export type ProxyResource = Resource & {}; @@ -295,6 +331,89 @@ export interface Resource { // @public export type ResourceIdentityType = string; +// @public +export type ResourceSyncRule = TrackedResource & { + readonly systemData?: SystemData; + priority?: number; + readonly provisioningState?: string; + selector?: ResourceSyncRulePropertiesSelector; + targetResourceGroup?: string; +}; + +// @public +export interface ResourceSyncRuleListResult { + readonly nextLink?: string; + readonly value?: ResourceSyncRule[]; +} + +// @public +export interface ResourceSyncRulePropertiesSelector { + matchExpressions?: MatchExpressionsProperties[]; + matchLabels?: { + [propertyName: string]: string; + }; +} + +// @public +export interface ResourceSyncRules { + beginCreateOrUpdate(resourceGroupName: string, resourceName: string, childResourceName: string, parameters: ResourceSyncRule, options?: ResourceSyncRulesCreateOrUpdateOptionalParams): Promise, ResourceSyncRulesCreateOrUpdateResponse>>; + beginCreateOrUpdateAndWait(resourceGroupName: string, resourceName: string, childResourceName: string, parameters: ResourceSyncRule, options?: ResourceSyncRulesCreateOrUpdateOptionalParams): Promise; + beginUpdate(resourceGroupName: string, resourceName: string, childResourceName: string, options?: ResourceSyncRulesUpdateOptionalParams): Promise, ResourceSyncRulesUpdateResponse>>; + beginUpdateAndWait(resourceGroupName: string, resourceName: string, childResourceName: string, options?: ResourceSyncRulesUpdateOptionalParams): Promise; + delete(resourceGroupName: string, resourceName: string, childResourceName: string, options?: ResourceSyncRulesDeleteOptionalParams): Promise; + get(resourceGroupName: string, resourceName: string, childResourceName: string, options?: ResourceSyncRulesGetOptionalParams): Promise; + listByCustomLocationID(resourceGroupName: string, resourceName: string, options?: ResourceSyncRulesListByCustomLocationIDOptionalParams): PagedAsyncIterableIterator; +} + +// @public +export interface ResourceSyncRulesCreateOrUpdateOptionalParams extends coreClient.OperationOptions { + resumeFrom?: string; + updateIntervalInMs?: number; +} + +// @public +export type ResourceSyncRulesCreateOrUpdateResponse = ResourceSyncRule; + +// @public +export interface ResourceSyncRulesDeleteOptionalParams extends coreClient.OperationOptions { +} + +// @public +export interface ResourceSyncRulesGetOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type ResourceSyncRulesGetResponse = ResourceSyncRule; + +// @public +export interface ResourceSyncRulesListByCustomLocationIDNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type ResourceSyncRulesListByCustomLocationIDNextResponse = ResourceSyncRuleListResult; + +// @public +export interface ResourceSyncRulesListByCustomLocationIDOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type ResourceSyncRulesListByCustomLocationIDResponse = ResourceSyncRuleListResult; + +// @public +export interface ResourceSyncRulesUpdateOptionalParams extends coreClient.OperationOptions { + priority?: number; + resumeFrom?: string; + selector?: ResourceSyncRulePropertiesSelector; + tags?: { + [propertyName: string]: string; + }; + targetResourceGroup?: string; + updateIntervalInMs?: number; +} + +// @public +export type ResourceSyncRulesUpdateResponse = ResourceSyncRule; + // @public export interface SystemData { createdAt?: Date; @@ -313,7 +432,6 @@ export type TrackedResource = Resource & { location: string; }; - // (No @packageDocumentation comment for this package) ``` diff --git a/sdk/extendedlocation/arm-extendedlocation/rollup.config.js b/sdk/extendedlocation/arm-extendedlocation/rollup.config.js index 9be1955eb7f1..3f89d7309da5 100644 --- a/sdk/extendedlocation/arm-extendedlocation/rollup.config.js +++ b/sdk/extendedlocation/arm-extendedlocation/rollup.config.js @@ -14,62 +14,14 @@ import json from "@rollup/plugin-json"; import nodeBuiltins from "builtin-modules"; -/** - * Gets the proper configuration needed for rollup's commonJS plugin for @opentelemetry/api. - * - * NOTE: this manual configuration is only needed because OpenTelemetry uses an - * __exportStar downleveled helper function to declare its exports which confuses - * rollup's automatic discovery mechanism. - * - * @returns an object reference that can be `...`'d into your cjs() configuration. - */ -export function openTelemetryCommonJs() { - const namedExports = {}; - - for (const key of [ - "@opentelemetry/api", - "@azure/core-tracing/node_modules/@opentelemetry/api" - ]) { - namedExports[key] = [ - "SpanKind", - "TraceFlags", - "getSpan", - "setSpan", - "SpanStatusCode", - "getSpanContext", - "setSpanContext" - ]; - } - - const releasedOpenTelemetryVersions = ["0.10.2", "1.0.0-rc.0"]; - - for (const version of releasedOpenTelemetryVersions) { - namedExports[ - // working around a limitation in the rollup common.js plugin - it's not able to resolve these modules so the named exports listed above will not get applied. We have to drill down to the actual path. - `../../../common/temp/node_modules/.pnpm/@opentelemetry/api@${version}/node_modules/@opentelemetry/api/build/src/index.js` - ] = [ - "SpanKind", - "TraceFlags", - "getSpan", - "setSpan", - "StatusCode", - "CanonicalCode", - "getSpanContext", - "setSpanContext" - ]; - } - - return namedExports; -} - // #region Warning Handler /** - * A function that can determine whether a rollupwarning should be ignored. If + * A function that can determine whether a rollup warning should be ignored. If * the function returns `true`, then the warning will not be displayed. */ -function ignoreNiseSinonEvalWarnings(warning) { +function ignoreNiseSinonEval(warning) { return ( warning.code === "EVAL" && warning.id && @@ -78,17 +30,14 @@ function ignoreNiseSinonEvalWarnings(warning) { ); } -function ignoreChaiCircularDependencyWarnings(warning) { +function ignoreChaiCircularDependency(warning) { return ( warning.code === "CIRCULAR_DEPENDENCY" && warning.importer && warning.importer.includes("node_modules/chai") === true ); } -const warningInhibitors = [ - ignoreChaiCircularDependencyWarnings, - ignoreNiseSinonEvalWarnings -]; +const warningInhibitors = [ignoreChaiCircularDependency, ignoreNiseSinonEval]; /** * Construct a warning handler for the shared rollup configuration @@ -122,22 +71,7 @@ function makeBrowserTestConfig() { nodeResolve({ mainFields: ["module", "browser"] }), - cjs({ - namedExports: { - // Chai's strange internal architecture makes it impossible to statically - // analyze its exports. - chai: [ - "version", - "use", - "util", - "config", - "expect", - "should", - "assert" - ], - ...openTelemetryCommonJs() - } - }), + cjs(), json(), sourcemaps() //viz({ filename: "dist-test/browser-stats.html", sourcemap: true }) @@ -173,7 +107,7 @@ export function makeConfig(pkg, options) { ], output: { file: "dist/index.js", format: "cjs", sourcemap: true }, preserveSymlinks: false, - plugins: [sourcemaps(), nodeResolve(), cjs()] + plugins: [sourcemaps(), nodeResolve()] }; const config = [baseConfig]; diff --git a/sdk/extendedlocation/arm-extendedlocation/src/customLocationsManagementClient.ts b/sdk/extendedlocation/arm-extendedlocation/src/customLocationsManagementClient.ts index 1a9cc4dbbec9..584f1d2af8a2 100644 --- a/sdk/extendedlocation/arm-extendedlocation/src/customLocationsManagementClient.ts +++ b/sdk/extendedlocation/arm-extendedlocation/src/customLocationsManagementClient.ts @@ -6,13 +6,23 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ +import * as coreClient from "@azure/core-client"; +import * as coreRestPipeline from "@azure/core-rest-pipeline"; +import { + PipelineRequest, + PipelineResponse, + SendRequest +} from "@azure/core-rest-pipeline"; import * as coreAuth from "@azure/core-auth"; -import { CustomLocationsImpl } from "./operations"; -import { CustomLocations } from "./operationsInterfaces"; -import { CustomLocationsManagementClientContext } from "./customLocationsManagementClientContext"; +import { CustomLocationsImpl, ResourceSyncRulesImpl } from "./operations"; +import { CustomLocations, ResourceSyncRules } from "./operationsInterfaces"; import { CustomLocationsManagementClientOptionalParams } from "./models"; -export class CustomLocationsManagementClient extends CustomLocationsManagementClientContext { +export class CustomLocationsManagementClient extends coreClient.ServiceClient { + $host: string; + apiVersion: string; + subscriptionId: string; + /** * Initializes a new instance of the CustomLocationsManagementClient class. * @param credentials Subscription credentials which uniquely identify client subscription. @@ -24,9 +34,103 @@ export class CustomLocationsManagementClient extends CustomLocationsManagementCl subscriptionId: string, options?: CustomLocationsManagementClientOptionalParams ) { - super(credentials, subscriptionId, options); + if (credentials === undefined) { + throw new Error("'credentials' cannot be null"); + } + if (subscriptionId === undefined) { + throw new Error("'subscriptionId' cannot be null"); + } + + // Initializing default values for options + if (!options) { + options = {}; + } + const defaults: CustomLocationsManagementClientOptionalParams = { + requestContentType: "application/json; charset=utf-8", + credential: credentials + }; + + const packageDetails = `azsdk-js-arm-extendedlocation/1.0.0-beta.2`; + 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 ?? options.baseUri ?? "https://management.azure.com" + }; + super(optionsWithDefaults); + + if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) { + const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies(); + const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some( + (pipelinePolicy) => + pipelinePolicy.name === + coreRestPipeline.bearerTokenAuthenticationPolicyName + ); + if (!bearerTokenAuthenticationPolicyFound) { + this.pipeline.removePolicy({ + name: coreRestPipeline.bearerTokenAuthenticationPolicyName + }); + this.pipeline.addPolicy( + coreRestPipeline.bearerTokenAuthenticationPolicy({ + scopes: `${optionsWithDefaults.baseUri}/.default`, + challengeCallbacks: { + authorizeRequestOnChallenge: + coreClient.authorizeRequestOnClaimChallenge + } + }) + ); + } + } + // Parameter assignments + this.subscriptionId = subscriptionId; + + // Assigning values to Constant parameters + this.$host = options.$host || "https://management.azure.com"; + this.apiVersion = options.apiVersion || "2021-08-31-preview"; this.customLocations = new CustomLocationsImpl(this); + this.resourceSyncRules = new ResourceSyncRulesImpl(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 item.replace(/(?<==).*$/, apiVersion); + } else { + return item; + } + }); + request.url = param[0] + "?" + newParams.join("&"); + } + return next(request); + } + }; + this.pipeline.addPolicy(apiVersionPolicy); } customLocations: CustomLocations; + resourceSyncRules: ResourceSyncRules; } diff --git a/sdk/extendedlocation/arm-extendedlocation/src/customLocationsManagementClientContext.ts b/sdk/extendedlocation/arm-extendedlocation/src/customLocationsManagementClientContext.ts deleted file mode 100644 index a3bc19cc2289..000000000000 --- a/sdk/extendedlocation/arm-extendedlocation/src/customLocationsManagementClientContext.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * Code generated by Microsoft (R) AutoRest Code Generator. - * Changes may cause incorrect behavior and will be lost if the code is regenerated. - */ - -import * as coreClient from "@azure/core-client"; -import * as coreAuth from "@azure/core-auth"; -import { CustomLocationsManagementClientOptionalParams } from "./models"; - -export class CustomLocationsManagementClientContext extends coreClient.ServiceClient { - $host: string; - apiVersion: string; - subscriptionId: string; - - /** - * Initializes a new instance of the CustomLocationsManagementClientContext class. - * @param credentials Subscription credentials which uniquely identify client subscription. - * @param subscriptionId The ID of the target subscription. - * @param options The parameter options - */ - constructor( - credentials: coreAuth.TokenCredential, - subscriptionId: string, - options?: CustomLocationsManagementClientOptionalParams - ) { - if (credentials === undefined) { - throw new Error("'credentials' cannot be null"); - } - if (subscriptionId === undefined) { - throw new Error("'subscriptionId' cannot be null"); - } - - // Initializing default values for options - if (!options) { - options = {}; - } - const defaults: CustomLocationsManagementClientOptionalParams = { - requestContentType: "application/json; charset=utf-8", - credential: credentials - }; - - const packageDetails = `azsdk-js-arm-extendedlocation/1.0.0-beta.1`; - const userAgentPrefix = - options.userAgentOptions && options.userAgentOptions.userAgentPrefix - ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` - : `${packageDetails}`; - - if (!options.credentialScopes) { - options.credentialScopes = ["https://management.azure.com/.default"]; - } - const optionsWithDefaults = { - ...defaults, - ...options, - userAgentOptions: { - userAgentPrefix - }, - baseUri: options.endpoint || "https://management.azure.com" - }; - super(optionsWithDefaults); - // Parameter assignments - this.subscriptionId = subscriptionId; - - // Assigning values to Constant parameters - this.$host = options.$host || "https://management.azure.com"; - this.apiVersion = options.apiVersion || "2021-08-15"; - } -} diff --git a/sdk/extendedlocation/arm-extendedlocation/src/index.ts b/sdk/extendedlocation/arm-extendedlocation/src/index.ts index 91e3a313133c..7e494646f202 100644 --- a/sdk/extendedlocation/arm-extendedlocation/src/index.ts +++ b/sdk/extendedlocation/arm-extendedlocation/src/index.ts @@ -9,5 +9,4 @@ /// export * from "./models"; export { CustomLocationsManagementClient } from "./customLocationsManagementClient"; -export { CustomLocationsManagementClientContext } from "./customLocationsManagementClientContext"; export * from "./operationsInterfaces"; diff --git a/sdk/extendedlocation/arm-extendedlocation/src/models/index.ts b/sdk/extendedlocation/arm-extendedlocation/src/models/index.ts index 83de0a370d8f..facc35a8924b 100644 --- a/sdk/extendedlocation/arm-extendedlocation/src/models/index.ts +++ b/sdk/extendedlocation/arm-extendedlocation/src/models/index.ts @@ -118,25 +118,6 @@ export interface CustomLocationListResult { readonly value?: CustomLocation[]; } -/** Common fields that are returned in the response for all Azure Resource Manager resources */ -export interface Resource { - /** - * Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly id?: string; - /** - * The name of the resource - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly name?: string; - /** - * The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - * NOTE: This property will not be serialized. It can only be populated by the server. - */ - readonly type?: string; -} - /** Identity for the resource. */ export interface Identity { /** @@ -177,6 +158,25 @@ export interface SystemData { lastModifiedAt?: Date; } +/** Common fields that are returned in the response for all Azure Resource Manager resources */ +export interface Resource { + /** + * Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly id?: string; + /** + * The name of the resource + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly name?: string; + /** + * The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly type?: string; +} + /** The Custom Locations patchable resource definition. */ export interface PatchableCustomLocations { /** Identity for the resource. */ @@ -223,6 +223,75 @@ export interface EnabledResourceTypePropertiesTypesMetadataItem { resourceType?: string; } +/** The Find Target Resource Group operation request. */ +export interface CustomLocationFindTargetResourceGroupProperties { + /** Labels of the custom resource, this is a map of {key,value} pairs. */ + labels?: { [propertyName: string]: string }; +} + +/** The Find Target Resource Group operation response. */ +export interface CustomLocationFindTargetResourceGroupResult { + /** + * The matching resource sync rule is the particular resource sync rule that matched the match expressions and labels and had lowest priority. This is the rule responsible for mapping the target resource to the target resource group. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly matchedResourceSyncRule?: string; + /** + * The target resource group of matching resource sync rule. The labels from the request will be used to find out matching resource sync rule against the selector property of the resource sync rule. The one with highest priority will be returned if there are multiple matching rules. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly targetResourceGroup?: string; +} + +/** The List Resource Sync Rules operation response. */ +export interface ResourceSyncRuleListResult { + /** + * The URL to use for getting the next set of results. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly nextLink?: string; + /** + * The list of Resource Sync Rules. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly value?: ResourceSyncRule[]; +} + +/** A label selector is composed of two parts, matchLabels and matchExpressions. The first part, matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is 'key', the operator is 'In', and the values array contains only 'value'. The second part, matchExpressions is a list of resource selector requirements. Valid operators include In, NotIn, Exists, and DoesNotExist. The values set must be non-empty in the case of In and NotIn. The values set must be empty in the case of Exists and DoesNotExist. All of the requirements, from both matchLabels and matchExpressions must all be satisfied in order to match. */ +export interface ResourceSyncRulePropertiesSelector { + /** MatchExpressions is a list of resource selector requirements. Valid operators include In, NotIn, Exists, and DoesNotExist. The values set must be non-empty in the case of In and NotIn. The values set must be empty in the case of Exists and DoesNotExist. */ + matchExpressions?: MatchExpressionsProperties[]; + /** MatchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is 'key', the operator is 'In', and the values array contains only 'value'. */ + matchLabels?: { [propertyName: string]: string }; +} + +/** Resource Sync Rules matchExpression property definition. */ +export interface MatchExpressionsProperties { + /** Key is the label key that the selector applies to. */ + key?: string; + /** The Operator field represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist. */ + operator?: string; + /** The label value */ + values?: string[]; +} + +/** The Resource Sync Rules patchable resource definition. */ +export interface PatchableResourceSyncRule { + /** Resource tags */ + tags?: { [propertyName: string]: string }; + /** Priority represents a priority of the Resource Sync Rule */ + priority?: number; + /** + * Provisioning State for the Resource Sync Rule. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly provisioningState?: string; + /** A label selector is composed of two parts, matchLabels and matchExpressions. The first part, matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is 'key', the operator is 'In', and the values array contains only 'value'. The second part, matchExpressions is a list of resource selector requirements. Valid operators include In, NotIn, Exists, and DoesNotExist. The values set must be non-empty in the case of In and NotIn. The values set must be empty in the case of Exists and DoesNotExist. All of the requirements, from both matchLabels and matchExpressions must all be satisfied in order to match. */ + selector?: ResourceSyncRulePropertiesSelector; + /** For an unmapped custom resource, its labels will be used to find matching resource sync rules. If this resource sync rule is one of the matching rules with highest priority, then the unmapped custom resource will be projected to the target resource group associated with this resource sync rule. The user creating this resource sync rule should have write permissions on the target resource group and this write permission will be validated when creating the resource sync rule. */ + targetResourceGroup?: string; +} + /** The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' */ export type TrackedResource = Resource & { /** Resource tags. */ @@ -259,6 +328,26 @@ export type CustomLocation = TrackedResource & { provisioningState?: string; }; +/** Resource Sync Rules definition. */ +export type ResourceSyncRule = TrackedResource & { + /** + * Metadata pertaining to creation and last modification of the resource + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly systemData?: SystemData; + /** Priority represents a priority of the Resource Sync Rule */ + priority?: number; + /** + * Provisioning State for the Resource Sync Rule. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly provisioningState?: string; + /** A label selector is composed of two parts, matchLabels and matchExpressions. The first part, matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is 'key', the operator is 'In', and the values array contains only 'value'. The second part, matchExpressions is a list of resource selector requirements. Valid operators include In, NotIn, Exists, and DoesNotExist. The values set must be non-empty in the case of In and NotIn. The values set must be empty in the case of Exists and DoesNotExist. All of the requirements, from both matchLabels and matchExpressions must all be satisfied in order to match. */ + selector?: ResourceSyncRulePropertiesSelector; + /** For an unmapped custom resource, its labels will be used to find matching resource sync rules. If this resource sync rule is one of the matching rules with highest priority, then the unmapped custom resource will be projected to the target resource group associated with this resource sync rule. The user creating this resource sync rule should have write permissions on the target resource group and this write permission will be validated when creating the resource sync rule. */ + targetResourceGroup?: string; +}; + /** EnabledResourceType definition. */ export type EnabledResourceType = ProxyResource & { /** @@ -406,6 +495,13 @@ export interface CustomLocationsListEnabledResourceTypesOptionalParams /** Contains response data for the listEnabledResourceTypes operation. */ export type CustomLocationsListEnabledResourceTypesResponse = EnabledResourceTypesListResult; +/** Optional parameters. */ +export interface CustomLocationsFindTargetResourceGroupOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the findTargetResourceGroup operation. */ +export type CustomLocationsFindTargetResourceGroupResponse = CustomLocationFindTargetResourceGroupResult; + /** Optional parameters. */ export interface CustomLocationsListOperationsNextOptionalParams extends coreClient.OperationOptions {} @@ -434,6 +530,63 @@ export interface CustomLocationsListEnabledResourceTypesNextOptionalParams /** Contains response data for the listEnabledResourceTypesNext operation. */ export type CustomLocationsListEnabledResourceTypesNextResponse = EnabledResourceTypesListResult; +/** Optional parameters. */ +export interface ResourceSyncRulesListByCustomLocationIDOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listByCustomLocationID operation. */ +export type ResourceSyncRulesListByCustomLocationIDResponse = ResourceSyncRuleListResult; + +/** Optional parameters. */ +export interface ResourceSyncRulesGetOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the get operation. */ +export type ResourceSyncRulesGetResponse = ResourceSyncRule; + +/** Optional parameters. */ +export interface ResourceSyncRulesCreateOrUpdateOptionalParams + extends coreClient.OperationOptions { + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; + /** A serialized poller which can be used to resume an existing paused Long-Running-Operation. */ + resumeFrom?: string; +} + +/** Contains response data for the createOrUpdate operation. */ +export type ResourceSyncRulesCreateOrUpdateResponse = ResourceSyncRule; + +/** Optional parameters. */ +export interface ResourceSyncRulesDeleteOptionalParams + extends coreClient.OperationOptions {} + +/** Optional parameters. */ +export interface ResourceSyncRulesUpdateOptionalParams + extends coreClient.OperationOptions { + /** Resource tags */ + tags?: { [propertyName: string]: string }; + /** Priority represents a priority of the Resource Sync Rule */ + priority?: number; + /** A label selector is composed of two parts, matchLabels and matchExpressions. The first part, matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is 'key', the operator is 'In', and the values array contains only 'value'. The second part, matchExpressions is a list of resource selector requirements. Valid operators include In, NotIn, Exists, and DoesNotExist. The values set must be non-empty in the case of In and NotIn. The values set must be empty in the case of Exists and DoesNotExist. All of the requirements, from both matchLabels and matchExpressions must all be satisfied in order to match. */ + selector?: ResourceSyncRulePropertiesSelector; + /** For an unmapped custom resource, its labels will be used to find matching resource sync rules. If this resource sync rule is one of the matching rules with highest priority, then the unmapped custom resource will be projected to the target resource group associated with this resource sync rule. The user creating this resource sync rule should have write permissions on the target resource group and this write permission will be validated when creating the resource sync rule. */ + targetResourceGroup?: string; + /** Delay to wait until next poll, in milliseconds. */ + updateIntervalInMs?: number; + /** A serialized poller which can be used to resume an existing paused Long-Running-Operation. */ + resumeFrom?: string; +} + +/** Contains response data for the update operation. */ +export type ResourceSyncRulesUpdateResponse = ResourceSyncRule; + +/** Optional parameters. */ +export interface ResourceSyncRulesListByCustomLocationIDNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listByCustomLocationIDNext operation. */ +export type ResourceSyncRulesListByCustomLocationIDNextResponse = ResourceSyncRuleListResult; + /** Optional parameters. */ export interface CustomLocationsManagementClientOptionalParams extends coreClient.ServiceClientOptions { diff --git a/sdk/extendedlocation/arm-extendedlocation/src/models/mappers.ts b/sdk/extendedlocation/arm-extendedlocation/src/models/mappers.ts index 032c9879f617..0cfad5d4232f 100644 --- a/sdk/extendedlocation/arm-extendedlocation/src/models/mappers.ts +++ b/sdk/extendedlocation/arm-extendedlocation/src/models/mappers.ts @@ -219,36 +219,6 @@ export const CustomLocationListResult: coreClient.CompositeMapper = { } }; -export const Resource: coreClient.CompositeMapper = { - type: { - name: "Composite", - className: "Resource", - modelProperties: { - id: { - serializedName: "id", - readOnly: true, - type: { - name: "String" - } - }, - name: { - serializedName: "name", - readOnly: true, - type: { - name: "String" - } - }, - type: { - serializedName: "type", - readOnly: true, - type: { - name: "String" - } - } - } - } -}; - export const Identity: coreClient.CompositeMapper = { type: { name: "Composite", @@ -344,6 +314,36 @@ export const SystemData: coreClient.CompositeMapper = { } }; +export const Resource: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "Resource", + modelProperties: { + id: { + serializedName: "id", + readOnly: true, + type: { + name: "String" + } + }, + name: { + serializedName: "name", + readOnly: true, + type: { + name: "String" + } + }, + type: { + serializedName: "type", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + export const PatchableCustomLocations: coreClient.CompositeMapper = { type: { name: "Composite", @@ -471,6 +471,176 @@ export const EnabledResourceTypePropertiesTypesMetadataItem: coreClient.Composit } }; +export const CustomLocationFindTargetResourceGroupProperties: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "CustomLocationFindTargetResourceGroupProperties", + modelProperties: { + labels: { + serializedName: "labels", + type: { + name: "Dictionary", + value: { type: { name: "String" } } + } + } + } + } +}; + +export const CustomLocationFindTargetResourceGroupResult: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "CustomLocationFindTargetResourceGroupResult", + modelProperties: { + matchedResourceSyncRule: { + serializedName: "matchedResourceSyncRule", + readOnly: true, + type: { + name: "String" + } + }, + targetResourceGroup: { + serializedName: "targetResourceGroup", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const ResourceSyncRuleListResult: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ResourceSyncRuleListResult", + modelProperties: { + nextLink: { + serializedName: "nextLink", + readOnly: true, + type: { + name: "String" + } + }, + value: { + serializedName: "value", + readOnly: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ResourceSyncRule" + } + } + } + } + } + } +}; + +export const ResourceSyncRulePropertiesSelector: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ResourceSyncRulePropertiesSelector", + modelProperties: { + matchExpressions: { + serializedName: "matchExpressions", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "MatchExpressionsProperties" + } + } + } + }, + matchLabels: { + serializedName: "matchLabels", + type: { + name: "Dictionary", + value: { type: { name: "String" } } + } + } + } + } +}; + +export const MatchExpressionsProperties: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "MatchExpressionsProperties", + modelProperties: { + key: { + serializedName: "key", + type: { + name: "String" + } + }, + operator: { + serializedName: "operator", + type: { + name: "String" + } + }, + values: { + serializedName: "values", + type: { + name: "Sequence", + element: { + type: { + name: "String" + } + } + } + } + } + } +}; + +export const PatchableResourceSyncRule: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "PatchableResourceSyncRule", + modelProperties: { + tags: { + serializedName: "tags", + type: { + name: "Dictionary", + value: { type: { name: "String" } } + } + }, + priority: { + serializedName: "properties.priority", + type: { + name: "Number" + } + }, + provisioningState: { + serializedName: "properties.provisioningState", + readOnly: true, + type: { + name: "String" + } + }, + selector: { + serializedName: "properties.selector", + type: { + name: "Composite", + className: "ResourceSyncRulePropertiesSelector" + } + }, + targetResourceGroup: { + serializedName: "properties.targetResourceGroup", + type: { + name: "String" + } + } + } + } +}; + export const TrackedResource: coreClient.CompositeMapper = { type: { name: "Composite", @@ -577,6 +747,49 @@ export const CustomLocation: coreClient.CompositeMapper = { } }; +export const ResourceSyncRule: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ResourceSyncRule", + modelProperties: { + ...TrackedResource.type.modelProperties, + systemData: { + serializedName: "systemData", + type: { + name: "Composite", + className: "SystemData" + } + }, + priority: { + serializedName: "properties.priority", + type: { + name: "Number" + } + }, + provisioningState: { + serializedName: "properties.provisioningState", + readOnly: true, + type: { + name: "String" + } + }, + selector: { + serializedName: "properties.selector", + type: { + name: "Composite", + className: "ResourceSyncRulePropertiesSelector" + } + }, + targetResourceGroup: { + serializedName: "properties.targetResourceGroup", + type: { + name: "String" + } + } + } + } +}; + export const EnabledResourceType: coreClient.CompositeMapper = { type: { name: "Composite", diff --git a/sdk/extendedlocation/arm-extendedlocation/src/models/parameters.ts b/sdk/extendedlocation/arm-extendedlocation/src/models/parameters.ts index f024bfc9a447..1a5aa79337f9 100644 --- a/sdk/extendedlocation/arm-extendedlocation/src/models/parameters.ts +++ b/sdk/extendedlocation/arm-extendedlocation/src/models/parameters.ts @@ -13,7 +13,10 @@ import { } from "@azure/core-client"; import { CustomLocation as CustomLocationMapper, - PatchableCustomLocations as PatchableCustomLocationsMapper + PatchableCustomLocations as PatchableCustomLocationsMapper, + CustomLocationFindTargetResourceGroupProperties as CustomLocationFindTargetResourceGroupPropertiesMapper, + ResourceSyncRule as ResourceSyncRuleMapper, + PatchableResourceSyncRule as PatchableResourceSyncRuleMapper } from "../models/mappers"; export const accept: OperationParameter = { @@ -43,7 +46,7 @@ export const $host: OperationURLParameter = { export const apiVersion: OperationQueryParameter = { parameterPath: "apiVersion", mapper: { - defaultValue: "2021-08-15", + defaultValue: "2021-08-31-preview", isConstant: true, serializedName: "api-version", type: { @@ -161,6 +164,11 @@ export const provisioningState: OperationParameter = { mapper: PatchableCustomLocationsMapper }; +export const parameters2: OperationParameter = { + parameterPath: "parameters", + mapper: CustomLocationFindTargetResourceGroupPropertiesMapper +}; + export const nextLink: OperationURLParameter = { parameterPath: "nextLink", mapper: { @@ -172,3 +180,46 @@ export const nextLink: OperationURLParameter = { }, skipEncoding: true }; + +export const childResourceName: OperationURLParameter = { + parameterPath: "childResourceName", + mapper: { + constraints: { + Pattern: new RegExp( + "^[a-zA-Z0-9]$|^[a-zA-Z0-9][-_a-zA-Z0-9]{0,61}[a-zA-Z0-9]$" + ), + MaxLength: 63, + MinLength: 1 + }, + serializedName: "childResourceName", + required: true, + type: { + name: "String" + } + } +}; + +export const parameters3: OperationParameter = { + parameterPath: "parameters", + mapper: ResourceSyncRuleMapper +}; + +export const tags1: OperationParameter = { + parameterPath: ["options", "tags"], + mapper: PatchableResourceSyncRuleMapper +}; + +export const priority: OperationParameter = { + parameterPath: ["options", "priority"], + mapper: PatchableResourceSyncRuleMapper +}; + +export const selector: OperationParameter = { + parameterPath: ["options", "selector"], + mapper: PatchableResourceSyncRuleMapper +}; + +export const targetResourceGroup: OperationParameter = { + parameterPath: ["options", "targetResourceGroup"], + mapper: PatchableResourceSyncRuleMapper +}; diff --git a/sdk/extendedlocation/arm-extendedlocation/src/operations/customLocations.ts b/sdk/extendedlocation/arm-extendedlocation/src/operations/customLocations.ts index e25a2f1fed07..6e0a34104dda 100644 --- a/sdk/extendedlocation/arm-extendedlocation/src/operations/customLocations.ts +++ b/sdk/extendedlocation/arm-extendedlocation/src/operations/customLocations.ts @@ -11,7 +11,7 @@ import { CustomLocations } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; -import { CustomLocationsManagementClientContext } from "../customLocationsManagementClientContext"; +import { CustomLocationsManagementClient } from "../customLocationsManagementClient"; import { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro"; import { LroImpl } from "../lroImpl"; import { @@ -37,6 +37,9 @@ import { CustomLocationsUpdateOptionalParams, CustomLocationsUpdateResponse, CustomLocationsListEnabledResourceTypesResponse, + CustomLocationFindTargetResourceGroupProperties, + CustomLocationsFindTargetResourceGroupOptionalParams, + CustomLocationsFindTargetResourceGroupResponse, CustomLocationsListOperationsNextResponse, CustomLocationsListBySubscriptionNextResponse, CustomLocationsListByResourceGroupNextResponse, @@ -46,13 +49,13 @@ import { /// /** Class containing CustomLocations operations. */ export class CustomLocationsImpl implements CustomLocations { - private readonly client: CustomLocationsManagementClientContext; + private readonly client: CustomLocationsManagementClient; /** * Initialize a new instance of the class CustomLocations class. * @param client Reference to the service client */ - constructor(client: CustomLocationsManagementClientContext) { + constructor(client: CustomLocationsManagementClient) { this.client = client; } @@ -388,11 +391,13 @@ export class CustomLocationsImpl implements CustomLocations { { resourceGroupName, resourceName, 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; } /** @@ -472,11 +477,13 @@ export class CustomLocationsImpl implements CustomLocations { { resourceGroupName, resourceName, options }, deleteOperationSpec ); - return new LroEngine(lro, { + const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, lroResourceLocationConfig: "azure-async-operation" }); + await poller.poll(); + return poller; } /** @@ -533,6 +540,26 @@ export class CustomLocationsImpl implements CustomLocations { ); } + /** + * Returns the target resource group associated with the resource sync rules of the Custom Location + * that match the rules passed in with the Find Target Resource Group Request. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName Custom Locations name. + * @param parameters Parameters of the find target resource group request. + * @param options The options parameters. + */ + findTargetResourceGroup( + resourceGroupName: string, + resourceName: string, + parameters: CustomLocationFindTargetResourceGroupProperties, + options?: CustomLocationsFindTargetResourceGroupOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, resourceName, parameters, options }, + findTargetResourceGroupOperationSpec + ); + } + /** * ListOperationsNext * @param nextLink The nextLink from the previous successful call to the ListOperations method. @@ -794,6 +821,31 @@ const listEnabledResourceTypesOperationSpec: coreClient.OperationSpec = { headerParameters: [Parameters.accept], serializer }; +const findTargetResourceGroupOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/findTargetResourceGroup", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.CustomLocationFindTargetResourceGroupResult + }, + 204: {}, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + requestBody: Parameters.parameters2, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.resourceName + ], + headerParameters: [Parameters.accept, Parameters.contentType], + mediaType: "json", + serializer +}; const listOperationsNextOperationSpec: coreClient.OperationSpec = { path: "{nextLink}", httpMethod: "GET", diff --git a/sdk/extendedlocation/arm-extendedlocation/src/operations/index.ts b/sdk/extendedlocation/arm-extendedlocation/src/operations/index.ts index e08b698e64ad..30c43fc69488 100644 --- a/sdk/extendedlocation/arm-extendedlocation/src/operations/index.ts +++ b/sdk/extendedlocation/arm-extendedlocation/src/operations/index.ts @@ -7,3 +7,4 @@ */ export * from "./customLocations"; +export * from "./resourceSyncRules"; diff --git a/sdk/extendedlocation/arm-extendedlocation/src/operations/resourceSyncRules.ts b/sdk/extendedlocation/arm-extendedlocation/src/operations/resourceSyncRules.ts new file mode 100644 index 000000000000..5c0be62895c5 --- /dev/null +++ b/sdk/extendedlocation/arm-extendedlocation/src/operations/resourceSyncRules.ts @@ -0,0 +1,562 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { ResourceSyncRules } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { CustomLocationsManagementClient } from "../customLocationsManagementClient"; +import { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro"; +import { LroImpl } from "../lroImpl"; +import { + ResourceSyncRule, + ResourceSyncRulesListByCustomLocationIDNextOptionalParams, + ResourceSyncRulesListByCustomLocationIDOptionalParams, + ResourceSyncRulesListByCustomLocationIDResponse, + ResourceSyncRulesGetOptionalParams, + ResourceSyncRulesGetResponse, + ResourceSyncRulesCreateOrUpdateOptionalParams, + ResourceSyncRulesCreateOrUpdateResponse, + ResourceSyncRulesDeleteOptionalParams, + ResourceSyncRulesUpdateOptionalParams, + ResourceSyncRulesUpdateResponse, + ResourceSyncRulesListByCustomLocationIDNextResponse +} from "../models"; + +/// +/** Class containing ResourceSyncRules operations. */ +export class ResourceSyncRulesImpl implements ResourceSyncRules { + private readonly client: CustomLocationsManagementClient; + + /** + * Initialize a new instance of the class ResourceSyncRules class. + * @param client Reference to the service client + */ + constructor(client: CustomLocationsManagementClient) { + this.client = client; + } + + /** + * Gets a list of Resource Sync Rules in the specified subscription. The operation returns properties + * of each Resource Sync Rule + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName Custom Locations name. + * @param options The options parameters. + */ + public listByCustomLocationID( + resourceGroupName: string, + resourceName: string, + options?: ResourceSyncRulesListByCustomLocationIDOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listByCustomLocationIDPagingAll( + resourceGroupName, + resourceName, + options + ); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: () => { + return this.listByCustomLocationIDPagingPage( + resourceGroupName, + resourceName, + options + ); + } + }; + } + + private async *listByCustomLocationIDPagingPage( + resourceGroupName: string, + resourceName: string, + options?: ResourceSyncRulesListByCustomLocationIDOptionalParams + ): AsyncIterableIterator { + let result = await this._listByCustomLocationID( + resourceGroupName, + resourceName, + options + ); + yield result.value || []; + let continuationToken = result.nextLink; + while (continuationToken) { + result = await this._listByCustomLocationIDNext( + resourceGroupName, + resourceName, + continuationToken, + options + ); + continuationToken = result.nextLink; + yield result.value || []; + } + } + + private async *listByCustomLocationIDPagingAll( + resourceGroupName: string, + resourceName: string, + options?: ResourceSyncRulesListByCustomLocationIDOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listByCustomLocationIDPagingPage( + resourceGroupName, + resourceName, + options + )) { + yield* page; + } + } + + /** + * Gets a list of Resource Sync Rules in the specified subscription. The operation returns properties + * of each Resource Sync Rule + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName Custom Locations name. + * @param options The options parameters. + */ + private _listByCustomLocationID( + resourceGroupName: string, + resourceName: string, + options?: ResourceSyncRulesListByCustomLocationIDOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, resourceName, options }, + listByCustomLocationIDOperationSpec + ); + } + + /** + * Gets the details of the resourceSyncRule with a specified resource group, subscription id Custom + * Location resource name and Resource Sync Rule name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName Custom Locations name. + * @param childResourceName Resource Sync Rule name. + * @param options The options parameters. + */ + get( + resourceGroupName: string, + resourceName: string, + childResourceName: string, + options?: ResourceSyncRulesGetOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, resourceName, childResourceName, options }, + getOperationSpec + ); + } + + /** + * Creates or updates a Resource Sync Rule in the parent Custom Location, Subscription Id and Resource + * Group + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName Custom Locations name. + * @param childResourceName Resource Sync Rule name. + * @param parameters Parameters supplied to create or update a Resource Sync Rule. + * @param options The options parameters. + */ + async beginCreateOrUpdate( + resourceGroupName: string, + resourceName: string, + childResourceName: string, + parameters: ResourceSyncRule, + options?: ResourceSyncRulesCreateOrUpdateOptionalParams + ): Promise< + PollerLike< + PollOperationState, + ResourceSyncRulesCreateOrUpdateResponse + > + > { + const directSendOperation = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec + ): Promise => { + return this.client.sendOperationRequest(args, spec); + }; + const sendOperation = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec + ) => { + let currentRawResponse: + | coreClient.FullOperationResponse + | undefined = undefined; + const providedCallback = args.options?.onResponse; + const callback: coreClient.RawResponseCallback = ( + rawResponse: coreClient.FullOperationResponse, + flatResponse: unknown + ) => { + currentRawResponse = rawResponse; + providedCallback?.(rawResponse, flatResponse); + }; + const updatedArgs = { + ...args, + options: { + ...args.options, + onResponse: callback + } + }; + const flatResponse = await directSendOperation(updatedArgs, spec); + return { + flatResponse, + rawResponse: { + statusCode: currentRawResponse!.status, + body: currentRawResponse!.parsedBody, + headers: currentRawResponse!.headers.toJSON() + } + }; + }; + + const lro = new LroImpl( + sendOperation, + { + resourceGroupName, + resourceName, + childResourceName, + parameters, + options + }, + createOrUpdateOperationSpec + ); + const poller = new LroEngine(lro, { + resumeFrom: options?.resumeFrom, + intervalInMs: options?.updateIntervalInMs, + lroResourceLocationConfig: "azure-async-operation" + }); + await poller.poll(); + return poller; + } + + /** + * Creates or updates a Resource Sync Rule in the parent Custom Location, Subscription Id and Resource + * Group + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName Custom Locations name. + * @param childResourceName Resource Sync Rule name. + * @param parameters Parameters supplied to create or update a Resource Sync Rule. + * @param options The options parameters. + */ + async beginCreateOrUpdateAndWait( + resourceGroupName: string, + resourceName: string, + childResourceName: string, + parameters: ResourceSyncRule, + options?: ResourceSyncRulesCreateOrUpdateOptionalParams + ): Promise { + const poller = await this.beginCreateOrUpdate( + resourceGroupName, + resourceName, + childResourceName, + parameters, + options + ); + return poller.pollUntilDone(); + } + + /** + * Deletes the Resource Sync Rule with the specified Resource Sync Rule Name, Custom Location Resource + * Name, Resource Group, and Subscription Id. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName Custom Locations name. + * @param childResourceName Resource Sync Rule name. + * @param options The options parameters. + */ + delete( + resourceGroupName: string, + resourceName: string, + childResourceName: string, + options?: ResourceSyncRulesDeleteOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, resourceName, childResourceName, options }, + deleteOperationSpec + ); + } + + /** + * Updates a Resource Sync Rule with the specified Resource Sync Rule name in the specified Resource + * Group, Subscription and Custom Location name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName Custom Locations name. + * @param childResourceName Resource Sync Rule name. + * @param options The options parameters. + */ + async beginUpdate( + resourceGroupName: string, + resourceName: string, + childResourceName: string, + options?: ResourceSyncRulesUpdateOptionalParams + ): Promise< + PollerLike< + PollOperationState, + ResourceSyncRulesUpdateResponse + > + > { + const directSendOperation = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec + ): Promise => { + return this.client.sendOperationRequest(args, spec); + }; + const sendOperation = async ( + args: coreClient.OperationArguments, + spec: coreClient.OperationSpec + ) => { + let currentRawResponse: + | coreClient.FullOperationResponse + | undefined = undefined; + const providedCallback = args.options?.onResponse; + const callback: coreClient.RawResponseCallback = ( + rawResponse: coreClient.FullOperationResponse, + flatResponse: unknown + ) => { + currentRawResponse = rawResponse; + providedCallback?.(rawResponse, flatResponse); + }; + const updatedArgs = { + ...args, + options: { + ...args.options, + onResponse: callback + } + }; + const flatResponse = await directSendOperation(updatedArgs, spec); + return { + flatResponse, + rawResponse: { + statusCode: currentRawResponse!.status, + body: currentRawResponse!.parsedBody, + headers: currentRawResponse!.headers.toJSON() + } + }; + }; + + const lro = new LroImpl( + sendOperation, + { resourceGroupName, resourceName, childResourceName, options }, + updateOperationSpec + ); + const poller = new LroEngine(lro, { + resumeFrom: options?.resumeFrom, + intervalInMs: options?.updateIntervalInMs, + lroResourceLocationConfig: "azure-async-operation" + }); + await poller.poll(); + return poller; + } + + /** + * Updates a Resource Sync Rule with the specified Resource Sync Rule name in the specified Resource + * Group, Subscription and Custom Location name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName Custom Locations name. + * @param childResourceName Resource Sync Rule name. + * @param options The options parameters. + */ + async beginUpdateAndWait( + resourceGroupName: string, + resourceName: string, + childResourceName: string, + options?: ResourceSyncRulesUpdateOptionalParams + ): Promise { + const poller = await this.beginUpdate( + resourceGroupName, + resourceName, + childResourceName, + options + ); + return poller.pollUntilDone(); + } + + /** + * ListByCustomLocationIDNext + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName Custom Locations name. + * @param nextLink The nextLink from the previous successful call to the ListByCustomLocationID method. + * @param options The options parameters. + */ + private _listByCustomLocationIDNext( + resourceGroupName: string, + resourceName: string, + nextLink: string, + options?: ResourceSyncRulesListByCustomLocationIDNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { resourceGroupName, resourceName, nextLink, options }, + listByCustomLocationIDNextOperationSpec + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const listByCustomLocationIDOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.ResourceSyncRuleListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.resourceName + ], + headerParameters: [Parameters.accept], + serializer +}; +const getOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.ResourceSyncRule + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.resourceName, + Parameters.childResourceName + ], + headerParameters: [Parameters.accept], + serializer +}; +const createOrUpdateOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName}", + httpMethod: "PUT", + responses: { + 200: { + bodyMapper: Mappers.ResourceSyncRule + }, + 201: { + bodyMapper: Mappers.ResourceSyncRule + }, + 202: { + bodyMapper: Mappers.ResourceSyncRule + }, + 204: { + bodyMapper: Mappers.ResourceSyncRule + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + requestBody: Parameters.parameters3, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.resourceName, + Parameters.childResourceName + ], + headerParameters: [Parameters.accept, Parameters.contentType], + mediaType: "json", + serializer +}; +const deleteOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName}", + httpMethod: "DELETE", + responses: { + 200: {}, + 204: {}, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.resourceName, + Parameters.childResourceName + ], + headerParameters: [Parameters.accept], + serializer +}; +const updateOperationSpec: coreClient.OperationSpec = { + path: + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/resourceSyncRules/{childResourceName}", + httpMethod: "PATCH", + responses: { + 200: { + bodyMapper: Mappers.ResourceSyncRule + }, + 201: { + bodyMapper: Mappers.ResourceSyncRule + }, + 202: { + bodyMapper: Mappers.ResourceSyncRule + }, + 204: { + bodyMapper: Mappers.ResourceSyncRule + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + requestBody: { + parameterPath: { + tags: ["options", "tags"], + priority: ["options", "priority"], + selector: ["options", "selector"], + targetResourceGroup: ["options", "targetResourceGroup"] + }, + mapper: { ...Mappers.PatchableResourceSyncRule, required: true } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.resourceName, + Parameters.childResourceName + ], + headerParameters: [Parameters.accept, Parameters.contentType], + mediaType: "json", + serializer +}; +const listByCustomLocationIDNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.ResourceSyncRuleListResult + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [ + Parameters.$host, + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.resourceName, + Parameters.nextLink + ], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/extendedlocation/arm-extendedlocation/src/operationsInterfaces/customLocations.ts b/sdk/extendedlocation/arm-extendedlocation/src/operationsInterfaces/customLocations.ts index 05daf8bd9711..1ab3a256394f 100644 --- a/sdk/extendedlocation/arm-extendedlocation/src/operationsInterfaces/customLocations.ts +++ b/sdk/extendedlocation/arm-extendedlocation/src/operationsInterfaces/customLocations.ts @@ -22,7 +22,10 @@ import { CustomLocationsCreateOrUpdateResponse, CustomLocationsDeleteOptionalParams, CustomLocationsUpdateOptionalParams, - CustomLocationsUpdateResponse + CustomLocationsUpdateResponse, + CustomLocationFindTargetResourceGroupProperties, + CustomLocationsFindTargetResourceGroupOptionalParams, + CustomLocationsFindTargetResourceGroupResponse } from "../models"; /// @@ -140,4 +143,18 @@ export interface CustomLocations { resourceName: string, options?: CustomLocationsUpdateOptionalParams ): Promise; + /** + * Returns the target resource group associated with the resource sync rules of the Custom Location + * that match the rules passed in with the Find Target Resource Group Request. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName Custom Locations name. + * @param parameters Parameters of the find target resource group request. + * @param options The options parameters. + */ + findTargetResourceGroup( + resourceGroupName: string, + resourceName: string, + parameters: CustomLocationFindTargetResourceGroupProperties, + options?: CustomLocationsFindTargetResourceGroupOptionalParams + ): Promise; } diff --git a/sdk/extendedlocation/arm-extendedlocation/src/operationsInterfaces/index.ts b/sdk/extendedlocation/arm-extendedlocation/src/operationsInterfaces/index.ts index e08b698e64ad..30c43fc69488 100644 --- a/sdk/extendedlocation/arm-extendedlocation/src/operationsInterfaces/index.ts +++ b/sdk/extendedlocation/arm-extendedlocation/src/operationsInterfaces/index.ts @@ -7,3 +7,4 @@ */ export * from "./customLocations"; +export * from "./resourceSyncRules"; diff --git a/sdk/extendedlocation/arm-extendedlocation/src/operationsInterfaces/resourceSyncRules.ts b/sdk/extendedlocation/arm-extendedlocation/src/operationsInterfaces/resourceSyncRules.ts new file mode 100644 index 000000000000..3e89ab70adff --- /dev/null +++ b/sdk/extendedlocation/arm-extendedlocation/src/operationsInterfaces/resourceSyncRules.ts @@ -0,0 +1,136 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { PollerLike, PollOperationState } from "@azure/core-lro"; +import { + ResourceSyncRule, + ResourceSyncRulesListByCustomLocationIDOptionalParams, + ResourceSyncRulesGetOptionalParams, + ResourceSyncRulesGetResponse, + ResourceSyncRulesCreateOrUpdateOptionalParams, + ResourceSyncRulesCreateOrUpdateResponse, + ResourceSyncRulesDeleteOptionalParams, + ResourceSyncRulesUpdateOptionalParams, + ResourceSyncRulesUpdateResponse +} from "../models"; + +/// +/** Interface representing a ResourceSyncRules. */ +export interface ResourceSyncRules { + /** + * Gets a list of Resource Sync Rules in the specified subscription. The operation returns properties + * of each Resource Sync Rule + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName Custom Locations name. + * @param options The options parameters. + */ + listByCustomLocationID( + resourceGroupName: string, + resourceName: string, + options?: ResourceSyncRulesListByCustomLocationIDOptionalParams + ): PagedAsyncIterableIterator; + /** + * Gets the details of the resourceSyncRule with a specified resource group, subscription id Custom + * Location resource name and Resource Sync Rule name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName Custom Locations name. + * @param childResourceName Resource Sync Rule name. + * @param options The options parameters. + */ + get( + resourceGroupName: string, + resourceName: string, + childResourceName: string, + options?: ResourceSyncRulesGetOptionalParams + ): Promise; + /** + * Creates or updates a Resource Sync Rule in the parent Custom Location, Subscription Id and Resource + * Group + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName Custom Locations name. + * @param childResourceName Resource Sync Rule name. + * @param parameters Parameters supplied to create or update a Resource Sync Rule. + * @param options The options parameters. + */ + beginCreateOrUpdate( + resourceGroupName: string, + resourceName: string, + childResourceName: string, + parameters: ResourceSyncRule, + options?: ResourceSyncRulesCreateOrUpdateOptionalParams + ): Promise< + PollerLike< + PollOperationState, + ResourceSyncRulesCreateOrUpdateResponse + > + >; + /** + * Creates or updates a Resource Sync Rule in the parent Custom Location, Subscription Id and Resource + * Group + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName Custom Locations name. + * @param childResourceName Resource Sync Rule name. + * @param parameters Parameters supplied to create or update a Resource Sync Rule. + * @param options The options parameters. + */ + beginCreateOrUpdateAndWait( + resourceGroupName: string, + resourceName: string, + childResourceName: string, + parameters: ResourceSyncRule, + options?: ResourceSyncRulesCreateOrUpdateOptionalParams + ): Promise; + /** + * Deletes the Resource Sync Rule with the specified Resource Sync Rule Name, Custom Location Resource + * Name, Resource Group, and Subscription Id. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName Custom Locations name. + * @param childResourceName Resource Sync Rule name. + * @param options The options parameters. + */ + delete( + resourceGroupName: string, + resourceName: string, + childResourceName: string, + options?: ResourceSyncRulesDeleteOptionalParams + ): Promise; + /** + * Updates a Resource Sync Rule with the specified Resource Sync Rule name in the specified Resource + * Group, Subscription and Custom Location name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName Custom Locations name. + * @param childResourceName Resource Sync Rule name. + * @param options The options parameters. + */ + beginUpdate( + resourceGroupName: string, + resourceName: string, + childResourceName: string, + options?: ResourceSyncRulesUpdateOptionalParams + ): Promise< + PollerLike< + PollOperationState, + ResourceSyncRulesUpdateResponse + > + >; + /** + * Updates a Resource Sync Rule with the specified Resource Sync Rule name in the specified Resource + * Group, Subscription and Custom Location name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param resourceName Custom Locations name. + * @param childResourceName Resource Sync Rule name. + * @param options The options parameters. + */ + beginUpdateAndWait( + resourceGroupName: string, + resourceName: string, + childResourceName: string, + options?: ResourceSyncRulesUpdateOptionalParams + ): Promise; +} diff --git a/sdk/extendedlocation/arm-extendedlocation/test/sampleTest.ts b/sdk/extendedlocation/arm-extendedlocation/test/sampleTest.ts index 7ed89b043e1b..25aeb3ebcc36 100644 --- a/sdk/extendedlocation/arm-extendedlocation/test/sampleTest.ts +++ b/sdk/extendedlocation/arm-extendedlocation/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/extendedlocation/arm-extendedlocation/tsconfig.json b/sdk/extendedlocation/arm-extendedlocation/tsconfig.json index 6e3251194117..3e6ae96443f3 100644 --- a/sdk/extendedlocation/arm-extendedlocation/tsconfig.json +++ b/sdk/extendedlocation/arm-extendedlocation/tsconfig.json @@ -9,11 +9,19 @@ "esModuleInterop": true, "allowSyntheticDefaultImports": true, "forceConsistentCasingInFileNames": true, - "lib": ["es6", "dom"], + "lib": [ + "es6", + "dom" + ], "declaration": true, "outDir": "./dist-esm", "importHelpers": true }, - "include": ["./src/**/*.ts", "./test/**/*.ts"], - "exclude": ["node_modules"] -} + "include": [ + "./src/**/*.ts", + "./test/**/*.ts" + ], + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/sdk/extendedlocation/ci.mgmt.yml b/sdk/extendedlocation/ci.mgmt.yml index f5563d261002..2f33c3274f59 100644 --- a/sdk/extendedlocation/ci.mgmt.yml +++ b/sdk/extendedlocation/ci.mgmt.yml @@ -1,5 +1,5 @@ # NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. - + trigger: branches: include: @@ -10,6 +10,7 @@ trigger: include: - sdk/extendedlocation/ci.mgmt.yml - sdk/extendedlocation/arm-extendedlocation/ + - sdk/extendedlocation/arm-extendedlocation pr: branches: include: @@ -23,11 +24,11 @@ pr: include: - sdk/extendedlocation/ci.mgmt.yml - sdk/extendedlocation/arm-extendedlocation/ - + - sdk/extendedlocation/arm-extendedlocation extends: template: /eng/pipelines/templates/stages/archetype-sdk-client.yml parameters: ServiceDirectory: extendedlocation Artifacts: - name: azure-arm-extendedlocation - safeName: azurearmextendedlocation \ No newline at end of file + safeName: azurearmextendedlocation