// 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 DatabaseSqlVulnerabilityAssessmentScanResult operations. */
export class DatabaseSqlVulnerabilityAssessmentScanResultImpl {
    client;
    /**
     * Initialize a new instance of the class DatabaseSqlVulnerabilityAssessmentScanResult class.
     * @param client Reference to the service client
     */
    constructor(client) {
        this.client = client;
    }
    /**
     * Gets a vulnerability assessment scan record of a 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 vulnerabilityAssessmentName The name of the SQL Vulnerability Assessment.
     * @param scanId The scan id of the SQL Vulnerability Assessment scan to retrieve result from.
     * @param options The options parameters.
     */
    listByScan(resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName, scanId, options) {
        const iter = this.listByScanPagingAll(resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName, scanId, 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.listByScanPagingPage(resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName, scanId, options, settings);
            },
        };
    }
    async *listByScanPagingPage(resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName, scanId, options, settings) {
        let result;
        let continuationToken = settings?.continuationToken;
        if (!continuationToken) {
            result = await this._listByScan(resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName, scanId, options);
            let page = result.value || [];
            continuationToken = result.nextLink;
            setContinuationToken(page, continuationToken);
            yield page;
        }
        while (continuationToken) {
            result = await this._listByScanNext(resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName, scanId, continuationToken, options);
            continuationToken = result.nextLink;
            let page = result.value || [];
            setContinuationToken(page, continuationToken);
            yield page;
        }
    }
    async *listByScanPagingAll(resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName, scanId, options) {
        for await (const page of this.listByScanPagingPage(resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName, scanId, options)) {
            yield* page;
        }
    }
    /**
     * Gets a vulnerability assessment scan record of a 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 vulnerabilityAssessmentName The name of the SQL Vulnerability Assessment.
     * @param scanId The scan id of the SQL Vulnerability Assessment scan to retrieve result from.
     * @param options The options parameters.
     */
    _listByScan(resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName, scanId, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            serverName,
            databaseName,
            vulnerabilityAssessmentName,
            scanId,
            options,
        }, listByScanOperationSpec);
    }
    /**
     * Gets a vulnerability assessment scan record of a 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 vulnerabilityAssessmentName The name of the SQL Vulnerability Assessment.
     * @param scanId The scan id of the SQL Vulnerability Assessment scan to retrieve result from.
     * @param scanResultId The scan result id of the specific result to retrieve.
     * @param options The options parameters.
     */
    get(resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName, scanId, scanResultId, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            serverName,
            databaseName,
            vulnerabilityAssessmentName,
            scanId,
            scanResultId,
            options,
        }, getOperationSpec);
    }
    /**
     * ListByScanNext
     * @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 vulnerabilityAssessmentName The name of the SQL Vulnerability Assessment.
     * @param scanId The scan id of the SQL Vulnerability Assessment scan to retrieve result from.
     * @param nextLink The nextLink from the previous successful call to the ListByScan method.
     * @param options The options parameters.
     */
    _listByScanNext(resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName, scanId, nextLink, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            serverName,
            databaseName,
            vulnerabilityAssessmentName,
            scanId,
            nextLink,
            options,
        }, listByScanNextOperationSpec);
    }
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const listByScanOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/scanResults",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.SQLVulnerabilityAssessmentScanListResult,
        },
        default: {},
    },
    queryParameters: [Parameters.apiVersion10],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.serverName,
        Parameters.databaseName,
        Parameters.scanId,
        Parameters.vulnerabilityAssessmentName1,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const getOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/scans/{scanId}/scanResults/{scanResultId}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.SqlVulnerabilityAssessmentScanResults,
        },
        default: {},
    },
    queryParameters: [Parameters.apiVersion10],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.serverName,
        Parameters.databaseName,
        Parameters.scanId,
        Parameters.vulnerabilityAssessmentName1,
        Parameters.scanResultId,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const listByScanNextOperationSpec = {
    path: "{nextLink}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.SQLVulnerabilityAssessmentScanListResult,
        },
        default: {},
    },
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.serverName,
        Parameters.databaseName,
        Parameters.nextLink,
        Parameters.scanId,
        Parameters.vulnerabilityAssessmentName1,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
//# sourceMappingURL=databaseSqlVulnerabilityAssessmentScanResult.js.map