diff --git a/sdk/managementgroups/arm-managementgroups/CHANGELOG.md b/sdk/managementgroups/arm-managementgroups/CHANGELOG.md index 125299177fac..53949b19f061 100644 --- a/sdk/managementgroups/arm-managementgroups/CHANGELOG.md +++ b/sdk/managementgroups/arm-managementgroups/CHANGELOG.md @@ -1,15 +1,25 @@ # Release History + +## 3.0.0 (2022-06-27) + +**Features** -## 2.0.2 (Unreleased) - -### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes - + - Added Interface ParentGroupBagInfo + - Added Type Alias EntitySearchType + - Added Type Alias EntityViewParameterType + - Added Type Alias ManagementGroupExpandType + - Added Enum KnownEntitySearchType + - Added Enum KnownEntityViewParameterType + - Added Enum KnownManagementGroupExpandType + +**Breaking Changes** + + - Removed Enum KnownEnum0 + - Removed Enum KnownEnum2 + - Removed Enum KnownEnum3 + - Removed Enum KnownManagementGroupChildType + - Removed Enum KnownPermissions + ## 2.0.1 (2022-04-24) **Features** diff --git a/sdk/managementgroups/arm-managementgroups/_meta.json b/sdk/managementgroups/arm-managementgroups/_meta.json index 08b80e28a6bb..e9daad317ee4 100644 --- a/sdk/managementgroups/arm-managementgroups/_meta.json +++ b/sdk/managementgroups/arm-managementgroups/_meta.json @@ -1,8 +1,8 @@ { - "commit": "184b23b63ee3a79fb41ca3aa55a31a8d9e636772", - "readme": "specification\\managementgroups\\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\\managementgroups\\resource-manager\\readme.md --use=@autorest/typescript@6.0.0-alpha.19.20220408.1 --generate-sample=true", + "commit": "22b3d184eef2d381291951969cad187fdb108245", + "readme": "specification/managementgroups/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=/mnt/vss/_work/1/s/azure-sdk-for-js ../azure-rest-api-specs/specification/managementgroups/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", - "release_tool": "@azure-tools/js-sdk-release-tools@2.2.6", - "use": "@autorest/typescript@6.0.0-alpha.19.20220408.1" -} + "release_tool": "@azure-tools/js-sdk-release-tools@2.3.2", + "use": "@autorest/typescript@6.0.0-alpha.19.20220425.1" +} \ No newline at end of file diff --git a/sdk/managementgroups/arm-managementgroups/package.json b/sdk/managementgroups/arm-managementgroups/package.json index 6b2cd2004e6e..87e478499103 100644 --- a/sdk/managementgroups/arm-managementgroups/package.json +++ b/sdk/managementgroups/arm-managementgroups/package.json @@ -3,7 +3,7 @@ "sdk-type": "mgmt", "author": "Microsoft Corporation", "description": "A generated SDK for ManagementGroupsAPI.", - "version": "2.0.2", + "version": "3.0.0", "engines": { "node": ">=12.0.0" }, @@ -40,9 +40,11 @@ "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/managementgroups/arm-managementgroups", "repository": { @@ -93,7 +95,7 @@ "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:node": "dev-tool run test:node-ts-input -- --timeout 1200000 'test/*.ts'", "integration-test:browser": "echo skipped", "docs": "echo skipped" }, @@ -106,13 +108,5 @@ } ] }, - "autoPublish": true, - "//sampleConfiguration": { - "productName": "", - "productSlugs": [ - "azure" - ], - "disableDocsMs": true, - "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure/arm-managementgroups?view=azure-node-preview" - } -} + "autoPublish": true +} \ No newline at end of file diff --git a/sdk/managementgroups/arm-managementgroups/review/arm-managementgroups.api.md b/sdk/managementgroups/arm-managementgroups/review/arm-managementgroups.api.md index 8bf14e1d640d..eb1144cef1e7 100644 --- a/sdk/managementgroups/arm-managementgroups/review/arm-managementgroups.api.md +++ b/sdk/managementgroups/arm-managementgroups/review/arm-managementgroups.api.md @@ -111,12 +111,12 @@ export interface EntitiesListNextOptionalParams extends coreClient.OperationOpti cacheControl?: string; filter?: string; groupName?: string; - search?: Enum2; + search?: EntitySearchType; select?: string; skip?: number; skiptoken?: string; top?: number; - view?: Enum3; + view?: EntityViewParameterType; } // @public @@ -127,12 +127,12 @@ export interface EntitiesListOptionalParams extends coreClient.OperationOptions cacheControl?: string; filter?: string; groupName?: string; - search?: Enum2; + search?: EntitySearchType; select?: string; skip?: number; skiptoken?: string; top?: number; - view?: Enum3; + view?: EntityViewParameterType; } // @public @@ -178,13 +178,10 @@ export interface EntityParentGroupInfo { } // @public -export type Enum0 = string; +export type EntitySearchType = string; // @public -export type Enum2 = string; - -// @public -export type Enum3 = string; +export type EntityViewParameterType = string; // @public export interface ErrorDetails { @@ -266,17 +263,7 @@ export interface HierarchySettingsUpdateOptionalParams extends coreClient.Operat export type HierarchySettingsUpdateResponse = HierarchySettings; // @public -export enum KnownEnum0 { - // (undocumented) - Ancestors = "ancestors", - // (undocumented) - Children = "children", - // (undocumented) - Path = "path" -} - -// @public -export enum KnownEnum2 { +export enum KnownEntitySearchType { // (undocumented) AllowedChildren = "AllowedChildren", // (undocumented) @@ -290,7 +277,7 @@ export enum KnownEnum2 { } // @public -export enum KnownEnum3 { +export enum KnownEntityViewParameterType { // (undocumented) Audit = "Audit", // (undocumented) @@ -302,23 +289,13 @@ export enum KnownEnum3 { } // @public -export enum KnownManagementGroupChildType { - // (undocumented) - MicrosoftManagementManagementGroups = "Microsoft.Management/managementGroups", +export enum KnownManagementGroupExpandType { // (undocumented) - Subscriptions = "/subscriptions" -} - -// @public -export enum KnownPermissions { - // (undocumented) - Delete = "delete", - // (undocumented) - Edit = "edit", + Ancestors = "ancestors", // (undocumented) - Noaccess = "noaccess", + Children = "children", // (undocumented) - View = "view" + Path = "path" } // @public @@ -348,7 +325,7 @@ export interface ManagementGroupChildInfo { } // @public -export type ManagementGroupChildType = string; +export type ManagementGroupChildType = "Microsoft.Management/managementGroups" | "/subscriptions"; // @public export interface ManagementGroupDetails { @@ -361,6 +338,9 @@ export interface ManagementGroupDetails { version?: number; } +// @public +export type ManagementGroupExpandType = string; + // @public export interface ManagementGroupInfo { displayName?: string; @@ -476,7 +456,7 @@ export type ManagementGroupsGetDescendantsResponse = DescendantListResult; // @public export interface ManagementGroupsGetOptionalParams extends coreClient.OperationOptions { cacheControl?: string; - expand?: Enum0; + expand?: ManagementGroupExpandType; filter?: string; recurse?: boolean; } @@ -603,6 +583,13 @@ export interface OperationsListOptionalParams extends coreClient.OperationOption // @public export type OperationsListResponse = OperationListResult; +// @public +export interface ParentGroupBagInfo { + displayName?: string; + id?: string; + name?: string; +} + // @public export interface ParentGroupInfo { displayName?: string; @@ -617,7 +604,7 @@ export interface PatchManagementGroupRequest { } // @public -type Permissions_2 = string; +type Permissions_2 = "noaccess" | "view" | "edit" | "delete"; export { Permissions_2 as Permissions } // @public @@ -638,7 +625,7 @@ export interface SubscriptionUnderManagementGroup { displayName?: string; readonly id?: string; readonly name?: string; - parent?: DescendantParentGroupInfo; + parent?: ParentGroupBagInfo; state?: string; tenant?: string; readonly type?: string; diff --git a/sdk/managementgroups/arm-managementgroups/src/managementGroupsAPI.ts b/sdk/managementgroups/arm-managementgroups/src/managementGroupsAPI.ts index 532061bb5380..533079f3429b 100644 --- a/sdk/managementgroups/arm-managementgroups/src/managementGroupsAPI.ts +++ b/sdk/managementgroups/arm-managementgroups/src/managementGroupsAPI.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 { ManagementGroupsImpl, @@ -62,7 +67,7 @@ export class ManagementGroupsAPI extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-managementgroups/2.0.2`; + const packageDetails = `azsdk-js-arm-managementgroups/3.0.0`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` @@ -117,6 +122,35 @@ export class ManagementGroupsAPI extends coreClient.ServiceClient { ); this.operations = new OperationsImpl(this); this.entities = new EntitiesImpl(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); } /** diff --git a/sdk/managementgroups/arm-managementgroups/src/models/index.ts b/sdk/managementgroups/arm-managementgroups/src/models/index.ts index 4794cdfda4fd..9bfd2e0b48b8 100644 --- a/sdk/managementgroups/arm-managementgroups/src/models/index.ts +++ b/sdk/managementgroups/arm-managementgroups/src/models/index.ts @@ -328,12 +328,22 @@ export interface SubscriptionUnderManagementGroup { tenant?: string; /** The friendly name of the subscription. */ displayName?: string; - /** The ID of the parent management group. */ - parent?: DescendantParentGroupInfo; + /** The ID, name and displayName of the parent management group. */ + parent?: ParentGroupBagInfo; /** The state of the subscription. */ state?: string; } +/** The ID, name and displayName of the parent management group. */ +export interface ParentGroupBagInfo { + /** The fully qualified ID for the parent management group. For example, /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000 */ + id?: string; + /** The name of the parent management group. For example, 00000000-0000-0000-0000-000000000000 */ + name?: string; + /** The friendly name of the parent management group. */ + displayName?: string; +} + /** The details of all subscriptions under management group. */ export interface ListSubscriptionUnderManagementGroup { /** The list of subscriptions. */ @@ -649,42 +659,26 @@ export interface ManagementGroupsDeleteHeaders { azureAsyncOperation?: string; } -/** Known values of {@link Enum0} that the service accepts. */ -export enum KnownEnum0 { +/** Known values of {@link ManagementGroupExpandType} that the service accepts. */ +export enum KnownManagementGroupExpandType { Children = "children", Path = "path", Ancestors = "ancestors" } /** - * Defines values for Enum0. \ - * {@link KnownEnum0} can be used interchangeably with Enum0, + * Defines values for ManagementGroupExpandType. \ + * {@link KnownManagementGroupExpandType} can be used interchangeably with ManagementGroupExpandType, * this enum contains the known values that the service supports. * ### Known values supported by the service * **children** \ * **path** \ * **ancestors** */ -export type Enum0 = string; - -/** Known values of {@link ManagementGroupChildType} that the service accepts. */ -export enum KnownManagementGroupChildType { - MicrosoftManagementManagementGroups = "Microsoft.Management/managementGroups", - Subscriptions = "/subscriptions" -} - -/** - * Defines values for ManagementGroupChildType. \ - * {@link KnownManagementGroupChildType} can be used interchangeably with ManagementGroupChildType, - * this enum contains the known values that the service supports. - * ### Known values supported by the service - * **Microsoft.Management\/managementGroups** \ - * **\/subscriptions** - */ -export type ManagementGroupChildType = string; +export type ManagementGroupExpandType = string; -/** Known values of {@link Enum2} that the service accepts. */ -export enum KnownEnum2 { +/** Known values of {@link EntitySearchType} that the service accepts. */ +export enum KnownEntitySearchType { AllowedParents = "AllowedParents", AllowedChildren = "AllowedChildren", ParentAndFirstLevelChildren = "ParentAndFirstLevelChildren", @@ -693,8 +687,8 @@ export enum KnownEnum2 { } /** - * Defines values for Enum2. \ - * {@link KnownEnum2} can be used interchangeably with Enum2, + * Defines values for EntitySearchType. \ + * {@link KnownEntitySearchType} can be used interchangeably with EntitySearchType, * this enum contains the known values that the service supports. * ### Known values supported by the service * **AllowedParents** \ @@ -703,10 +697,10 @@ export enum KnownEnum2 { * **ParentOnly** \ * **ChildrenOnly** */ -export type Enum2 = string; +export type EntitySearchType = string; -/** Known values of {@link Enum3} that the service accepts. */ -export enum KnownEnum3 { +/** Known values of {@link EntityViewParameterType} that the service accepts. */ +export enum KnownEntityViewParameterType { FullHierarchy = "FullHierarchy", GroupsOnly = "GroupsOnly", SubscriptionsOnly = "SubscriptionsOnly", @@ -714,8 +708,8 @@ export enum KnownEnum3 { } /** - * Defines values for Enum3. \ - * {@link KnownEnum3} can be used interchangeably with Enum3, + * Defines values for EntityViewParameterType. \ + * {@link KnownEntityViewParameterType} can be used interchangeably with EntityViewParameterType, * this enum contains the known values that the service supports. * ### Known values supported by the service * **FullHierarchy** \ @@ -723,29 +717,15 @@ export enum KnownEnum3 { * **SubscriptionsOnly** \ * **Audit** */ -export type Enum3 = string; - -/** Known values of {@link Permissions} that the service accepts. */ -export enum KnownPermissions { - Noaccess = "noaccess", - View = "view", - Edit = "edit", - Delete = "delete" -} - -/** - * Defines values for Permissions. \ - * {@link KnownPermissions} can be used interchangeably with Permissions, - * this enum contains the known values that the service supports. - * ### Known values supported by the service - * **noaccess** \ - * **view** \ - * **edit** \ - * **delete** - */ -export type Permissions = string; +export type EntityViewParameterType = string; +/** Defines values for ManagementGroupChildType. */ +export type ManagementGroupChildType = + | "Microsoft.Management/managementGroups" + | "/subscriptions"; /** Defines values for Reason. */ export type Reason = "Invalid" | "AlreadyExists"; +/** Defines values for Permissions. */ +export type Permissions = "noaccess" | "view" | "edit" | "delete"; /** Defines values for Status. */ export type Status = | "NotStarted" @@ -777,7 +757,7 @@ export interface ManagementGroupsGetOptionalParams /** Indicates whether the request should utilize any caches. Populate the header with 'no-cache' value to bypass existing caches. */ cacheControl?: string; /** The $expand=children query string parameter allows clients to request inclusion of children in the response payload. $expand=path includes the path from the root group to the current group. $expand=ancestors includes the ancestor Ids of the current group. */ - expand?: Enum0; + expand?: ManagementGroupExpandType; /** The $recurse=true query string parameter allows clients to request inclusion of entire hierarchy in the response payload. Note that $expand=children must be passed up if $recurse is set to true. */ recurse?: boolean; /** A filter which allows the exclusion of subscriptions from results (i.e. '$filter=children.childType ne Subscription') */ @@ -1023,9 +1003,9 @@ export interface EntitiesListOptionalParams * With $search=ParentOnly the API will return only the group if the user has access to at least one of the descendants of the group. * With $search=ChildrenOnly the API will return only the first level of children of the group entity info specified in $filter. The user must have direct access to the children entities or one of it's descendants for it to show up in the results. */ - search?: Enum2; + search?: EntitySearchType; /** The view parameter allows clients to filter the type of data that is returned by the getEntities call. */ - view?: Enum3; + view?: EntityViewParameterType; /** A filter which allows the get entities call to focus on a particular group (i.e. "$filter=name eq 'groupName'") */ groupName?: string; } @@ -1060,9 +1040,9 @@ export interface EntitiesListNextOptionalParams * With $search=ParentOnly the API will return only the group if the user has access to at least one of the descendants of the group. * With $search=ChildrenOnly the API will return only the first level of children of the group entity info specified in $filter. The user must have direct access to the children entities or one of it's descendants for it to show up in the results. */ - search?: Enum2; + search?: EntitySearchType; /** The view parameter allows clients to filter the type of data that is returned by the getEntities call. */ - view?: Enum3; + view?: EntityViewParameterType; /** A filter which allows the get entities call to focus on a particular group (i.e. "$filter=name eq 'groupName'") */ groupName?: string; } diff --git a/sdk/managementgroups/arm-managementgroups/src/models/mappers.ts b/sdk/managementgroups/arm-managementgroups/src/models/mappers.ts index 5699213581ef..86d039c189db 100644 --- a/sdk/managementgroups/arm-managementgroups/src/models/mappers.ts +++ b/sdk/managementgroups/arm-managementgroups/src/models/mappers.ts @@ -311,7 +311,11 @@ export const ManagementGroupChildInfo: coreClient.CompositeMapper = { type: { serializedName: "type", type: { - name: "String" + name: "Enum", + allowedValues: [ + "Microsoft.Management/managementGroups", + "/subscriptions" + ] } }, id: { @@ -487,7 +491,11 @@ export const CreateManagementGroupChildInfo: coreClient.CompositeMapper = { serializedName: "type", readOnly: true, type: { - name: "String" + name: "Enum", + allowedValues: [ + "Microsoft.Management/managementGroups", + "/subscriptions" + ] } }, id: { @@ -731,7 +739,7 @@ export const SubscriptionUnderManagementGroup: coreClient.CompositeMapper = { serializedName: "properties.parent", type: { name: "Composite", - className: "DescendantParentGroupInfo" + className: "ParentGroupBagInfo" } }, state: { @@ -744,6 +752,33 @@ export const SubscriptionUnderManagementGroup: coreClient.CompositeMapper = { } }; +export const ParentGroupBagInfo: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ParentGroupBagInfo", + modelProperties: { + id: { + serializedName: "id", + type: { + name: "String" + } + }, + name: { + serializedName: "name", + type: { + name: "String" + } + }, + displayName: { + serializedName: "displayName", + type: { + name: "String" + } + } + } + } +}; + export const ListSubscriptionUnderManagementGroup: coreClient.CompositeMapper = { type: { name: "Composite", @@ -1148,14 +1183,16 @@ export const EntityInfo: coreClient.CompositeMapper = { serializedName: "properties.permissions", nullable: true, type: { - name: "String" + name: "Enum", + allowedValues: ["noaccess", "view", "edit", "delete"] } }, inheritedPermissions: { serializedName: "properties.inheritedPermissions", nullable: true, type: { - name: "String" + name: "Enum", + allowedValues: ["noaccess", "view", "edit", "delete"] } }, numberOfDescendants: { @@ -1330,7 +1367,8 @@ export const EntityHierarchyItem: coreClient.CompositeMapper = { permissions: { serializedName: "properties.permissions", type: { - name: "String" + name: "Enum", + allowedValues: ["noaccess", "view", "edit", "delete"] } }, children: { diff --git a/sdk/managementgroups/arm-managementgroups/test/sampleTest.ts b/sdk/managementgroups/arm-managementgroups/test/sampleTest.ts index 7ed89b043e1b..25aeb3ebcc36 100644 --- a/sdk/managementgroups/arm-managementgroups/test/sampleTest.ts +++ b/sdk/managementgroups/arm-managementgroups/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/managementgroups/arm-managementgroups/tsconfig.json b/sdk/managementgroups/arm-managementgroups/tsconfig.json index 12b08be3a018..3e6ae96443f3 100644 --- a/sdk/managementgroups/arm-managementgroups/tsconfig.json +++ b/sdk/managementgroups/arm-managementgroups/tsconfig.json @@ -15,17 +15,11 @@ ], "declaration": true, "outDir": "./dist-esm", - "importHelpers": true, - "paths": { - "@azure/arm-managementgroups": [ - "./src/index" - ] - } + "importHelpers": true }, "include": [ "./src/**/*.ts", - "./test/**/*.ts", - "samples-dev/**/*.ts" + "./test/**/*.ts" ], "exclude": [ "node_modules"