Initial commit

This commit is contained in:
2025-03-07 19:22:02 +01:00
commit 4a98255d83
55743 changed files with 5280367 additions and 0 deletions
+241
View File
@@ -0,0 +1,241 @@
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the 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 { Alias } 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 { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro";
import { LroImpl } from "../lroImpl";
import {
PutAliasRequest,
AliasCreateOptionalParams,
AliasCreateResponse,
AliasGetOptionalParams,
AliasGetResponse,
AliasDeleteOptionalParams,
AliasListOptionalParams,
AliasListResponse
} from "../models";
/** Class containing Alias operations. */
export class AliasImpl implements Alias {
private readonly client: SubscriptionClient;
/**
* Initialize a new instance of the class Alias class.
* @param client Reference to the service client
*/
constructor(client: SubscriptionClient) {
this.client = client;
}
/**
* Create Alias Subscription.
* @param aliasName AliasName is the name for the subscription creation request. Note that this is not
* the same as subscription name and this doesnt have any other lifecycle need beyond the request for
* subscription creation.
* @param body The parameters required to create a new subscription.
* @param options The options parameters.
*/
async beginCreate(
aliasName: string,
body: PutAliasRequest,
options?: AliasCreateOptionalParams
): Promise<
PollerLike<PollOperationState<AliasCreateResponse>, AliasCreateResponse>
> {
const directSendOperation = async (
args: coreClient.OperationArguments,
spec: coreClient.OperationSpec
): Promise<AliasCreateResponse> => {
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,
{ aliasName, body, options },
createOperationSpec
);
const poller = new LroEngine(lro, {
resumeFrom: options?.resumeFrom,
intervalInMs: options?.updateIntervalInMs
});
await poller.poll();
return poller;
}
/**
* Create Alias Subscription.
* @param aliasName AliasName is the name for the subscription creation request. Note that this is not
* the same as subscription name and this doesnt have any other lifecycle need beyond the request for
* subscription creation.
* @param body The parameters required to create a new subscription.
* @param options The options parameters.
*/
async beginCreateAndWait(
aliasName: string,
body: PutAliasRequest,
options?: AliasCreateOptionalParams
): Promise<AliasCreateResponse> {
const poller = await this.beginCreate(aliasName, body, options);
return poller.pollUntilDone();
}
/**
* Get Alias Subscription.
* @param aliasName AliasName is the name for the subscription creation request. Note that this is not
* the same as subscription name and this doesnt have any other lifecycle need beyond the request for
* subscription creation.
* @param options The options parameters.
*/
get(
aliasName: string,
options?: AliasGetOptionalParams
): Promise<AliasGetResponse> {
return this.client.sendOperationRequest(
{ aliasName, options },
getOperationSpec
);
}
/**
* Delete Alias.
* @param aliasName AliasName is the name for the subscription creation request. Note that this is not
* the same as subscription name and this doesnt have any other lifecycle need beyond the request for
* subscription creation.
* @param options The options parameters.
*/
delete(
aliasName: string,
options?: AliasDeleteOptionalParams
): Promise<void> {
return this.client.sendOperationRequest(
{ aliasName, options },
deleteOperationSpec
);
}
/**
* List Alias Subscription.
* @param options The options parameters.
*/
list(options?: AliasListOptionalParams): Promise<AliasListResponse> {
return this.client.sendOperationRequest({ options }, listOperationSpec);
}
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const createOperationSpec: coreClient.OperationSpec = {
path: "/providers/Microsoft.Subscription/aliases/{aliasName}",
httpMethod: "PUT",
responses: {
200: {
bodyMapper: Mappers.SubscriptionAliasResponse
},
201: {
bodyMapper: Mappers.SubscriptionAliasResponse
},
202: {
bodyMapper: Mappers.SubscriptionAliasResponse
},
204: {
bodyMapper: Mappers.SubscriptionAliasResponse
},
default: {
bodyMapper: Mappers.ErrorResponseBody
}
},
requestBody: Parameters.body2,
queryParameters: [Parameters.apiVersion1],
urlParameters: [Parameters.$host, Parameters.aliasName],
headerParameters: [Parameters.accept, Parameters.contentType],
mediaType: "json",
serializer
};
const getOperationSpec: coreClient.OperationSpec = {
path: "/providers/Microsoft.Subscription/aliases/{aliasName}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.SubscriptionAliasResponse
},
default: {
bodyMapper: Mappers.ErrorResponseBody
}
},
queryParameters: [Parameters.apiVersion1],
urlParameters: [Parameters.$host, Parameters.aliasName],
headerParameters: [Parameters.accept],
serializer
};
const deleteOperationSpec: coreClient.OperationSpec = {
path: "/providers/Microsoft.Subscription/aliases/{aliasName}",
httpMethod: "DELETE",
responses: {
200: {},
204: {},
default: {
bodyMapper: Mappers.ErrorResponseBody
}
},
queryParameters: [Parameters.apiVersion1],
urlParameters: [Parameters.$host, Parameters.aliasName],
headerParameters: [Parameters.accept],
serializer
};
const listOperationSpec: coreClient.OperationSpec = {
path: "/providers/Microsoft.Subscription/aliases",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.SubscriptionAliasListResult
},
default: {
bodyMapper: Mappers.ErrorResponseBody
}
},
queryParameters: [Parameters.apiVersion1],
urlParameters: [Parameters.$host],
headerParameters: [Parameters.accept],
serializer
};
+65
View File
@@ -0,0 +1,65 @@
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import { BillingAccount } 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 {
BillingAccountGetPolicyOptionalParams,
BillingAccountGetPolicyResponse
} from "../models";
/** Class containing BillingAccount operations. */
export class BillingAccountImpl implements BillingAccount {
private readonly client: SubscriptionClient;
/**
* Initialize a new instance of the class BillingAccount class.
* @param client Reference to the service client
*/
constructor(client: SubscriptionClient) {
this.client = client;
}
/**
* Get Billing Account Policy.
* @param billingAccountId Billing Account Id.
* @param options The options parameters.
*/
getPolicy(
billingAccountId: string,
options?: BillingAccountGetPolicyOptionalParams
): Promise<BillingAccountGetPolicyResponse> {
return this.client.sendOperationRequest(
{ billingAccountId, options },
getPolicyOperationSpec
);
}
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const getPolicyOperationSpec: coreClient.OperationSpec = {
path:
"/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Subscription/policies/default",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.BillingAccountPoliciesResponse
},
default: {
bodyMapper: Mappers.ErrorResponseBody
}
},
queryParameters: [Parameters.apiVersion1],
urlParameters: [Parameters.$host, Parameters.billingAccountId],
headerParameters: [Parameters.accept],
serializer
};
+15
View File
@@ -0,0 +1,15 @@
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
export * from "./subscriptions";
export * from "./tenants";
export * from "./subscriptionOperations";
export * from "./operations";
export * from "./alias";
export * from "./subscriptionPolicy";
export * from "./billingAccount";
+150
View File
@@ -0,0 +1,150 @@
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the 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, PageSettings } from "@azure/core-paging";
import { setContinuationToken } from "../pagingHelper";
import { Operations } from "../operationsInterfaces";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { SubscriptionClient } from "../subscriptionClient";
import {
Operation,
OperationsListNextOptionalParams,
OperationsListOptionalParams,
OperationsListResponse,
OperationsListNextResponse
} from "../models";
/// <reference lib="esnext.asynciterable" />
/** Class containing Operations operations. */
export class OperationsImpl implements Operations {
private readonly client: SubscriptionClient;
/**
* Initialize a new instance of the class Operations class.
* @param client Reference to the service client
*/
constructor(client: SubscriptionClient) {
this.client = client;
}
/**
* Lists all of the available Microsoft.Subscription API operations.
* @param options The options parameters.
*/
public list(
options?: OperationsListOptionalParams
): PagedAsyncIterableIterator<Operation> {
const iter = this.listPagingAll(options);
return {
next() {
return iter.next();
},
[Symbol.asyncIterator]() {
return this;
},
byPage: (settings?: PageSettings) => {
if (settings?.maxPageSize) {
throw new Error("maxPageSize is not supported by this operation.");
}
return this.listPagingPage(options, settings);
}
};
}
private async *listPagingPage(
options?: OperationsListOptionalParams,
settings?: PageSettings
): AsyncIterableIterator<Operation[]> {
let result: OperationsListResponse;
let continuationToken = settings?.continuationToken;
if (!continuationToken) {
result = await this._list(options);
let page = result.value || [];
continuationToken = result.nextLink;
setContinuationToken(page, continuationToken);
yield page;
}
while (continuationToken) {
result = await this._listNext(continuationToken, options);
continuationToken = result.nextLink;
let page = result.value || [];
setContinuationToken(page, continuationToken);
yield page;
}
}
private async *listPagingAll(
options?: OperationsListOptionalParams
): AsyncIterableIterator<Operation> {
for await (const page of this.listPagingPage(options)) {
yield* page;
}
}
/**
* Lists all of the available Microsoft.Subscription API operations.
* @param options The options parameters.
*/
private _list(
options?: OperationsListOptionalParams
): Promise<OperationsListResponse> {
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?: OperationsListNextOptionalParams
): Promise<OperationsListNextResponse> {
return this.client.sendOperationRequest(
{ nextLink, options },
listNextOperationSpec
);
}
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const listOperationSpec: coreClient.OperationSpec = {
path: "/providers/Microsoft.Subscription/operations",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.OperationListResult
},
default: {
bodyMapper: Mappers.ErrorResponseBody
}
},
queryParameters: [Parameters.apiVersion1],
urlParameters: [Parameters.$host],
headerParameters: [Parameters.accept],
serializer
};
const listNextOperationSpec: coreClient.OperationSpec = {
path: "{nextLink}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.OperationListResult
},
default: {
bodyMapper: Mappers.ErrorResponseBody
}
},
queryParameters: [Parameters.apiVersion1],
urlParameters: [Parameters.$host, Parameters.nextLink],
headerParameters: [Parameters.accept],
serializer
};
@@ -0,0 +1,292 @@
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the 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 { SubscriptionOperations } 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 { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro";
import { LroImpl } from "../lroImpl";
import {
SubscriptionCancelOptionalParams,
SubscriptionCancelResponse,
SubscriptionName,
SubscriptionRenameOptionalParams,
SubscriptionRenameResponse,
SubscriptionEnableOptionalParams,
SubscriptionEnableResponse,
AcceptOwnershipRequest,
SubscriptionAcceptOwnershipOptionalParams,
SubscriptionAcceptOwnershipResponse,
SubscriptionAcceptOwnershipStatusOptionalParams,
SubscriptionAcceptOwnershipStatusResponse
} from "../models";
/** Class containing SubscriptionOperations operations. */
export class SubscriptionOperationsImpl implements SubscriptionOperations {
private readonly client: SubscriptionClient;
/**
* Initialize a new instance of the class SubscriptionOperations class.
* @param client Reference to the service client
*/
constructor(client: SubscriptionClient) {
this.client = client;
}
/**
* The operation to cancel a subscription
* @param subscriptionId Subscription Id.
* @param options The options parameters.
*/
cancel(
subscriptionId: string,
options?: SubscriptionCancelOptionalParams
): Promise<SubscriptionCancelResponse> {
return this.client.sendOperationRequest(
{ subscriptionId, options },
cancelOperationSpec
);
}
/**
* The operation to rename a subscription
* @param subscriptionId Subscription Id.
* @param body Subscription Name
* @param options The options parameters.
*/
rename(
subscriptionId: string,
body: SubscriptionName,
options?: SubscriptionRenameOptionalParams
): Promise<SubscriptionRenameResponse> {
return this.client.sendOperationRequest(
{ subscriptionId, body, options },
renameOperationSpec
);
}
/**
* The operation to enable a subscription
* @param subscriptionId Subscription Id.
* @param options The options parameters.
*/
enable(
subscriptionId: string,
options?: SubscriptionEnableOptionalParams
): Promise<SubscriptionEnableResponse> {
return this.client.sendOperationRequest(
{ subscriptionId, options },
enableOperationSpec
);
}
/**
* Accept subscription ownership.
* @param subscriptionId Subscription Id.
* @param body The parameters required to accept subscription ownership.
* @param options The options parameters.
*/
async beginAcceptOwnership(
subscriptionId: string,
body: AcceptOwnershipRequest,
options?: SubscriptionAcceptOwnershipOptionalParams
): Promise<
PollerLike<
PollOperationState<SubscriptionAcceptOwnershipResponse>,
SubscriptionAcceptOwnershipResponse
>
> {
const directSendOperation = async (
args: coreClient.OperationArguments,
spec: coreClient.OperationSpec
): Promise<SubscriptionAcceptOwnershipResponse> => {
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,
{ subscriptionId, body, options },
acceptOwnershipOperationSpec
);
const poller = new LroEngine(lro, {
resumeFrom: options?.resumeFrom,
intervalInMs: options?.updateIntervalInMs
});
await poller.poll();
return poller;
}
/**
* Accept subscription ownership.
* @param subscriptionId Subscription Id.
* @param body The parameters required to accept subscription ownership.
* @param options The options parameters.
*/
async beginAcceptOwnershipAndWait(
subscriptionId: string,
body: AcceptOwnershipRequest,
options?: SubscriptionAcceptOwnershipOptionalParams
): Promise<SubscriptionAcceptOwnershipResponse> {
const poller = await this.beginAcceptOwnership(
subscriptionId,
body,
options
);
return poller.pollUntilDone();
}
/**
* Accept subscription ownership status.
* @param subscriptionId Subscription Id.
* @param options The options parameters.
*/
acceptOwnershipStatus(
subscriptionId: string,
options?: SubscriptionAcceptOwnershipStatusOptionalParams
): Promise<SubscriptionAcceptOwnershipStatusResponse> {
return this.client.sendOperationRequest(
{ subscriptionId, options },
acceptOwnershipStatusOperationSpec
);
}
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const cancelOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/cancel",
httpMethod: "POST",
responses: {
200: {
bodyMapper: Mappers.CanceledSubscriptionId
},
default: {
bodyMapper: Mappers.ErrorResponseBody
}
},
queryParameters: [Parameters.apiVersion1],
urlParameters: [Parameters.$host, Parameters.subscriptionId],
headerParameters: [Parameters.accept],
serializer
};
const renameOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/rename",
httpMethod: "POST",
responses: {
200: {
bodyMapper: Mappers.RenamedSubscriptionId
},
default: {
bodyMapper: Mappers.ErrorResponseBody
}
},
requestBody: Parameters.body,
queryParameters: [Parameters.apiVersion1],
urlParameters: [Parameters.$host, Parameters.subscriptionId],
headerParameters: [Parameters.accept, Parameters.contentType],
mediaType: "json",
serializer
};
const enableOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/providers/Microsoft.Subscription/enable",
httpMethod: "POST",
responses: {
200: {
bodyMapper: Mappers.EnabledSubscriptionId
},
default: {
bodyMapper: Mappers.ErrorResponseBody
}
},
queryParameters: [Parameters.apiVersion1],
urlParameters: [Parameters.$host, Parameters.subscriptionId],
headerParameters: [Parameters.accept],
serializer
};
const acceptOwnershipOperationSpec: coreClient.OperationSpec = {
path:
"/providers/Microsoft.Subscription/subscriptions/{subscriptionId}/acceptOwnership",
httpMethod: "POST",
responses: {
200: {
headersMapper: Mappers.SubscriptionAcceptOwnershipHeaders
},
201: {
headersMapper: Mappers.SubscriptionAcceptOwnershipHeaders
},
202: {
headersMapper: Mappers.SubscriptionAcceptOwnershipHeaders
},
204: {
headersMapper: Mappers.SubscriptionAcceptOwnershipHeaders
},
default: {
bodyMapper: Mappers.ErrorResponseBody
}
},
requestBody: Parameters.body1,
queryParameters: [Parameters.apiVersion1],
urlParameters: [Parameters.$host, Parameters.subscriptionId],
headerParameters: [Parameters.accept, Parameters.contentType],
mediaType: "json",
serializer
};
const acceptOwnershipStatusOperationSpec: coreClient.OperationSpec = {
path:
"/providers/Microsoft.Subscription/subscriptions/{subscriptionId}/acceptOwnershipStatus",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.AcceptOwnershipStatusResponse
},
default: {
bodyMapper: Mappers.ErrorResponseBody
}
},
queryParameters: [Parameters.apiVersion1],
urlParameters: [Parameters.$host, Parameters.subscriptionId],
headerParameters: [Parameters.accept],
serializer
};
@@ -0,0 +1,220 @@
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the 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, PageSettings } from "@azure/core-paging";
import { setContinuationToken } from "../pagingHelper";
import { SubscriptionPolicy } 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 {
GetTenantPolicyResponse,
SubscriptionPolicyListPolicyForTenantNextOptionalParams,
SubscriptionPolicyListPolicyForTenantOptionalParams,
SubscriptionPolicyListPolicyForTenantResponse,
PutTenantPolicyRequestProperties,
SubscriptionPolicyAddUpdatePolicyForTenantOptionalParams,
SubscriptionPolicyAddUpdatePolicyForTenantResponse,
SubscriptionPolicyGetPolicyForTenantOptionalParams,
SubscriptionPolicyGetPolicyForTenantResponse,
SubscriptionPolicyListPolicyForTenantNextResponse
} from "../models";
/// <reference lib="esnext.asynciterable" />
/** Class containing SubscriptionPolicy operations. */
export class SubscriptionPolicyImpl implements SubscriptionPolicy {
private readonly client: SubscriptionClient;
/**
* Initialize a new instance of the class SubscriptionPolicy class.
* @param client Reference to the service client
*/
constructor(client: SubscriptionClient) {
this.client = client;
}
/**
* Get the subscription tenant policy for the user's tenant.
* @param options The options parameters.
*/
public listPolicyForTenant(
options?: SubscriptionPolicyListPolicyForTenantOptionalParams
): PagedAsyncIterableIterator<GetTenantPolicyResponse> {
const iter = this.listPolicyForTenantPagingAll(options);
return {
next() {
return iter.next();
},
[Symbol.asyncIterator]() {
return this;
},
byPage: (settings?: PageSettings) => {
if (settings?.maxPageSize) {
throw new Error("maxPageSize is not supported by this operation.");
}
return this.listPolicyForTenantPagingPage(options, settings);
}
};
}
private async *listPolicyForTenantPagingPage(
options?: SubscriptionPolicyListPolicyForTenantOptionalParams,
settings?: PageSettings
): AsyncIterableIterator<GetTenantPolicyResponse[]> {
let result: SubscriptionPolicyListPolicyForTenantResponse;
let continuationToken = settings?.continuationToken;
if (!continuationToken) {
result = await this._listPolicyForTenant(options);
let page = result.value || [];
continuationToken = result.nextLink;
setContinuationToken(page, continuationToken);
yield page;
}
while (continuationToken) {
result = await this._listPolicyForTenantNext(continuationToken, options);
continuationToken = result.nextLink;
let page = result.value || [];
setContinuationToken(page, continuationToken);
yield page;
}
}
private async *listPolicyForTenantPagingAll(
options?: SubscriptionPolicyListPolicyForTenantOptionalParams
): AsyncIterableIterator<GetTenantPolicyResponse> {
for await (const page of this.listPolicyForTenantPagingPage(options)) {
yield* page;
}
}
/**
* Create or Update Subscription tenant policy for user's tenant.
* @param body Put tenant policy request properties.
* @param options The options parameters.
*/
addUpdatePolicyForTenant(
body: PutTenantPolicyRequestProperties,
options?: SubscriptionPolicyAddUpdatePolicyForTenantOptionalParams
): Promise<SubscriptionPolicyAddUpdatePolicyForTenantResponse> {
return this.client.sendOperationRequest(
{ body, options },
addUpdatePolicyForTenantOperationSpec
);
}
/**
* Get the subscription tenant policy for the user's tenant.
* @param options The options parameters.
*/
getPolicyForTenant(
options?: SubscriptionPolicyGetPolicyForTenantOptionalParams
): Promise<SubscriptionPolicyGetPolicyForTenantResponse> {
return this.client.sendOperationRequest(
{ options },
getPolicyForTenantOperationSpec
);
}
/**
* Get the subscription tenant policy for the user's tenant.
* @param options The options parameters.
*/
private _listPolicyForTenant(
options?: SubscriptionPolicyListPolicyForTenantOptionalParams
): Promise<SubscriptionPolicyListPolicyForTenantResponse> {
return this.client.sendOperationRequest(
{ options },
listPolicyForTenantOperationSpec
);
}
/**
* ListPolicyForTenantNext
* @param nextLink The nextLink from the previous successful call to the ListPolicyForTenant method.
* @param options The options parameters.
*/
private _listPolicyForTenantNext(
nextLink: string,
options?: SubscriptionPolicyListPolicyForTenantNextOptionalParams
): Promise<SubscriptionPolicyListPolicyForTenantNextResponse> {
return this.client.sendOperationRequest(
{ nextLink, options },
listPolicyForTenantNextOperationSpec
);
}
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const addUpdatePolicyForTenantOperationSpec: coreClient.OperationSpec = {
path: "/providers/Microsoft.Subscription/policies/default",
httpMethod: "PUT",
responses: {
200: {
bodyMapper: Mappers.GetTenantPolicyResponse
},
default: {
bodyMapper: Mappers.ErrorResponseBody
}
},
requestBody: Parameters.body3,
queryParameters: [Parameters.apiVersion1],
urlParameters: [Parameters.$host],
headerParameters: [Parameters.accept, Parameters.contentType],
mediaType: "json",
serializer
};
const getPolicyForTenantOperationSpec: coreClient.OperationSpec = {
path: "/providers/Microsoft.Subscription/policies/default",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.GetTenantPolicyResponse
},
default: {
bodyMapper: Mappers.ErrorResponseBody
}
},
queryParameters: [Parameters.apiVersion1],
urlParameters: [Parameters.$host],
headerParameters: [Parameters.accept],
serializer
};
const listPolicyForTenantOperationSpec: coreClient.OperationSpec = {
path: "/providers/Microsoft.Subscription/policies",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.GetTenantPolicyListResponse
},
default: {
bodyMapper: Mappers.ErrorResponseBody
}
},
queryParameters: [Parameters.apiVersion1],
urlParameters: [Parameters.$host],
headerParameters: [Parameters.accept],
serializer
};
const listPolicyForTenantNextOperationSpec: coreClient.OperationSpec = {
path: "{nextLink}",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.GetTenantPolicyListResponse
},
default: {
bodyMapper: Mappers.ErrorResponseBody
}
},
queryParameters: [Parameters.apiVersion1],
urlParameters: [Parameters.$host, Parameters.nextLink],
headerParameters: [Parameters.accept],
serializer
};
+255
View File
@@ -0,0 +1,255 @@
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the 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, PageSettings } from "@azure/core-paging";
import { setContinuationToken } from "../pagingHelper";
import { Subscriptions } from "../operationsInterfaces";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { SubscriptionClient } from "../subscriptionClient";
import {
Location,
SubscriptionsListLocationsOptionalParams,
SubscriptionsListLocationsResponse,
Subscription,
SubscriptionsListNextOptionalParams,
SubscriptionsListOptionalParams,
SubscriptionsListResponse,
SubscriptionsGetOptionalParams,
SubscriptionsGetResponse,
SubscriptionsListNextResponse
} from "../models";
/// <reference lib="esnext.asynciterable" />
/** 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<Location> {
const iter = this.listLocationsPagingAll(subscriptionId, options);
return {
next() {
return iter.next();
},
[Symbol.asyncIterator]() {
return this;
},
byPage: (settings?: PageSettings) => {
if (settings?.maxPageSize) {
throw new Error("maxPageSize is not supported by this operation.");
}
return this.listLocationsPagingPage(subscriptionId, options, settings);
}
};
}
private async *listLocationsPagingPage(
subscriptionId: string,
options?: SubscriptionsListLocationsOptionalParams,
_settings?: PageSettings
): AsyncIterableIterator<Location[]> {
let result: SubscriptionsListLocationsResponse;
result = await this._listLocations(subscriptionId, options);
yield result.value || [];
}
private async *listLocationsPagingAll(
subscriptionId: string,
options?: SubscriptionsListLocationsOptionalParams
): AsyncIterableIterator<Location> {
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<Subscription> {
const iter = this.listPagingAll(options);
return {
next() {
return iter.next();
},
[Symbol.asyncIterator]() {
return this;
},
byPage: (settings?: PageSettings) => {
if (settings?.maxPageSize) {
throw new Error("maxPageSize is not supported by this operation.");
}
return this.listPagingPage(options, settings);
}
};
}
private async *listPagingPage(
options?: SubscriptionsListOptionalParams,
settings?: PageSettings
): AsyncIterableIterator<Subscription[]> {
let result: SubscriptionsListResponse;
let continuationToken = settings?.continuationToken;
if (!continuationToken) {
result = await this._list(options);
let page = result.value || [];
continuationToken = result.nextLink;
setContinuationToken(page, continuationToken);
yield page;
}
while (continuationToken) {
result = await this._listNext(continuationToken, options);
continuationToken = result.nextLink;
let page = result.value || [];
setContinuationToken(page, continuationToken);
yield page;
}
}
private async *listPagingAll(
options?: SubscriptionsListOptionalParams
): AsyncIterableIterator<Subscription> {
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<SubscriptionsListLocationsResponse> {
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<SubscriptionsGetResponse> {
return this.client.sendOperationRequest(
{ subscriptionId, options },
getOperationSpec
);
}
/**
* Gets all subscriptions for a tenant.
* @param options The options parameters.
*/
private _list(
options?: SubscriptionsListOptionalParams
): Promise<SubscriptionsListResponse> {
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<SubscriptionsListNextResponse> {
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
};
+144
View File
@@ -0,0 +1,144 @@
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the 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, PageSettings } from "@azure/core-paging";
import { setContinuationToken } from "../pagingHelper";
import { Tenants } from "../operationsInterfaces";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { SubscriptionClient } from "../subscriptionClient";
import {
TenantIdDescription,
TenantsListNextOptionalParams,
TenantsListOptionalParams,
TenantsListResponse,
TenantsListNextResponse
} from "../models";
/// <reference lib="esnext.asynciterable" />
/** 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<TenantIdDescription> {
const iter = this.listPagingAll(options);
return {
next() {
return iter.next();
},
[Symbol.asyncIterator]() {
return this;
},
byPage: (settings?: PageSettings) => {
if (settings?.maxPageSize) {
throw new Error("maxPageSize is not supported by this operation.");
}
return this.listPagingPage(options, settings);
}
};
}
private async *listPagingPage(
options?: TenantsListOptionalParams,
settings?: PageSettings
): AsyncIterableIterator<TenantIdDescription[]> {
let result: TenantsListResponse;
let continuationToken = settings?.continuationToken;
if (!continuationToken) {
result = await this._list(options);
let page = result.value || [];
continuationToken = result.nextLink;
setContinuationToken(page, continuationToken);
yield page;
}
while (continuationToken) {
result = await this._listNext(continuationToken, options);
continuationToken = result.nextLink;
let page = result.value || [];
setContinuationToken(page, continuationToken);
yield page;
}
}
private async *listPagingAll(
options?: TenantsListOptionalParams
): AsyncIterableIterator<TenantIdDescription> {
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<TenantsListResponse> {
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<TenantsListNextResponse> {
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
};