UNPKG

@azure/arm-compute

Version:
347 lines 14.2 kB
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import { setContinuationToken } from "../pagingHelper.js"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers.js"; import * as Parameters from "../models/parameters.js"; /// <reference lib="esnext.asynciterable" /> /** Class containing CapacityReservationGroups operations. */ export class CapacityReservationGroupsImpl { client; /** * Initialize a new instance of the class CapacityReservationGroups class. * @param client Reference to the service client */ constructor(client) { this.client = client; } /** * Lists all of the capacity reservation groups in the subscription. Use the nextLink property in the * response to get the next page of capacity reservation groups. * @param options The options parameters. */ listBySubscription(options) { const iter = this.listBySubscriptionPagingAll(options); return { next() { return iter.next(); }, [Symbol.asyncIterator]() { return this; }, byPage: (settings) => { if (settings?.maxPageSize) { throw new Error("maxPageSize is not supported by this operation."); } return this.listBySubscriptionPagingPage(options, settings); }, }; } async *listBySubscriptionPagingPage(options, settings) { let result; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._listBySubscription(options); const page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listBySubscriptionNext(continuationToken, options); continuationToken = result.nextLink; const page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } async *listBySubscriptionPagingAll(options) { for await (const page of this.listBySubscriptionPagingPage(options)) { yield* page; } } /** * Lists all of the capacity reservation groups in the specified resource group. Use the nextLink * property in the response to get the next page of capacity reservation groups. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param options The options parameters. */ listByResourceGroup(resourceGroupName, options) { const iter = this.listByResourceGroupPagingAll(resourceGroupName, options); return { next() { return iter.next(); }, [Symbol.asyncIterator]() { return this; }, byPage: (settings) => { if (settings?.maxPageSize) { throw new Error("maxPageSize is not supported by this operation."); } return this.listByResourceGroupPagingPage(resourceGroupName, options, settings); }, }; } async *listByResourceGroupPagingPage(resourceGroupName, options, settings) { let result; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._listByResourceGroup(resourceGroupName, options); const page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listByResourceGroupNext(resourceGroupName, continuationToken, options); continuationToken = result.nextLink; const page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } async *listByResourceGroupPagingAll(resourceGroupName, options) { for await (const page of this.listByResourceGroupPagingPage(resourceGroupName, options)) { yield* page; } } /** * Lists all of the capacity reservation groups in the subscription. Use the nextLink property in the * response to get the next page of capacity reservation groups. * @param options The options parameters. */ _listBySubscription(options) { return this.client.sendOperationRequest({ options }, listBySubscriptionOperationSpec); } /** * Lists all of the capacity reservation groups in the specified resource group. Use the nextLink * property in the response to get the next page of capacity reservation groups. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param options The options parameters. */ _listByResourceGroup(resourceGroupName, options) { return this.client.sendOperationRequest({ resourceGroupName, options }, listByResourceGroupOperationSpec); } /** * The operation that retrieves information about a capacity reservation group. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param capacityReservationGroupName The name of the capacity reservation group. * @param options The options parameters. */ get(resourceGroupName, capacityReservationGroupName, options) { return this.client.sendOperationRequest({ resourceGroupName, capacityReservationGroupName, options }, getOperationSpec); } /** * The operation to create or update a capacity reservation group. When updating a capacity reservation * group, only tags and sharing profile may be modified. Please refer to * https://aka.ms/CapacityReservation for more details. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param capacityReservationGroupName The name of the capacity reservation group. * @param parameters Parameters supplied to the Create capacity reservation Group. * @param options The options parameters. */ createOrUpdate(resourceGroupName, capacityReservationGroupName, parameters, options) { return this.client.sendOperationRequest({ resourceGroupName, capacityReservationGroupName, parameters, options }, createOrUpdateOperationSpec); } /** * The operation to update a capacity reservation group. When updating a capacity reservation group, * only tags and sharing profile may be modified. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param capacityReservationGroupName The name of the capacity reservation group. * @param parameters Parameters supplied to the Update capacity reservation Group operation. * @param options The options parameters. */ update(resourceGroupName, capacityReservationGroupName, parameters, options) { return this.client.sendOperationRequest({ resourceGroupName, capacityReservationGroupName, parameters, options }, updateOperationSpec); } /** * The operation to delete a capacity reservation group. This operation is allowed only if all the * associated resources are disassociated from the reservation group and all capacity reservations * under the reservation group have also been deleted. Please refer to * https://aka.ms/CapacityReservation for more details. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param capacityReservationGroupName The name of the capacity reservation group. * @param options The options parameters. */ delete(resourceGroupName, capacityReservationGroupName, options) { return this.client.sendOperationRequest({ resourceGroupName, capacityReservationGroupName, options }, deleteOperationSpec); } /** * ListBySubscriptionNext * @param nextLink The nextLink from the previous successful call to the ListBySubscription method. * @param options The options parameters. */ _listBySubscriptionNext(nextLink, options) { return this.client.sendOperationRequest({ nextLink, options }, listBySubscriptionNextOperationSpec); } /** * ListByResourceGroupNext * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param nextLink The nextLink from the previous successful call to the ListByResourceGroup method. * @param options The options parameters. */ _listByResourceGroupNext(resourceGroupName, nextLink, options) { return this.client.sendOperationRequest({ resourceGroupName, nextLink, options }, listByResourceGroupNextOperationSpec); } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const listBySubscriptionOperationSpec = { path: "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/capacityReservationGroups", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.CapacityReservationGroupListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion, Parameters.expand1, Parameters.resourceIdsOnly], urlParameters: [Parameters.$host, Parameters.subscriptionId], headerParameters: [Parameters.accept], serializer, }; const listByResourceGroupOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.CapacityReservationGroupListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion, Parameters.expand1], urlParameters: [Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName], headerParameters: [Parameters.accept], serializer, }; const getOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.CapacityReservationGroup, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion, Parameters.expand2], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.capacityReservationGroupName, ], headerParameters: [Parameters.accept], serializer, }; const createOrUpdateOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}", httpMethod: "PUT", responses: { 200: { bodyMapper: Mappers.CapacityReservationGroup, }, 201: { bodyMapper: Mappers.CapacityReservationGroup, }, default: { bodyMapper: Mappers.CloudError, }, }, requestBody: Parameters.parameters4, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.capacityReservationGroupName, ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer, }; const updateOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}", httpMethod: "PATCH", responses: { 200: { bodyMapper: Mappers.CapacityReservationGroup, }, default: { bodyMapper: Mappers.CloudError, }, }, requestBody: Parameters.parameters5, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.capacityReservationGroupName, ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer, }; const deleteOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}", httpMethod: "DELETE", responses: { 200: {}, 204: {}, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.capacityReservationGroupName, ], headerParameters: [Parameters.accept], serializer, }; const listBySubscriptionNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.CapacityReservationGroupListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, urlParameters: [Parameters.$host, Parameters.nextLink, Parameters.subscriptionId], headerParameters: [Parameters.accept], serializer, }; const listByResourceGroupNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.CapacityReservationGroupListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, urlParameters: [ Parameters.$host, Parameters.nextLink, Parameters.subscriptionId, Parameters.resourceGroupName, ], headerParameters: [Parameters.accept], serializer, }; //# sourceMappingURL=capacityReservationGroups.js.map