@azure/arm-compute
Version:
A generated SDK for ComputeManagementClient.
296 lines • 11.9 kB
JavaScript
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
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";
/** Class containing VirtualMachineScaleSetRollingUpgrades operations. */
export class VirtualMachineScaleSetRollingUpgradesImpl {
client;
/**
* Initialize a new instance of the class VirtualMachineScaleSetRollingUpgrades class.
* @param client Reference to the service client
*/
constructor(client) {
this.client = client;
}
/**
* Starts a rolling upgrade to move all extensions for all virtual machine scale set instances to the
* latest available extension version. Instances which are already running the latest extension
* versions are not affected.
* @param resourceGroupName The name of the resource group. The name is case insensitive.
* @param vmScaleSetName The name of the VM scale set.
* @param options The options parameters.
*/
async beginStartExtensionUpgrade(resourceGroupName, vmScaleSetName, 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, vmScaleSetName, options },
spec: startExtensionUpgradeOperationSpec,
});
const poller = await createHttpPoller(lro, {
restoreFrom: options?.resumeFrom,
intervalInMs: options?.updateIntervalInMs,
resourceLocationConfig: "location",
});
await poller.poll();
return poller;
}
/**
* Starts a rolling upgrade to move all extensions for all virtual machine scale set instances to the
* latest available extension version. Instances which are already running the latest extension
* versions are not affected.
* @param resourceGroupName The name of the resource group. The name is case insensitive.
* @param vmScaleSetName The name of the VM scale set.
* @param options The options parameters.
*/
async beginStartExtensionUpgradeAndWait(resourceGroupName, vmScaleSetName, options) {
const poller = await this.beginStartExtensionUpgrade(resourceGroupName, vmScaleSetName, options);
return poller.pollUntilDone();
}
/**
* Starts a rolling upgrade to move all virtual machine scale set instances to the latest available
* Platform Image OS version. Instances which are already running the latest available OS version are
* not affected.
* @param resourceGroupName The name of the resource group. The name is case insensitive.
* @param vmScaleSetName The name of the VM scale set.
* @param options The options parameters.
*/
async beginStartOSUpgrade(resourceGroupName, vmScaleSetName, 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, vmScaleSetName, options },
spec: startOSUpgradeOperationSpec,
});
const poller = await createHttpPoller(lro, {
restoreFrom: options?.resumeFrom,
intervalInMs: options?.updateIntervalInMs,
resourceLocationConfig: "location",
});
await poller.poll();
return poller;
}
/**
* Starts a rolling upgrade to move all virtual machine scale set instances to the latest available
* Platform Image OS version. Instances which are already running the latest available OS version are
* not affected.
* @param resourceGroupName The name of the resource group. The name is case insensitive.
* @param vmScaleSetName The name of the VM scale set.
* @param options The options parameters.
*/
async beginStartOSUpgradeAndWait(resourceGroupName, vmScaleSetName, options) {
const poller = await this.beginStartOSUpgrade(resourceGroupName, vmScaleSetName, options);
return poller.pollUntilDone();
}
/**
* Cancels the current virtual machine scale set rolling upgrade.
* @param resourceGroupName The name of the resource group. The name is case insensitive.
* @param vmScaleSetName The name of the VM scale set.
* @param options The options parameters.
*/
async beginCancel(resourceGroupName, vmScaleSetName, 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, vmScaleSetName, options },
spec: cancelOperationSpec,
});
const poller = await createHttpPoller(lro, {
restoreFrom: options?.resumeFrom,
intervalInMs: options?.updateIntervalInMs,
resourceLocationConfig: "location",
});
await poller.poll();
return poller;
}
/**
* Cancels the current virtual machine scale set rolling upgrade.
* @param resourceGroupName The name of the resource group. The name is case insensitive.
* @param vmScaleSetName The name of the VM scale set.
* @param options The options parameters.
*/
async beginCancelAndWait(resourceGroupName, vmScaleSetName, options) {
const poller = await this.beginCancel(resourceGroupName, vmScaleSetName, options);
return poller.pollUntilDone();
}
/**
* Gets the status of the latest virtual machine scale set rolling upgrade.
* @param resourceGroupName The name of the resource group. The name is case insensitive.
* @param vmScaleSetName The name of the VM scale set.
* @param options The options parameters.
*/
getLatest(resourceGroupName, vmScaleSetName, options) {
return this.client.sendOperationRequest({ resourceGroupName, vmScaleSetName, options }, getLatestOperationSpec);
}
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const startExtensionUpgradeOperationSpec = {
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade",
httpMethod: "POST",
responses: {
200: {},
201: {},
202: {},
204: {},
default: {
bodyMapper: Mappers.CloudError,
},
},
queryParameters: [Parameters.apiVersion],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.vmScaleSetName,
],
headerParameters: [Parameters.accept],
serializer,
};
const startOSUpgradeOperationSpec = {
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade",
httpMethod: "POST",
responses: {
200: {},
201: {},
202: {},
204: {},
default: {
bodyMapper: Mappers.CloudError,
},
},
queryParameters: [Parameters.apiVersion],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.vmScaleSetName,
],
headerParameters: [Parameters.accept],
serializer,
};
const cancelOperationSpec = {
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel",
httpMethod: "POST",
responses: {
200: {},
201: {},
202: {},
204: {},
default: {
bodyMapper: Mappers.CloudError,
},
},
queryParameters: [Parameters.apiVersion],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.vmScaleSetName,
],
headerParameters: [Parameters.accept],
serializer,
};
const getLatestOperationSpec = {
path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.RollingUpgradeStatusInfo,
},
default: {
bodyMapper: Mappers.CloudError,
},
},
queryParameters: [Parameters.apiVersion],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.vmScaleSetName,
],
headerParameters: [Parameters.accept],
serializer,
};
//# sourceMappingURL=virtualMachineScaleSetRollingUpgrades.js.map