"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.ManagedDatabaseMoveOperationsImpl = void 0;
const tslib_1 = require("tslib");
const pagingHelper_js_1 = require("../pagingHelper.js");
const coreClient = tslib_1.__importStar(require("@azure/core-client"));
const Mappers = tslib_1.__importStar(require("../models/mappers.js"));
const Parameters = tslib_1.__importStar(require("../models/parameters.js"));
/// <reference lib="esnext.asynciterable" />
/** Class containing ManagedDatabaseMoveOperations operations. */
class ManagedDatabaseMoveOperationsImpl {
    client;
    /**
     * Initialize a new instance of the class ManagedDatabaseMoveOperations class.
     * @param client Reference to the service client
     */
    constructor(client) {
        this.client = client;
    }
    /**
     * Lists managed database move operations.
     * @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 locationName
     * @param options The options parameters.
     */
    listByLocation(resourceGroupName, locationName, options) {
        const iter = this.listByLocationPagingAll(resourceGroupName, locationName, 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.listByLocationPagingPage(resourceGroupName, locationName, options, settings);
            },
        };
    }
    async *listByLocationPagingPage(resourceGroupName, locationName, options, settings) {
        let result;
        let continuationToken = settings?.continuationToken;
        if (!continuationToken) {
            result = await this._listByLocation(resourceGroupName, locationName, options);
            let page = result.value || [];
            continuationToken = result.nextLink;
            (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken);
            yield page;
        }
        while (continuationToken) {
            result = await this._listByLocationNext(resourceGroupName, locationName, continuationToken, options);
            continuationToken = result.nextLink;
            let page = result.value || [];
            (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken);
            yield page;
        }
    }
    async *listByLocationPagingAll(resourceGroupName, locationName, options) {
        for await (const page of this.listByLocationPagingPage(resourceGroupName, locationName, options)) {
            yield* page;
        }
    }
    /**
     * Lists managed database move operations.
     * @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 locationName
     * @param options The options parameters.
     */
    _listByLocation(resourceGroupName, locationName, options) {
        return this.client.sendOperationRequest({ resourceGroupName, locationName, options }, listByLocationOperationSpec);
    }
    /**
     * Gets a managed database move operation.
     * @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 locationName
     * @param operationId
     * @param options The options parameters.
     */
    get(resourceGroupName, locationName, operationId, options) {
        return this.client.sendOperationRequest({ resourceGroupName, locationName, operationId, options }, getOperationSpec);
    }
    /**
     * ListByLocationNext
     * @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 locationName
     * @param nextLink The nextLink from the previous successful call to the ListByLocation method.
     * @param options The options parameters.
     */
    _listByLocationNext(resourceGroupName, locationName, nextLink, options) {
        return this.client.sendOperationRequest({ resourceGroupName, locationName, nextLink, options }, listByLocationNextOperationSpec);
    }
}
exports.ManagedDatabaseMoveOperationsImpl = ManagedDatabaseMoveOperationsImpl;
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const listByLocationOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/managedDatabaseMoveOperationResults",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.ManagedDatabaseMoveOperationListResult,
        },
        default: {},
    },
    queryParameters: [Parameters.filter1, Parameters.onlyLatestPerDatabase, Parameters.apiVersion9],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.locationName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const getOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/managedDatabaseMoveOperationResults/{operationId}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.ManagedDatabaseMoveOperationResult,
        },
        default: {},
    },
    queryParameters: [Parameters.apiVersion9],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.locationName,
        Parameters.operationId,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const listByLocationNextOperationSpec = {
    path: "{nextLink}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.ManagedDatabaseMoveOperationListResult,
        },
        default: {},
    },
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.nextLink,
        Parameters.locationName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
//# sourceMappingURL=managedDatabaseMoveOperations.js.map