import { PagedAsyncIterableIterator } from "@azure/core-paging" ; import { UsageOperations } from "../operationsInterfaces" ; import * as coreClient from "@azure/core-client" ; import * as Mappers from "../models/mappers" ; import * as Parameters from "../models/parameters" ; import { ComputeManagementClient } from "../computeManagementClient" ; import { Usage , UsageListNextOptionalParams , UsageListOptionalParams , UsageListResponse , UsageListNextResponse } from "../models" ; /** Class containing UsageOperations operations. */ export class UsageOperationsImpl implements UsageOperations { private readonly client : ComputeManagementClient ; param client constructor ( client ) { this . client = client ; } param location param options public list ( location , options ? ) { const iter = this . listPagingAll ( location , options ) ; return { next ( ) { return iter . next ( ) ; } , [ Symbol . asyncIterator ] ( ) { return this ; } , byPage : ( ) => { return this . listPagingPage ( location , options ) ; } } ; } private async * listPagingPage ( location , options ? ) { let result = await this . _list ( location , options ) ; yield result . value || [ ] ; let continuationToken = result . nextLink ; while ( continuationToken ) { result = await this . _listNext ( location , continuationToken , options ) ; continuationToken = result . nextLink ; yield result . value || [ ] ; } } private async * listPagingAll ( location , options ? ) { for await ( const page of this . listPagingPage ( location , options ) ) { yield * page ; } } param location param options private _list ( location , options ? ) { return this . client . sendOperationRequest ( { location , options } , listOperationSpec ) ; } param location param nextLink param options private _listNext ( location , nextLink , options ? ) { return this . client . sendOperationRequest ( { location , nextLink , options } , listNextOperationSpec ) ; } } const serializer = coreClient . createSerializer ( Mappers , false ) ; const listOperationSpec = { path : "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . ListUsagesResult } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . location1 ] , headerParameters : [ Parameters . accept ] , serializer } ; const listNextOperationSpec = { path : "{nextLink}" , httpMethod : "GET" , responses : { 200 : { bodyMapper : Mappers . ListUsagesResult } } , queryParameters : [ Parameters . apiVersion ] , urlParameters : [ Parameters . $host , Parameters . subscriptionId , Parameters . nextLink , Parameters . location1 ] , headerParameters : [ Parameters . accept ] , serializer } ;