import { PagedAsyncIterableIterator } from "@azure/core-paging" ; import { CloudServiceRoleInstances } 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 { RoleInstance , CloudServiceRoleInstancesListNextOptionalParams , CloudServiceRoleInstancesListOptionalParams , CloudServiceRoleInstancesDeleteOptionalParams , CloudServiceRoleInstancesGetOptionalParams , CloudServiceRoleInstancesGetResponse , CloudServiceRoleInstancesGetInstanceViewOptionalParams , CloudServiceRoleInstancesGetInstanceViewResponse , CloudServiceRoleInstancesListResponse , CloudServiceRoleInstancesRestartOptionalParams , CloudServiceRoleInstancesReimageOptionalParams , CloudServiceRoleInstancesRebuildOptionalParams , CloudServiceRoleInstancesGetRemoteDesktopFileOptionalParams , CloudServiceRoleInstancesGetRemoteDesktopFileResponse , CloudServiceRoleInstancesListNextResponse } from "../models" ; /** Class containing CloudServiceRoleInstances operations. */ export class CloudServiceRoleInstancesImpl implements CloudServiceRoleInstances { private readonly client : ComputeManagementClient ; param client constructor ( client ) { this . client = client ; } param resourceGroupName param cloudServiceName param options public list ( resourceGroupName , cloudServiceName , options ? ) { const iter = this . listPagingAll ( resourceGroupName , cloudServiceName , options ) ; return { next ( ) { return iter . next ( ) ; } , [ Symbol . asyncIterator ] ( ) { return this ; } , byPage : ( ) => { return this . listPagingPage ( resourceGroupName , cloudServiceName , options ) ; } } ; } private async * listPagingPage ( resourceGroupName , cloudServiceName , options ? ) { let result = await this . _list ( resourceGroupName , cloudServiceName , options ) ; yield result . value || [ ] ; let continuationToken = result . nextLink ; while ( continuationToken ) { result = await this . _listNext ( resourceGroupName , cloudServiceName , continuationToken , options ) ; continuationToken = result . nextLink ; yield result . value || [ ] ; } } private async * listPagingAll ( resourceGroupName , cloudServiceName , options ? ) { for await ( const page of this . listPagingPage ( resourceGroupName , cloudServiceName , options ) ) { yield * page ; } } param roleInstanceName param resourceGroupName param cloudServiceName param options async beginDelete ( roleInstanceName , resourceGroupName , cloudServiceName , 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 , { roleInstanceName , resourceGroupName , cloudServiceName , options } , deleteOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs } ) ; } param roleInstanceName param resourceGroupName param cloudServiceName param options async beginDeleteAndWait ( roleInstanceName , resourceGroupName , cloudServiceName , options ? ) { const poller = await this . beginDelete ( roleInstanceName , resourceGroupName , cloudServiceName , options ) ; return poller . pollUntilDone ( ) ; } param roleInstanceName param resourceGroupName param cloudServiceName param options get ( roleInstanceName , resourceGroupName , cloudServiceName , options ? ) { return this . client . sendOperationRequest ( { roleInstanceName , resourceGroupName , cloudServiceName , options } , getOperationSpec ) ; } param roleInstanceName param resourceGroupName param cloudServiceName param options getInstanceView ( roleInstanceName , resourceGroupName , cloudServiceName , options ? ) { return this . client . sendOperationRequest ( { roleInstanceName , resourceGroupName , cloudServiceName , options } , getInstanceViewOperationSpec ) ; } param resourceGroupName param cloudServiceName param options private _list ( resourceGroupName , cloudServiceName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , cloudServiceName , options } , listOperationSpec ) ; } param roleInstanceName param resourceGroupName param cloudServiceName param options async beginRestart ( roleInstanceName , resourceGroupName , cloudServiceName , 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 , { roleInstanceName , resourceGroupName , cloudServiceName , options } , restartOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs } ) ; } param roleInstanceName param resourceGroupName param cloudServiceName param options async beginRestartAndWait ( roleInstanceName , resourceGroupName , cloudServiceName , options ? ) { const poller = await this . beginRestart ( roleInstanceName , resourceGroupName , cloudServiceName , options ) ; return poller . pollUntilDone ( ) ; } param roleInstanceName param resourceGroupName param cloudServiceName param options async beginReimage ( roleInstanceName , resourceGroupName , cloudServiceName , 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 , { roleInstanceName , resourceGroupName , cloudServiceName , options } , reimageOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs } ) ; } param roleInstanceName param resourceGroupName param cloudServiceName param options async beginReimageAndWait ( roleInstanceName , resourceGroupName , cloudServiceName , options ? ) { const poller = await this . beginReimage ( roleInstanceName , resourceGroupName , cloudServiceName , options ) ; return poller . pollUntilDone ( ) ; } param roleInstanceName param resourceGroupName param cloudServiceName param options async beginRebuild ( roleInstanceName , resourceGroupName , cloudServiceName , 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 , { roleInstanceName , resourceGroupName , cloudServiceName , options } , rebuildOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs } ) ; } param roleInstanceName param resourceGroupName param cloudServiceName param options async beginRebuildAndWait ( roleInstanceName , resourceGroupName , cloudServiceName , options ? ) { const poller = await this . beginRebuild ( roleInstanceName , resourceGroupName , cloudServiceName , options ) ; return poller . pollUntilDone ( ) ; } param roleInstanceName param resourceGroupName param cloudServiceName param options getRemoteDesktopFile ( roleInstanceName , resourceGroupName , cloudServiceName , options ? ) { return this . client . sendOperationRequest ( { roleInstanceName , resourceGroupName , cloudServiceName , options } , getRemoteDesktopFileOperationSpec ) ; } param resourceGroupName param cloudServiceName param nextLink param options private _listNext ( resourceGroupName , cloudServiceName , nextLink , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , cloudServiceName , nextLink , options } , listNextOperationSpec ) ; } } const serializer = coreClient . createSerializer ( Mappers , 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 . apiVersion2 ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . roleInstanceName , 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 . expand1 , Parameters . apiVersion2 ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . roleInstanceName , 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 . apiVersion2 ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . roleInstanceName , 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 . expand1 , Parameters . apiVersion2 ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , 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 . apiVersion2 ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . roleInstanceName , 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 . apiVersion2 ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . roleInstanceName , 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 . apiVersion2 ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . roleInstanceName , 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 . apiVersion2 ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . roleInstanceName , Parameters . cloudServiceName ] , headerParameters : [ Parameters . accept2 ] , serializer } ; const listNextOperationSpec = { path : "{nextLink}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . RoleInstanceListResult } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . expand1 , Parameters . apiVersion2 ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . nextLink , Parameters . cloudServiceName ] , headerParameters : [ Parameters . accept ] , serializer } ;