import { PagedAsyncIterableIterator } from "@azure/core-paging" ; import { LoadBalancerBackendAddressPools } from "../operationsInterfaces" ; import * as coreClient from "@azure/core-client" ; import * as Mappers from "../models/mappers" ; import * as Parameters from "../models/parameters" ; import { NetworkManagementClient } from "../networkManagementClient" ; import { PollerLike , PollOperationState , LroEngine } from "@azure/core-lro" ; import { LroImpl } from "../lroImpl" ; import { BackendAddressPool , LoadBalancerBackendAddressPoolsListNextOptionalParams , LoadBalancerBackendAddressPoolsListOptionalParams , LoadBalancerBackendAddressPoolsListResponse , LoadBalancerBackendAddressPoolsGetOptionalParams , LoadBalancerBackendAddressPoolsGetResponse , LoadBalancerBackendAddressPoolsCreateOrUpdateOptionalParams , LoadBalancerBackendAddressPoolsCreateOrUpdateResponse , LoadBalancerBackendAddressPoolsDeleteOptionalParams , LoadBalancerBackendAddressPoolsListNextResponse } from "../models" ; /** Class containing LoadBalancerBackendAddressPools operations. */ export class LoadBalancerBackendAddressPoolsImpl implements LoadBalancerBackendAddressPools { private readonly client : NetworkManagementClient ; param client constructor ( client ) { this . client = client ; } param resourceGroupName param loadBalancerName param options public list ( resourceGroupName , loadBalancerName , options ? ) { const iter = this . listPagingAll ( resourceGroupName , loadBalancerName , options ) ; return { next ( ) { return iter . next ( ) ; } , [ Symbol . asyncIterator ] ( ) { return this ; } , byPage : ( ) => { return this . listPagingPage ( resourceGroupName , loadBalancerName , options ) ; } } ; } private async * listPagingPage ( resourceGroupName , loadBalancerName , options ? ) { let result = await this . _list ( resourceGroupName , loadBalancerName , options ) ; yield result . value || [ ] ; let continuationToken = result . nextLink ; while ( continuationToken ) { result = await this . _listNext ( resourceGroupName , loadBalancerName , continuationToken , options ) ; continuationToken = result . nextLink ; yield result . value || [ ] ; } } private async * listPagingAll ( resourceGroupName , loadBalancerName , options ? ) { for await ( const page of this . listPagingPage ( resourceGroupName , loadBalancerName , options ) ) { yield * page ; } } param resourceGroupName param loadBalancerName param options private _list ( resourceGroupName , loadBalancerName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , loadBalancerName , options } , listOperationSpec ) ; } param resourceGroupName param loadBalancerName param backendAddressPoolName param options get ( resourceGroupName , loadBalancerName , backendAddressPoolName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , loadBalancerName , backendAddressPoolName , options } , getOperationSpec ) ; } param resourceGroupName param loadBalancerName param backendAddressPoolName param parameters param options async beginCreateOrUpdate ( resourceGroupName , loadBalancerName , backendAddressPoolName , parameters , options ? ) { const directSendOperation = async ( args , spec ) : Promise < LoadBalancerBackendAddressPoolsCreateOrUpdateResponse > => { 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 , loadBalancerName , backendAddressPoolName , parameters , options } , createOrUpdateOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs , lroResourceLocationConfig : "azure-async-operation" } ) ; } param resourceGroupName param loadBalancerName param backendAddressPoolName param parameters param options async beginCreateOrUpdateAndWait ( resourceGroupName , loadBalancerName , backendAddressPoolName , parameters , options ? ) { const poller = await this . beginCreateOrUpdate ( resourceGroupName , loadBalancerName , backendAddressPoolName , parameters , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param loadBalancerName param backendAddressPoolName param options async beginDelete ( resourceGroupName , loadBalancerName , backendAddressPoolName , 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 , loadBalancerName , backendAddressPoolName , options } , deleteOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs , lroResourceLocationConfig : "location" } ) ; } param resourceGroupName param loadBalancerName param backendAddressPoolName param options async beginDeleteAndWait ( resourceGroupName , loadBalancerName , backendAddressPoolName , options ? ) { const poller = await this . beginDelete ( resourceGroupName , loadBalancerName , backendAddressPoolName , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param loadBalancerName param nextLink param options private _listNext ( resourceGroupName , loadBalancerName , nextLink , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , loadBalancerName , nextLink , options } , listNextOperationSpec ) ; } } const serializer = coreClient . createSerializer ( Mappers , false ) ; const listOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/backendAddressPools" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . LoadBalancerBackendAddressPoolListResult } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . loadBalancerName ] , headerParameters : [ Parameters . accept ] , serializer } ; const getOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/backendAddressPools/{backendAddressPoolName}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . BackendAddressPool } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . loadBalancerName , Parameters . backendAddressPoolName ] , headerParameters : [ Parameters . accept ] , serializer } ; const createOrUpdateOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/backendAddressPools/{backendAddressPoolName}" , httpMethod : "PUT" , responses : { 200 : { bodyMapper : Mappers . BackendAddressPool } , 201 : { bodyMapper : Mappers . BackendAddressPool } , 202 : { bodyMapper : Mappers . BackendAddressPool } , 204 : { bodyMapper : Mappers . BackendAddressPool } , default : { bodyMapper : Mappers . CloudError } } , requestBody : Parameters . parameters25 , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . loadBalancerName , Parameters . backendAddressPoolName ] , headerParameters : [ Parameters . accept , Parameters . contentType ] , mediaType : "json" , serializer } ; const deleteOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/backendAddressPools/{backendAddressPoolName}" , httpMethod : "DELETE" , responses : { 200 : { } , 201 : { } , 202 : { } , 204 : { } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . loadBalancerName , Parameters . backendAddressPoolName ] , headerParameters : [ Parameters . accept ] , serializer } ; const listNextOperationSpec = { path : "{nextLink}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . LoadBalancerBackendAddressPoolListResult } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . nextLink , Parameters . loadBalancerName ] , headerParameters : [ Parameters . accept ] , serializer } ;