import { PagedAsyncIterableIterator } from "@azure/core-paging" ; import { VirtualMachineScaleSetVMRunCommands } 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 { VirtualMachineRunCommand , VirtualMachineScaleSetVMRunCommandsListNextOptionalParams , VirtualMachineScaleSetVMRunCommandsListOptionalParams , VirtualMachineScaleSetVMRunCommandsCreateOrUpdateOptionalParams , VirtualMachineScaleSetVMRunCommandsCreateOrUpdateResponse , VirtualMachineRunCommandUpdate , VirtualMachineScaleSetVMRunCommandsUpdateOptionalParams , VirtualMachineScaleSetVMRunCommandsUpdateResponse , VirtualMachineScaleSetVMRunCommandsDeleteOptionalParams , VirtualMachineScaleSetVMRunCommandsGetOptionalParams , VirtualMachineScaleSetVMRunCommandsGetResponse , VirtualMachineScaleSetVMRunCommandsListResponse , VirtualMachineScaleSetVMRunCommandsListNextResponse } from "../models" ; /** Class containing VirtualMachineScaleSetVMRunCommands operations. */ export class VirtualMachineScaleSetVMRunCommandsImpl implements VirtualMachineScaleSetVMRunCommands { private readonly client : ComputeManagementClient ; param client constructor ( client ) { this . client = client ; } param resourceGroupName param vmScaleSetName param instanceId param options public list ( resourceGroupName , vmScaleSetName , instanceId , options ? ) { const iter = this . listPagingAll ( resourceGroupName , vmScaleSetName , instanceId , options ) ; return { next ( ) { return iter . next ( ) ; } , [ Symbol . asyncIterator ] ( ) { return this ; } , byPage : ( ) => { return this . listPagingPage ( resourceGroupName , vmScaleSetName , instanceId , options ) ; } } ; } private async * listPagingPage ( resourceGroupName , vmScaleSetName , instanceId , options ? ) { let result = await this . _list ( resourceGroupName , vmScaleSetName , instanceId , options ) ; yield result . value || [ ] ; let continuationToken = result . nextLink ; while ( continuationToken ) { result = await this . _listNext ( resourceGroupName , vmScaleSetName , instanceId , continuationToken , options ) ; continuationToken = result . nextLink ; yield result . value || [ ] ; } } private async * listPagingAll ( resourceGroupName , vmScaleSetName , instanceId , options ? ) { for await ( const page of this . listPagingPage ( resourceGroupName , vmScaleSetName , instanceId , options ) ) { yield * page ; } } param resourceGroupName param vmScaleSetName param instanceId param runCommandName param runCommand param options async beginCreateOrUpdate ( resourceGroupName , vmScaleSetName , instanceId , runCommandName , runCommand , options ? ) { const directSendOperation = async ( args , spec ) : Promise < VirtualMachineScaleSetVMRunCommandsCreateOrUpdateResponse > => { 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 , instanceId , runCommandName , runCommand , options } , createOrUpdateOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs } ) ; } param resourceGroupName param vmScaleSetName param instanceId param runCommandName param runCommand param options async beginCreateOrUpdateAndWait ( resourceGroupName , vmScaleSetName , instanceId , runCommandName , runCommand , options ? ) { const poller = await this . beginCreateOrUpdate ( resourceGroupName , vmScaleSetName , instanceId , runCommandName , runCommand , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param vmScaleSetName param instanceId param runCommandName param runCommand param options async beginUpdate ( resourceGroupName , vmScaleSetName , instanceId , runCommandName , runCommand , options ? ) { const directSendOperation = async ( args , spec ) : Promise < VirtualMachineScaleSetVMRunCommandsUpdateResponse > => { 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 , instanceId , runCommandName , runCommand , options } , updateOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs } ) ; } param resourceGroupName param vmScaleSetName param instanceId param runCommandName param runCommand param options async beginUpdateAndWait ( resourceGroupName , vmScaleSetName , instanceId , runCommandName , runCommand , options ? ) { const poller = await this . beginUpdate ( resourceGroupName , vmScaleSetName , instanceId , runCommandName , runCommand , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param vmScaleSetName param instanceId param runCommandName param options async beginDelete ( resourceGroupName , vmScaleSetName , instanceId , runCommandName , 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 , instanceId , runCommandName , options } , deleteOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs } ) ; } param resourceGroupName param vmScaleSetName param instanceId param runCommandName param options async beginDeleteAndWait ( resourceGroupName , vmScaleSetName , instanceId , runCommandName , options ? ) { const poller = await this . beginDelete ( resourceGroupName , vmScaleSetName , instanceId , runCommandName , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param vmScaleSetName param instanceId param runCommandName param options get ( resourceGroupName , vmScaleSetName , instanceId , runCommandName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , vmScaleSetName , instanceId , runCommandName , options } , getOperationSpec ) ; } param resourceGroupName param vmScaleSetName param instanceId param options private _list ( resourceGroupName , vmScaleSetName , instanceId , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , vmScaleSetName , instanceId , options } , listOperationSpec ) ; } param resourceGroupName param vmScaleSetName param instanceId param nextLink param options private _listNext ( resourceGroupName , vmScaleSetName , instanceId , nextLink , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , vmScaleSetName , instanceId , nextLink , options } , listNextOperationSpec ) ; } } const serializer = coreClient . createSerializer ( Mappers , false ) ; const createOrUpdateOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}" , httpMethod : "PUT" , responses : { 200 : { bodyMapper : Mappers . VirtualMachineRunCommand } , 201 : { bodyMapper : Mappers . VirtualMachineRunCommand } , 202 : { bodyMapper : Mappers . VirtualMachineRunCommand } , 204 : { bodyMapper : Mappers . VirtualMachineRunCommand } , default : { bodyMapper : Mappers . CloudError } } , requestBody : Parameters . runCommand , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . vmScaleSetName , Parameters . instanceId , Parameters . runCommandName ] , headerParameters : [ Parameters . contentType , Parameters . accept1 ] , mediaType : "json" , serializer } ; const updateOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}" , httpMethod : "PATCH" , responses : { 200 : { bodyMapper : Mappers . VirtualMachineRunCommand } , 201 : { bodyMapper : Mappers . VirtualMachineRunCommand } , 202 : { bodyMapper : Mappers . VirtualMachineRunCommand } , 204 : { bodyMapper : Mappers . VirtualMachineRunCommand } , default : { bodyMapper : Mappers . CloudError } } , requestBody : Parameters . runCommand1 , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . vmScaleSetName , Parameters . instanceId , Parameters . runCommandName ] , headerParameters : [ Parameters . contentType , Parameters . accept1 ] , mediaType : "json" , serializer } ; const deleteOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}" , httpMethod : "DELETE" , responses : { 200 : { } , 201 : { } , 202 : { } , 204 : { } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . vmScaleSetName , Parameters . instanceId , Parameters . runCommandName ] , headerParameters : [ Parameters . accept1 ] , serializer } ; const getOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands/{runCommandName}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . VirtualMachineRunCommand } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion , Parameters . expand ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . vmScaleSetName , Parameters . instanceId , Parameters . runCommandName ] , headerParameters : [ Parameters . accept1 ] , serializer } ; const listOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualMachines/{instanceId}/runCommands" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . VirtualMachineRunCommandsListResult } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion , Parameters . expand ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . vmScaleSetName , Parameters . instanceId ] , headerParameters : [ Parameters . accept1 ] , serializer } ; const listNextOperationSpec = { path : "{nextLink}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . VirtualMachineRunCommandsListResult } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion , Parameters . expand ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . nextLink , Parameters . vmScaleSetName , Parameters . instanceId ] , headerParameters : [ Parameters . accept1 ] , serializer } ;