// 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 ManagedDatabaseSensitivityLabels operations. */
export class ManagedDatabaseSensitivityLabelsImpl {
    client;
    /**
     * Initialize a new instance of the class ManagedDatabaseSensitivityLabels class.
     * @param client Reference to the service client
     */
    constructor(client) {
        this.client = client;
    }
    /**
     * Gets the sensitivity labels of a given database
     * @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.
     */
    listCurrentByDatabase(resourceGroupName, managedInstanceName, databaseName, options) {
        const iter = this.listCurrentByDatabasePagingAll(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.listCurrentByDatabasePagingPage(resourceGroupName, managedInstanceName, databaseName, options, settings);
            },
        };
    }
    async *listCurrentByDatabasePagingPage(resourceGroupName, managedInstanceName, databaseName, options, settings) {
        let result;
        let continuationToken = settings?.continuationToken;
        if (!continuationToken) {
            result = await this._listCurrentByDatabase(resourceGroupName, managedInstanceName, databaseName, options);
            let page = result.value || [];
            continuationToken = result.nextLink;
            setContinuationToken(page, continuationToken);
            yield page;
        }
        while (continuationToken) {
            result = await this._listCurrentByDatabaseNext(resourceGroupName, managedInstanceName, databaseName, continuationToken, options);
            continuationToken = result.nextLink;
            let page = result.value || [];
            setContinuationToken(page, continuationToken);
            yield page;
        }
    }
    async *listCurrentByDatabasePagingAll(resourceGroupName, managedInstanceName, databaseName, options) {
        for await (const page of this.listCurrentByDatabasePagingPage(resourceGroupName, managedInstanceName, databaseName, options)) {
            yield* page;
        }
    }
    /**
     * Gets the sensitivity labels of a given database
     * @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.
     */
    listRecommendedByDatabase(resourceGroupName, managedInstanceName, databaseName, options) {
        const iter = this.listRecommendedByDatabasePagingAll(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.listRecommendedByDatabasePagingPage(resourceGroupName, managedInstanceName, databaseName, options, settings);
            },
        };
    }
    async *listRecommendedByDatabasePagingPage(resourceGroupName, managedInstanceName, databaseName, options, settings) {
        let result;
        let continuationToken = settings?.continuationToken;
        if (!continuationToken) {
            result = await this._listRecommendedByDatabase(resourceGroupName, managedInstanceName, databaseName, options);
            let page = result.value || [];
            continuationToken = result.nextLink;
            setContinuationToken(page, continuationToken);
            yield page;
        }
        while (continuationToken) {
            result = await this._listRecommendedByDatabaseNext(resourceGroupName, managedInstanceName, databaseName, continuationToken, options);
            continuationToken = result.nextLink;
            let page = result.value || [];
            setContinuationToken(page, continuationToken);
            yield page;
        }
    }
    async *listRecommendedByDatabasePagingAll(resourceGroupName, managedInstanceName, databaseName, options) {
        for await (const page of this.listRecommendedByDatabasePagingPage(resourceGroupName, managedInstanceName, databaseName, options)) {
            yield* page;
        }
    }
    /**
     * Gets the sensitivity label of a given 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 sensitivityLabelSource The source of the sensitivity label.
     * @param options The options parameters.
     */
    get(resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, columnName, sensitivityLabelSource, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            managedInstanceName,
            databaseName,
            schemaName,
            tableName,
            columnName,
            sensitivityLabelSource,
            options,
        }, getOperationSpec);
    }
    /**
     * Creates or updates the sensitivity label of a given 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 parameters The column sensitivity label resource.
     * @param options The options parameters.
     */
    createOrUpdate(resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, columnName, parameters, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            managedInstanceName,
            databaseName,
            schemaName,
            tableName,
            columnName,
            parameters,
            options,
        }, createOrUpdateOperationSpec);
    }
    /**
     * Deletes the sensitivity label of a given 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.
     */
    delete(resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, columnName, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            managedInstanceName,
            databaseName,
            schemaName,
            tableName,
            columnName,
            options,
        }, deleteOperationSpec);
    }
    /**
     * Disables sensitivity recommendations on a given 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.
     */
    disableRecommendation(resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, columnName, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            managedInstanceName,
            databaseName,
            schemaName,
            tableName,
            columnName,
            options,
        }, disableRecommendationOperationSpec);
    }
    /**
     * Enables sensitivity recommendations on a given column (recommendations are enabled by default on all
     * 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 columnName The name of the column.
     * @param options The options parameters.
     */
    enableRecommendation(resourceGroupName, managedInstanceName, databaseName, schemaName, tableName, columnName, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            managedInstanceName,
            databaseName,
            schemaName,
            tableName,
            columnName,
            options,
        }, enableRecommendationOperationSpec);
    }
    /**
     * Gets the sensitivity labels of a given database
     * @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.
     */
    _listCurrentByDatabase(resourceGroupName, managedInstanceName, databaseName, options) {
        return this.client.sendOperationRequest({ resourceGroupName, managedInstanceName, databaseName, options }, listCurrentByDatabaseOperationSpec);
    }
    /**
     * Update sensitivity labels of a given database using an operations batch.
     * @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 parameters A list of sensitivity label update operations.
     * @param options The options parameters.
     */
    update(resourceGroupName, managedInstanceName, databaseName, parameters, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            managedInstanceName,
            databaseName,
            parameters,
            options,
        }, updateOperationSpec);
    }
    /**
     * Gets the sensitivity labels of a given database
     * @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.
     */
    _listRecommendedByDatabase(resourceGroupName, managedInstanceName, databaseName, options) {
        return this.client.sendOperationRequest({ resourceGroupName, managedInstanceName, databaseName, options }, listRecommendedByDatabaseOperationSpec);
    }
    /**
     * ListCurrentByDatabaseNext
     * @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 ListCurrentByDatabase method.
     * @param options The options parameters.
     */
    _listCurrentByDatabaseNext(resourceGroupName, managedInstanceName, databaseName, nextLink, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            managedInstanceName,
            databaseName,
            nextLink,
            options,
        }, listCurrentByDatabaseNextOperationSpec);
    }
    /**
     * ListRecommendedByDatabaseNext
     * @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 ListRecommendedByDatabase
     *                 method.
     * @param options The options parameters.
     */
    _listRecommendedByDatabaseNext(resourceGroupName, managedInstanceName, databaseName, nextLink, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            managedInstanceName,
            databaseName,
            nextLink,
            options,
        }, listRecommendedByDatabaseNextOperationSpec);
    }
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const getOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.SensitivityLabel,
        },
        default: {},
    },
    queryParameters: [Parameters.apiVersion3],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.databaseName,
        Parameters.schemaName,
        Parameters.tableName,
        Parameters.columnName,
        Parameters.managedInstanceName,
        Parameters.sensitivityLabelSource,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const createOrUpdateOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}",
    httpMethod: "PUT",
    responses: {
        200: {
            bodyMapper: Mappers.SensitivityLabel,
        },
        201: {
            bodyMapper: Mappers.SensitivityLabel,
        },
        default: {},
    },
    requestBody: Parameters.parameters64,
    queryParameters: [Parameters.apiVersion3],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.databaseName,
        Parameters.schemaName,
        Parameters.tableName,
        Parameters.columnName,
        Parameters.managedInstanceName,
        Parameters.sensitivityLabelSource1,
    ],
    headerParameters: [Parameters.contentType, Parameters.accept],
    mediaType: "json",
    serializer,
};
const deleteOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}",
    httpMethod: "DELETE",
    responses: { 200: {}, default: {} },
    queryParameters: [Parameters.apiVersion3],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.databaseName,
        Parameters.schemaName,
        Parameters.tableName,
        Parameters.columnName,
        Parameters.managedInstanceName,
        Parameters.sensitivityLabelSource1,
    ],
    serializer,
};
const disableRecommendationOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/disable",
    httpMethod: "POST",
    responses: { 200: {}, default: {} },
    queryParameters: [Parameters.apiVersion3],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.databaseName,
        Parameters.schemaName,
        Parameters.tableName,
        Parameters.columnName,
        Parameters.managedInstanceName,
        Parameters.sensitivityLabelSource2,
    ],
    serializer,
};
const enableRecommendationOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/columns/{columnName}/sensitivityLabels/{sensitivityLabelSource}/enable",
    httpMethod: "POST",
    responses: { 200: {}, default: {} },
    queryParameters: [Parameters.apiVersion3],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.databaseName,
        Parameters.schemaName,
        Parameters.tableName,
        Parameters.columnName,
        Parameters.managedInstanceName,
        Parameters.sensitivityLabelSource2,
    ],
    serializer,
};
const listCurrentByDatabaseOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/currentSensitivityLabels",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.SensitivityLabelListResult,
        },
        default: {},
    },
    queryParameters: [
        Parameters.skipToken,
        Parameters.filter1,
        Parameters.apiVersion3,
        Parameters.count,
    ],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.databaseName,
        Parameters.managedInstanceName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const updateOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/currentSensitivityLabels",
    httpMethod: "PATCH",
    responses: { 200: {}, default: {} },
    requestBody: Parameters.parameters65,
    queryParameters: [Parameters.apiVersion3],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.databaseName,
        Parameters.managedInstanceName,
    ],
    headerParameters: [Parameters.contentType],
    mediaType: "json",
    serializer,
};
const listRecommendedByDatabaseOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/databases/{databaseName}/recommendedSensitivityLabels",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.SensitivityLabelListResult,
        },
        default: {},
    },
    queryParameters: [
        Parameters.skipToken,
        Parameters.filter1,
        Parameters.apiVersion3,
        Parameters.includeDisabledRecommendations,
    ],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.databaseName,
        Parameters.managedInstanceName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const listCurrentByDatabaseNextOperationSpec = {
    path: "{nextLink}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.SensitivityLabelListResult,
        },
        default: {},
    },
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.databaseName,
        Parameters.nextLink,
        Parameters.managedInstanceName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const listRecommendedByDatabaseNextOperationSpec = {
    path: "{nextLink}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.SensitivityLabelListResult,
        },
        default: {},
    },
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.databaseName,
        Parameters.nextLink,
        Parameters.managedInstanceName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
//# sourceMappingURL=managedDatabaseSensitivityLabels.js.map