/* * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. * * Code generated by Microsoft (R) AutoRest Code Generator. * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; import { LocationBasedPerformanceTier } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; import { MariaDBManagementClient } from "../mariaDBManagementClient"; import { PerformanceTierProperties, LocationBasedPerformanceTierListOptionalParams, LocationBasedPerformanceTierListResponse } from "../models"; /// /** Class containing LocationBasedPerformanceTier operations. */ export class LocationBasedPerformanceTierImpl implements LocationBasedPerformanceTier { private readonly client: MariaDBManagementClient; /** * Initialize a new instance of the class LocationBasedPerformanceTier class. * @param client Reference to the service client */ constructor(client: MariaDBManagementClient) { this.client = client; } /** * List all the performance tiers at specified location in a given subscription. * @param locationName The name of the location. * @param options The options parameters. */ public list( locationName: string, options?: LocationBasedPerformanceTierListOptionalParams ): PagedAsyncIterableIterator { const iter = this.listPagingAll(locationName, options); return { next() { return iter.next(); }, [Symbol.asyncIterator]() { return this; }, byPage: (settings?: PageSettings) => { if (settings?.maxPageSize) { throw new Error("maxPageSize is not supported by this operation."); } return this.listPagingPage(locationName, options, settings); } }; } private async *listPagingPage( locationName: string, options?: LocationBasedPerformanceTierListOptionalParams, _settings?: PageSettings ): AsyncIterableIterator { let result: LocationBasedPerformanceTierListResponse; result = await this._list(locationName, options); yield result.value || []; } private async *listPagingAll( locationName: string, options?: LocationBasedPerformanceTierListOptionalParams ): AsyncIterableIterator { for await (const page of this.listPagingPage(locationName, options)) { yield* page; } } /** * List all the performance tiers at specified location in a given subscription. * @param locationName The name of the location. * @param options The options parameters. */ private _list( locationName: string, options?: LocationBasedPerformanceTierListOptionalParams ): Promise { return this.client.sendOperationRequest( { locationName, options }, listOperationSpec ); } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const listOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/providers/Microsoft.DBforMariaDB/locations/{locationName}/performanceTiers", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.PerformanceTierListResult }, default: { bodyMapper: Mappers.CloudError } }, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.locationName ], headerParameters: [Parameters.accept], serializer };