UNPKG

@azure/arm-compute

Version:
566 lines 22.6 kB
/* * 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 { 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 CloudServiceRoleInstances operations. */ export class CloudServiceRoleInstancesImpl { client; /** * Initialize a new instance of the class CloudServiceRoleInstances class. * @param client Reference to the service client */ constructor(client) { this.client = client; } /** * Gets the list of all role instances in a cloud service. Use nextLink property in the response to get * the next page of role instances. Do this till nextLink is null to fetch all the role instances. * @param resourceGroupName Name of the resource group. * @param cloudServiceName Name of the cloud service. * @param options The options parameters. */ list(resourceGroupName, cloudServiceName, options) { const iter = this.listPagingAll(resourceGroupName, cloudServiceName, 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.listPagingPage(resourceGroupName, cloudServiceName, options, settings); }, }; } async *listPagingPage(resourceGroupName, cloudServiceName, options, settings) { let result; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._list(resourceGroupName, cloudServiceName, options); let page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listNext(resourceGroupName, cloudServiceName, continuationToken, options); continuationToken = result.nextLink; let page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } async *listPagingAll(resourceGroupName, cloudServiceName, options) { for await (const page of this.listPagingPage(resourceGroupName, cloudServiceName, options)) { yield* page; } } /** * Deletes a role instance from a cloud service. * @param roleInstanceName Name of the role instance. * @param resourceGroupName Name of the resource group. * @param cloudServiceName Name of the cloud service. * @param options The options parameters. */ async beginDelete(roleInstanceName, resourceGroupName, cloudServiceName, 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: { roleInstanceName, resourceGroupName, cloudServiceName, options }, spec: deleteOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, }); await poller.poll(); return poller; } /** * Deletes a role instance from a cloud service. * @param roleInstanceName Name of the role instance. * @param resourceGroupName Name of the resource group. * @param cloudServiceName Name of the cloud service. * @param options The options parameters. */ async beginDeleteAndWait(roleInstanceName, resourceGroupName, cloudServiceName, options) { const poller = await this.beginDelete(roleInstanceName, resourceGroupName, cloudServiceName, options); return poller.pollUntilDone(); } /** * Gets a role instance from a cloud service. * @param roleInstanceName Name of the role instance. * @param resourceGroupName Name of the resource group. * @param cloudServiceName Name of the cloud service. * @param options The options parameters. */ get(roleInstanceName, resourceGroupName, cloudServiceName, options) { return this.client.sendOperationRequest({ roleInstanceName, resourceGroupName, cloudServiceName, options }, getOperationSpec); } /** * Retrieves information about the run-time state of a role instance in a cloud service. * @param roleInstanceName Name of the role instance. * @param resourceGroupName Name of the resource group. * @param cloudServiceName Name of the cloud service. * @param options The options parameters. */ getInstanceView(roleInstanceName, resourceGroupName, cloudServiceName, options) { return this.client.sendOperationRequest({ roleInstanceName, resourceGroupName, cloudServiceName, options }, getInstanceViewOperationSpec); } /** * Gets the list of all role instances in a cloud service. Use nextLink property in the response to get * the next page of role instances. Do this till nextLink is null to fetch all the role instances. * @param resourceGroupName Name of the resource group. * @param cloudServiceName Name of the cloud service. * @param options The options parameters. */ _list(resourceGroupName, cloudServiceName, options) { return this.client.sendOperationRequest({ resourceGroupName, cloudServiceName, options }, listOperationSpec); } /** * The Reboot Role Instance asynchronous operation requests a reboot of a role instance in the cloud * service. * @param roleInstanceName Name of the role instance. * @param resourceGroupName Name of the resource group. * @param cloudServiceName Name of the cloud service. * @param options The options parameters. */ async beginRestart(roleInstanceName, resourceGroupName, cloudServiceName, 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: { roleInstanceName, resourceGroupName, cloudServiceName, options }, spec: restartOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, }); await poller.poll(); return poller; } /** * The Reboot Role Instance asynchronous operation requests a reboot of a role instance in the cloud * service. * @param roleInstanceName Name of the role instance. * @param resourceGroupName Name of the resource group. * @param cloudServiceName Name of the cloud service. * @param options The options parameters. */ async beginRestartAndWait(roleInstanceName, resourceGroupName, cloudServiceName, options) { const poller = await this.beginRestart(roleInstanceName, resourceGroupName, cloudServiceName, options); return poller.pollUntilDone(); } /** * The Reimage Role Instance asynchronous operation reinstalls the operating system on instances of web * roles or worker roles. * @param roleInstanceName Name of the role instance. * @param resourceGroupName Name of the resource group. * @param cloudServiceName Name of the cloud service. * @param options The options parameters. */ async beginReimage(roleInstanceName, resourceGroupName, cloudServiceName, 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: { roleInstanceName, resourceGroupName, cloudServiceName, options }, spec: reimageOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, }); await poller.poll(); return poller; } /** * The Reimage Role Instance asynchronous operation reinstalls the operating system on instances of web * roles or worker roles. * @param roleInstanceName Name of the role instance. * @param resourceGroupName Name of the resource group. * @param cloudServiceName Name of the cloud service. * @param options The options parameters. */ async beginReimageAndWait(roleInstanceName, resourceGroupName, cloudServiceName, options) { const poller = await this.beginReimage(roleInstanceName, resourceGroupName, cloudServiceName, options); return poller.pollUntilDone(); } /** * The Rebuild Role Instance asynchronous operation reinstalls the operating system on instances of web * roles or worker roles and initializes the storage resources that are used by them. If you do not * want to initialize storage resources, you can use Reimage Role Instance. * @param roleInstanceName Name of the role instance. * @param resourceGroupName Name of the resource group. * @param cloudServiceName Name of the cloud service. * @param options The options parameters. */ async beginRebuild(roleInstanceName, resourceGroupName, cloudServiceName, 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: { roleInstanceName, resourceGroupName, cloudServiceName, options }, spec: rebuildOperationSpec, }); const poller = await createHttpPoller(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, }); await poller.poll(); return poller; } /** * The Rebuild Role Instance asynchronous operation reinstalls the operating system on instances of web * roles or worker roles and initializes the storage resources that are used by them. If you do not * want to initialize storage resources, you can use Reimage Role Instance. * @param roleInstanceName Name of the role instance. * @param resourceGroupName Name of the resource group. * @param cloudServiceName Name of the cloud service. * @param options The options parameters. */ async beginRebuildAndWait(roleInstanceName, resourceGroupName, cloudServiceName, options) { const poller = await this.beginRebuild(roleInstanceName, resourceGroupName, cloudServiceName, options); return poller.pollUntilDone(); } /** * Gets a remote desktop file for a role instance in a cloud service. * @param roleInstanceName Name of the role instance. * @param resourceGroupName Name of the resource group. * @param cloudServiceName Name of the cloud service. * @param options The options parameters. */ getRemoteDesktopFile(roleInstanceName, resourceGroupName, cloudServiceName, options) { return this.client.sendOperationRequest({ roleInstanceName, resourceGroupName, cloudServiceName, options }, getRemoteDesktopFileOperationSpec); } /** * ListNext * @param resourceGroupName Name of the resource group. * @param cloudServiceName Name of the cloud service. * @param nextLink The nextLink from the previous successful call to the List method. * @param options The options parameters. */ _listNext(resourceGroupName, cloudServiceName, nextLink, options) { return this.client.sendOperationRequest({ resourceGroupName, cloudServiceName, nextLink, options }, listNextOperationSpec); } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const deleteOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}", httpMethod: "DELETE", responses: { 200: {}, 201: {}, 202: {}, 204: {}, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion4], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.roleInstanceName, Parameters.resourceGroupName1, Parameters.cloudServiceName, ], headerParameters: [Parameters.accept], serializer, }; const getOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.RoleInstance, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.expand3, Parameters.apiVersion4], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.roleInstanceName, Parameters.resourceGroupName1, Parameters.cloudServiceName, ], headerParameters: [Parameters.accept], serializer, }; const getInstanceViewOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/instanceView", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.RoleInstanceView, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion4], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.roleInstanceName, Parameters.resourceGroupName1, Parameters.cloudServiceName, ], headerParameters: [Parameters.accept], serializer, }; const listOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.RoleInstanceListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.expand3, Parameters.apiVersion4], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName1, Parameters.cloudServiceName, ], headerParameters: [Parameters.accept], serializer, }; const restartOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/restart", httpMethod: "POST", responses: { 200: {}, 201: {}, 202: {}, 204: {}, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion4], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.roleInstanceName, Parameters.resourceGroupName1, Parameters.cloudServiceName, ], headerParameters: [Parameters.accept], serializer, }; const reimageOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/reimage", httpMethod: "POST", responses: { 200: {}, 201: {}, 202: {}, 204: {}, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion4], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.roleInstanceName, Parameters.resourceGroupName1, Parameters.cloudServiceName, ], headerParameters: [Parameters.accept], serializer, }; const rebuildOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/rebuild", httpMethod: "POST", responses: { 200: {}, 201: {}, 202: {}, 204: {}, default: { bodyMapper: Mappers.CloudError, }, }, queryParameters: [Parameters.apiVersion4], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.roleInstanceName, Parameters.resourceGroupName1, Parameters.cloudServiceName, ], headerParameters: [Parameters.accept], serializer, }; const getRemoteDesktopFileOperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cloudServices/{cloudServiceName}/roleInstances/{roleInstanceName}/remoteDesktopFile", httpMethod: "GET", responses: { 200: { bodyMapper: { type: { name: "Stream" }, serializedName: "parsedResponse", }, }, default: {}, }, queryParameters: [Parameters.apiVersion4], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.roleInstanceName, Parameters.resourceGroupName1, Parameters.cloudServiceName, ], headerParameters: [Parameters.accept2], serializer, }; const listNextOperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.RoleInstanceListResult, }, default: { bodyMapper: Mappers.CloudError, }, }, urlParameters: [ Parameters.$host, Parameters.nextLink, Parameters.subscriptionId, Parameters.resourceGroupName1, Parameters.cloudServiceName, ], headerParameters: [Parameters.accept], serializer, }; //# sourceMappingURL=cloudServiceRoleInstances.js.map