// 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 SqlVulnerabilityAssessmentRuleBaseline operations. */
export class SqlVulnerabilityAssessmentRuleBaselineImpl {
    client;
    /**
     * Initialize a new instance of the class SqlVulnerabilityAssessmentRuleBaseline class.
     * @param client Reference to the service client
     */
    constructor(client) {
        this.client = client;
    }
    /**
     * Gets a system database's sql vulnerability assessment rule baseline.
     * @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 vulnerabilityAssessmentName The name of the vulnerability assessment.
     * @param baselineName
     * @param options The options parameters.
     */
    listByBaseline(resourceGroupName, serverName, vulnerabilityAssessmentName, baselineName, options) {
        const iter = this.listByBaselinePagingAll(resourceGroupName, serverName, vulnerabilityAssessmentName, baselineName, 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.listByBaselinePagingPage(resourceGroupName, serverName, vulnerabilityAssessmentName, baselineName, options, settings);
            },
        };
    }
    async *listByBaselinePagingPage(resourceGroupName, serverName, vulnerabilityAssessmentName, baselineName, options, settings) {
        let result;
        let continuationToken = settings?.continuationToken;
        if (!continuationToken) {
            result = await this._listByBaseline(resourceGroupName, serverName, vulnerabilityAssessmentName, baselineName, options);
            let page = result.value || [];
            continuationToken = result.nextLink;
            setContinuationToken(page, continuationToken);
            yield page;
        }
        while (continuationToken) {
            result = await this._listByBaselineNext(resourceGroupName, serverName, vulnerabilityAssessmentName, baselineName, continuationToken, options);
            continuationToken = result.nextLink;
            let page = result.value || [];
            setContinuationToken(page, continuationToken);
            yield page;
        }
    }
    async *listByBaselinePagingAll(resourceGroupName, serverName, vulnerabilityAssessmentName, baselineName, options) {
        for await (const page of this.listByBaselinePagingPage(resourceGroupName, serverName, vulnerabilityAssessmentName, baselineName, options)) {
            yield* page;
        }
    }
    /**
     * Gets a system database's sql vulnerability assessment rule baseline.
     * @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 vulnerabilityAssessmentName The name of the vulnerability assessment.
     * @param baselineName
     * @param options The options parameters.
     */
    _listByBaseline(resourceGroupName, serverName, vulnerabilityAssessmentName, baselineName, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            serverName,
            vulnerabilityAssessmentName,
            baselineName,
            options,
        }, listByBaselineOperationSpec);
    }
    /**
     * Gets a system database's sql vulnerability assessment rule baseline.
     * @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 vulnerabilityAssessmentName The name of the vulnerability assessment.
     * @param baselineName
     * @param ruleId The vulnerability assessment rule ID.
     * @param options The options parameters.
     */
    get(resourceGroupName, serverName, vulnerabilityAssessmentName, baselineName, ruleId, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            serverName,
            vulnerabilityAssessmentName,
            baselineName,
            ruleId,
            options,
        }, getOperationSpec);
    }
    /**
     * Creates or updates a database's vulnerability assessment rule baseline.
     * @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 vulnerabilityAssessmentName The name of the vulnerability assessment.
     * @param baselineName
     * @param ruleId The vulnerability assessment rule ID.
     * @param parameters The requested rule baseline resource.
     * @param options The options parameters.
     */
    createOrUpdate(resourceGroupName, serverName, vulnerabilityAssessmentName, baselineName, ruleId, parameters, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            serverName,
            vulnerabilityAssessmentName,
            baselineName,
            ruleId,
            parameters,
            options,
        }, createOrUpdateOperationSpec);
    }
    /**
     * ListByBaselineNext
     * @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 vulnerabilityAssessmentName The name of the vulnerability assessment.
     * @param baselineName
     * @param nextLink The nextLink from the previous successful call to the ListByBaseline method.
     * @param options The options parameters.
     */
    _listByBaselineNext(resourceGroupName, serverName, vulnerabilityAssessmentName, baselineName, nextLink, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            serverName,
            vulnerabilityAssessmentName,
            baselineName,
            nextLink,
            options,
        }, listByBaselineNextOperationSpec);
    }
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const listByBaselineOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines/{baselineName}/rules",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.DatabaseSqlVulnerabilityAssessmentRuleBaselineListResult,
        },
        default: {},
    },
    queryParameters: [Parameters.apiVersion10, Parameters.systemDatabaseName],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.serverName,
        Parameters.vulnerabilityAssessmentName,
        Parameters.baselineName1,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const getOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines/{baselineName}/rules/{ruleId}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.DatabaseSqlVulnerabilityAssessmentRuleBaseline,
        },
        default: {},
    },
    queryParameters: [Parameters.apiVersion10, Parameters.systemDatabaseName],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.serverName,
        Parameters.vulnerabilityAssessmentName,
        Parameters.ruleId,
        Parameters.baselineName1,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const createOrUpdateOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/baselines/{baselineName}/rules/{ruleId}",
    httpMethod: "PUT",
    responses: {
        200: {
            bodyMapper: Mappers.DatabaseSqlVulnerabilityAssessmentRuleBaseline,
        },
        default: {},
    },
    requestBody: Parameters.parameters91,
    queryParameters: [Parameters.apiVersion10, Parameters.systemDatabaseName],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.serverName,
        Parameters.vulnerabilityAssessmentName,
        Parameters.ruleId,
        Parameters.baselineName1,
    ],
    headerParameters: [Parameters.contentType, Parameters.accept],
    mediaType: "json",
    serializer,
};
const listByBaselineNextOperationSpec = {
    path: "{nextLink}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.DatabaseSqlVulnerabilityAssessmentRuleBaselineListResult,
        },
        default: {},
    },
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.serverName,
        Parameters.nextLink,
        Parameters.vulnerabilityAssessmentName,
        Parameters.baselineName1,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
//# sourceMappingURL=sqlVulnerabilityAssessmentRuleBaseline.js.map