/*
* 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 { ServerBasedPerformanceTier } 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,
ServerBasedPerformanceTierListOptionalParams,
ServerBasedPerformanceTierListResponse
} from "../models";
///
/** Class containing ServerBasedPerformanceTier operations. */
export class ServerBasedPerformanceTierImpl
implements ServerBasedPerformanceTier {
private readonly client: MariaDBManagementClient;
/**
* Initialize a new instance of the class ServerBasedPerformanceTier class.
* @param client Reference to the service client
*/
constructor(client: MariaDBManagementClient) {
this.client = client;
}
/**
* List all the performance tiers for a MariaDB server.
* @param resourceGroupName The name of the resource group. The name is case insensitive.
* @param serverName The name of the server.
* @param options The options parameters.
*/
public list(
resourceGroupName: string,
serverName: string,
options?: ServerBasedPerformanceTierListOptionalParams
): PagedAsyncIterableIterator {
const iter = this.listPagingAll(resourceGroupName, serverName, 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(
resourceGroupName,
serverName,
options,
settings
);
}
};
}
private async *listPagingPage(
resourceGroupName: string,
serverName: string,
options?: ServerBasedPerformanceTierListOptionalParams,
_settings?: PageSettings
): AsyncIterableIterator {
let result: ServerBasedPerformanceTierListResponse;
result = await this._list(resourceGroupName, serverName, options);
yield result.value || [];
}
private async *listPagingAll(
resourceGroupName: string,
serverName: string,
options?: ServerBasedPerformanceTierListOptionalParams
): AsyncIterableIterator {
for await (const page of this.listPagingPage(
resourceGroupName,
serverName,
options
)) {
yield* page;
}
}
/**
* List all the performance tiers for a MariaDB server.
* @param resourceGroupName The name of the resource group. The name is case insensitive.
* @param serverName The name of the server.
* @param options The options parameters.
*/
private _list(
resourceGroupName: string,
serverName: string,
options?: ServerBasedPerformanceTierListOptionalParams
): Promise {
return this.client.sendOperationRequest(
{ resourceGroupName, serverName, options },
listOperationSpec
);
}
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const listOperationSpec: coreClient.OperationSpec = {
path:
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/performanceTiers",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.PerformanceTierListResult
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion],
urlParameters: [
Parameters.$host,
Parameters.subscriptionId,
Parameters.resourceGroupName,
Parameters.serverName
],
headerParameters: [Parameters.accept],
serializer
};