import { PagedAsyncIterableIterator } from "@azure/core-paging" ; import { Triggers } from "../operationsInterfaces" ; import * as coreClient from "@azure/core-client" ; import * as Mappers from "../models/mappers" ; import * as Parameters from "../models/parameters" ; import { DataFactoryClient } from "../dataFactoryClient" ; import { PollerLike , PollOperationState , LroEngine } from "@azure/core-lro" ; import { LroImpl } from "../lroImpl" ; import { TriggerResource , TriggersListByFactoryNextOptionalParams , TriggersListByFactoryOptionalParams , TriggersListByFactoryResponse , TriggerFilterParameters , TriggersQueryByFactoryOptionalParams , TriggersQueryByFactoryResponse , TriggersCreateOrUpdateOptionalParams , TriggersCreateOrUpdateResponse , TriggersGetOptionalParams , TriggersGetResponse , TriggersDeleteOptionalParams , TriggersSubscribeToEventsOptionalParams , TriggersSubscribeToEventsResponse , TriggersGetEventSubscriptionStatusOptionalParams , TriggersGetEventSubscriptionStatusResponse , TriggersUnsubscribeFromEventsOptionalParams , TriggersUnsubscribeFromEventsResponse , TriggersStartOptionalParams , TriggersStopOptionalParams , TriggersListByFactoryNextResponse } from "../models" ; /** Class containing Triggers operations. */ export class TriggersImpl implements Triggers { private readonly client : DataFactoryClient ; param client constructor ( client ) { this . client = client ; } param resourceGroupName param factoryName param options public listByFactory ( resourceGroupName , factoryName , options ? ) { const iter = this . listByFactoryPagingAll ( resourceGroupName , factoryName , options ) ; return { next ( ) { return iter . next ( ) ; } , [ Symbol . asyncIterator ] ( ) { return this ; } , byPage : ( ) => { return this . listByFactoryPagingPage ( resourceGroupName , factoryName , options ) ; } } ; } private async * listByFactoryPagingPage ( resourceGroupName , factoryName , options ? ) { let result = await this . _listByFactory ( resourceGroupName , factoryName , options ) ; yield result . value || [ ] ; let continuationToken = result . nextLink ; while ( continuationToken ) { result = await this . _listByFactoryNext ( resourceGroupName , factoryName , continuationToken , options ) ; continuationToken = result . nextLink ; yield result . value || [ ] ; } } private async * listByFactoryPagingAll ( resourceGroupName , factoryName , options ? ) { for await ( const page of this . listByFactoryPagingPage ( resourceGroupName , factoryName , options ) ) { yield * page ; } } param resourceGroupName param factoryName param options private _listByFactory ( resourceGroupName , factoryName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , factoryName , options } , listByFactoryOperationSpec ) ; } param resourceGroupName param factoryName param filterParameters param options queryByFactory ( resourceGroupName , factoryName , filterParameters , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , factoryName , filterParameters , options } , queryByFactoryOperationSpec ) ; } param resourceGroupName param factoryName param triggerName param trigger param options createOrUpdate ( resourceGroupName , factoryName , triggerName , trigger , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , factoryName , triggerName , trigger , options } , createOrUpdateOperationSpec ) ; } param resourceGroupName param factoryName param triggerName param options get ( resourceGroupName , factoryName , triggerName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , factoryName , triggerName , options } , getOperationSpec ) ; } param resourceGroupName param factoryName param triggerName param options delete ( resourceGroupName , factoryName , triggerName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , factoryName , triggerName , options } , deleteOperationSpec ) ; } param resourceGroupName param factoryName param triggerName param options async beginSubscribeToEvents ( resourceGroupName , factoryName , triggerName , options ? ) { const directSendOperation = async ( args , spec ) : Promise < TriggersSubscribeToEventsResponse > => { 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 , factoryName , triggerName , options } , subscribeToEventsOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs } ) ; } param resourceGroupName param factoryName param triggerName param options async beginSubscribeToEventsAndWait ( resourceGroupName , factoryName , triggerName , options ? ) { const poller = await this . beginSubscribeToEvents ( resourceGroupName , factoryName , triggerName , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param factoryName param triggerName param options getEventSubscriptionStatus ( resourceGroupName , factoryName , triggerName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , factoryName , triggerName , options } , getEventSubscriptionStatusOperationSpec ) ; } param resourceGroupName param factoryName param triggerName param options async beginUnsubscribeFromEvents ( resourceGroupName , factoryName , triggerName , options ? ) { const directSendOperation = async ( args , spec ) : Promise < TriggersUnsubscribeFromEventsResponse > => { 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 , factoryName , triggerName , options } , unsubscribeFromEventsOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs } ) ; } param resourceGroupName param factoryName param triggerName param options async beginUnsubscribeFromEventsAndWait ( resourceGroupName , factoryName , triggerName , options ? ) { const poller = await this . beginUnsubscribeFromEvents ( resourceGroupName , factoryName , triggerName , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param factoryName param triggerName param options async beginStart ( resourceGroupName , factoryName , triggerName , 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 , factoryName , triggerName , options } , startOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs } ) ; } param resourceGroupName param factoryName param triggerName param options async beginStartAndWait ( resourceGroupName , factoryName , triggerName , options ? ) { const poller = await this . beginStart ( resourceGroupName , factoryName , triggerName , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param factoryName param triggerName param options async beginStop ( resourceGroupName , factoryName , triggerName , 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 , factoryName , triggerName , options } , stopOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs } ) ; } param resourceGroupName param factoryName param triggerName param options async beginStopAndWait ( resourceGroupName , factoryName , triggerName , options ? ) { const poller = await this . beginStop ( resourceGroupName , factoryName , triggerName , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param factoryName param nextLink param options private _listByFactoryNext ( resourceGroupName , factoryName , nextLink , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , factoryName , nextLink , options } , listByFactoryNextOperationSpec ) ; } } const serializer = coreClient . createSerializer ( Mappers , false ) ; const listByFactoryOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/triggers" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . TriggerListResponse } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . factoryName ] , headerParameters : [ Parameters . accept ] , serializer } ; const queryByFactoryOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/querytriggers" , httpMethod : "POST" , responses : { 200 : { bodyMapper : Mappers . TriggerQueryResponse } , default : { bodyMapper : Mappers . CloudError } } , requestBody : Parameters . filterParameters1 , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . factoryName ] , headerParameters : [ Parameters . accept , Parameters . contentType ] , mediaType : "json" , serializer } ; const createOrUpdateOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/triggers/{triggerName}" , httpMethod : "PUT" , responses : { 200 : { bodyMapper : Mappers . TriggerResource } , default : { bodyMapper : Mappers . CloudError } } , requestBody : Parameters . trigger , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . factoryName , Parameters . triggerName ] , headerParameters : [ Parameters . accept , Parameters . contentType , Parameters . ifMatch ] , mediaType : "json" , serializer } ; const getOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/triggers/{triggerName}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . TriggerResource } , 304 : { } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . factoryName , Parameters . triggerName ] , headerParameters : [ Parameters . accept , Parameters . ifNoneMatch ] , serializer } ; const deleteOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/triggers/{triggerName}" , httpMethod : "DELETE" , responses : { 200 : { } , 204 : { } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . factoryName , Parameters . triggerName ] , headerParameters : [ Parameters . accept ] , serializer } ; const subscribeToEventsOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/triggers/{triggerName}/subscribeToEvents" , httpMethod : "POST" , responses : { 200 : { bodyMapper : Mappers . TriggerSubscriptionOperationStatus } , 201 : { bodyMapper : Mappers . TriggerSubscriptionOperationStatus } , 202 : { bodyMapper : Mappers . TriggerSubscriptionOperationStatus } , 204 : { bodyMapper : Mappers . TriggerSubscriptionOperationStatus } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . factoryName , Parameters . triggerName ] , headerParameters : [ Parameters . accept ] , serializer } ; const getEventSubscriptionStatusOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/triggers/{triggerName}/getEventSubscriptionStatus" , httpMethod : "POST" , responses : { 200 : { bodyMapper : Mappers . TriggerSubscriptionOperationStatus } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . factoryName , Parameters . triggerName ] , headerParameters : [ Parameters . accept ] , serializer } ; const unsubscribeFromEventsOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/triggers/{triggerName}/unsubscribeFromEvents" , httpMethod : "POST" , responses : { 200 : { bodyMapper : Mappers . TriggerSubscriptionOperationStatus } , 201 : { bodyMapper : Mappers . TriggerSubscriptionOperationStatus } , 202 : { bodyMapper : Mappers . TriggerSubscriptionOperationStatus } , 204 : { bodyMapper : Mappers . TriggerSubscriptionOperationStatus } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . factoryName , Parameters . triggerName ] , headerParameters : [ Parameters . accept ] , serializer } ; const startOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/triggers/{triggerName}/start" , httpMethod : "POST" , responses : { 200 : { } , 201 : { } , 202 : { } , 204 : { } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . factoryName , Parameters . triggerName ] , headerParameters : [ Parameters . accept ] , serializer } ; const stopOperationSpec = { path : "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/triggers/{triggerName}/stop" , httpMethod : "POST" , responses : { 200 : { } , 201 : { } , 202 : { } , 204 : { } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . factoryName , Parameters . triggerName ] , headerParameters : [ Parameters . accept ] , serializer } ; const listByFactoryNextOperationSpec = { path : "{nextLink}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . TriggerListResponse } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . nextLink , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . factoryName ] , headerParameters : [ Parameters . accept ] , serializer } ;