"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.SensitivityLabelsImpl = 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 SensitivityLabels operations. */
class SensitivityLabelsImpl {
    client;
    /**
     * Initialize a new instance of the class SensitivityLabels 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 serverName The name of the server.
     * @param databaseName The name of the database.
     * @param options The options parameters.
     */
    listCurrentByDatabase(resourceGroupName, serverName, databaseName, options) {
        const iter = this.listCurrentByDatabasePagingAll(resourceGroupName, serverName, 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, serverName, databaseName, options, settings);
            },
        };
    }
    async *listCurrentByDatabasePagingPage(resourceGroupName, serverName, databaseName, options, settings) {
        let result;
        let continuationToken = settings?.continuationToken;
        if (!continuationToken) {
            result = await this._listCurrentByDatabase(resourceGroupName, serverName, databaseName, options);
            let page = result.value || [];
            continuationToken = result.nextLink;
            (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken);
            yield page;
        }
        while (continuationToken) {
            result = await this._listCurrentByDatabaseNext(resourceGroupName, serverName, databaseName, continuationToken, options);
            continuationToken = result.nextLink;
            let page = result.value || [];
            (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken);
            yield page;
        }
    }
    async *listCurrentByDatabasePagingAll(resourceGroupName, serverName, databaseName, options) {
        for await (const page of this.listCurrentByDatabasePagingPage(resourceGroupName, serverName, 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 serverName The name of the server.
     * @param databaseName The name of the database.
     * @param options The options parameters.
     */
    listRecommendedByDatabase(resourceGroupName, serverName, databaseName, options) {
        const iter = this.listRecommendedByDatabasePagingAll(resourceGroupName, serverName, 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, serverName, databaseName, options, settings);
            },
        };
    }
    async *listRecommendedByDatabasePagingPage(resourceGroupName, serverName, databaseName, options, settings) {
        let result;
        let continuationToken = settings?.continuationToken;
        if (!continuationToken) {
            result = await this._listRecommendedByDatabase(resourceGroupName, serverName, databaseName, options);
            let page = result.value || [];
            continuationToken = result.nextLink;
            (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken);
            yield page;
        }
        while (continuationToken) {
            result = await this._listRecommendedByDatabaseNext(resourceGroupName, serverName, databaseName, continuationToken, options);
            continuationToken = result.nextLink;
            let page = result.value || [];
            (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken);
            yield page;
        }
    }
    async *listRecommendedByDatabasePagingAll(resourceGroupName, serverName, databaseName, options) {
        for await (const page of this.listRecommendedByDatabasePagingPage(resourceGroupName, serverName, 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 serverName The name of the server.
     * @param databaseName The name of the database.
     * @param options The options parameters.
     */
    _listCurrentByDatabase(resourceGroupName, serverName, databaseName, options) {
        return this.client.sendOperationRequest({ resourceGroupName, serverName, 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 serverName The name of the server.
     * @param databaseName The name of the database.
     * @param parameters A list of sensitivity label update operations.
     * @param options The options parameters.
     */
    update(resourceGroupName, serverName, databaseName, parameters, options) {
        return this.client.sendOperationRequest({ resourceGroupName, serverName, 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 serverName The name of the server.
     * @param databaseName The name of the database.
     * @param options The options parameters.
     */
    _listRecommendedByDatabase(resourceGroupName, serverName, databaseName, options) {
        return this.client.sendOperationRequest({ resourceGroupName, serverName, databaseName, options }, listRecommendedByDatabaseOperationSpec);
    }
    /**
     * 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 serverName The name of the server.
     * @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, serverName, databaseName, schemaName, tableName, columnName, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            serverName,
            databaseName,
            schemaName,
            tableName,
            columnName,
            options,
        }, enableRecommendationOperationSpec);
    }
    /**
     * 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 serverName The name of the server.
     * @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, serverName, databaseName, schemaName, tableName, columnName, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            serverName,
            databaseName,
            schemaName,
            tableName,
            columnName,
            options,
        }, disableRecommendationOperationSpec);
    }
    /**
     * 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 serverName The name of the server.
     * @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, serverName, databaseName, schemaName, tableName, columnName, sensitivityLabelSource, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            serverName,
            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 serverName The name of the server.
     * @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, serverName, databaseName, schemaName, tableName, columnName, parameters, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            serverName,
            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 serverName The name of the server.
     * @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, serverName, databaseName, schemaName, tableName, columnName, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            serverName,
            databaseName,
            schemaName,
            tableName,
            columnName,
            options,
        }, deleteOperationSpec);
    }
    /**
     * 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 serverName The name of the server.
     * @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, serverName, databaseName, nextLink, options) {
        return this.client.sendOperationRequest({ resourceGroupName, serverName, 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 serverName The name of the server.
     * @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, serverName, databaseName, nextLink, options) {
        return this.client.sendOperationRequest({ resourceGroupName, serverName, databaseName, nextLink, options }, listRecommendedByDatabaseNextOperationSpec);
    }
}
exports.SensitivityLabelsImpl = SensitivityLabelsImpl;
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const listCurrentByDatabaseOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/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.serverName,
        Parameters.databaseName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const updateOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/currentSensitivityLabels",
    httpMethod: "PATCH",
    responses: { 200: {}, default: {} },
    requestBody: Parameters.parameters65,
    queryParameters: [Parameters.apiVersion3],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.serverName,
        Parameters.databaseName,
    ],
    headerParameters: [Parameters.contentType],
    mediaType: "json",
    serializer,
};
const listRecommendedByDatabaseOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/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.serverName,
        Parameters.databaseName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const enableRecommendationOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/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.serverName,
        Parameters.databaseName,
        Parameters.schemaName,
        Parameters.tableName,
        Parameters.columnName,
        Parameters.sensitivityLabelSource2,
    ],
    serializer,
};
const disableRecommendationOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/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.serverName,
        Parameters.databaseName,
        Parameters.schemaName,
        Parameters.tableName,
        Parameters.columnName,
        Parameters.sensitivityLabelSource2,
    ],
    serializer,
};
const getOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/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.serverName,
        Parameters.databaseName,
        Parameters.schemaName,
        Parameters.tableName,
        Parameters.columnName,
        Parameters.sensitivityLabelSource,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const createOrUpdateOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/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.serverName,
        Parameters.databaseName,
        Parameters.schemaName,
        Parameters.tableName,
        Parameters.columnName,
        Parameters.sensitivityLabelSource1,
    ],
    headerParameters: [Parameters.contentType, Parameters.accept],
    mediaType: "json",
    serializer,
};
const deleteOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/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.serverName,
        Parameters.databaseName,
        Parameters.schemaName,
        Parameters.tableName,
        Parameters.columnName,
        Parameters.sensitivityLabelSource1,
    ],
    serializer,
};
const listCurrentByDatabaseNextOperationSpec = {
    path: "{nextLink}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.SensitivityLabelListResult,
        },
        default: {},
    },
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.serverName,
        Parameters.databaseName,
        Parameters.nextLink,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const listRecommendedByDatabaseNextOperationSpec = {
    path: "{nextLink}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.SensitivityLabelListResult,
        },
        default: {},
    },
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.serverName,
        Parameters.databaseName,
        Parameters.nextLink,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
//# sourceMappingURL=sensitivityLabels.js.map