import { PagedAsyncIterableIterator } from "@azure/core-paging" ; import { ConnectionMonitors } 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 { ConnectionMonitorResult , ConnectionMonitorsListOptionalParams , ConnectionMonitor , ConnectionMonitorsCreateOrUpdateOptionalParams , ConnectionMonitorsCreateOrUpdateResponse , ConnectionMonitorsGetOptionalParams , ConnectionMonitorsGetResponse , ConnectionMonitorsDeleteOptionalParams , TagsObject , ConnectionMonitorsUpdateTagsOptionalParams , ConnectionMonitorsUpdateTagsResponse , ConnectionMonitorsStopOptionalParams , ConnectionMonitorsStartOptionalParams , ConnectionMonitorsQueryOptionalParams , ConnectionMonitorsQueryResponse , ConnectionMonitorsListResponse } from "../models" ; /** Class containing ConnectionMonitors operations. */ export class ConnectionMonitorsImpl implements ConnectionMonitors { private readonly client : NetworkManagementClient ; param client constructor ( client ) { this . client = client ; } param resourceGroupName param networkWatcherName param options public list ( resourceGroupName , networkWatcherName , options ? ) { const iter = this . listPagingAll ( resourceGroupName , networkWatcherName , options ) ; return { next ( ) { return iter . next ( ) ; } , [ Symbol . asyncIterator ] ( ) { return this ; } , byPage : ( ) => { return this . listPagingPage ( resourceGroupName , networkWatcherName , options ) ; } } ; } private async * listPagingPage ( resourceGroupName , networkWatcherName , options ? ) { let result = await this . _list ( resourceGroupName , networkWatcherName , options ) ; yield result . value || [ ] ; } private async * listPagingAll ( resourceGroupName , networkWatcherName , options ? ) { for await ( const page of this . listPagingPage ( resourceGroupName , networkWatcherName , options ) ) { yield * page ; } } param resourceGroupName param networkWatcherName param connectionMonitorName param parameters param options async beginCreateOrUpdate ( resourceGroupName , networkWatcherName , connectionMonitorName , parameters , options ? ) { const directSendOperation = async ( args , spec ) : Promise < ConnectionMonitorsCreateOrUpdateResponse > => { 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 , networkWatcherName , connectionMonitorName , parameters , options } , createOrUpdateOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs , lroResourceLocationConfig : "azure-async-operation" } ) ; } param resourceGroupName param networkWatcherName param connectionMonitorName param parameters param options async beginCreateOrUpdateAndWait ( resourceGroupName , networkWatcherName , connectionMonitorName , parameters , options ? ) { const poller = await this . beginCreateOrUpdate ( resourceGroupName , networkWatcherName , connectionMonitorName , parameters , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param networkWatcherName param connectionMonitorName param options get ( resourceGroupName , networkWatcherName , connectionMonitorName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , networkWatcherName , connectionMonitorName , options } , getOperationSpec ) ; } param resourceGroupName param networkWatcherName param connectionMonitorName param options async beginDelete ( resourceGroupName , networkWatcherName , connectionMonitorName , 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 , networkWatcherName , connectionMonitorName , options } , deleteOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs , lroResourceLocationConfig : "location" } ) ; } param resourceGroupName param networkWatcherName param connectionMonitorName param options async beginDeleteAndWait ( resourceGroupName , networkWatcherName , connectionMonitorName , options ? ) { const poller = await this . beginDelete ( resourceGroupName , networkWatcherName , connectionMonitorName , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param networkWatcherName param connectionMonitorName param parameters param options updateTags ( resourceGroupName , networkWatcherName , connectionMonitorName , parameters , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , networkWatcherName , connectionMonitorName , parameters , options } , updateTagsOperationSpec ) ; } param resourceGroupName param networkWatcherName param connectionMonitorName param options async beginStop ( resourceGroupName , networkWatcherName , connectionMonitorName , 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 , networkWatcherName , connectionMonitorName , options } , stopOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs , lroResourceLocationConfig : "location" } ) ; } param resourceGroupName param networkWatcherName param connectionMonitorName param options async beginStopAndWait ( resourceGroupName , networkWatcherName , connectionMonitorName , options ? ) { const poller = await this . beginStop ( resourceGroupName , networkWatcherName , connectionMonitorName , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param networkWatcherName param connectionMonitorName param options async beginStart ( resourceGroupName , networkWatcherName , connectionMonitorName , 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 , networkWatcherName , connectionMonitorName , options } , startOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs , lroResourceLocationConfig : "location" } ) ; } param resourceGroupName param networkWatcherName param connectionMonitorName param options async beginStartAndWait ( resourceGroupName , networkWatcherName , connectionMonitorName , options ? ) { const poller = await this . beginStart ( resourceGroupName , networkWatcherName , connectionMonitorName , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param networkWatcherName param connectionMonitorName param options async beginQuery ( resourceGroupName , networkWatcherName , connectionMonitorName , options ? ) { const directSendOperation = async ( args , spec ) : Promise < ConnectionMonitorsQueryResponse > => { 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 , networkWatcherName , connectionMonitorName , options } , queryOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs , lroResourceLocationConfig : "location" } ) ; } param resourceGroupName param networkWatcherName param connectionMonitorName param options async beginQueryAndWait ( resourceGroupName , networkWatcherName , connectionMonitorName , options ? ) { const poller = await this . beginQuery ( resourceGroupName , networkWatcherName , connectionMonitorName , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param networkWatcherName param options private _list ( resourceGroupName , networkWatcherName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , networkWatcherName , options } , listOperationSpec ) ; } } const serializer = coreClient . createSerializer ( Mappers , false ) ; const createOrUpdateOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/connectionMonitors/{connectionMonitorName}" , httpMethod : "PUT" , responses : { 200 : { bodyMapper : Mappers . ConnectionMonitorResult } , 201 : { bodyMapper : Mappers . ConnectionMonitorResult } , 202 : { bodyMapper : Mappers . ConnectionMonitorResult } , 204 : { bodyMapper : Mappers . ConnectionMonitorResult } , default : { bodyMapper : Mappers . ErrorResponse } } , requestBody : Parameters . parameters46 , queryParameters : [ Parameters . apiVersion , Parameters . migrate ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . networkWatcherName , Parameters . connectionMonitorName ] , headerParameters : [ Parameters . accept , Parameters . contentType ] , mediaType : "json" , serializer } ; const getOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/connectionMonitors/{connectionMonitorName}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . ConnectionMonitorResult } , default : { bodyMapper : Mappers . ErrorResponse } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . networkWatcherName , Parameters . connectionMonitorName ] , headerParameters : [ Parameters . accept ] , serializer } ; const deleteOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/connectionMonitors/{connectionMonitorName}" , httpMethod : "DELETE" , responses : { 200 : { } , 201 : { } , 202 : { } , 204 : { } , default : { bodyMapper : Mappers . ErrorResponse } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . networkWatcherName , Parameters . connectionMonitorName ] , headerParameters : [ Parameters . accept ] , serializer } ; const updateTagsOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/connectionMonitors/{connectionMonitorName}" , httpMethod : "PATCH" , responses : { 200 : { bodyMapper : Mappers . ConnectionMonitorResult } , default : { bodyMapper : Mappers . ErrorResponse } } , requestBody : Parameters . parameters1 , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . networkWatcherName , Parameters . connectionMonitorName ] , headerParameters : [ Parameters . accept , Parameters . contentType ] , mediaType : "json" , serializer } ; const stopOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/connectionMonitors/{connectionMonitorName}/stop" , httpMethod : "POST" , responses : { 200 : { } , 201 : { } , 202 : { } , 204 : { } , default : { bodyMapper : Mappers . ErrorResponse } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . networkWatcherName , Parameters . connectionMonitorName ] , headerParameters : [ Parameters . accept ] , serializer } ; const startOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/connectionMonitors/{connectionMonitorName}/start" , httpMethod : "POST" , responses : { 200 : { } , 201 : { } , 202 : { } , 204 : { } , default : { bodyMapper : Mappers . ErrorResponse } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . networkWatcherName , Parameters . connectionMonitorName ] , headerParameters : [ Parameters . accept ] , serializer } ; const queryOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/connectionMonitors/{connectionMonitorName}/query" , httpMethod : "POST" , responses : { 200 : { bodyMapper : Mappers . ConnectionMonitorQueryResult } , 201 : { bodyMapper : Mappers . ConnectionMonitorQueryResult } , 202 : { bodyMapper : Mappers . ConnectionMonitorQueryResult } , 204 : { bodyMapper : Mappers . ConnectionMonitorQueryResult } , default : { bodyMapper : Mappers . ErrorResponse } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . networkWatcherName , Parameters . connectionMonitorName ] , headerParameters : [ Parameters . accept ] , serializer } ; const listOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/connectionMonitors" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . ConnectionMonitorListResult } , default : { bodyMapper : Mappers . ErrorResponse } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . resourceGroupName , Parameters . subscriptionId , Parameters . networkWatcherName ] , headerParameters : [ Parameters . accept ] , serializer } ;