UNPKG

@azure/arm-compute

Version:
744 lines 30.6 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"; import { createHttpPoller } from "@azure/core-lro"; import { createLroSpec } from "../lroImpl.js"; /// <reference lib="esnext.asynciterable" /> /** Class containing DedicatedHosts operations. */ export class DedicatedHostsImpl { client; /** * Initialize a new instance of the class DedicatedHosts class. * @param client Reference to the service client */ constructor(client) { this.client = client; } /** * Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink property in * the response to get the next page of dedicated hosts. * @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. */ listByHostGroup(resourceGroupName, hostGroupName, options) { const iter = this.listByHostGroupPagingAll(resourceGroupName, hostGroupName, 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.listByHostGroupPagingPage(resourceGroupName, hostGroupName, options, settings); }, }; } async *listByHostGroupPagingPage(resourceGroupName, hostGroupName, options, settings) { let result; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._listByHostGroup(resourceGroupName, hostGroupName, options); const page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listByHostGroupNext(resourceGroupName, hostGroupName, continuationToken, options); continuationToken = result.nextLink; const page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } async *listByHostGroupPagingAll(resourceGroupName, hostGroupName, options) { for await (const page of this.listByHostGroupPagingPage(resourceGroupName, hostGroupName, options)) { yield* page; } } /** * Lists all available dedicated host sizes to which the specified dedicated host can be resized. NOTE: * The dedicated host sizes provided can be used to only scale up the existing dedicated host. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param hostGroupName The name of the dedicated host group. * @param hostName The name of the dedicated host. * @param options The options parameters. */ listAvailableSizes(resourceGroupName, hostGroupName, hostName, options) { const iter = this.listAvailableSizesPagingAll(resourceGroupName, hostGroupName, hostName, 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.listAvailableSizesPagingPage(resourceGroupName, hostGroupName, hostName, options, settings); }, }; } async *listAvailableSizesPagingPage(resourceGroupName, hostGroupName, hostName, options, settings) { let result; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._listAvailableSizes(resourceGroupName, hostGroupName, hostName, options); const page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listAvailableSizesNext(resourceGroupName, hostGroupName, hostName, continuationToken, options); continuationToken = result.nextLink; const page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } async *listAvailableSizesPagingAll(resourceGroupName, hostGroupName, hostName, options) { for await (const page of this.listAvailableSizesPagingPage(resourceGroupName, hostGroupName, hostName, options)) { yield* page; } } /** * Lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink property in * the response to get the next page of dedicated hosts. * @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. */ _listByHostGroup(resourceGroupName, hostGroupName, options) { return this.client.sendOperationRequest({ resourceGroupName, hostGroupName, options }, listByHostGroupOperationSpec); } /** * Retrieves information about a dedicated host. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param hostGroupName The name of the dedicated host group. * @param hostName The name of the dedicated host. * @param options The options parameters. */ get(resourceGroupName, hostGroupName, hostName, options) { return this.client.sendOperationRequest({ resourceGroupName, hostGroupName, hostName, options }, getOperationSpec); } /** * Create or update a dedicated host . * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param hostGroupName The name of the dedicated host group. * @param hostName The name of the dedicated host. * @param parameters Parameters supplied to the Create Dedicated Host. * @param options The options parameters. */ async beginCreateOrUpdate(resourceGroupName, hostGroupName, hostName, parameters, options) { const directSendOperation = async (args, spec) => { return this.client.sendOperationRequest(args, spec); }; const sendOperationFn = async (args, spec) => { let currentRawResponse = undefined; const providedCallback = args.options?.onResponse; const callback = (rawResponse, flatResponse) => { 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 = createLroSpec({ sendOperationFn, args: { resourceGroupName, hostGroupName, hostName, parameters, options }, spec: createOrUpdateOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Create or update a dedicated host . * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param hostGroupName The name of the dedicated host group. * @param hostName The name of the dedicated host. * @param parameters Parameters supplied to the Create Dedicated Host. * @param options The options parameters. */ async beginCreateOrUpdateAndWait(resourceGroupName, hostGroupName, hostName, parameters, options) { const poller = await this.beginCreateOrUpdate(resourceGroupName, hostGroupName, hostName, parameters, options); return poller.pollUntilDone(); } /** * Update a dedicated host . * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param hostGroupName The name of the dedicated host group. * @param hostName The name of the dedicated host. * @param parameters Parameters supplied to the Update Dedicated Host operation. * @param options The options parameters. */ async beginUpdate(resourceGroupName, hostGroupName, hostName, parameters, options) { const directSendOperation = async (args, spec) => { return this.client.sendOperationRequest(args, spec); }; const sendOperationFn = async (args, spec) => { let currentRawResponse = undefined; const providedCallback = args.options?.onResponse; const callback = (rawResponse, flatResponse) => { 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 = createLroSpec({ sendOperationFn, args: { resourceGroupName, hostGroupName, hostName, parameters, options }, spec: updateOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Update a dedicated host . * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param hostGroupName The name of the dedicated host group. * @param hostName The name of the dedicated host. * @param parameters Parameters supplied to the Update Dedicated Host operation. * @param options The options parameters. */ async beginUpdateAndWait(resourceGroupName, hostGroupName, hostName, parameters, options) { const poller = await this.beginUpdate(resourceGroupName, hostGroupName, hostName, parameters, options); return poller.pollUntilDone(); } /** * Delete a dedicated host. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param hostGroupName The name of the dedicated host group. * @param hostName The name of the dedicated host. * @param options The options parameters. */ async beginDelete(resourceGroupName, hostGroupName, hostName, options) { const directSendOperation = async (args, spec) => { return this.client.sendOperationRequest(args, spec); }; const sendOperationFn = async (args, spec) => { let currentRawResponse = undefined; const providedCallback = args.options?.onResponse; const callback = (rawResponse, flatResponse) => { 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 = createLroSpec({ sendOperationFn, args: { resourceGroupName, hostGroupName, hostName, options }, spec: deleteOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Delete a dedicated host. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param hostGroupName The name of the dedicated host group. * @param hostName The name of the dedicated host. * @param options The options parameters. */ async beginDeleteAndWait(resourceGroupName, hostGroupName, hostName, options) { const poller = await this.beginDelete(resourceGroupName, hostGroupName, hostName, options); return poller.pollUntilDone(); } /** * Lists all available dedicated host sizes to which the specified dedicated host can be resized. NOTE: * The dedicated host sizes provided can be used to only scale up the existing dedicated host. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param hostGroupName The name of the dedicated host group. * @param hostName The name of the dedicated host. * @param options The options parameters. */ _listAvailableSizes(resourceGroupName, hostGroupName, hostName, options) { return this.client.sendOperationRequest({ resourceGroupName, hostGroupName, hostName, options }, listAvailableSizesOperationSpec); } /** * Redeploy the dedicated host. The operation will complete successfully once the dedicated host has * migrated to a new node and is running. To determine the health of VMs deployed on the dedicated host * after the redeploy check the Resource Health Center in the Azure Portal. Please refer to * https://docs.microsoft.com/azure/service-health/resource-health-overview for more details. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param hostGroupName The name of the dedicated host group. * @param hostName The name of the dedicated host. * @param options The options parameters. */ async beginRedeploy(resourceGroupName, hostGroupName, hostName, options) { const directSendOperation = async (args, spec) => { return this.client.sendOperationRequest(args, spec); }; const sendOperationFn = async (args, spec) => { let currentRawResponse = undefined; const providedCallback = args.options?.onResponse; const callback = (rawResponse, flatResponse) => { 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 = createLroSpec({ sendOperationFn, args: { resourceGroupName, hostGroupName, hostName, options }, spec: redeployOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Redeploy the dedicated host. The operation will complete successfully once the dedicated host has * migrated to a new node and is running. To determine the health of VMs deployed on the dedicated host * after the redeploy check the Resource Health Center in the Azure Portal. Please refer to * https://docs.microsoft.com/azure/service-health/resource-health-overview for more details. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param hostGroupName The name of the dedicated host group. * @param hostName The name of the dedicated host. * @param options The options parameters. */ async beginRedeployAndWait(resourceGroupName, hostGroupName, hostName, options) { const poller = await this.beginRedeploy(resourceGroupName, hostGroupName, hostName, options); return poller.pollUntilDone(); } /** * Restart the dedicated host. The operation will complete successfully once the dedicated host has * restarted and is running. To determine the health of VMs deployed on the dedicated host after the * restart check the Resource Health Center in the Azure Portal. Please refer to * https://docs.microsoft.com/azure/service-health/resource-health-overview for more details. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param hostGroupName The name of the dedicated host group. * @param hostName The name of the dedicated host. * @param options The options parameters. */ async beginRestart(resourceGroupName, hostGroupName, hostName, options) { const directSendOperation = async (args, spec) => { return this.client.sendOperationRequest(args, spec); }; const sendOperationFn = async (args, spec) => { let currentRawResponse = undefined; const providedCallback = args.options?.onResponse; const callback = (rawResponse, flatResponse) => { 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 = createLroSpec({ sendOperationFn, args: { resourceGroupName, hostGroupName, hostName, options }, spec: restartOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location", }); await poller.poll(); return poller; } /** * Restart the dedicated host. The operation will complete successfully once the dedicated host has * restarted and is running. To determine the health of VMs deployed on the dedicated host after the * restart check the Resource Health Center in the Azure Portal. Please refer to * https://docs.microsoft.com/azure/service-health/resource-health-overview for more details. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param hostGroupName The name of the dedicated host group. * @param hostName The name of the dedicated host. * @param options The options parameters. */ async beginRestartAndWait(resourceGroupName, hostGroupName, hostName, options) { const poller = await this.beginRestart(resourceGroupName, hostGroupName, hostName, options); return poller.pollUntilDone(); } /** * ListByHostGroupNext * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param hostGroupName The name of the dedicated host group. * @param nextLink The nextLink from the previous successful call to the ListByHostGroup method. * @param options The options parameters. */ _listByHostGroupNext(resourceGroupName, hostGroupName, nextLink, options) { return this.client.sendOperationRequest({ resourceGroupName, hostGroupName, nextLink, options }, listByHostGroupNextOperationSpec); } /** * ListAvailableSizesNext * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param hostGroupName The name of the dedicated host group. * @param hostName The name of the dedicated host. * @param nextLink The nextLink from the previous successful call to the ListAvailableSizes method. * @param options The options parameters. */ _listAvailableSizesNext(resourceGroupName, hostGroupName, hostName, nextLink, options) { return this.client.sendOperationRequest({ resourceGroupName, hostGroupName, hostName, nextLink, options }, listAvailableSizesNextOperationSpec); } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const listByHostGroupOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.DedicatedHostListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.hostGroupName, ], headerParameters: [Parameters.accept], serializer, }; const getOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.DedicatedHost, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion, Parameters.expand3], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.hostGroupName, Parameters.hostName, ], headerParameters: [Parameters.accept], serializer, }; const createOrUpdateOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", httpMethod: "PUT", responses: { 200: { bodyMapper: Mappers.DedicatedHost, }, 201: { bodyMapper: Mappers.DedicatedHost, }, 202: { bodyMapper: Mappers.DedicatedHost, }, 204: { bodyMapper: Mappers.DedicatedHost, }, default: { bodyMapper: Mappers.CloudError, }, }, requestBody: Parameters.parameters33, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.hostGroupName, Parameters.hostName, ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer, }; const updateOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", httpMethod: "PATCH", responses: { 200: { bodyMapper: Mappers.DedicatedHost, headersMapper: Mappers.DedicatedHostsUpdateHeaders, }, 201: { bodyMapper: Mappers.DedicatedHost, headersMapper: Mappers.DedicatedHostsUpdateHeaders, }, 202: { bodyMapper: Mappers.DedicatedHost, headersMapper: Mappers.DedicatedHostsUpdateHeaders, }, 204: { bodyMapper: Mappers.DedicatedHost, headersMapper: Mappers.DedicatedHostsUpdateHeaders, }, default: { bodyMapper: Mappers.CloudError, }, }, requestBody: Parameters.parameters34, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.hostGroupName, Parameters.hostName, ], headerParameters: [Parameters.accept, Parameters.contentType], mediaType: "json", serializer, }; const deleteOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", httpMethod: "DELETE", responses: { 200: {}, 201: {}, 202: {}, 204: {}, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.hostGroupName, Parameters.hostName, ], headerParameters: [Parameters.accept], serializer, }; const listAvailableSizesOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}/hostSizes", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.DedicatedHostSizeListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.hostGroupName, Parameters.hostName, ], headerParameters: [Parameters.accept], serializer, }; const redeployOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}/redeploy", httpMethod: "POST", responses: { 200: { headersMapper: Mappers.DedicatedHostsRedeployHeaders, }, 201: { headersMapper: Mappers.DedicatedHostsRedeployHeaders, }, 202: { headersMapper: Mappers.DedicatedHostsRedeployHeaders, }, 204: { headersMapper: Mappers.DedicatedHostsRedeployHeaders, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.hostGroupName, Parameters.hostName, ], headerParameters: [Parameters.accept], serializer, }; const restartOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}/restart", httpMethod: "POST", responses: { 200: { headersMapper: Mappers.DedicatedHostsRestartHeaders, }, 201: { headersMapper: Mappers.DedicatedHostsRestartHeaders, }, 202: { headersMapper: Mappers.DedicatedHostsRestartHeaders, }, 204: { headersMapper: Mappers.DedicatedHostsRestartHeaders, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.hostGroupName, Parameters.hostName, ], headerParameters: [Parameters.accept], serializer, }; const listByHostGroupNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.DedicatedHostListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, urlParameters: [ Parameters.$host, Parameters.nextLink, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.hostGroupName, ], headerParameters: [Parameters.accept], serializer, }; const listAvailableSizesNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.DedicatedHostSizeListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, urlParameters: [ Parameters.$host, Parameters.nextLink, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.hostGroupName, Parameters.hostName, ], headerParameters: [Parameters.accept], serializer, }; //# sourceMappingURL=dedicatedHosts.js.map