import { PagedAsyncIterableIterator } from "@azure/core-paging" ; import { ServiceEndpointPolicyDefinitions } 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 { ServiceEndpointPolicyDefinition , ServiceEndpointPolicyDefinitionsListByResourceGroupNextOptionalParams , ServiceEndpointPolicyDefinitionsListByResourceGroupOptionalParams , ServiceEndpointPolicyDefinitionsDeleteOptionalParams , ServiceEndpointPolicyDefinitionsGetOptionalParams , ServiceEndpointPolicyDefinitionsGetResponse , ServiceEndpointPolicyDefinitionsCreateOrUpdateOptionalParams , ServiceEndpointPolicyDefinitionsCreateOrUpdateResponse , ServiceEndpointPolicyDefinitionsListByResourceGroupResponse , ServiceEndpointPolicyDefinitionsListByResourceGroupNextResponse } from "../models" ; /** Class containing ServiceEndpointPolicyDefinitions operations. */ export class ServiceEndpointPolicyDefinitionsImpl implements ServiceEndpointPolicyDefinitions { private readonly client : NetworkManagementClient ; param client constructor ( client ) { this . client = client ; } param resourceGroupName param serviceEndpointPolicyName param options public listByResourceGroup ( resourceGroupName , serviceEndpointPolicyName , options ? ) { const iter = this . listByResourceGroupPagingAll ( resourceGroupName , serviceEndpointPolicyName , options ) ; return { next ( ) { return iter . next ( ) ; } , [ Symbol . asyncIterator ] ( ) { return this ; } , byPage : ( ) => { return this . listByResourceGroupPagingPage ( resourceGroupName , serviceEndpointPolicyName , options ) ; } } ; } private async * listByResourceGroupPagingPage ( resourceGroupName , serviceEndpointPolicyName , options ? ) { let result = await this . _listByResourceGroup ( resourceGroupName , serviceEndpointPolicyName , options ) ; yield result . value || [ ] ; let continuationToken = result . nextLink ; while ( continuationToken ) { result = await this . _listByResourceGroupNext ( resourceGroupName , serviceEndpointPolicyName , continuationToken , options ) ; continuationToken = result . nextLink ; yield result . value || [ ] ; } } private async * listByResourceGroupPagingAll ( resourceGroupName , serviceEndpointPolicyName , options ? ) { for await ( const page of this . listByResourceGroupPagingPage ( resourceGroupName , serviceEndpointPolicyName , options ) ) { yield * page ; } } param resourceGroupName param serviceEndpointPolicyName param serviceEndpointPolicyDefinitionName param options async beginDelete ( resourceGroupName , serviceEndpointPolicyName , serviceEndpointPolicyDefinitionName , 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 , serviceEndpointPolicyName , serviceEndpointPolicyDefinitionName , options } , deleteOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs , lroResourceLocationConfig : "location" } ) ; } param resourceGroupName param serviceEndpointPolicyName param serviceEndpointPolicyDefinitionName param options async beginDeleteAndWait ( resourceGroupName , serviceEndpointPolicyName , serviceEndpointPolicyDefinitionName , options ? ) { const poller = await this . beginDelete ( resourceGroupName , serviceEndpointPolicyName , serviceEndpointPolicyDefinitionName , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param serviceEndpointPolicyName param serviceEndpointPolicyDefinitionName param options get ( resourceGroupName , serviceEndpointPolicyName , serviceEndpointPolicyDefinitionName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , serviceEndpointPolicyName , serviceEndpointPolicyDefinitionName , options } , getOperationSpec ) ; } param resourceGroupName param serviceEndpointPolicyName param serviceEndpointPolicyDefinitionName param serviceEndpointPolicyDefinitions param options async beginCreateOrUpdate ( resourceGroupName , serviceEndpointPolicyName , serviceEndpointPolicyDefinitionName , serviceEndpointPolicyDefinitions , options ? ) { const directSendOperation = async ( args , spec ) : Promise < ServiceEndpointPolicyDefinitionsCreateOrUpdateResponse > => { 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 , serviceEndpointPolicyName , serviceEndpointPolicyDefinitionName , serviceEndpointPolicyDefinitions , options } , createOrUpdateOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs , lroResourceLocationConfig : "azure-async-operation" } ) ; } param resourceGroupName param serviceEndpointPolicyName param serviceEndpointPolicyDefinitionName param serviceEndpointPolicyDefinitions param options async beginCreateOrUpdateAndWait ( resourceGroupName , serviceEndpointPolicyName , serviceEndpointPolicyDefinitionName , serviceEndpointPolicyDefinitions , options ? ) { const poller = await this . beginCreateOrUpdate ( resourceGroupName , serviceEndpointPolicyName , serviceEndpointPolicyDefinitionName , serviceEndpointPolicyDefinitions , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param serviceEndpointPolicyName param options private _listByResourceGroup ( resourceGroupName , serviceEndpointPolicyName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , serviceEndpointPolicyName , options } , listByResourceGroupOperationSpec ) ; } param resourceGroupName param serviceEndpointPolicyName param nextLink param options private _listByResourceGroupNext ( resourceGroupName , serviceEndpointPolicyName , nextLink , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , serviceEndpointPolicyName , nextLink , options } , listByResourceGroupNextOperationSpec ) ; } } const serializer = coreClient . createSerializer ( Mappers , false ) ; const deleteOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/serviceEndpointPolicies/{serviceEndpointPolicyName}/serviceEndpointPolicyDefinitions/{serviceEndpointPolicyDefinitionName}" , httpMethod : "DELETE" , responses : { 200 : { } , 201 : { } , 202 : { } , 204 : { } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . serviceEndpointPolicyName , Parameters . serviceEndpointPolicyDefinitionName ] , headerParameters : [ Parameters . accept ] , serializer } ; const getOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/serviceEndpointPolicies/{serviceEndpointPolicyName}/serviceEndpointPolicyDefinitions/{serviceEndpointPolicyDefinitionName}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . ServiceEndpointPolicyDefinition } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . serviceEndpointPolicyName , Parameters . serviceEndpointPolicyDefinitionName ] , headerParameters : [ Parameters . accept ] , serializer } ; const createOrUpdateOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/serviceEndpointPolicies/{serviceEndpointPolicyName}/serviceEndpointPolicyDefinitions/{serviceEndpointPolicyDefinitionName}" , httpMethod : "PUT" , responses : { 200 : { bodyMapper : Mappers . ServiceEndpointPolicyDefinition } , 201 : { bodyMapper : Mappers . ServiceEndpointPolicyDefinition } , 202 : { bodyMapper : Mappers . ServiceEndpointPolicyDefinition } , 204 : { bodyMapper : Mappers . ServiceEndpointPolicyDefinition } , default : { bodyMapper : Mappers . CloudError } } , requestBody : Parameters . serviceEndpointPolicyDefinitions , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . serviceEndpointPolicyName , Parameters . serviceEndpointPolicyDefinitionName ] , headerParameters : [ Parameters . accept , Parameters . contentType ] , mediaType : "json" , serializer } ; const listByResourceGroupOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/serviceEndpointPolicies/{serviceEndpointPolicyName}/serviceEndpointPolicyDefinitions" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . ServiceEndpointPolicyDefinitionListResult } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . serviceEndpointPolicyName ] , headerParameters : [ Parameters . accept ] , serializer } ; const listByResourceGroupNextOperationSpec = { path : "{nextLink}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . ServiceEndpointPolicyDefinitionListResult } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . nextLink , Parameters . serviceEndpointPolicyName ] , headerParameters : [ Parameters . accept ] , serializer } ;