/* * 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 { ServerParameters } 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 { PollerLike, PollOperationState, LroEngine } from "@azure/core-lro"; import { LroImpl } from "../lroImpl"; import { ConfigurationListResult, ServerParametersListUpdateConfigurationsOptionalParams, ServerParametersListUpdateConfigurationsResponse } from "../models"; /** Class containing ServerParameters operations. */ export class ServerParametersImpl implements ServerParameters { private readonly client: MariaDBManagementClient; /** * Initialize a new instance of the class ServerParameters class. * @param client Reference to the service client */ constructor(client: MariaDBManagementClient) { this.client = client; } /** * Update a list of configurations in a given server. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param serverName The name of the server. * @param value The parameters for updating a list of server configuration. * @param options The options parameters. */ async beginListUpdateConfigurations( resourceGroupName: string, serverName: string, value: ConfigurationListResult, options?: ServerParametersListUpdateConfigurationsOptionalParams ): Promise< PollerLike< PollOperationState, ServerParametersListUpdateConfigurationsResponse > > { const directSendOperation = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ): Promise => { return this.client.sendOperationRequest(args, spec); }; const sendOperation = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ) => { let currentRawResponse: | coreClient.FullOperationResponse | undefined = undefined; const providedCallback = args.options?.onResponse; const callback: coreClient.RawResponseCallback = ( rawResponse: coreClient.FullOperationResponse, flatResponse: unknown ) => { 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, serverName, value, options }, listUpdateConfigurationsOperationSpec ); const poller = new LroEngine(lro, { resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, lroResourceLocationConfig: "azure-async-operation" }); await poller.poll(); return poller; } /** * Update a list of configurations in a given server. * @param resourceGroupName The name of the resource group. The name is case insensitive. * @param serverName The name of the server. * @param value The parameters for updating a list of server configuration. * @param options The options parameters. */ async beginListUpdateConfigurationsAndWait( resourceGroupName: string, serverName: string, value: ConfigurationListResult, options?: ServerParametersListUpdateConfigurationsOptionalParams ): Promise { const poller = await this.beginListUpdateConfigurations( resourceGroupName, serverName, value, options ); return poller.pollUntilDone(); } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const listUpdateConfigurationsOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforMariaDB/servers/{serverName}/updateConfigurations", httpMethod: "POST", responses: { 200: { bodyMapper: Mappers.ConfigurationListResult }, 201: { bodyMapper: Mappers.ConfigurationListResult }, 202: { bodyMapper: Mappers.ConfigurationListResult }, 204: { bodyMapper: Mappers.ConfigurationListResult }, default: { bodyMapper: Mappers.CloudError } }, requestBody: Parameters.value, queryParameters: [Parameters.apiVersion], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.serverName ], headerParameters: [Parameters.contentType, Parameters.accept], mediaType: "json", serializer };