// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { setContinuationToken } from "../pagingHelper.js";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers.js";
import * as Parameters from "../models/parameters.js";
import { createHttpPoller } from "@azure/core-lro";
import { createLroSpec } from "../lroImpl.js";
/// <reference lib="esnext.asynciterable" />
/** Class containing ManagedInstances operations. */
export class ManagedInstancesImpl {
    client;
    /**
     * Initialize a new instance of the class ManagedInstances class.
     * @param client Reference to the service client
     */
    constructor(client) {
        this.client = client;
    }
    /**
     * Gets a list of all managed instances in the subscription.
     * @param options The options parameters.
     */
    list(options) {
        const iter = this.listPagingAll(options);
        return {
            next() {
                return iter.next();
            },
            [Symbol.asyncIterator]() {
                return this;
            },
            byPage: (settings) => {
                if (settings?.maxPageSize) {
                    throw new Error("maxPageSize is not supported by this operation.");
                }
                return this.listPagingPage(options, settings);
            },
        };
    }
    async *listPagingPage(options, settings) {
        let result;
        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;
        }
    }
    async *listPagingAll(options) {
        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.
     */
    listByInstancePool(resourceGroupName, instancePoolName, options) {
        const iter = this.listByInstancePoolPagingAll(resourceGroupName, instancePoolName, options);
        return {
            next() {
                return iter.next();
            },
            [Symbol.asyncIterator]() {
                return this;
            },
            byPage: (settings) => {
                if (settings?.maxPageSize) {
                    throw new Error("maxPageSize is not supported by this operation.");
                }
                return this.listByInstancePoolPagingPage(resourceGroupName, instancePoolName, options, settings);
            },
        };
    }
    async *listByInstancePoolPagingPage(resourceGroupName, instancePoolName, options, settings) {
        let result;
        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;
        }
    }
    async *listByInstancePoolPagingAll(resourceGroupName, instancePoolName, options) {
        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.
     */
    listByResourceGroup(resourceGroupName, options) {
        const iter = this.listByResourceGroupPagingAll(resourceGroupName, options);
        return {
            next() {
                return iter.next();
            },
            [Symbol.asyncIterator]() {
                return this;
            },
            byPage: (settings) => {
                if (settings?.maxPageSize) {
                    throw new Error("maxPageSize is not supported by this operation.");
                }
                return this.listByResourceGroupPagingPage(resourceGroupName, options, settings);
            },
        };
    }
    async *listByResourceGroupPagingPage(resourceGroupName, options, settings) {
        let result;
        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;
        }
    }
    async *listByResourceGroupPagingAll(resourceGroupName, options) {
        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.
     */
    listOutboundNetworkDependenciesByManagedInstance(resourceGroupName, managedInstanceName, options) {
        const iter = this.listOutboundNetworkDependenciesByManagedInstancePagingAll(resourceGroupName, managedInstanceName, options);
        return {
            next() {
                return iter.next();
            },
            [Symbol.asyncIterator]() {
                return this;
            },
            byPage: (settings) => {
                if (settings?.maxPageSize) {
                    throw new Error("maxPageSize is not supported by this operation.");
                }
                return this.listOutboundNetworkDependenciesByManagedInstancePagingPage(resourceGroupName, managedInstanceName, options, settings);
            },
        };
    }
    async *listOutboundNetworkDependenciesByManagedInstancePagingPage(resourceGroupName, managedInstanceName, options, settings) {
        let result;
        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;
        }
    }
    async *listOutboundNetworkDependenciesByManagedInstancePagingAll(resourceGroupName, managedInstanceName, options) {
        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.
     */
    listByManagedInstance(resourceGroupName, managedInstanceName, options) {
        const iter = this.listByManagedInstancePagingAll(resourceGroupName, managedInstanceName, options);
        return {
            next() {
                return iter.next();
            },
            [Symbol.asyncIterator]() {
                return this;
            },
            byPage: (settings) => {
                if (settings?.maxPageSize) {
                    throw new Error("maxPageSize is not supported by this operation.");
                }
                return this.listByManagedInstancePagingPage(resourceGroupName, managedInstanceName, options, settings);
            },
        };
    }
    async *listByManagedInstancePagingPage(resourceGroupName, managedInstanceName, options, settings) {
        let result;
        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;
        }
    }
    async *listByManagedInstancePagingAll(resourceGroupName, managedInstanceName, options) {
        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.
     */
    _list(options) {
        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.
     */
    _listByInstancePool(resourceGroupName, instancePoolName, options) {
        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.
     */
    _listByResourceGroup(resourceGroupName, options) {
        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, managedInstanceName, options) {
        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, managedInstanceName, parameters, options) {
        const directSendOperation = async (args, spec) => {
            return this.client.sendOperationRequest(args, spec);
        };
        const sendOperationFn = async (args, spec) => {
            let currentRawResponse = undefined;
            const providedCallback = args.options?.onResponse;
            const callback = (rawResponse, flatResponse) => {
                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(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, managedInstanceName, parameters, options) {
        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, managedInstanceName, options) {
        const directSendOperation = async (args, spec) => {
            return this.client.sendOperationRequest(args, spec);
        };
        const sendOperationFn = async (args, spec) => {
            let currentRawResponse = undefined;
            const providedCallback = args.options?.onResponse;
            const callback = (rawResponse, flatResponse) => {
                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, managedInstanceName, options) {
        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, managedInstanceName, parameters, options) {
        const directSendOperation = async (args, spec) => {
            return this.client.sendOperationRequest(args, spec);
        };
        const sendOperationFn = async (args, spec) => {
            let currentRawResponse = undefined;
            const providedCallback = args.options?.onResponse;
            const callback = (rawResponse, flatResponse) => {
                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(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, managedInstanceName, parameters, options) {
        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, managedInstanceName, options) {
        const directSendOperation = async (args, spec) => {
            return this.client.sendOperationRequest(args, spec);
        };
        const sendOperationFn = async (args, spec) => {
            let currentRawResponse = undefined;
            const providedCallback = args.options?.onResponse;
            const callback = (rawResponse, flatResponse) => {
                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, managedInstanceName, options) {
        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.
     */
    _listOutboundNetworkDependenciesByManagedInstance(resourceGroupName, managedInstanceName, options) {
        return this.client.sendOperationRequest({ resourceGroupName, managedInstanceName, options }, listOutboundNetworkDependenciesByManagedInstanceOperationSpec);
    }
    /**
     * Refresh external governance enablement status.
     * @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 beginRefreshStatus(resourceGroupName, managedInstanceName, options) {
        const directSendOperation = async (args, spec) => {
            return this.client.sendOperationRequest(args, spec);
        };
        const sendOperationFn = async (args, spec) => {
            let currentRawResponse = undefined;
            const providedCallback = args.options?.onResponse;
            const callback = (rawResponse, flatResponse) => {
                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: refreshStatusOperationSpec,
        });
        const poller = await createHttpPoller(lro, {
            restoreFrom: options?.resumeFrom,
            intervalInMs: options?.updateIntervalInMs,
            resourceLocationConfig: "location",
        });
        await poller.poll();
        return poller;
    }
    /**
     * Refresh external governance enablement status.
     * @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 beginRefreshStatusAndWait(resourceGroupName, managedInstanceName, options) {
        const poller = await this.beginRefreshStatus(resourceGroupName, managedInstanceName, options);
        return poller.pollUntilDone();
    }
    /**
     * 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, managedInstanceName, options) {
        const directSendOperation = async (args, spec) => {
            return this.client.sendOperationRequest(args, spec);
        };
        const sendOperationFn = async (args, spec) => {
            let currentRawResponse = undefined;
            const providedCallback = args.options?.onResponse;
            const callback = (rawResponse, flatResponse) => {
                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, managedInstanceName, options) {
        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, managedInstanceName, options) {
        const directSendOperation = async (args, spec) => {
            return this.client.sendOperationRequest(args, spec);
        };
        const sendOperationFn = async (args, spec) => {
            let currentRawResponse = undefined;
            const providedCallback = args.options?.onResponse;
            const callback = (rawResponse, flatResponse) => {
                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, managedInstanceName, options) {
        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.
     */
    _listByManagedInstance(resourceGroupName, managedInstanceName, options) {
        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.
     */
    _listNext(nextLink, options) {
        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.
     */
    _listByInstancePoolNext(resourceGroupName, instancePoolName, nextLink, options) {
        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.
     */
    _listByResourceGroupNext(resourceGroupName, nextLink, options) {
        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.
     */
    _listOutboundNetworkDependenciesByManagedInstanceNext(resourceGroupName, managedInstanceName, nextLink, options) {
        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.
     */
    _listByManagedInstanceNext(resourceGroupName, managedInstanceName, nextLink, options) {
        return this.client.sendOperationRequest({ resourceGroupName, managedInstanceName, nextLink, options }, listByManagedInstanceNextOperationSpec);
    }
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const listOperationSpec = {
    path: "/subscriptions/{subscriptionId}/providers/Microsoft.Sql/managedInstances",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.ManagedInstanceListResult,
        },
        default: {},
    },
    queryParameters: [Parameters.expand, Parameters.apiVersion4],
    urlParameters: [Parameters.$host, Parameters.subscriptionId],
    headerParameters: [Parameters.accept],
    serializer,
};
const listByInstancePoolOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/instancePools/{instancePoolName}/managedInstances",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.ManagedInstanceListResult,
        },
        default: {},
    },
    queryParameters: [Parameters.expand, Parameters.apiVersion4],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.instancePoolName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const listByResourceGroupOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.ManagedInstanceListResult,
        },
        default: {},
    },
    queryParameters: [Parameters.expand, Parameters.apiVersion4],
    urlParameters: [Parameters.$host, Parameters.subscriptionId, Parameters.resourceGroupName],
    headerParameters: [Parameters.accept],
    serializer,
};
const getOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.ManagedInstance,
        },
        default: {},
    },
    queryParameters: [Parameters.expand, Parameters.apiVersion4],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.managedInstanceName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const createOrUpdateOperationSpec = {
    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.parameters97,
    queryParameters: [Parameters.apiVersion4],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.managedInstanceName,
    ],
    headerParameters: [Parameters.contentType, Parameters.accept],
    mediaType: "json",
    serializer,
};
const deleteOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}",
    httpMethod: "DELETE",
    responses: { 200: {}, 201: {}, 202: {}, 204: {}, default: {} },
    queryParameters: [Parameters.apiVersion4],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.managedInstanceName,
    ],
    serializer,
};
const updateOperationSpec = {
    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.parameters98,
    queryParameters: [Parameters.apiVersion4],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.managedInstanceName,
    ],
    headerParameters: [Parameters.contentType, Parameters.accept],
    mediaType: "json",
    serializer,
};
const failoverOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/failover",
    httpMethod: "POST",
    responses: { 200: {}, 201: {}, 202: {}, 204: {}, default: {} },
    queryParameters: [Parameters.replicaType, Parameters.apiVersion4],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.managedInstanceName,
    ],
    serializer,
};
const listOutboundNetworkDependenciesByManagedInstanceOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/outboundNetworkDependenciesEndpoints",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.OutboundEnvironmentEndpointCollection,
        },
        default: {},
    },
    queryParameters: [Parameters.apiVersion4],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.managedInstanceName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const refreshStatusOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/refreshExternalGovernanceStatus",
    httpMethod: "POST",
    responses: {
        200: {
            bodyMapper: Mappers.RefreshExternalGovernanceStatusOperationResultMI,
        },
        201: {
            bodyMapper: Mappers.RefreshExternalGovernanceStatusOperationResultMI,
        },
        202: {
            bodyMapper: Mappers.RefreshExternalGovernanceStatusOperationResultMI,
        },
        204: {
            bodyMapper: Mappers.RefreshExternalGovernanceStatusOperationResultMI,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    queryParameters: [Parameters.apiVersion4],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.managedInstanceName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const startOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/start",
    httpMethod: "POST",
    responses: {
        200: {
            bodyMapper: Mappers.ManagedInstance,
        },
        201: {
            bodyMapper: Mappers.ManagedInstance,
        },
        202: {
            bodyMapper: Mappers.ManagedInstance,
        },
        204: {
            bodyMapper: Mappers.ManagedInstance,
        },
        default: {},
    },
    queryParameters: [Parameters.apiVersion4],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.managedInstanceName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const stopOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/stop",
    httpMethod: "POST",
    responses: {
        200: {
            bodyMapper: Mappers.ManagedInstance,
        },
        201: {
            bodyMapper: Mappers.ManagedInstance,
        },
        202: {
            bodyMapper: Mappers.ManagedInstance,
        },
        204: {
            bodyMapper: Mappers.ManagedInstance,
        },
        default: {},
    },
    queryParameters: [Parameters.apiVersion4],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.managedInstanceName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const listByManagedInstanceOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/topqueries",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.TopQueriesListResult,
        },
        default: {},
    },
    queryParameters: [
        Parameters.apiVersion4,
        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 = {
    path: "{nextLink}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.ManagedInstanceListResult,
        },
        default: {},
    },
    urlParameters: [Parameters.$host, Parameters.subscriptionId, Parameters.nextLink],
    headerParameters: [Parameters.accept],
    serializer,
};
const listByInstancePoolNextOperationSpec = {
    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 = {
    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 = {
    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 = {
    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,
};
//# sourceMappingURL=managedInstances.js.map