import { PagedAsyncIterableIterator } from "@azure/core-paging" ; import { ResourceGroups } from "../operationsInterfaces" ; import * as coreClient from "@azure/core-client" ; import * as Mappers from "../models/mappers" ; import * as Parameters from "../models/parameters" ; import { ResourceManagementClient } from "../resourceManagementClient" ; import { PollerLike , PollOperationState , LroEngine } from "@azure/core-lro" ; import { LroImpl } from "../lroImpl" ; import { ResourceGroup , ResourceGroupsListNextOptionalParams , ResourceGroupsListOptionalParams , ResourceGroupsCheckExistenceOptionalParams , ResourceGroupsCreateOrUpdateOptionalParams , ResourceGroupsCreateOrUpdateResponse , ResourceGroupsDeleteOptionalParams , ResourceGroupsGetOptionalParams , ResourceGroupsGetResponse , ResourceGroupPatchable , ResourceGroupsUpdateOptionalParams , ResourceGroupsUpdateResponse , ExportTemplateRequest , ResourceGroupsExportTemplateOptionalParams , ResourceGroupsExportTemplateResponse , ResourceGroupsListResponse , ResourceGroupsListNextResponse } from "../models" ; /** Class containing ResourceGroups operations. */ export class ResourceGroupsImpl implements ResourceGroups { private readonly client : ResourceManagementClient ; param client constructor ( client ) { this . client = client ; } param options public list ( options ? ) { const iter = this . listPagingAll ( options ) ; return { next ( ) { return iter . next ( ) ; } , [ Symbol . asyncIterator ] ( ) { return this ; } , byPage : ( ) => { return this . listPagingPage ( options ) ; } } ; } private async * listPagingPage ( options ? ) { let result = await this . _list ( options ) ; yield result . value || [ ] ; let continuationToken = result . nextLink ; while ( continuationToken ) { result = await this . _listNext ( continuationToken , options ) ; continuationToken = result . nextLink ; yield result . value || [ ] ; } } private async * listPagingAll ( options ? ) { for await ( const page of this . listPagingPage ( options ) ) { yield * page ; } } param resourceGroupName param options checkExistence ( resourceGroupName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , options } , checkExistenceOperationSpec ) ; } param resourceGroupName param parameters param options createOrUpdate ( resourceGroupName , parameters , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , parameters , options } , createOrUpdateOperationSpec ) ; } param resourceGroupName param options async beginDelete ( resourceGroupName , 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 , options } , deleteOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs } ) ; } param resourceGroupName param options async beginDeleteAndWait ( resourceGroupName , options ? ) { const poller = await this . beginDelete ( resourceGroupName , options ) ; return poller . pollUntilDone ( ) ; } param resourceGroupName param options get ( resourceGroupName , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , options } , getOperationSpec ) ; } param resourceGroupName param parameters param options update ( resourceGroupName , parameters , options ? ) { return this . client . sendOperationRequest ( { resourceGroupName , parameters , options } , updateOperationSpec ) ; } param resourceGroupName param parameters param options async beginExportTemplate ( resourceGroupName , parameters , options ? ) { const directSendOperation = async ( args , spec ) : Promise < ResourceGroupsExportTemplateResponse > => { 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 , parameters , options } , exportTemplateOperationSpec ) ; return new LroEngine ( lro , { resumeFrom : options ?. resumeFrom , intervalInMs : options ?. updateIntervalInMs , lroResourceLocationConfig : "location" } ) ; } param resourceGroupName param parameters param options async beginExportTemplateAndWait ( resourceGroupName , parameters , options ? ) { const poller = await this . beginExportTemplate ( resourceGroupName , parameters , options ) ; return poller . pollUntilDone ( ) ; } param options private _list ( options ? ) { return this . client . sendOperationRequest ( { options } , listOperationSpec ) ; } param nextLink param options private _listNext ( nextLink , options ? ) { return this . client . sendOperationRequest ( { nextLink , options } , listNextOperationSpec ) ; } } const serializer = coreClient . createSerializer ( Mappers , false ) ; const checkExistenceOperationSpec = { path : "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}" , httpMethod : "HEAD" , responses : { 204 : { } , 404 : { } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName ] , headerParameters : [ Parameters . accept ] , serializer } ; const createOrUpdateOperationSpec = { path : "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}" , httpMethod : "PUT" , responses : { 200 : { bodyMapper : Mappers . ResourceGroup } , 201 : { bodyMapper : Mappers . ResourceGroup } , default : { bodyMapper : Mappers . CloudError } } , requestBody : Parameters . parameters5 , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName ] , headerParameters : [ Parameters . accept , Parameters . contentType ] , mediaType : "json" , serializer } ; const deleteOperationSpec = { path : "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}" , httpMethod : "DELETE" , responses : { 200 : { } , 201 : { } , 202 : { } , 204 : { } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName ] , headerParameters : [ Parameters . accept ] , serializer } ; const getOperationSpec = { path : "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . ResourceGroup } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName ] , headerParameters : [ Parameters . accept ] , serializer } ; const updateOperationSpec = { path : "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}" , httpMethod : "PATCH" , responses : { 200 : { bodyMapper : Mappers . ResourceGroup } , default : { bodyMapper : Mappers . CloudError } } , requestBody : Parameters . parameters6 , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName ] , headerParameters : [ Parameters . accept , Parameters . contentType ] , mediaType : "json" , serializer } ; const exportTemplateOperationSpec = { path : "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate" , httpMethod : "POST" , responses : { 200 : { bodyMapper : Mappers . ResourceGroupExportResult } , 201 : { bodyMapper : Mappers . ResourceGroupExportResult } , 202 : { bodyMapper : Mappers . ResourceGroupExportResult } , 204 : { bodyMapper : Mappers . ResourceGroupExportResult } , default : { bodyMapper : Mappers . CloudError } } , requestBody : Parameters . parameters7 , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . resourceGroupName ] , headerParameters : [ Parameters . accept , Parameters . contentType ] , mediaType : "json" , serializer } ; const listOperationSpec = { path : "/subscriptions/{subscriptionId}/resourcegroups" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . ResourceGroupListResult } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion , Parameters . filter , Parameters . top ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId ] , headerParameters : [ Parameters . accept ] , serializer } ; const listNextOperationSpec = { path : "{nextLink}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . ResourceGroupListResult } , default : { bodyMapper : Mappers . CloudError } } , queryParameters : [ Parameters . apiVersion , Parameters . filter , Parameters . top ] , urlParameters : [ Parameters . $host , Parameters . nextLink , Parameters . subscriptionId ] , headerParameters : [ Parameters . accept ] , serializer } ;