// 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";
/// <reference lib="esnext.asynciterable" />
/** Class containing ManagedDatabaseColumns operations. */
export class ManagedDatabaseColumnsImpl {
    client;
    /**
     * Initialize a new instance of the class ManagedDatabaseColumns class.
     * @param client Reference to the service client
     */
    constructor(client) {
        this.client = client;
    }
    /**
     * List managed database columns
     * @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 databaseName The name of the database.
     * @param options The options parameters.
     */
    listByDatabase(resourceGroupName, managedInstanceName, databaseName, options) {
        const iter = this.listByDatabasePagingAll(resourceGroupName, managedInstanceName, databaseName, 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.listByDatabasePagingPage(resourceGroupName, managedInstanceName, databaseName, options, settings);
            },
        };
    }
    async *listByDatabasePagingPage(resourceGroupName, managedInstanceName, databaseName, options, settings) {
        let result;
        let continuationToken = settings?.continuationToken;
        if (!continuationToken) {
            result = await this._listByDatabase(resourceGroupName, managedInstanceName, databaseName, options);
            let page = result.value || [];
            continuationToken = result.nextLink;
            setContinuationToken(page, continuationToken);
            yield page;
        }
        while (continuationToken) {
            result = await this._listByDatabaseNext(resourceGroupName, managedInstanceName, databaseName, continuationToken, options);
            continuationToken = result.nextLink;
            let page = result.value || [];
            setContinuationToken(page, continuationToken);
            yield page;
        }
    }
    async *listByDatabasePagingAll(resourceGroupName, managedInstanceName, databaseName, options) {
        for await (const page of this.listByDatabasePagingPage(resourceGroupName, managedInstanceName, databaseName, options)) {
            yield* page;
        }
    }
    /**
     * List managed database columns
     * @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 databaseName The name of the database.
     * @param schemaName The name of the schema.
     * @param tableName The name of the table.
     * @param options The options parameters.
     */
    listByTable(resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, options) {
        const iter = this.listByTablePagingAll(resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, 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.listByTablePagingPage(resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, options, settings);
            },
        };
    }
    async *listByTablePagingPage(resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, options, settings) {
        let result;
        let continuationToken = settings?.continuationToken;
        if (!continuationToken) {
            result = await this._listByTable(resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, options);
            let page = result.value || [];
            continuationToken = result.nextLink;
            setContinuationToken(page, continuationToken);
            yield page;
        }
        while (continuationToken) {
            result = await this._listByTableNext(resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, continuationToken, options);
            continuationToken = result.nextLink;
            let page = result.value || [];
            setContinuationToken(page, continuationToken);
            yield page;
        }
    }
    async *listByTablePagingAll(resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, options) {
        for await (const page of this.listByTablePagingPage(resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, options)) {
            yield* page;
        }
    }
    /**
     * List managed database columns
     * @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 databaseName The name of the database.
     * @param options The options parameters.
     */
    _listByDatabase(resourceGroupName, managedInstanceName, databaseName, options) {
        return this.client.sendOperationRequest({ resourceGroupName, managedInstanceName, databaseName, options }, listByDatabaseOperationSpec);
    }
    /**
     * List managed database columns
     * @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 databaseName The name of the database.
     * @param schemaName The name of the schema.
     * @param tableName The name of the table.
     * @param options The options parameters.
     */
    _listByTable(resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            managedInstanceName,
            databaseName,
            schemaName,
            tableName,
            options,
        }, listByTableOperationSpec);
    }
    /**
     * Get managed database column
     * @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 databaseName The name of the database.
     * @param schemaName The name of the schema.
     * @param tableName The name of the table.
     * @param columnName The name of the column.
     * @param options The options parameters.
     */
    get(resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, columnName, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            managedInstanceName,
            databaseName,
            schemaName,
            tableName,
            columnName,
            options,
        }, getOperationSpec);
    }
    /**
     * ListByDatabaseNext
     * @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 databaseName The name of the database.
     * @param nextLink The nextLink from the previous successful call to the ListByDatabase method.
     * @param options The options parameters.
     */
    _listByDatabaseNext(resourceGroupName, managedInstanceName, databaseName, nextLink, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            managedInstanceName,
            databaseName,
            nextLink,
            options,
        }, listByDatabaseNextOperationSpec);
    }
    /**
     * ListByTableNext
     * @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 databaseName The name of the database.
     * @param schemaName The name of the schema.
     * @param tableName The name of the table.
     * @param nextLink The nextLink from the previous successful call to the ListByTable method.
     * @param options The options parameters.
     */
    _listByTableNext(resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, nextLink, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            managedInstanceName,
            databaseName,
            schemaName,
            tableName,
            nextLink,
            options,
        }, listByTableNextOperationSpec);
    }
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const listByDatabaseOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/columns",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.DatabaseColumnListResult,
        },
        default: {},
    },
    queryParameters: [
        Parameters.apiVersion3,
        Parameters.schema,
        Parameters.table,
        Parameters.column,
        Parameters.orderBy,
        Parameters.skiptoken,
    ],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.databaseName,
        Parameters.managedInstanceName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const listByTableOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.DatabaseColumnListResult,
        },
        default: {},
    },
    queryParameters: [Parameters.filter1, Parameters.apiVersion3],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.databaseName,
        Parameters.schemaName,
        Parameters.tableName,
        Parameters.managedInstanceName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const getOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.DatabaseColumn,
        },
        default: {},
    },
    queryParameters: [Parameters.apiVersion3],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.databaseName,
        Parameters.schemaName,
        Parameters.tableName,
        Parameters.columnName,
        Parameters.managedInstanceName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const listByDatabaseNextOperationSpec = {
    path: "{nextLink}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.DatabaseColumnListResult,
        },
        default: {},
    },
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.databaseName,
        Parameters.nextLink,
        Parameters.managedInstanceName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const listByTableNextOperationSpec = {
    path: "{nextLink}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.DatabaseColumnListResult,
        },
        default: {},
    },
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.databaseName,
        Parameters.nextLink,
        Parameters.schemaName,
        Parameters.tableName,
        Parameters.managedInstanceName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
//# sourceMappingURL=managedDatabaseColumns.js.map