/* * 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 { setContinuationToken } from "../pagingHelper"; import { ManagedInstances } from "../operationsInterfaces"; import * as coreClient from "@azure/core-client"; import * as Mappers from "../models/mappers"; import * as Parameters from "../models/parameters"; import { SqlManagementClient } from "../sqlManagementClient"; import { SimplePollerLike, OperationState, createHttpPoller } from "@azure/core-lro"; import { createLroSpec } from "../lroImpl"; import { ManagedInstance, ManagedInstancesListNextOptionalParams, ManagedInstancesListOptionalParams, ManagedInstancesListResponse, ManagedInstancesListByInstancePoolNextOptionalParams, ManagedInstancesListByInstancePoolOptionalParams, ManagedInstancesListByInstancePoolResponse, ManagedInstancesListByResourceGroupNextOptionalParams, ManagedInstancesListByResourceGroupOptionalParams, ManagedInstancesListByResourceGroupResponse, OutboundEnvironmentEndpoint, ManagedInstancesListOutboundNetworkDependenciesByManagedInstanceNextOptionalParams, ManagedInstancesListOutboundNetworkDependenciesByManagedInstanceOptionalParams, ManagedInstancesListOutboundNetworkDependenciesByManagedInstanceResponse, TopQueries, ManagedInstancesListByManagedInstanceNextOptionalParams, ManagedInstancesListByManagedInstanceOptionalParams, ManagedInstancesListByManagedInstanceResponse, ManagedInstancesGetOptionalParams, ManagedInstancesGetResponse, ManagedInstancesCreateOrUpdateOptionalParams, ManagedInstancesCreateOrUpdateResponse, ManagedInstancesDeleteOptionalParams, ManagedInstanceUpdate, ManagedInstancesUpdateOptionalParams, ManagedInstancesUpdateResponse, ManagedInstancesFailoverOptionalParams, ManagedInstancesStartOptionalParams, ManagedInstancesStopOptionalParams, ManagedInstancesListNextResponse, ManagedInstancesListByInstancePoolNextResponse, ManagedInstancesListByResourceGroupNextResponse, ManagedInstancesListOutboundNetworkDependenciesByManagedInstanceNextResponse, ManagedInstancesListByManagedInstanceNextResponse } from "../models"; /// /** Class containing ManagedInstances operations. */ export class ManagedInstancesImpl implements ManagedInstances { private readonly client: SqlManagementClient; /** * Initialize a new instance of the class ManagedInstances class. * @param client Reference to the service client */ constructor(client: SqlManagementClient) { this.client = client; } /** * Gets a list of all managed instances in the subscription. * @param options The options parameters. */ public list( options?: ManagedInstancesListOptionalParams ): PagedAsyncIterableIterator { const iter = this.listPagingAll(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(options, settings); } }; } private async *listPagingPage( options?: ManagedInstancesListOptionalParams, settings?: PageSettings ): AsyncIterableIterator { let result: ManagedInstancesListResponse; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._list(options); let page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listNext(continuationToken, options); continuationToken = result.nextLink; let page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } private async *listPagingAll( options?: ManagedInstancesListOptionalParams ): AsyncIterableIterator { for await (const page of this.listPagingPage(options)) { yield* page; } } /** * Gets a list of all managed instances in an instance pool. * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param instancePoolName The instance pool name. * @param options The options parameters. */ public listByInstancePool( resourceGroupName: string, instancePoolName: string, options?: ManagedInstancesListByInstancePoolOptionalParams ): PagedAsyncIterableIterator { const iter = this.listByInstancePoolPagingAll( resourceGroupName, instancePoolName, 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.listByInstancePoolPagingPage( resourceGroupName, instancePoolName, options, settings ); } }; } private async *listByInstancePoolPagingPage( resourceGroupName: string, instancePoolName: string, options?: ManagedInstancesListByInstancePoolOptionalParams, settings?: PageSettings ): AsyncIterableIterator { let result: ManagedInstancesListByInstancePoolResponse; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._listByInstancePool( resourceGroupName, instancePoolName, options ); let page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listByInstancePoolNext( resourceGroupName, instancePoolName, continuationToken, options ); continuationToken = result.nextLink; let page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } private async *listByInstancePoolPagingAll( resourceGroupName: string, instancePoolName: string, options?: ManagedInstancesListByInstancePoolOptionalParams ): AsyncIterableIterator { for await (const page of this.listByInstancePoolPagingPage( resourceGroupName, instancePoolName, options )) { yield* page; } } /** * Gets a list of managed instances in a resource group. * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param options The options parameters. */ public listByResourceGroup( resourceGroupName: string, options?: ManagedInstancesListByResourceGroupOptionalParams ): PagedAsyncIterableIterator { const iter = this.listByResourceGroupPagingAll(resourceGroupName, 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.listByResourceGroupPagingPage( resourceGroupName, options, settings ); } }; } private async *listByResourceGroupPagingPage( resourceGroupName: string, options?: ManagedInstancesListByResourceGroupOptionalParams, settings?: PageSettings ): AsyncIterableIterator { let result: ManagedInstancesListByResourceGroupResponse; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._listByResourceGroup(resourceGroupName, options); let page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listByResourceGroupNext( resourceGroupName, continuationToken, options ); continuationToken = result.nextLink; let page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } private async *listByResourceGroupPagingAll( resourceGroupName: string, options?: ManagedInstancesListByResourceGroupOptionalParams ): AsyncIterableIterator { for await (const page of this.listByResourceGroupPagingPage( resourceGroupName, options )) { yield* page; } } /** * Gets the collection of outbound network dependencies for the given managed instance. * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param managedInstanceName The name of the managed instance. * @param options The options parameters. */ public listOutboundNetworkDependenciesByManagedInstance( resourceGroupName: string, managedInstanceName: string, options?: ManagedInstancesListOutboundNetworkDependenciesByManagedInstanceOptionalParams ): PagedAsyncIterableIterator { const iter = this.listOutboundNetworkDependenciesByManagedInstancePagingAll( resourceGroupName, managedInstanceName, 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.listOutboundNetworkDependenciesByManagedInstancePagingPage( resourceGroupName, managedInstanceName, options, settings ); } }; } private async *listOutboundNetworkDependenciesByManagedInstancePagingPage( resourceGroupName: string, managedInstanceName: string, options?: ManagedInstancesListOutboundNetworkDependenciesByManagedInstanceOptionalParams, settings?: PageSettings ): AsyncIterableIterator { let result: ManagedInstancesListOutboundNetworkDependenciesByManagedInstanceResponse; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._listOutboundNetworkDependenciesByManagedInstance( resourceGroupName, managedInstanceName, options ); let page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listOutboundNetworkDependenciesByManagedInstanceNext( resourceGroupName, managedInstanceName, continuationToken, options ); continuationToken = result.nextLink; let page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } private async *listOutboundNetworkDependenciesByManagedInstancePagingAll( resourceGroupName: string, managedInstanceName: string, options?: ManagedInstancesListOutboundNetworkDependenciesByManagedInstanceOptionalParams ): AsyncIterableIterator { for await (const page of this.listOutboundNetworkDependenciesByManagedInstancePagingPage( resourceGroupName, managedInstanceName, options )) { yield* page; } } /** * Get top resource consuming queries of a managed instance. * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param managedInstanceName The name of the managed instance. * @param options The options parameters. */ public listByManagedInstance( resourceGroupName: string, managedInstanceName: string, options?: ManagedInstancesListByManagedInstanceOptionalParams ): PagedAsyncIterableIterator { const iter = this.listByManagedInstancePagingAll( resourceGroupName, managedInstanceName, 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.listByManagedInstancePagingPage( resourceGroupName, managedInstanceName, options, settings ); } }; } private async *listByManagedInstancePagingPage( resourceGroupName: string, managedInstanceName: string, options?: ManagedInstancesListByManagedInstanceOptionalParams, settings?: PageSettings ): AsyncIterableIterator { let result: ManagedInstancesListByManagedInstanceResponse; let continuationToken = settings?.continuationToken; if (!continuationToken) { result = await this._listByManagedInstance( resourceGroupName, managedInstanceName, options ); let page = result.value || []; continuationToken = result.nextLink; setContinuationToken(page, continuationToken); yield page; } while (continuationToken) { result = await this._listByManagedInstanceNext( resourceGroupName, managedInstanceName, continuationToken, options ); continuationToken = result.nextLink; let page = result.value || []; setContinuationToken(page, continuationToken); yield page; } } private async *listByManagedInstancePagingAll( resourceGroupName: string, managedInstanceName: string, options?: ManagedInstancesListByManagedInstanceOptionalParams ): AsyncIterableIterator { for await (const page of this.listByManagedInstancePagingPage( resourceGroupName, managedInstanceName, options )) { yield* page; } } /** * Gets a list of all managed instances in the subscription. * @param options The options parameters. */ private _list( options?: ManagedInstancesListOptionalParams ): Promise { return this.client.sendOperationRequest({ options }, listOperationSpec); } /** * Gets a list of all managed instances in an instance pool. * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param instancePoolName The instance pool name. * @param options The options parameters. */ private _listByInstancePool( resourceGroupName: string, instancePoolName: string, options?: ManagedInstancesListByInstancePoolOptionalParams ): Promise { return this.client.sendOperationRequest( { resourceGroupName, instancePoolName, options }, listByInstancePoolOperationSpec ); } /** * Gets a list of managed instances in a resource group. * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param options The options parameters. */ private _listByResourceGroup( resourceGroupName: string, options?: ManagedInstancesListByResourceGroupOptionalParams ): Promise { return this.client.sendOperationRequest( { resourceGroupName, options }, listByResourceGroupOperationSpec ); } /** * Gets a managed instance. * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param managedInstanceName The name of the managed instance. * @param options The options parameters. */ get( resourceGroupName: string, managedInstanceName: string, options?: ManagedInstancesGetOptionalParams ): Promise { return this.client.sendOperationRequest( { resourceGroupName, managedInstanceName, options }, getOperationSpec ); } /** * Creates or updates a managed instance. * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param managedInstanceName The name of the managed instance. * @param parameters The requested managed instance resource state. * @param options The options parameters. */ async beginCreateOrUpdate( resourceGroupName: string, managedInstanceName: string, parameters: ManagedInstance, options?: ManagedInstancesCreateOrUpdateOptionalParams ): Promise< SimplePollerLike< OperationState, ManagedInstancesCreateOrUpdateResponse > > { const directSendOperation = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ): Promise => { return this.client.sendOperationRequest(args, spec); }; const sendOperationFn = 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 = createLroSpec({ sendOperationFn, args: { resourceGroupName, managedInstanceName, parameters, options }, spec: createOrUpdateOperationSpec }); const poller = await createHttpPoller< ManagedInstancesCreateOrUpdateResponse, OperationState >(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); await poller.poll(); return poller; } /** * Creates or updates a managed instance. * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param managedInstanceName The name of the managed instance. * @param parameters The requested managed instance resource state. * @param options The options parameters. */ async beginCreateOrUpdateAndWait( resourceGroupName: string, managedInstanceName: string, parameters: ManagedInstance, options?: ManagedInstancesCreateOrUpdateOptionalParams ): Promise { const poller = await this.beginCreateOrUpdate( resourceGroupName, managedInstanceName, parameters, options ); return poller.pollUntilDone(); } /** * Deletes a managed instance. * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param managedInstanceName The name of the managed instance. * @param options The options parameters. */ async beginDelete( resourceGroupName: string, managedInstanceName: string, options?: ManagedInstancesDeleteOptionalParams ): Promise, void>> { const directSendOperation = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ): Promise => { return this.client.sendOperationRequest(args, spec); }; const sendOperationFn = 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 = createLroSpec({ sendOperationFn, args: { resourceGroupName, managedInstanceName, options }, spec: deleteOperationSpec }); const poller = await createHttpPoller>(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); await poller.poll(); return poller; } /** * Deletes a managed instance. * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param managedInstanceName The name of the managed instance. * @param options The options parameters. */ async beginDeleteAndWait( resourceGroupName: string, managedInstanceName: string, options?: ManagedInstancesDeleteOptionalParams ): Promise { const poller = await this.beginDelete( resourceGroupName, managedInstanceName, options ); return poller.pollUntilDone(); } /** * Updates a managed instance. * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param managedInstanceName The name of the managed instance. * @param parameters The requested managed instance resource state. * @param options The options parameters. */ async beginUpdate( resourceGroupName: string, managedInstanceName: string, parameters: ManagedInstanceUpdate, options?: ManagedInstancesUpdateOptionalParams ): Promise< SimplePollerLike< OperationState, ManagedInstancesUpdateResponse > > { const directSendOperation = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ): Promise => { return this.client.sendOperationRequest(args, spec); }; const sendOperationFn = 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 = createLroSpec({ sendOperationFn, args: { resourceGroupName, managedInstanceName, parameters, options }, spec: updateOperationSpec }); const poller = await createHttpPoller< ManagedInstancesUpdateResponse, OperationState >(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); await poller.poll(); return poller; } /** * Updates a managed instance. * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param managedInstanceName The name of the managed instance. * @param parameters The requested managed instance resource state. * @param options The options parameters. */ async beginUpdateAndWait( resourceGroupName: string, managedInstanceName: string, parameters: ManagedInstanceUpdate, options?: ManagedInstancesUpdateOptionalParams ): Promise { const poller = await this.beginUpdate( resourceGroupName, managedInstanceName, parameters, options ); return poller.pollUntilDone(); } /** * Failovers a managed instance. * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param managedInstanceName The name of the managed instance to failover. * @param options The options parameters. */ async beginFailover( resourceGroupName: string, managedInstanceName: string, options?: ManagedInstancesFailoverOptionalParams ): Promise, void>> { const directSendOperation = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ): Promise => { return this.client.sendOperationRequest(args, spec); }; const sendOperationFn = 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 = createLroSpec({ sendOperationFn, args: { resourceGroupName, managedInstanceName, options }, spec: failoverOperationSpec }); const poller = await createHttpPoller>(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs }); await poller.poll(); return poller; } /** * Failovers a managed instance. * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param managedInstanceName The name of the managed instance to failover. * @param options The options parameters. */ async beginFailoverAndWait( resourceGroupName: string, managedInstanceName: string, options?: ManagedInstancesFailoverOptionalParams ): Promise { const poller = await this.beginFailover( resourceGroupName, managedInstanceName, options ); return poller.pollUntilDone(); } /** * Gets the collection of outbound network dependencies for the given managed instance. * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param managedInstanceName The name of the managed instance. * @param options The options parameters. */ private _listOutboundNetworkDependenciesByManagedInstance( resourceGroupName: string, managedInstanceName: string, options?: ManagedInstancesListOutboundNetworkDependenciesByManagedInstanceOptionalParams ): Promise< ManagedInstancesListOutboundNetworkDependenciesByManagedInstanceResponse > { return this.client.sendOperationRequest( { resourceGroupName, managedInstanceName, options }, listOutboundNetworkDependenciesByManagedInstanceOperationSpec ); } /** * Starts the managed instance. * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param managedInstanceName The name of the managed instance. * @param options The options parameters. */ async beginStart( resourceGroupName: string, managedInstanceName: string, options?: ManagedInstancesStartOptionalParams ): Promise, void>> { const directSendOperation = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ): Promise => { return this.client.sendOperationRequest(args, spec); }; const sendOperationFn = 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 = createLroSpec({ sendOperationFn, args: { resourceGroupName, managedInstanceName, options }, spec: startOperationSpec }); const poller = await createHttpPoller>(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location" }); await poller.poll(); return poller; } /** * Starts the managed instance. * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param managedInstanceName The name of the managed instance. * @param options The options parameters. */ async beginStartAndWait( resourceGroupName: string, managedInstanceName: string, options?: ManagedInstancesStartOptionalParams ): Promise { const poller = await this.beginStart( resourceGroupName, managedInstanceName, options ); return poller.pollUntilDone(); } /** * Stops the managed instance. * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param managedInstanceName The name of the managed instance. * @param options The options parameters. */ async beginStop( resourceGroupName: string, managedInstanceName: string, options?: ManagedInstancesStopOptionalParams ): Promise, void>> { const directSendOperation = async ( args: coreClient.OperationArguments, spec: coreClient.OperationSpec ): Promise => { return this.client.sendOperationRequest(args, spec); }; const sendOperationFn = 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 = createLroSpec({ sendOperationFn, args: { resourceGroupName, managedInstanceName, options }, spec: stopOperationSpec }); const poller = await createHttpPoller>(lro, { restoreFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs, resourceLocationConfig: "location" }); await poller.poll(); return poller; } /** * Stops the managed instance. * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param managedInstanceName The name of the managed instance. * @param options The options parameters. */ async beginStopAndWait( resourceGroupName: string, managedInstanceName: string, options?: ManagedInstancesStopOptionalParams ): Promise { const poller = await this.beginStop( resourceGroupName, managedInstanceName, options ); return poller.pollUntilDone(); } /** * Get top resource consuming queries of a managed instance. * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param managedInstanceName The name of the managed instance. * @param options The options parameters. */ private _listByManagedInstance( resourceGroupName: string, managedInstanceName: string, options?: ManagedInstancesListByManagedInstanceOptionalParams ): Promise { return this.client.sendOperationRequest( { resourceGroupName, managedInstanceName, options }, listByManagedInstanceOperationSpec ); } /** * ListNext * @param nextLink The nextLink from the previous successful call to the List method. * @param options The options parameters. */ private _listNext( nextLink: string, options?: ManagedInstancesListNextOptionalParams ): Promise { return this.client.sendOperationRequest( { nextLink, options }, listNextOperationSpec ); } /** * ListByInstancePoolNext * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param instancePoolName The instance pool name. * @param nextLink The nextLink from the previous successful call to the ListByInstancePool method. * @param options The options parameters. */ private _listByInstancePoolNext( resourceGroupName: string, instancePoolName: string, nextLink: string, options?: ManagedInstancesListByInstancePoolNextOptionalParams ): Promise { return this.client.sendOperationRequest( { resourceGroupName, instancePoolName, nextLink, options }, listByInstancePoolNextOperationSpec ); } /** * ListByResourceGroupNext * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param nextLink The nextLink from the previous successful call to the ListByResourceGroup method. * @param options The options parameters. */ private _listByResourceGroupNext( resourceGroupName: string, nextLink: string, options?: ManagedInstancesListByResourceGroupNextOptionalParams ): Promise { return this.client.sendOperationRequest( { resourceGroupName, nextLink, options }, listByResourceGroupNextOperationSpec ); } /** * ListOutboundNetworkDependenciesByManagedInstanceNext * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param managedInstanceName The name of the managed instance. * @param nextLink The nextLink from the previous successful call to the * ListOutboundNetworkDependenciesByManagedInstance method. * @param options The options parameters. */ private _listOutboundNetworkDependenciesByManagedInstanceNext( resourceGroupName: string, managedInstanceName: string, nextLink: string, options?: ManagedInstancesListOutboundNetworkDependenciesByManagedInstanceNextOptionalParams ): Promise< ManagedInstancesListOutboundNetworkDependenciesByManagedInstanceNextResponse > { return this.client.sendOperationRequest( { resourceGroupName, managedInstanceName, nextLink, options }, listOutboundNetworkDependenciesByManagedInstanceNextOperationSpec ); } /** * ListByManagedInstanceNext * @param resourceGroupName The name of the resource group that contains the resource. You can obtain * this value from the Azure Resource Manager API or the portal. * @param managedInstanceName The name of the managed instance. * @param nextLink The nextLink from the previous successful call to the ListByManagedInstance method. * @param options The options parameters. */ private _listByManagedInstanceNext( resourceGroupName: string, managedInstanceName: string, nextLink: string, options?: ManagedInstancesListByManagedInstanceNextOptionalParams ): Promise { return this.client.sendOperationRequest( { resourceGroupName, managedInstanceName, nextLink, options }, listByManagedInstanceNextOperationSpec ); } } // Operation Specifications const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); const listOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/managedInstances", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ManagedInstanceListResult }, default: {} }, queryParameters: [Parameters.apiVersion1, Parameters.expand], urlParameters: [Parameters.$host, Parameters.subscriptionId], headerParameters: [Parameters.accept], serializer }; const listByInstancePoolOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}/managedInstances", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ManagedInstanceListResult }, default: {} }, queryParameters: [Parameters.apiVersion1, Parameters.expand], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.instancePoolName ], headerParameters: [Parameters.accept], serializer }; const listByResourceGroupOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ManagedInstanceListResult }, default: {} }, queryParameters: [Parameters.apiVersion1, Parameters.expand], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName ], headerParameters: [Parameters.accept], serializer }; const getOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ManagedInstance }, default: {} }, queryParameters: [Parameters.apiVersion1, Parameters.expand], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.managedInstanceName ], headerParameters: [Parameters.accept], serializer }; const createOrUpdateOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}", httpMethod: "PUT", responses: { 200: { bodyMapper: Mappers.ManagedInstance }, 201: { bodyMapper: Mappers.ManagedInstance }, 202: { bodyMapper: Mappers.ManagedInstance }, 204: { bodyMapper: Mappers.ManagedInstance }, default: {} }, requestBody: Parameters.parameters96, queryParameters: [Parameters.apiVersion1], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.managedInstanceName ], headerParameters: [Parameters.contentType, Parameters.accept], mediaType: "json", serializer }; const deleteOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}", httpMethod: "DELETE", responses: { 200: {}, 201: {}, 202: {}, 204: {}, default: {} }, queryParameters: [Parameters.apiVersion1], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.managedInstanceName ], serializer }; const updateOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}", httpMethod: "PATCH", responses: { 200: { bodyMapper: Mappers.ManagedInstance }, 201: { bodyMapper: Mappers.ManagedInstance }, 202: { bodyMapper: Mappers.ManagedInstance }, 204: { bodyMapper: Mappers.ManagedInstance }, default: {} }, requestBody: Parameters.parameters97, queryParameters: [Parameters.apiVersion1], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.managedInstanceName ], headerParameters: [Parameters.contentType, Parameters.accept], mediaType: "json", serializer }; const failoverOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/failover", httpMethod: "POST", responses: { 200: {}, 201: {}, 202: {}, 204: {}, default: {} }, queryParameters: [Parameters.apiVersion1, Parameters.replicaType], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.managedInstanceName ], serializer }; const listOutboundNetworkDependenciesByManagedInstanceOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/outboundNetworkDependenciesEndpoints", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.OutboundEnvironmentEndpointCollection }, default: {} }, queryParameters: [Parameters.apiVersion1], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.managedInstanceName ], headerParameters: [Parameters.accept], serializer }; const startOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/start", httpMethod: "POST", responses: { 200: {}, 201: {}, 202: {}, 204: {}, default: {} }, queryParameters: [Parameters.apiVersion1], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.managedInstanceName ], serializer }; const stopOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/stop", httpMethod: "POST", responses: { 200: {}, 201: {}, 202: {}, 204: {}, default: {} }, queryParameters: [Parameters.apiVersion1], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.managedInstanceName ], serializer }; const listByManagedInstanceOperationSpec: coreClient.OperationSpec = { path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/topqueries", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.TopQueriesListResult }, default: {} }, queryParameters: [ Parameters.apiVersion1, Parameters.startTime, Parameters.endTime, Parameters.interval, Parameters.numberOfQueries, Parameters.databases, Parameters.aggregationFunction, Parameters.observationMetric ], urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.managedInstanceName ], headerParameters: [Parameters.accept], serializer }; const listNextOperationSpec: coreClient.OperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ManagedInstanceListResult }, default: {} }, urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.nextLink ], headerParameters: [Parameters.accept], serializer }; const listByInstancePoolNextOperationSpec: coreClient.OperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ManagedInstanceListResult }, default: {} }, urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.nextLink, Parameters.instancePoolName ], headerParameters: [Parameters.accept], serializer }; const listByResourceGroupNextOperationSpec: coreClient.OperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.ManagedInstanceListResult }, default: {} }, urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.nextLink ], headerParameters: [Parameters.accept], serializer }; const listOutboundNetworkDependenciesByManagedInstanceNextOperationSpec: coreClient.OperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.OutboundEnvironmentEndpointCollection }, default: {} }, urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.nextLink, Parameters.managedInstanceName ], headerParameters: [Parameters.accept], serializer }; const listByManagedInstanceNextOperationSpec: coreClient.OperationSpec = { path: "{nextLink}", httpMethod: "GET", responses: { 200: { bodyMapper: Mappers.TopQueriesListResult }, default: {} }, urlParameters: [ Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName, Parameters.nextLink, Parameters.managedInstanceName ], headerParameters: [Parameters.accept], serializer };