import { PagedAsyncIterableIterator } from "@azure/core-paging" ; import { DiskRestorePointOperations } 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 { DiskRestorePoint , DiskRestorePointListByRestorePointNextOptionalParams , DiskRestorePointListByRestorePointOptionalParams , DiskRestorePointGetOptionalParams , DiskRestorePointGetResponse , DiskRestorePointListByRestorePointResponse , GrantAccessData , DiskRestorePointGrantAccessOptionalParams , DiskRestorePointGrantAccessResponse , DiskRestorePointRevokeAccessOptionalParams , DiskRestorePointListByRestorePointNextResponse } from "../models" ; /** Class containing DiskRestorePointOperations operations. */ export class DiskRestorePointOperationsImpl implements DiskRestorePointOperations { private readonly client : ComputeManagementClient ; param client constructor ( client ) { this . client = client ; } param resourceGroupName param restorePointCollectionName param vmRestorePointName param options public listByRestorePoint ( resourceGroupName , restorePointCollectionName , vmRestorePointName , options ? ) { const iter = this . listByRestorePointPagingAll ( resourceGroupName , restorePointCollectionName , vmRestorePointName , options ) ; return { next ( ) { return iter . next ( ) ; } , [ Symbol . asyncIterator ] ( ) { return this ; } , byPage : ( ) => { return this . listByRestorePointPagingPage ( resourceGroupName , restorePointCollectionName , vmRestorePointName , options ) ; } } ; } private async * listByRestorePointPagingPage ( resourceGroupName , restorePointCollectionName , vmRestorePointName , options ? ) { let result = await this . _listByRestorePoint ( resourceGroupName , restorePointCollectionName , vmRestorePointName , options ) ; yield result . value || [ ] ; let continuationToken = result . nextLink ; while ( continuationToken ) { result = await this . _listByRestorePointNext ( resourceGroupName , restorePointCollectionName , vmRestorePointName , continuationToken , options ) ; continuationToken = result . nextLink ; yield result . value || [ ] ; } } private async * listByRestorePointPagingAll ( resourceGroupName , restorePointCollectionName , vmRestorePointName , options ? ) { for await ( const page of this . listByRestorePointPagingPage ( resourceGroupName , restorePointCollectionName , vmRestorePointName , options ) ) { yield * page ; } } param resourceGroupName param restorePointCollectionName param vmRestorePointName param diskRestorePointName param options get ( resourceGroupName , restorePointCollectionName , vmRestorePointName , diskRestorePointName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , restorePointCollectionName , vmRestorePointName , diskRestorePointName , options } , getOperationSpec ) ; } param resourceGroupName param restorePointCollectionName param vmRestorePointName param options private _listByRestorePoint ( resourceGroupName , restorePointCollectionName , vmRestorePointName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , restorePointCollectionName , vmRestorePointName , options } , listByRestorePointOperationSpec ) ; } param resourceGroupName param restorePointCollectionName param vmRestorePointName param diskRestorePointName param grantAccessData param options async beginGrantAccess ( resourceGroupName , restorePointCollectionName , vmRestorePointName , diskRestorePointName , grantAccessData , options ? ) { const directSendOperation = async ( args , spec ) : Promise < DiskRestorePointGrantAccessResponse > => { 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 , restorePointCollectionName , vmRestorePointName , diskRestorePointName , grantAccessData , options } , grantAccessOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs , lroResourceLocationConfig : "location" } ) ; } param resourceGroupName param restorePointCollectionName param vmRestorePointName param diskRestorePointName param grantAccessData param options async beginGrantAccessAndWait ( resourceGroupName , restorePointCollectionName , vmRestorePointName , diskRestorePointName , grantAccessData , options ? ) { const poller = await this . beginGrantAccess ( resourceGroupName , restorePointCollectionName , vmRestorePointName , diskRestorePointName , grantAccessData , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param restorePointCollectionName param vmRestorePointName param diskRestorePointName param options async beginRevokeAccess ( resourceGroupName , restorePointCollectionName , vmRestorePointName , diskRestorePointName , 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 , restorePointCollectionName , vmRestorePointName , diskRestorePointName , options } , revokeAccessOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs , lroResourceLocationConfig : "location" } ) ; } param resourceGroupName param restorePointCollectionName param vmRestorePointName param diskRestorePointName param options async beginRevokeAccessAndWait ( resourceGroupName , restorePointCollectionName , vmRestorePointName , diskRestorePointName , options ? ) { const poller = await this . beginRevokeAccess ( resourceGroupName , restorePointCollectionName , vmRestorePointName , diskRestorePointName , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param restorePointCollectionName param vmRestorePointName param nextLink param options private _listByRestorePointNext ( resourceGroupName , restorePointCollectionName , vmRestorePointName , nextLink , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , restorePointCollectionName , vmRestorePointName , nextLink , options } , listByRestorePointNextOperationSpec ) ; } } const serializer = coreClient . createSerializer ( Mappers , false ) ; const getOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . DiskRestorePoint } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion1 ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . restorePointCollectionName , Parameters . vmRestorePointName , Parameters . diskRestorePointName ] , headerParameters : [ Parameters . accept ] , serializer } ; const listByRestorePointOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . DiskRestorePointList } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion1 ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . restorePointCollectionName , Parameters . vmRestorePointName ] , headerParameters : [ Parameters . accept ] , serializer } ; const grantAccessOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}/beginGetAccess" , httpMethod : "POST" , responses : { 200 : { bodyMapper : Mappers . AccessUri } , 201 : { bodyMapper : Mappers . AccessUri } , 202 : { bodyMapper : Mappers . AccessUri } , 204 : { bodyMapper : Mappers . AccessUri } , default : { bodyMapper : Mappers . CloudError } } , requestBody : Parameters . grantAccessData , queryParameters : [ Parameters . apiVersion1 ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . restorePointCollectionName , Parameters . vmRestorePointName , Parameters . diskRestorePointName ] , headerParameters : [ Parameters . accept , Parameters . contentType ] , mediaType : "json" , serializer } ; const revokeAccessOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/restorePointCollections/{restorePointCollectionName}/restorePoints/{vmRestorePointName}/diskRestorePoints/{diskRestorePointName}/endGetAccess" , httpMethod : "POST" , responses : { 200 : { } , 201 : { } , 202 : { } , 204 : { } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion1 ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . restorePointCollectionName , Parameters . vmRestorePointName , Parameters . diskRestorePointName ] , headerParameters : [ Parameters . accept ] , serializer } ; const listByRestorePointNextOperationSpec = { path : "{nextLink}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . DiskRestorePointList } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion1 ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . nextLink , Parameters . restorePointCollectionName , Parameters . vmRestorePointName ] , headerParameters : [ Parameters . accept ] , serializer } ;