import { VirtualMachineScaleSetRollingUpgrades } from "../operationsInterfaces" ; import * as coreClient from "@azure/core-client" ; import * as Mappers from "../models/mappers" ; import * as Parameters from "../models/parameters" ; import { ComputeManagementClient } from "../computeManagementClient" ; import { PollerLike , PollOperationState , LroEngine } from "@azure/core-lro" ; import { LroImpl } from "../lroImpl" ; import { VirtualMachineScaleSetRollingUpgradesCancelOptionalParams , VirtualMachineScaleSetRollingUpgradesStartOSUpgradeOptionalParams , VirtualMachineScaleSetRollingUpgradesStartExtensionUpgradeOptionalParams , VirtualMachineScaleSetRollingUpgradesGetLatestOptionalParams , VirtualMachineScaleSetRollingUpgradesGetLatestResponse } from "../models" ; /** Class containing VirtualMachineScaleSetRollingUpgrades operations. */ export class VirtualMachineScaleSetRollingUpgradesImpl implements VirtualMachineScaleSetRollingUpgrades { private readonly client : ComputeManagementClient ; param client constructor ( client ) { this . client = client ; } param resourceGroupName param vmScaleSetName param options async beginCancel ( resourceGroupName , vmScaleSetName , options ? ) { const directSendOperation = async ( args , spec ) : Promise < void > => { return this . client . sendOperationRequest ( args , spec ) ; } ; const sendOperation = 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 = new LroImpl ( sendOperation , { resourceGroupName , vmScaleSetName , options } , cancelOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs } ) ; } param resourceGroupName param vmScaleSetName param options async beginCancelAndWait ( resourceGroupName , vmScaleSetName , options ? ) { const poller = await this . beginCancel ( resourceGroupName , vmScaleSetName , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param vmScaleSetName param options async beginStartOSUpgrade ( resourceGroupName , vmScaleSetName , options ? ) { const directSendOperation = async ( args , spec ) : Promise < void > => { return this . client . sendOperationRequest ( args , spec ) ; } ; const sendOperation = 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 = new LroImpl ( sendOperation , { resourceGroupName , vmScaleSetName , options } , startOSUpgradeOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs } ) ; } param resourceGroupName param vmScaleSetName param options async beginStartOSUpgradeAndWait ( resourceGroupName , vmScaleSetName , options ? ) { const poller = await this . beginStartOSUpgrade ( resourceGroupName , vmScaleSetName , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param vmScaleSetName param options async beginStartExtensionUpgrade ( resourceGroupName , vmScaleSetName , options ? ) { const directSendOperation = async ( args , spec ) : Promise < void > => { return this . client . sendOperationRequest ( args , spec ) ; } ; const sendOperation = 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 = new LroImpl ( sendOperation , { resourceGroupName , vmScaleSetName , options } , startExtensionUpgradeOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs } ) ; } param resourceGroupName param vmScaleSetName param options async beginStartExtensionUpgradeAndWait ( resourceGroupName , vmScaleSetName , options ? ) { const poller = await this . beginStartExtensionUpgrade ( resourceGroupName , vmScaleSetName , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param vmScaleSetName param options getLatest ( resourceGroupName , vmScaleSetName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , vmScaleSetName , options } , getLatestOperationSpec ) ; } } const serializer = coreClient . createSerializer ( Mappers , false ) ; const cancelOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel" , httpMethod : "POST" , responses : { 200 : { } , 201 : { } , 202 : { } , 204 : { } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . vmScaleSetName ] , serializer } ; const startOSUpgradeOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade" , httpMethod : "POST" , responses : { 200 : { } , 201 : { } , 202 : { } , 204 : { } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . vmScaleSetName ] , serializer } ; const startExtensionUpgradeOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade" , httpMethod : "POST" , responses : { 200 : { } , 201 : { } , 202 : { } , 204 : { } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . vmScaleSetName ] , serializer } ; const getLatestOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . RollingUpgradeStatusInfo } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . vmScaleSetName ] , headerParameters : [ Parameters . accept ] , serializer } ;