// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers.js";
import * as Parameters from "../models/parameters.js";
import { createHttpPoller } from "@azure/core-lro";
import { createLroSpec } from "../lroImpl.js";
/** Class containing SqlVulnerabilityAssessmentExecuteScan operations. */
export class SqlVulnerabilityAssessmentExecuteScanImpl {
    client;
    /**
     * Initialize a new instance of the class SqlVulnerabilityAssessmentExecuteScan class.
     * @param client Reference to the service client
     */
    constructor(client) {
        this.client = client;
    }
    /**
     * Executes a Vulnerability Assessment database scan.
     * @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 options The options parameters.
     */
    async beginExecute(resourceGroupName, serverName, vulnerabilityAssessmentName, options) {
        const directSendOperation = async (args, spec) => {
            return this.client.sendOperationRequest(args, spec);
        };
        const sendOperationFn = async (args, spec) => {
            let currentRawResponse = undefined;
            const providedCallback = args.options?.onResponse;
            const callback = (rawResponse, flatResponse) => {
                currentRawResponse = rawResponse;
                providedCallback?.(rawResponse, flatResponse);
            };
            const updatedArgs = {
                ...args,
                options: {
                    ...args.options,
                    onResponse: callback,
                },
            };
            const flatResponse = await directSendOperation(updatedArgs, spec);
            return {
                flatResponse,
                rawResponse: {
                    statusCode: currentRawResponse.status,
                    body: currentRawResponse.parsedBody,
                    headers: currentRawResponse.headers.toJSON(),
                },
            };
        };
        const lro = createLroSpec({
            sendOperationFn,
            args: {
                resourceGroupName,
                serverName,
                vulnerabilityAssessmentName,
                options,
            },
            spec: executeOperationSpec,
        });
        const poller = await createHttpPoller(lro, {
            restoreFrom: options?.resumeFrom,
            intervalInMs: options?.updateIntervalInMs,
        });
        await poller.poll();
        return poller;
    }
    /**
     * Executes a Vulnerability Assessment database scan.
     * @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 options The options parameters.
     */
    async beginExecuteAndWait(resourceGroupName, serverName, vulnerabilityAssessmentName, options) {
        const poller = await this.beginExecute(resourceGroupName, serverName, vulnerabilityAssessmentName, options);
        return poller.pollUntilDone();
    }
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const executeOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/sqlVulnerabilityAssessments/{vulnerabilityAssessmentName}/initiateScan",
    httpMethod: "POST",
    responses: { 200: {}, 201: {}, 202: {}, 204: {}, default: {} },
    queryParameters: [Parameters.apiVersion10, Parameters.systemDatabaseName],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.serverName,
        Parameters.vulnerabilityAssessmentName,
    ],
    serializer,
};
//# sourceMappingURL=sqlVulnerabilityAssessmentExecuteScan.js.map