UNPKG

@azure/arm-compute

Version:
342 lines 13.1 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 DedicatedHostGroups operations. */ export class DedicatedHostGroupsImpl { client; /** * Initialize a new instance of the class DedicatedHostGroups class. * @param client Reference to the service client */ constructor(client) { this.client = client; } /** * Lists all of the dedicated host groups in the subscription. Use the nextLink property in the * response to get the next page of dedicated host 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 dedicated host groups in the specified resource group. Use the nextLink property in * the response to get the next page of dedicated host 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 dedicated host groups in the subscription. Use the nextLink property in the * response to get the next page of dedicated host groups. * @param options The options parameters. */ _listBySubscription(options) { return this.client.sendOperationRequest({ options }, listBySubscriptionOperationSpec); } /** * Lists all of the dedicated host groups in the specified resource group. Use the nextLink property in * the response to get the next page of dedicated host 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); } /** * Retrieves information about a dedicated host group. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param hostGroupName The name of the dedicated host group. * @param options The options parameters. */ get(resourceGroupName, hostGroupName, options) { return this.client.sendOperationRequest({ resourceGroupName, hostGroupName, options }, getOperationSpec); } /** * Create or update a dedicated host group. For details of Dedicated Host and Dedicated Host Groups * please see [Dedicated Host Documentation] (https://go.microsoft.com/fwlink/?linkid=2082596) * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param hostGroupName The name of the dedicated host group. * @param parameters Parameters supplied to the Create Dedicated Host Group. * @param options The options parameters. */ createOrUpdate(resourceGroupName, hostGroupName, parameters, options) { return this.client.sendOperationRequest({ resourceGroupName, hostGroupName, parameters, options }, createOrUpdateOperationSpec); } /** * Update an dedicated host group. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param hostGroupName The name of the dedicated host group. * @param parameters Parameters supplied to the Update Dedicated Host Group operation. * @param options The options parameters. */ update(resourceGroupName, hostGroupName, parameters, options) { return this.client.sendOperationRequest({ resourceGroupName, hostGroupName, parameters, options }, updateOperationSpec); } /** * Delete a dedicated host group. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param hostGroupName The name of the dedicated host group. * @param options The options parameters. */ delete(resourceGroupName, hostGroupName, options) { return this.client.sendOperationRequest({ resourceGroupName, hostGroupName, 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/hostGroups", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.DedicatedHostGroupListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.$host, Parameters.subscriptionId], headerParameters: [Parameters.accept], serializer, }; const listByResourceGroupOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.DedicatedHostGroupListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName], headerParameters: [Parameters.accept], serializer, }; const getOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.DedicatedHostGroup, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion, Parameters.expand3], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.hostGroupName, ], headerParameters: [Parameters.accept], serializer, }; const createOrUpdateOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", httpMethod: "PUT", responses: { 200: { bodyMapper: Mappers.DedicatedHostGroup, }, 201: { bodyMapper: Mappers.DedicatedHostGroup, }, default: { bodyMapper: Mappers.CloudError, }, }, requestBody: Parameters.parameters6, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.hostGroupName, ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer, }; const updateOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", httpMethod: "PATCH", responses: { 200: { bodyMapper: Mappers.DedicatedHostGroup, }, default: { bodyMapper: Mappers.CloudError, }, }, requestBody: Parameters.parameters7, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.hostGroupName, ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer, }; const deleteOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", httpMethod: "DELETE", responses: { 200: {}, 204: {}, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.hostGroupName, ], headerParameters: [Parameters.accept], serializer, }; const listBySubscriptionNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.DedicatedHostGroupListResult, }, 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.DedicatedHostGroupListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, urlParameters: [ Parameters.$host, Parameters.nextLink, Parameters.subscriptionId, Parameters.resourceGroupName, ], headerParameters: [Parameters.accept], serializer, }; //# sourceMappingURL=dedicatedHostGroups.js.map