import { PagedAsyncIterableIterator } from "@azure/core-paging" ; import { DeploymentScripts } from "../operationsInterfaces" ; import * as coreClient from "@azure/core-client" ; import * as Mappers from "../models/mappers" ; import * as Parameters from "../models/parameters" ; import { DeploymentScriptsClient } from "../deploymentScriptsClient" ; import { PollerLike , PollOperationState , LroEngine } from "@azure/core-lro" ; import { LroImpl } from "../lroImpl" ; import { DeploymentScriptUnion , DeploymentScriptsListBySubscriptionNextOptionalParams , DeploymentScriptsListBySubscriptionOptionalParams , DeploymentScriptsListByResourceGroupNextOptionalParams , DeploymentScriptsListByResourceGroupOptionalParams , DeploymentScriptsCreateOptionalParams , DeploymentScriptsCreateResponse , DeploymentScriptsUpdateOptionalParams , DeploymentScriptsUpdateResponse , DeploymentScriptsGetOptionalParams , DeploymentScriptsGetResponse , DeploymentScriptsDeleteOptionalParams , DeploymentScriptsListBySubscriptionResponse , DeploymentScriptsGetLogsOptionalParams , DeploymentScriptsGetLogsResponse , DeploymentScriptsGetLogsDefaultOptionalParams , DeploymentScriptsGetLogsDefaultResponse , DeploymentScriptsListByResourceGroupResponse , DeploymentScriptsListBySubscriptionNextResponse , DeploymentScriptsListByResourceGroupNextResponse } from "../models" ; /** Class containing DeploymentScripts operations. */ export class DeploymentScriptsImpl implements DeploymentScripts { private readonly client : DeploymentScriptsClient ; param client constructor ( client ) { this . client = client ; } param options public listBySubscription ( options ? ) { const iter = this . listBySubscriptionPagingAll ( options ) ; return { next ( ) { return iter . next ( ) ; } , [ Symbol . asyncIterator ] ( ) { return this ; } , byPage : ( ) => { return this . listBySubscriptionPagingPage ( options ) ; } } ; } private async * listBySubscriptionPagingPage ( options ? ) { let result = await this . _listBySubscription ( options ) ; yield result . value || [ ] ; let continuationToken = result . nextLink ; while ( continuationToken ) { result = await this . _listBySubscriptionNext ( continuationToken , options ) ; continuationToken = result . nextLink ; yield result . value || [ ] ; } } private async * listBySubscriptionPagingAll ( options ? ) { for await ( const page of this . listBySubscriptionPagingPage ( options ) ) { yield * page ; } } param resourceGroupName param options public listByResourceGroup ( resourceGroupName , options ? ) { const iter = this . listByResourceGroupPagingAll ( resourceGroupName , options ) ; return { next ( ) { return iter . next ( ) ; } , [ Symbol . asyncIterator ] ( ) { return this ; } , byPage : ( ) => { return this . listByResourceGroupPagingPage ( resourceGroupName , options ) ; } } ; } private async * listByResourceGroupPagingPage ( resourceGroupName , options ? ) { let result = await this . _listByResourceGroup ( resourceGroupName , options ) ; yield result . value || [ ] ; let continuationToken = result . nextLink ; while ( continuationToken ) { result = await this . _listByResourceGroupNext ( resourceGroupName , continuationToken , options ) ; continuationToken = result . nextLink ; yield result . value || [ ] ; } } private async * listByResourceGroupPagingAll ( resourceGroupName , options ? ) { for await ( const page of this . listByResourceGroupPagingPage ( resourceGroupName , options ) ) { yield * page ; } } param resourceGroupName param scriptName param deploymentScript param options async beginCreate ( resourceGroupName , scriptName , deploymentScript , options ? ) { const directSendOperation = async ( args , spec ) : Promise < DeploymentScriptsCreateResponse > => { 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 , scriptName , deploymentScript , options } , createOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs } ) ; } param resourceGroupName param scriptName param deploymentScript param options async beginCreateAndWait ( resourceGroupName , scriptName , deploymentScript , options ? ) { const poller = await this . beginCreate ( resourceGroupName , scriptName , deploymentScript , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param scriptName param options update ( resourceGroupName , scriptName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , scriptName , options } , updateOperationSpec ) ; } param resourceGroupName param scriptName param options get ( resourceGroupName , scriptName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , scriptName , options } , getOperationSpec ) ; } param resourceGroupName param scriptName param options delete ( resourceGroupName , scriptName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , scriptName , options } , deleteOperationSpec ) ; } param options private _listBySubscription ( options ? ) { return this . client . sendOperationRequest ( { options } , listBySubscriptionOperationSpec ) ; } param resourceGroupName param scriptName param options getLogs ( resourceGroupName , scriptName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , scriptName , options } , getLogsOperationSpec ) ; } param resourceGroupName param scriptName param options getLogsDefault ( resourceGroupName , scriptName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , scriptName , options } , getLogsDefaultOperationSpec ) ; } param resourceGroupName param options private _listByResourceGroup ( resourceGroupName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , options } , listByResourceGroupOperationSpec ) ; } param nextLink param options private _listBySubscriptionNext ( nextLink , options ? ) { return this . client . sendOperationRequest ( { nextLink , options } , listBySubscriptionNextOperationSpec ) ; } param resourceGroupName param nextLink param options private _listByResourceGroupNext ( resourceGroupName , nextLink , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , nextLink , options } , listByResourceGroupNextOperationSpec ) ; } } const serializer = coreClient . createSerializer ( Mappers , false ) ; const createOperationSpec = { path : "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}" , httpMethod : "PUT" , responses : { 200 : { bodyMapper : Mappers . DeploymentScript } , 201 : { bodyMapper : Mappers . DeploymentScript } , 202 : { bodyMapper : Mappers . DeploymentScript } , 204 : { bodyMapper : Mappers . DeploymentScript } , default : { bodyMapper : Mappers . DeploymentScriptsError } } , requestBody : Parameters . deploymentScript , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . scriptName ] , headerParameters : [ Parameters . contentType , Parameters . accept ] , mediaType : "json" , serializer } ; const updateOperationSpec = { path : "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}" , httpMethod : "PATCH" , responses : { 200 : { bodyMapper : Mappers . DeploymentScript } , default : { bodyMapper : Mappers . DeploymentScriptsError } } , requestBody : Parameters . deploymentScript1 , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . scriptName ] , headerParameters : [ Parameters . contentType , Parameters . accept ] , mediaType : "json" , serializer } ; const getOperationSpec = { path : "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . DeploymentScript } , default : { bodyMapper : Mappers . DeploymentScriptsError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . scriptName ] , headerParameters : [ Parameters . accept ] , serializer } ; const deleteOperationSpec = { path : "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}" , httpMethod : "DELETE" , responses : { 200 : { } , 204 : { } , default : { bodyMapper : Mappers . DeploymentScriptsError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . scriptName ] , headerParameters : [ Parameters . accept ] , serializer } ; const listBySubscriptionOperationSpec = { path : "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentScripts" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . DeploymentScriptListResult } , default : { bodyMapper : Mappers . DeploymentScriptsError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId ] , headerParameters : [ Parameters . accept ] , serializer } ; const getLogsOperationSpec = { path : "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . ScriptLogsList } , default : { bodyMapper : Mappers . DeploymentScriptsError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . scriptName ] , headerParameters : [ Parameters . accept ] , serializer } ; const getLogsDefaultOperationSpec = { path : "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts/{scriptName}/logs/default" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . ScriptLog } , default : { bodyMapper : Mappers . DeploymentScriptsError } } , queryParameters : [ Parameters . apiVersion , Parameters . tail ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . scriptName ] , headerParameters : [ Parameters . accept ] , serializer } ; const listByResourceGroupOperationSpec = { path : "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentScripts" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . DeploymentScriptListResult } , default : { bodyMapper : Mappers . DeploymentScriptsError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName ] , headerParameters : [ Parameters . accept ] , serializer } ; const listBySubscriptionNextOperationSpec = { path : "{nextLink}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . DeploymentScriptListResult } , default : { bodyMapper : Mappers . DeploymentScriptsError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . nextLink ] , headerParameters : [ Parameters . accept ] , serializer } ; const listByResourceGroupNextOperationSpec = { path : "{nextLink}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . DeploymentScriptListResult } , default : { bodyMapper : Mappers . DeploymentScriptsError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName , Parameters . nextLink ] , headerParameters : [ Parameters . accept ] , serializer } ;