import { PagedAsyncIterableIterator } from "@azure/core-paging" ; import { RouteFilterRules } 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 { RouteFilterRule , RouteFilterRulesListByRouteFilterNextOptionalParams , RouteFilterRulesListByRouteFilterOptionalParams , RouteFilterRulesDeleteOptionalParams , RouteFilterRulesGetOptionalParams , RouteFilterRulesGetResponse , RouteFilterRulesCreateOrUpdateOptionalParams , RouteFilterRulesCreateOrUpdateResponse , RouteFilterRulesListByRouteFilterResponse , RouteFilterRulesListByRouteFilterNextResponse } from "../models" ; /** Class containing RouteFilterRules operations. */ export class RouteFilterRulesImpl implements RouteFilterRules { private readonly client : NetworkManagementClient ; param client constructor ( client ) { this . client = client ; } param resourceGroupName param routeFilterName param options public listByRouteFilter ( resourceGroupName , routeFilterName , options ? ) { const iter = this . listByRouteFilterPagingAll ( resourceGroupName , routeFilterName , options ) ; return { next ( ) { return iter . next ( ) ; } , [ Symbol . asyncIterator ] ( ) { return this ; } , byPage : ( ) => { return this . listByRouteFilterPagingPage ( resourceGroupName , routeFilterName , options ) ; } } ; } private async * listByRouteFilterPagingPage ( resourceGroupName , routeFilterName , options ? ) { let result = await this . _listByRouteFilter ( resourceGroupName , routeFilterName , options ) ; yield result . value || [ ] ; let continuationToken = result . nextLink ; while ( continuationToken ) { result = await this . _listByRouteFilterNext ( resourceGroupName , routeFilterName , continuationToken , options ) ; continuationToken = result . nextLink ; yield result . value || [ ] ; } } private async * listByRouteFilterPagingAll ( resourceGroupName , routeFilterName , options ? ) { for await ( const page of this . listByRouteFilterPagingPage ( resourceGroupName , routeFilterName , options ) ) { yield * page ; } } param resourceGroupName param routeFilterName param ruleName param options async beginDelete ( resourceGroupName , routeFilterName , ruleName , 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 , routeFilterName , ruleName , options } , deleteOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs , lroResourceLocationConfig : "location" } ) ; } param resourceGroupName param routeFilterName param ruleName param options async beginDeleteAndWait ( resourceGroupName , routeFilterName , ruleName , options ? ) { const poller = await this . beginDelete ( resourceGroupName , routeFilterName , ruleName , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param routeFilterName param ruleName param options get ( resourceGroupName , routeFilterName , ruleName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , routeFilterName , ruleName , options } , getOperationSpec ) ; } param resourceGroupName param routeFilterName param ruleName param routeFilterRuleParameters param options async beginCreateOrUpdate ( resourceGroupName , routeFilterName , ruleName , routeFilterRuleParameters , options ? ) { const directSendOperation = async ( args , spec ) : Promise < RouteFilterRulesCreateOrUpdateResponse > => { 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 , routeFilterName , ruleName , routeFilterRuleParameters , options } , createOrUpdateOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs , lroResourceLocationConfig : "azure-async-operation" } ) ; } param resourceGroupName param routeFilterName param ruleName param routeFilterRuleParameters param options async beginCreateOrUpdateAndWait ( resourceGroupName , routeFilterName , ruleName , routeFilterRuleParameters , options ? ) { const poller = await this . beginCreateOrUpdate ( resourceGroupName , routeFilterName , ruleName , routeFilterRuleParameters , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param routeFilterName param options private _listByRouteFilter ( resourceGroupName , routeFilterName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , routeFilterName , options } , listByRouteFilterOperationSpec ) ; } param resourceGroupName param routeFilterName param nextLink param options private _listByRouteFilterNext ( resourceGroupName , routeFilterName , nextLink , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , routeFilterName , nextLink , options } , listByRouteFilterNextOperationSpec ) ; } } const serializer = coreClient . createSerializer ( Mappers , false ) ; const deleteOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeFilters/{routeFilterName}/routeFilterRules/{ruleName}" , httpMethod : "DELETE" , responses : { 200 : { } , 201 : { } , 202 : { } , 204 : { } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . routeFilterName , Parameters . ruleName ] , headerParameters : [ Parameters . accept ] , serializer } ; const getOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeFilters/{routeFilterName}/routeFilterRules/{ruleName}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . RouteFilterRule } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . routeFilterName , Parameters . ruleName ] , headerParameters : [ Parameters . accept ] , serializer } ; const createOrUpdateOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeFilters/{routeFilterName}/routeFilterRules/{ruleName}" , httpMethod : "PUT" , responses : { 200 : { bodyMapper : Mappers . RouteFilterRule } , 201 : { bodyMapper : Mappers . RouteFilterRule } , 202 : { bodyMapper : Mappers . RouteFilterRule } , 204 : { bodyMapper : Mappers . RouteFilterRule } , default : { bodyMapper : Mappers . CloudError } } , requestBody : Parameters . routeFilterRuleParameters , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . routeFilterName , Parameters . ruleName ] , headerParameters : [ Parameters . accept , Parameters . contentType ] , mediaType : "json" , serializer } ; const listByRouteFilterOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/routeFilters/{routeFilterName}/routeFilterRules" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . RouteFilterRuleListResult } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . routeFilterName ] , headerParameters : [ Parameters . accept ] , serializer } ; const listByRouteFilterNextOperationSpec = { path : "{nextLink}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . RouteFilterRuleListResult } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . nextLink , Parameters . routeFilterName ] , headerParameters : [ Parameters . accept ] , serializer } ;