From 2150c2a4d65a6071fe34ec67cdff198fcaf24678 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 12 Jan 2022 11:02:14 +0000 Subject: [PATCH] CodeGen from PR 17318 in Azure/azure-rest-api-specs Merge 16d2e2ea855d9628714dc8e41e0f8319297487f3 into 691920cda83cc0b89a8c821d0bb285100fad22b4 --- .../arm-subscriptions/CHANGELOG.md | 59 +++- sdk/subscription/arm-subscriptions/LICENSE | 2 +- sdk/subscription/arm-subscriptions/README.md | 3 +- sdk/subscription/arm-subscriptions/_meta.json | 6 +- .../arm-subscriptions/package.json | 18 +- .../review/arm-subscriptions.api.md | 139 +++++++++- .../arm-subscriptions/src/models/index.ts | 178 ++++++++++++- .../arm-subscriptions/src/models/mappers.ts | 251 +++++++++++++++++- .../src/models/parameters.ts | 36 ++- .../arm-subscriptions/src/operations/alias.ts | 8 +- .../src/operations/billingAccount.ts | 2 +- .../arm-subscriptions/src/operations/index.ts | 4 +- .../src/operations/operations.ts | 4 +- ...scription.ts => subscriptionOperations.ts} | 23 +- .../src/operations/subscriptionPolicy.ts | 10 +- .../src/operations/subscriptions.ts | 237 +++++++++++++++++ .../src/operations/tenants.ts | 131 +++++++++ .../src/operationsInterfaces/index.ts | 4 +- ...scription.ts => subscriptionOperations.ts} | 4 +- .../src/operationsInterfaces/subscriptions.ts | 48 ++++ .../src/operationsInterfaces/tenants.ts | 22 ++ .../src/subscriptionClient.ts | 20 +- 22 files changed, 1109 insertions(+), 100 deletions(-) rename sdk/subscription/arm-subscriptions/src/operations/{subscription.ts => subscriptionOperations.ts} (92%) create mode 100644 sdk/subscription/arm-subscriptions/src/operations/subscriptions.ts create mode 100644 sdk/subscription/arm-subscriptions/src/operations/tenants.ts rename sdk/subscription/arm-subscriptions/src/operationsInterfaces/{subscription.ts => subscriptionOperations.ts} (96%) create mode 100644 sdk/subscription/arm-subscriptions/src/operationsInterfaces/subscriptions.ts create mode 100644 sdk/subscription/arm-subscriptions/src/operationsInterfaces/tenants.ts diff --git a/sdk/subscription/arm-subscriptions/CHANGELOG.md b/sdk/subscription/arm-subscriptions/CHANGELOG.md index dc4b0b725ff7..b27270adc253 100644 --- a/sdk/subscription/arm-subscriptions/CHANGELOG.md +++ b/sdk/subscription/arm-subscriptions/CHANGELOG.md @@ -1,15 +1,52 @@ # Release History - -## 4.0.1 (Unreleased) - -### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes - + +## 5.0.0 (2022-01-12) + +**Features** + + - Added operation group SubscriptionOperations + - Added operation group Subscriptions + - Added operation group Tenants + - Added Interface Location_2 + - Added Interface LocationListResult + - Added Interface Subscription + - Added Interface SubscriptionListResult + - Added Interface SubscriptionPolicies + - Added Interface SubscriptionsGetOptionalParams + - Added Interface SubscriptionsListLocationsOptionalParams + - Added Interface SubscriptionsListNextOptionalParams + - Added Interface SubscriptionsListOptionalParams + - Added Interface TenantIdDescription + - Added Interface TenantListResult + - Added Interface TenantsListNextOptionalParams + - Added Interface TenantsListOptionalParams + - Added Type Alias SpendingLimit + - Added Type Alias SubscriptionsGetResponse + - Added Type Alias SubscriptionsListLocationsResponse + - Added Type Alias SubscriptionsListNextResponse + - Added Type Alias SubscriptionsListResponse + - Added Type Alias SubscriptionState + - Added Type Alias TenantsListNextResponse + - Added Type Alias TenantsListResponse + - Interface CanceledSubscriptionId has a new optional parameter subscriptionId + - Interface EnabledSubscriptionId has a new optional parameter subscriptionId + - Interface RenamedSubscriptionId has a new optional parameter subscriptionId + - Interface SubscriptionAliasResponseProperties has a new optional parameter createdTime + - Class SubscriptionClient has a new parameter subscriptionOperations + - Class SubscriptionClient has a new parameter subscriptions + - Class SubscriptionClient has a new parameter tenants + +**Breaking Changes** + + - Removed operation group Subscription + - Interface CanceledSubscriptionId no longer has parameter value + - Interface EnabledSubscriptionId no longer has parameter value + - Interface RenamedSubscriptionId no longer has parameter value + - Interface SubscriptionClientOptionalParams no longer has parameter apiVersion + - Class SubscriptionClient no longer has parameter apiVersion + - Class SubscriptionClient no longer has parameter subscription + + ## 4.0.0 (2021-12-22) The package of @azure/arm-subscriptions is using our next generation design principles since version 4.0.0, which contains breaking changes. diff --git a/sdk/subscription/arm-subscriptions/LICENSE b/sdk/subscription/arm-subscriptions/LICENSE index ccb63b166732..5d1d36e0af80 100644 --- a/sdk/subscription/arm-subscriptions/LICENSE +++ b/sdk/subscription/arm-subscriptions/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2021 Microsoft +Copyright (c) 2022 Microsoft Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/sdk/subscription/arm-subscriptions/README.md b/sdk/subscription/arm-subscriptions/README.md index 164861ff0676..fca45a751d00 100644 --- a/sdk/subscription/arm-subscriptions/README.md +++ b/sdk/subscription/arm-subscriptions/README.md @@ -49,7 +49,8 @@ For more information about how to create an Azure AD Application check out [this ```javascript const { SubscriptionClient } = require("@azure/arm-subscriptions"); const { DefaultAzureCredential } = require("@azure/identity"); -const client = new SubscriptionClient(new DefaultAzureCredential()); +const subscriptionId = "00000000-0000-0000-0000-000000000000"; +const client = new SubscriptionClient(new DefaultAzureCredential(), subscriptionId); ``` diff --git a/sdk/subscription/arm-subscriptions/_meta.json b/sdk/subscription/arm-subscriptions/_meta.json index a71971d81909..c4288baa8059 100644 --- a/sdk/subscription/arm-subscriptions/_meta.json +++ b/sdk/subscription/arm-subscriptions/_meta.json @@ -1,7 +1,7 @@ { - "commit": "0cd7b3e83d5e7e21222dcc4bdde4565562da0cdf", + "commit": "428c2dd8a6e3b4d59239f8fbbd121d13b21d399d", "readme": "specification/subscription/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/subscription/resource-manager/readme.md --use=@autorest/typescript@6.0.0-alpha.16.20211217.1", + "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=/home/vsts/work/1/s/azure-sdk-for-js ../azure-rest-api-specs/specification/subscription/resource-manager/readme.md --use=@autorest/typescript@6.0.0-alpha.16.20220105.1", "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "use": "@autorest/typescript@6.0.0-alpha.16.20211217.1" + "use": "@autorest/typescript@6.0.0-alpha.16.20220105.1" } \ No newline at end of file diff --git a/sdk/subscription/arm-subscriptions/package.json b/sdk/subscription/arm-subscriptions/package.json index 375f8ae8b1eb..a9c6fa1103c4 100644 --- a/sdk/subscription/arm-subscriptions/package.json +++ b/sdk/subscription/arm-subscriptions/package.json @@ -3,10 +3,8 @@ "sdk-type": "mgmt", "author": "Microsoft Corporation", "description": "A generated SDK for SubscriptionClient.", - "version": "4.0.1", - "engines": { - "node": ">=12.0.0" - }, + "version": "5.0.0", + "engines": { "node": ">=12.0.0" }, "dependencies": { "@azure/core-lro": "^2.2.0", "@azure/abort-controller": "^1.0.0", @@ -16,13 +14,7 @@ "@azure/core-rest-pipeline": "^1.1.0", "tslib": "^2.2.0" }, - "keywords": [ - "node", - "azure", - "typescript", - "browser", - "isomorphic" - ], + "keywords": ["node", "azure", "typescript", "browser", "isomorphic"], "license": "MIT", "main": "./dist/index.js", "module": "./dist-esm/src/index.js", @@ -49,9 +41,7 @@ "type": "git", "url": "https://github.com/Azure/azure-sdk-for-js.git" }, - "bugs": { - "url": "https://github.com/Azure/azure-sdk-for-js/issues" - }, + "bugs": { "url": "https://github.com/Azure/azure-sdk-for-js/issues" }, "files": [ "dist/**/*.js", "dist/**/*.js.map", diff --git a/sdk/subscription/arm-subscriptions/review/arm-subscriptions.api.md b/sdk/subscription/arm-subscriptions/review/arm-subscriptions.api.md index 463fa0ebfa9e..37c2268b781e 100644 --- a/sdk/subscription/arm-subscriptions/review/arm-subscriptions.api.md +++ b/sdk/subscription/arm-subscriptions/review/arm-subscriptions.api.md @@ -104,7 +104,7 @@ export interface BillingAccountPoliciesResponseProperties { // @public export interface CanceledSubscriptionId { - readonly value?: string; + readonly subscriptionId?: string; } // @public @@ -112,7 +112,7 @@ export type CreatedByType = string; // @public export interface EnabledSubscriptionId { - readonly value?: string; + readonly subscriptionId?: string; } // @public @@ -183,6 +183,22 @@ export enum KnownWorkload { Production = "Production" } +// @public +interface Location_2 { + readonly displayName?: string; + readonly id?: string; + readonly latitude?: string; + readonly longitude?: string; + readonly name?: string; + readonly subscriptionId?: string; +} +export { Location_2 as Location } + +// @public +export interface LocationListResult { + value?: Location_2[]; +} + // @public export interface Operation { display?: OperationDisplay; @@ -260,7 +276,7 @@ export interface PutTenantPolicyRequestProperties { // @public export interface RenamedSubscriptionId { - readonly value?: string; + readonly subscriptionId?: string; } // @public @@ -269,14 +285,17 @@ export interface ServiceTenantResponse { tenantName?: string; } +// @public +export type SpendingLimit = "On" | "Off" | "CurrentPeriodOff"; + // @public export interface Subscription { - acceptOwnershipStatus(subscriptionId: string, options?: SubscriptionAcceptOwnershipStatusOptionalParams): Promise; - beginAcceptOwnership(subscriptionId: string, body: AcceptOwnershipRequest, options?: SubscriptionAcceptOwnershipOptionalParams): Promise, SubscriptionAcceptOwnershipResponse>>; - beginAcceptOwnershipAndWait(subscriptionId: string, body: AcceptOwnershipRequest, options?: SubscriptionAcceptOwnershipOptionalParams): Promise; - cancel(subscriptionId: string, options?: SubscriptionCancelOptionalParams): Promise; - enable(subscriptionId: string, options?: SubscriptionEnableOptionalParams): Promise; - rename(subscriptionId: string, body: SubscriptionName, options?: SubscriptionRenameOptionalParams): Promise; + authorizationSource?: string; + readonly displayName?: string; + readonly id?: string; + readonly state?: SubscriptionState; + readonly subscriptionId?: string; + subscriptionPolicies?: SubscriptionPolicies; } // @public @@ -321,6 +340,7 @@ export interface SubscriptionAliasResponseProperties { readonly acceptOwnershipState?: AcceptOwnership; readonly acceptOwnershipUrl?: string; billingScope?: string; + createdTime?: string; displayName?: string; managementGroupId?: string; provisioningState?: ProvisioningState; @@ -348,21 +368,22 @@ export class SubscriptionClient extends coreClient.ServiceClient { // (undocumented) alias: Alias; // (undocumented) - apiVersion: string; - // (undocumented) billingAccount: BillingAccount; // (undocumented) operations: Operations; // (undocumented) - subscription: Subscription; + subscriptionOperations: SubscriptionOperations; // (undocumented) subscriptionPolicy: SubscriptionPolicy; + // (undocumented) + subscriptions: Subscriptions; + // (undocumented) + tenants: Tenants; } // @public export interface SubscriptionClientOptionalParams extends coreClient.ServiceClientOptions { $host?: string; - apiVersion?: string; endpoint?: string; } @@ -373,11 +394,34 @@ export interface SubscriptionEnableOptionalParams extends coreClient.OperationOp // @public export type SubscriptionEnableResponse = EnabledSubscriptionId; +// @public +export interface SubscriptionListResult { + nextLink: string; + value?: Subscription[]; +} + // @public export interface SubscriptionName { subscriptionName?: string; } +// @public +export interface SubscriptionOperations { + acceptOwnershipStatus(subscriptionId: string, options?: SubscriptionAcceptOwnershipStatusOptionalParams): Promise; + beginAcceptOwnership(subscriptionId: string, body: AcceptOwnershipRequest, options?: SubscriptionAcceptOwnershipOptionalParams): Promise, SubscriptionAcceptOwnershipResponse>>; + beginAcceptOwnershipAndWait(subscriptionId: string, body: AcceptOwnershipRequest, options?: SubscriptionAcceptOwnershipOptionalParams): Promise; + cancel(subscriptionId: string, options?: SubscriptionCancelOptionalParams): Promise; + enable(subscriptionId: string, options?: SubscriptionEnableOptionalParams): Promise; + rename(subscriptionId: string, body: SubscriptionName, options?: SubscriptionRenameOptionalParams): Promise; +} + +// @public +export interface SubscriptionPolicies { + readonly locationPlacementId?: string; + readonly quotaId?: string; + readonly spendingLimit?: SpendingLimit; +} + // @public export interface SubscriptionPolicy { addUpdatePolicyForTenant(body: PutTenantPolicyRequestProperties, options?: SubscriptionPolicyAddUpdatePolicyForTenantOptionalParams): Promise; @@ -420,6 +464,44 @@ export interface SubscriptionRenameOptionalParams extends coreClient.OperationOp // @public export type SubscriptionRenameResponse = RenamedSubscriptionId; +// @public +export interface Subscriptions { + get(subscriptionId: string, options?: SubscriptionsGetOptionalParams): Promise; + list(options?: SubscriptionsListOptionalParams): PagedAsyncIterableIterator; + listLocations(subscriptionId: string, options?: SubscriptionsListLocationsOptionalParams): PagedAsyncIterableIterator; +} + +// @public +export interface SubscriptionsGetOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type SubscriptionsGetResponse = Subscription; + +// @public +export interface SubscriptionsListLocationsOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type SubscriptionsListLocationsResponse = LocationListResult; + +// @public +export interface SubscriptionsListNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type SubscriptionsListNextResponse = SubscriptionListResult; + +// @public +export interface SubscriptionsListOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type SubscriptionsListResponse = SubscriptionListResult; + +// @public +export type SubscriptionState = "Enabled" | "Warned" | "PastDue" | "Disabled" | "Deleted"; + // @public export interface SystemData { createdAt?: Date; @@ -430,6 +512,18 @@ export interface SystemData { lastModifiedByType?: CreatedByType; } +// @public +export interface TenantIdDescription { + readonly id?: string; + readonly tenantId?: string; +} + +// @public +export interface TenantListResult { + nextLink: string; + value?: TenantIdDescription[]; +} + // @public export interface TenantPolicy { blockSubscriptionsIntoTenant?: boolean; @@ -438,6 +532,25 @@ export interface TenantPolicy { readonly policyId?: string; } +// @public +export interface Tenants { + list(options?: TenantsListOptionalParams): PagedAsyncIterableIterator; +} + +// @public +export interface TenantsListNextOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type TenantsListNextResponse = TenantListResult; + +// @public +export interface TenantsListOptionalParams extends coreClient.OperationOptions { +} + +// @public +export type TenantsListResponse = TenantListResult; + // @public export type Workload = string; diff --git a/sdk/subscription/arm-subscriptions/src/models/index.ts b/sdk/subscription/arm-subscriptions/src/models/index.ts index e76afd65ee4c..a2d07f6ff54b 100644 --- a/sdk/subscription/arm-subscriptions/src/models/index.ts +++ b/sdk/subscription/arm-subscriptions/src/models/index.ts @@ -8,13 +8,130 @@ import * as coreClient from "@azure/core-client"; +/** Location list operation response. */ +export interface LocationListResult { + /** An array of locations. */ + value?: Location[]; +} + +/** Location information. */ +export interface Location { + /** + * The fully qualified ID of the location. For example, /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly id?: string; + /** + * The subscription ID. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly subscriptionId?: string; + /** + * The location name. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly name?: string; + /** + * The display name of the location. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly displayName?: string; + /** + * The latitude of the location. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly latitude?: string; + /** + * The longitude of the location. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly longitude?: string; +} + +/** Subscription information. */ +export interface Subscription { + /** + * The fully qualified ID for the subscription. For example, /subscriptions/00000000-0000-0000-0000-000000000000. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly id?: string; + /** + * The subscription ID. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly subscriptionId?: string; + /** + * The subscription display name. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly displayName?: string; + /** + * The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly state?: SubscriptionState; + /** The subscription policies. */ + subscriptionPolicies?: SubscriptionPolicies; + /** The authorization source of the request. Valid values are one or more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, RoleBased'. */ + authorizationSource?: string; +} + +/** Subscription policies. */ +export interface SubscriptionPolicies { + /** + * The subscription location placement ID. The ID indicates which regions are visible for a subscription. For example, a subscription with a location placement Id of Public_2014-09-01 has access to Azure public regions. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly locationPlacementId?: string; + /** + * The subscription quota ID. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly quotaId?: string; + /** + * The subscription spending limit. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly spendingLimit?: SpendingLimit; +} + +/** Subscription list operation response. */ +export interface SubscriptionListResult { + /** An array of subscriptions. */ + value?: Subscription[]; + /** The URL to get the next set of results. */ + nextLink: string; +} + +/** Tenant Ids information. */ +export interface TenantListResult { + /** An array of tenants. */ + value?: TenantIdDescription[]; + /** The URL to use for getting the next set of results. */ + nextLink: string; +} + +/** Tenant Id information. */ +export interface TenantIdDescription { + /** + * The fully qualified ID of the tenant. For example, /tenants/00000000-0000-0000-0000-000000000000. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly id?: string; + /** + * The tenant ID. For example, 00000000-0000-0000-0000-000000000000. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly tenantId?: string; +} + /** The ID of the canceled subscription */ export interface CanceledSubscriptionId { /** * The ID of the canceled subscription * NOTE: This property will not be serialized. It can only be populated by the server. */ - readonly value?: string; + readonly subscriptionId?: string; } /** Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message. */ @@ -47,7 +164,7 @@ export interface RenamedSubscriptionId { * The ID of the subscriptions that is being renamed * NOTE: This property will not be serialized. It can only be populated by the server. */ - readonly value?: string; + readonly subscriptionId?: string; } /** The ID of the subscriptions that is being enabled */ @@ -56,7 +173,7 @@ export interface EnabledSubscriptionId { * The ID of the subscriptions that is being enabled * NOTE: This property will not be serialized. It can only be populated by the server. */ - readonly value?: string; + readonly subscriptionId?: string; } /** Result of the request to list operations. It contains a list of operations and a URL link to get the next set of results. */ @@ -190,6 +307,8 @@ export interface SubscriptionAliasResponseProperties { subscriptionOwnerId?: string; /** The Management Group Id. */ managementGroupId?: string; + /** Created Time */ + createdTime?: string; /** Tags for the subscription */ tags?: { [propertyName: string]: string }; } @@ -451,6 +570,57 @@ export enum KnownCreatedByType { * **Key** */ export type CreatedByType = string; +/** Defines values for SubscriptionState. */ +export type SubscriptionState = + | "Enabled" + | "Warned" + | "PastDue" + | "Disabled" + | "Deleted"; +/** Defines values for SpendingLimit. */ +export type SpendingLimit = "On" | "Off" | "CurrentPeriodOff"; + +/** Optional parameters. */ +export interface SubscriptionsListLocationsOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listLocations operation. */ +export type SubscriptionsListLocationsResponse = LocationListResult; + +/** Optional parameters. */ +export interface SubscriptionsGetOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the get operation. */ +export type SubscriptionsGetResponse = Subscription; + +/** Optional parameters. */ +export interface SubscriptionsListOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the list operation. */ +export type SubscriptionsListResponse = SubscriptionListResult; + +/** Optional parameters. */ +export interface SubscriptionsListNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listNext operation. */ +export type SubscriptionsListNextResponse = SubscriptionListResult; + +/** Optional parameters. */ +export interface TenantsListOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the list operation. */ +export type TenantsListResponse = TenantListResult; + +/** Optional parameters. */ +export interface TenantsListNextOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the listNext operation. */ +export type TenantsListNextResponse = TenantListResult; /** Optional parameters. */ export interface SubscriptionCancelOptionalParams @@ -573,8 +743,6 @@ export interface SubscriptionClientOptionalParams extends coreClient.ServiceClientOptions { /** server parameter */ $host?: string; - /** Api Version */ - apiVersion?: string; /** Overrides client endpoint. */ endpoint?: string; } diff --git a/sdk/subscription/arm-subscriptions/src/models/mappers.ts b/sdk/subscription/arm-subscriptions/src/models/mappers.ts index bd0e0f1c2216..2cd311ec000a 100644 --- a/sdk/subscription/arm-subscriptions/src/models/mappers.ts +++ b/sdk/subscription/arm-subscriptions/src/models/mappers.ts @@ -8,13 +8,246 @@ import * as coreClient from "@azure/core-client"; -export const CanceledSubscriptionId: coreClient.CompositeMapper = { +export const LocationListResult: coreClient.CompositeMapper = { type: { name: "Composite", - className: "CanceledSubscriptionId", + className: "LocationListResult", modelProperties: { value: { serializedName: "value", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "Location" + } + } + } + } + } + } +}; + +export const Location: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "Location", + modelProperties: { + id: { + serializedName: "id", + readOnly: true, + type: { + name: "String" + } + }, + subscriptionId: { + serializedName: "subscriptionId", + readOnly: true, + type: { + name: "String" + } + }, + name: { + serializedName: "name", + readOnly: true, + type: { + name: "String" + } + }, + displayName: { + serializedName: "displayName", + readOnly: true, + type: { + name: "String" + } + }, + latitude: { + serializedName: "latitude", + readOnly: true, + type: { + name: "String" + } + }, + longitude: { + serializedName: "longitude", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const Subscription: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "Subscription", + modelProperties: { + id: { + serializedName: "id", + readOnly: true, + type: { + name: "String" + } + }, + subscriptionId: { + serializedName: "subscriptionId", + readOnly: true, + type: { + name: "String" + } + }, + displayName: { + serializedName: "displayName", + readOnly: true, + type: { + name: "String" + } + }, + state: { + serializedName: "state", + readOnly: true, + type: { + name: "Enum", + allowedValues: ["Enabled", "Warned", "PastDue", "Disabled", "Deleted"] + } + }, + subscriptionPolicies: { + serializedName: "subscriptionPolicies", + type: { + name: "Composite", + className: "SubscriptionPolicies" + } + }, + authorizationSource: { + serializedName: "authorizationSource", + type: { + name: "String" + } + } + } + } +}; + +export const SubscriptionPolicies: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "SubscriptionPolicies", + modelProperties: { + locationPlacementId: { + serializedName: "locationPlacementId", + readOnly: true, + type: { + name: "String" + } + }, + quotaId: { + serializedName: "quotaId", + readOnly: true, + type: { + name: "String" + } + }, + spendingLimit: { + serializedName: "spendingLimit", + readOnly: true, + type: { + name: "Enum", + allowedValues: ["On", "Off", "CurrentPeriodOff"] + } + } + } + } +}; + +export const SubscriptionListResult: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "SubscriptionListResult", + modelProperties: { + value: { + serializedName: "value", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "Subscription" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + required: true, + type: { + name: "String" + } + } + } + } +}; + +export const TenantListResult: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "TenantListResult", + modelProperties: { + value: { + serializedName: "value", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "TenantIdDescription" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + required: true, + type: { + name: "String" + } + } + } + } +}; + +export const TenantIdDescription: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "TenantIdDescription", + modelProperties: { + id: { + serializedName: "id", + readOnly: true, + type: { + name: "String" + } + }, + tenantId: { + serializedName: "tenantId", + readOnly: true, + type: { + name: "String" + } + } + } + } +}; + +export const CanceledSubscriptionId: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "CanceledSubscriptionId", + modelProperties: { + subscriptionId: { + serializedName: "subscriptionId", readOnly: true, type: { name: "String" @@ -93,8 +326,8 @@ export const RenamedSubscriptionId: coreClient.CompositeMapper = { name: "Composite", className: "RenamedSubscriptionId", modelProperties: { - value: { - serializedName: "value", + subscriptionId: { + serializedName: "subscriptionId", readOnly: true, type: { name: "String" @@ -109,8 +342,8 @@ export const EnabledSubscriptionId: coreClient.CompositeMapper = { name: "Composite", className: "EnabledSubscriptionId", modelProperties: { - value: { - serializedName: "value", + subscriptionId: { + serializedName: "subscriptionId", readOnly: true, type: { name: "String" @@ -416,6 +649,12 @@ export const SubscriptionAliasResponseProperties: coreClient.CompositeMapper = { name: "String" } }, + createdTime: { + serializedName: "createdTime", + type: { + name: "String" + } + }, tags: { serializedName: "tags", type: { diff --git a/sdk/subscription/arm-subscriptions/src/models/parameters.ts b/sdk/subscription/arm-subscriptions/src/models/parameters.ts index 447b3f3ffb4d..9e3494646de8 100644 --- a/sdk/subscription/arm-subscriptions/src/models/parameters.ts +++ b/sdk/subscription/arm-subscriptions/src/models/parameters.ts @@ -54,6 +54,30 @@ export const subscriptionId: OperationURLParameter = { }; export const apiVersion: OperationQueryParameter = { + parameterPath: "apiVersion", + mapper: { + defaultValue: "2016-06-01", + isConstant: true, + serializedName: "api-version", + type: { + name: "String" + } + } +}; + +export const nextLink: OperationURLParameter = { + parameterPath: "nextLink", + mapper: { + serializedName: "nextLink", + required: true, + type: { + name: "String" + } + }, + skipEncoding: true +}; + +export const apiVersion1: OperationQueryParameter = { parameterPath: "apiVersion", mapper: { defaultValue: "2021-10-01", @@ -87,18 +111,6 @@ export const body1: OperationParameter = { mapper: AcceptOwnershipRequestMapper }; -export const nextLink: OperationURLParameter = { - parameterPath: "nextLink", - mapper: { - serializedName: "nextLink", - required: true, - type: { - name: "String" - } - }, - skipEncoding: true -}; - export const body2: OperationParameter = { parameterPath: "body", mapper: PutAliasRequestMapper diff --git a/sdk/subscription/arm-subscriptions/src/operations/alias.ts b/sdk/subscription/arm-subscriptions/src/operations/alias.ts index 711fe95a5f6b..c04684911d03 100644 --- a/sdk/subscription/arm-subscriptions/src/operations/alias.ts +++ b/sdk/subscription/arm-subscriptions/src/operations/alias.ts @@ -184,7 +184,7 @@ const createOperationSpec: coreClient.OperationSpec = { } }, requestBody: Parameters.body2, - queryParameters: [Parameters.apiVersion], + queryParameters: [Parameters.apiVersion1], urlParameters: [Parameters.$host, Parameters.aliasName], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", @@ -201,7 +201,7 @@ const getOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.ErrorResponseBody } }, - queryParameters: [Parameters.apiVersion], + queryParameters: [Parameters.apiVersion1], urlParameters: [Parameters.$host, Parameters.aliasName], headerParameters: [Parameters.accept], serializer @@ -216,7 +216,7 @@ const deleteOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.ErrorResponseBody } }, - queryParameters: [Parameters.apiVersion], + queryParameters: [Parameters.apiVersion1], urlParameters: [Parameters.$host, Parameters.aliasName], headerParameters: [Parameters.accept], serializer @@ -232,7 +232,7 @@ const listOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.ErrorResponseBody } }, - queryParameters: [Parameters.apiVersion], + queryParameters: [Parameters.apiVersion1], urlParameters: [Parameters.$host], headerParameters: [Parameters.accept], serializer diff --git a/sdk/subscription/arm-subscriptions/src/operations/billingAccount.ts b/sdk/subscription/arm-subscriptions/src/operations/billingAccount.ts index 0e96f93ac594..91e372e6f18a 100644 --- a/sdk/subscription/arm-subscriptions/src/operations/billingAccount.ts +++ b/sdk/subscription/arm-subscriptions/src/operations/billingAccount.ts @@ -58,7 +58,7 @@ const getPolicyOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.ErrorResponseBody } }, - queryParameters: [Parameters.apiVersion], + queryParameters: [Parameters.apiVersion1], urlParameters: [Parameters.$host, Parameters.billingAccountId], headerParameters: [Parameters.accept], serializer diff --git a/sdk/subscription/arm-subscriptions/src/operations/index.ts b/sdk/subscription/arm-subscriptions/src/operations/index.ts index c39ebaa92543..2a569a3b44dc 100644 --- a/sdk/subscription/arm-subscriptions/src/operations/index.ts +++ b/sdk/subscription/arm-subscriptions/src/operations/index.ts @@ -6,7 +6,9 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -export * from "./subscription"; +export * from "./subscriptions"; +export * from "./tenants"; +export * from "./subscriptionOperations"; export * from "./operations"; export * from "./alias"; export * from "./subscriptionPolicy"; diff --git a/sdk/subscription/arm-subscriptions/src/operations/operations.ts b/sdk/subscription/arm-subscriptions/src/operations/operations.ts index 9a7bf4146673..5173f3aa9812 100644 --- a/sdk/subscription/arm-subscriptions/src/operations/operations.ts +++ b/sdk/subscription/arm-subscriptions/src/operations/operations.ts @@ -114,7 +114,7 @@ const listOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.ErrorResponseBody } }, - queryParameters: [Parameters.apiVersion], + queryParameters: [Parameters.apiVersion1], urlParameters: [Parameters.$host], headerParameters: [Parameters.accept], serializer @@ -130,7 +130,7 @@ const listNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.ErrorResponseBody } }, - queryParameters: [Parameters.apiVersion], + queryParameters: [Parameters.apiVersion1], urlParameters: [Parameters.$host, Parameters.nextLink], headerParameters: [Parameters.accept], serializer diff --git a/sdk/subscription/arm-subscriptions/src/operations/subscription.ts b/sdk/subscription/arm-subscriptions/src/operations/subscriptionOperations.ts similarity index 92% rename from sdk/subscription/arm-subscriptions/src/operations/subscription.ts rename to sdk/subscription/arm-subscriptions/src/operations/subscriptionOperations.ts index 18d58f8d7fcd..4c28cfc786ce 100644 --- a/sdk/subscription/arm-subscriptions/src/operations/subscription.ts +++ b/sdk/subscription/arm-subscriptions/src/operations/subscriptionOperations.ts @@ -6,7 +6,7 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { Subscription } from "../operationsInterfaces"; +import { SubscriptionOperations } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; @@ -28,12 +28,12 @@ import { SubscriptionAcceptOwnershipStatusResponse } from "../models"; -/** Class containing Subscription operations. */ -export class SubscriptionImpl implements Subscription { +/** Class containing SubscriptionOperations operations. */ +export class SubscriptionOperationsImpl implements SubscriptionOperations { private readonly client: SubscriptionClient; /** - * Initialize a new instance of the class Subscription class. + * Initialize a new instance of the class SubscriptionOperations class. * @param client Reference to the service client */ constructor(client: SubscriptionClient) { @@ -202,7 +202,7 @@ const cancelOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.ErrorResponseBody } }, - queryParameters: [Parameters.apiVersion], + queryParameters: [Parameters.apiVersion1], urlParameters: [Parameters.$host, Parameters.subscriptionId], headerParameters: [Parameters.accept], serializer @@ -220,7 +220,7 @@ const renameOperationSpec: coreClient.OperationSpec = { } }, requestBody: Parameters.body, - queryParameters: [Parameters.apiVersion], + queryParameters: [Parameters.apiVersion1], urlParameters: [Parameters.$host, Parameters.subscriptionId], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", @@ -238,13 +238,14 @@ const enableOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.ErrorResponseBody } }, - queryParameters: [Parameters.apiVersion], + queryParameters: [Parameters.apiVersion1], urlParameters: [Parameters.$host, Parameters.subscriptionId], headerParameters: [Parameters.accept], serializer }; const acceptOwnershipOperationSpec: coreClient.OperationSpec = { - path: "/providers/Microsoft.Subscription/{subscriptionId}/acceptOwnership", + path: + "/providers/Microsoft.Subscription/subscriptions/{subscriptionId}/acceptOwnership", httpMethod: "POST", responses: { 200: { @@ -264,7 +265,7 @@ const acceptOwnershipOperationSpec: coreClient.OperationSpec = { } }, requestBody: Parameters.body1, - queryParameters: [Parameters.apiVersion], + queryParameters: [Parameters.apiVersion1], urlParameters: [Parameters.$host, Parameters.subscriptionId], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", @@ -272,7 +273,7 @@ const acceptOwnershipOperationSpec: coreClient.OperationSpec = { }; const acceptOwnershipStatusOperationSpec: coreClient.OperationSpec = { path: - "/providers/Microsoft.Subscription/{subscriptionId}/acceptOwnershipStatus", + "/providers/Microsoft.Subscription/subscriptions/{subscriptionId}/acceptOwnershipStatus", httpMethod: "GET", responses: { 200: { @@ -282,7 +283,7 @@ const acceptOwnershipStatusOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.ErrorResponseBody } }, - queryParameters: [Parameters.apiVersion], + queryParameters: [Parameters.apiVersion1], urlParameters: [Parameters.$host, Parameters.subscriptionId], headerParameters: [Parameters.accept], serializer diff --git a/sdk/subscription/arm-subscriptions/src/operations/subscriptionPolicy.ts b/sdk/subscription/arm-subscriptions/src/operations/subscriptionPolicy.ts index f905b1b6ea8a..9a93d3f93f9a 100644 --- a/sdk/subscription/arm-subscriptions/src/operations/subscriptionPolicy.ts +++ b/sdk/subscription/arm-subscriptions/src/operations/subscriptionPolicy.ts @@ -143,7 +143,7 @@ const addUpdatePolicyForTenantOperationSpec: coreClient.OperationSpec = { path: "/providers/Microsoft.Subscription/policies/default", httpMethod: "PUT", responses: { - 201: { + 200: { bodyMapper: Mappers.GetTenantPolicyResponse }, default: { @@ -151,7 +151,7 @@ const addUpdatePolicyForTenantOperationSpec: coreClient.OperationSpec = { } }, requestBody: Parameters.body3, - queryParameters: [Parameters.apiVersion], + queryParameters: [Parameters.apiVersion1], urlParameters: [Parameters.$host], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", @@ -168,7 +168,7 @@ const getPolicyForTenantOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.ErrorResponseBody } }, - queryParameters: [Parameters.apiVersion], + queryParameters: [Parameters.apiVersion1], urlParameters: [Parameters.$host], headerParameters: [Parameters.accept], serializer @@ -184,7 +184,7 @@ const listPolicyForTenantOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.ErrorResponseBody } }, - queryParameters: [Parameters.apiVersion], + queryParameters: [Parameters.apiVersion1], urlParameters: [Parameters.$host], headerParameters: [Parameters.accept], serializer @@ -200,7 +200,7 @@ const listPolicyForTenantNextOperationSpec: coreClient.OperationSpec = { bodyMapper: Mappers.ErrorResponseBody } }, - queryParameters: [Parameters.apiVersion], + queryParameters: [Parameters.apiVersion1], urlParameters: [Parameters.$host, Parameters.nextLink], headerParameters: [Parameters.accept], serializer diff --git a/sdk/subscription/arm-subscriptions/src/operations/subscriptions.ts b/sdk/subscription/arm-subscriptions/src/operations/subscriptions.ts new file mode 100644 index 000000000000..bf19d7b45b8f --- /dev/null +++ b/sdk/subscription/arm-subscriptions/src/operations/subscriptions.ts @@ -0,0 +1,237 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { Subscriptions } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { SubscriptionClient } from "../subscriptionClient"; +import { + Location, + SubscriptionsListLocationsOptionalParams, + Subscription, + SubscriptionsListNextOptionalParams, + SubscriptionsListOptionalParams, + SubscriptionsListLocationsResponse, + SubscriptionsGetOptionalParams, + SubscriptionsGetResponse, + SubscriptionsListResponse, + SubscriptionsListNextResponse +} from "../models"; + +/// +/** Class containing Subscriptions operations. */ +export class SubscriptionsImpl implements Subscriptions { + private readonly client: SubscriptionClient; + + /** + * Initialize a new instance of the class Subscriptions class. + * @param client Reference to the service client + */ + constructor(client: SubscriptionClient) { + this.client = client; + } + + /** + * This operation provides all the locations that are available for resource providers; however, each + * resource provider may support a subset of this list. + * @param subscriptionId The ID of the target subscription. + * @param options The options parameters. + */ + public listLocations( + subscriptionId: string, + options?: SubscriptionsListLocationsOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listLocationsPagingAll(subscriptionId, options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: () => { + return this.listLocationsPagingPage(subscriptionId, options); + } + }; + } + + private async *listLocationsPagingPage( + subscriptionId: string, + options?: SubscriptionsListLocationsOptionalParams + ): AsyncIterableIterator { + let result = await this._listLocations(subscriptionId, options); + yield result.value || []; + } + + private async *listLocationsPagingAll( + subscriptionId: string, + options?: SubscriptionsListLocationsOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listLocationsPagingPage( + subscriptionId, + options + )) { + yield* page; + } + } + + /** + * Gets all subscriptions for a tenant. + * @param options The options parameters. + */ + public list( + options?: SubscriptionsListOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listPagingAll(options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: () => { + return this.listPagingPage(options); + } + }; + } + + private async *listPagingPage( + options?: SubscriptionsListOptionalParams + ): AsyncIterableIterator { + let result = await this._list(options); + yield result.value || []; + let continuationToken = result.nextLink; + while (continuationToken) { + result = await this._listNext(continuationToken, options); + continuationToken = result.nextLink; + yield result.value || []; + } + } + + private async *listPagingAll( + options?: SubscriptionsListOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listPagingPage(options)) { + yield* page; + } + } + + /** + * This operation provides all the locations that are available for resource providers; however, each + * resource provider may support a subset of this list. + * @param subscriptionId The ID of the target subscription. + * @param options The options parameters. + */ + private _listLocations( + subscriptionId: string, + options?: SubscriptionsListLocationsOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { subscriptionId, options }, + listLocationsOperationSpec + ); + } + + /** + * Gets details about a specified subscription. + * @param subscriptionId The ID of the target subscription. + * @param options The options parameters. + */ + get( + subscriptionId: string, + options?: SubscriptionsGetOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { subscriptionId, options }, + getOperationSpec + ); + } + + /** + * Gets all subscriptions for a tenant. + * @param options The options parameters. + */ + private _list( + options?: SubscriptionsListOptionalParams + ): Promise { + return this.client.sendOperationRequest({ options }, listOperationSpec); + } + + /** + * ListNext + * @param nextLink The nextLink from the previous successful call to the List method. + * @param options The options parameters. + */ + private _listNext( + nextLink: string, + options?: SubscriptionsListNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { nextLink, options }, + listNextOperationSpec + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const listLocationsOperationSpec: coreClient.OperationSpec = { + path: "/subscriptions/{subscriptionId}/locations", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.LocationListResult + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.subscriptionId], + headerParameters: [Parameters.accept], + serializer +}; +const getOperationSpec: coreClient.OperationSpec = { + path: "/subscriptions/{subscriptionId}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.Subscription + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.subscriptionId], + headerParameters: [Parameters.accept], + serializer +}; +const listOperationSpec: coreClient.OperationSpec = { + path: "/subscriptions", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.SubscriptionListResult + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host], + headerParameters: [Parameters.accept], + serializer +}; +const listNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.SubscriptionListResult + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.nextLink], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/subscription/arm-subscriptions/src/operations/tenants.ts b/sdk/subscription/arm-subscriptions/src/operations/tenants.ts new file mode 100644 index 000000000000..2c55e1cd3aac --- /dev/null +++ b/sdk/subscription/arm-subscriptions/src/operations/tenants.ts @@ -0,0 +1,131 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the 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 { Tenants } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { SubscriptionClient } from "../subscriptionClient"; +import { + TenantIdDescription, + TenantsListNextOptionalParams, + TenantsListOptionalParams, + TenantsListResponse, + TenantsListNextResponse +} from "../models"; + +/// +/** Class containing Tenants operations. */ +export class TenantsImpl implements Tenants { + private readonly client: SubscriptionClient; + + /** + * Initialize a new instance of the class Tenants class. + * @param client Reference to the service client + */ + constructor(client: SubscriptionClient) { + this.client = client; + } + + /** + * Gets the tenants for your account. + * @param options The options parameters. + */ + public list( + options?: TenantsListOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listPagingAll(options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: () => { + return this.listPagingPage(options); + } + }; + } + + private async *listPagingPage( + options?: TenantsListOptionalParams + ): AsyncIterableIterator { + let result = await this._list(options); + yield result.value || []; + let continuationToken = result.nextLink; + while (continuationToken) { + result = await this._listNext(continuationToken, options); + continuationToken = result.nextLink; + yield result.value || []; + } + } + + private async *listPagingAll( + options?: TenantsListOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listPagingPage(options)) { + yield* page; + } + } + + /** + * Gets the tenants for your account. + * @param options The options parameters. + */ + private _list( + options?: TenantsListOptionalParams + ): Promise { + return this.client.sendOperationRequest({ options }, listOperationSpec); + } + + /** + * ListNext + * @param nextLink The nextLink from the previous successful call to the List method. + * @param options The options parameters. + */ + private _listNext( + nextLink: string, + options?: TenantsListNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { nextLink, options }, + listNextOperationSpec + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const listOperationSpec: coreClient.OperationSpec = { + path: "/tenants", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.TenantListResult + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host], + headerParameters: [Parameters.accept], + serializer +}; +const listNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.TenantListResult + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.nextLink], + headerParameters: [Parameters.accept], + serializer +}; diff --git a/sdk/subscription/arm-subscriptions/src/operationsInterfaces/index.ts b/sdk/subscription/arm-subscriptions/src/operationsInterfaces/index.ts index c39ebaa92543..2a569a3b44dc 100644 --- a/sdk/subscription/arm-subscriptions/src/operationsInterfaces/index.ts +++ b/sdk/subscription/arm-subscriptions/src/operationsInterfaces/index.ts @@ -6,7 +6,9 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -export * from "./subscription"; +export * from "./subscriptions"; +export * from "./tenants"; +export * from "./subscriptionOperations"; export * from "./operations"; export * from "./alias"; export * from "./subscriptionPolicy"; diff --git a/sdk/subscription/arm-subscriptions/src/operationsInterfaces/subscription.ts b/sdk/subscription/arm-subscriptions/src/operationsInterfaces/subscriptionOperations.ts similarity index 96% rename from sdk/subscription/arm-subscriptions/src/operationsInterfaces/subscription.ts rename to sdk/subscription/arm-subscriptions/src/operationsInterfaces/subscriptionOperations.ts index 783273102e86..ee66d9822d36 100644 --- a/sdk/subscription/arm-subscriptions/src/operationsInterfaces/subscription.ts +++ b/sdk/subscription/arm-subscriptions/src/operationsInterfaces/subscriptionOperations.ts @@ -22,8 +22,8 @@ import { SubscriptionAcceptOwnershipStatusResponse } from "../models"; -/** Interface representing a Subscription. */ -export interface Subscription { +/** Interface representing a SubscriptionOperations. */ +export interface SubscriptionOperations { /** * The operation to cancel a subscription * @param subscriptionId Subscription Id. diff --git a/sdk/subscription/arm-subscriptions/src/operationsInterfaces/subscriptions.ts b/sdk/subscription/arm-subscriptions/src/operationsInterfaces/subscriptions.ts new file mode 100644 index 000000000000..23e6c628c7a7 --- /dev/null +++ b/sdk/subscription/arm-subscriptions/src/operationsInterfaces/subscriptions.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { + Location, + SubscriptionsListLocationsOptionalParams, + Subscription, + SubscriptionsListOptionalParams, + SubscriptionsGetOptionalParams, + SubscriptionsGetResponse +} from "../models"; + +/// +/** Interface representing a Subscriptions. */ +export interface Subscriptions { + /** + * This operation provides all the locations that are available for resource providers; however, each + * resource provider may support a subset of this list. + * @param subscriptionId The ID of the target subscription. + * @param options The options parameters. + */ + listLocations( + subscriptionId: string, + options?: SubscriptionsListLocationsOptionalParams + ): PagedAsyncIterableIterator; + /** + * Gets all subscriptions for a tenant. + * @param options The options parameters. + */ + list( + options?: SubscriptionsListOptionalParams + ): PagedAsyncIterableIterator; + /** + * Gets details about a specified subscription. + * @param subscriptionId The ID of the target subscription. + * @param options The options parameters. + */ + get( + subscriptionId: string, + options?: SubscriptionsGetOptionalParams + ): Promise; +} diff --git a/sdk/subscription/arm-subscriptions/src/operationsInterfaces/tenants.ts b/sdk/subscription/arm-subscriptions/src/operationsInterfaces/tenants.ts new file mode 100644 index 000000000000..423790d0f0ac --- /dev/null +++ b/sdk/subscription/arm-subscriptions/src/operationsInterfaces/tenants.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the 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 { TenantIdDescription, TenantsListOptionalParams } from "../models"; + +/// +/** Interface representing a Tenants. */ +export interface Tenants { + /** + * Gets the tenants for your account. + * @param options The options parameters. + */ + list( + options?: TenantsListOptionalParams + ): PagedAsyncIterableIterator; +} diff --git a/sdk/subscription/arm-subscriptions/src/subscriptionClient.ts b/sdk/subscription/arm-subscriptions/src/subscriptionClient.ts index 69e99e301383..fa93e65267c1 100644 --- a/sdk/subscription/arm-subscriptions/src/subscriptionClient.ts +++ b/sdk/subscription/arm-subscriptions/src/subscriptionClient.ts @@ -9,14 +9,18 @@ import * as coreClient from "@azure/core-client"; import * as coreAuth from "@azure/core-auth"; import { - SubscriptionImpl, + SubscriptionsImpl, + TenantsImpl, + SubscriptionOperationsImpl, OperationsImpl, AliasImpl, SubscriptionPolicyImpl, BillingAccountImpl } from "./operations"; import { - Subscription, + Subscriptions, + Tenants, + SubscriptionOperations, Operations, Alias, SubscriptionPolicy, @@ -26,7 +30,6 @@ import { SubscriptionClientOptionalParams } from "./models"; export class SubscriptionClient extends coreClient.ServiceClient { $host: string; - apiVersion: string; /** * Initializes a new instance of the SubscriptionClient class. @@ -50,7 +53,7 @@ export class SubscriptionClient extends coreClient.ServiceClient { credential: credentials }; - const packageDetails = `azsdk-js-arm-subscriptions/4.0.0`; + const packageDetails = `azsdk-js-arm-subscriptions/5.0.0`; const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}` @@ -71,15 +74,18 @@ export class SubscriptionClient extends coreClient.ServiceClient { // Assigning values to Constant parameters this.$host = options.$host || "https://management.azure.com"; - this.apiVersion = options.apiVersion || "2021-10-01"; - this.subscription = new SubscriptionImpl(this); + this.subscriptions = new SubscriptionsImpl(this); + this.tenants = new TenantsImpl(this); + this.subscriptionOperations = new SubscriptionOperationsImpl(this); this.operations = new OperationsImpl(this); this.alias = new AliasImpl(this); this.subscriptionPolicy = new SubscriptionPolicyImpl(this); this.billingAccount = new BillingAccountImpl(this); } - subscription: Subscription; + subscriptions: Subscriptions; + tenants: Tenants; + subscriptionOperations: SubscriptionOperations; operations: Operations; alias: Alias; subscriptionPolicy: SubscriptionPolicy;