/*
 * Copyright (c) Microsoft Corporation.
 * Licensed under the MIT License.
 *
 * Code generated by Microsoft (R) AutoRest Code Generator.
 * Changes may cause incorrect behavior and will be lost if the code is regenerated.
 */
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 InboundSecurityRuleOperations operations. */
export class InboundSecurityRuleOperationsImpl {
    client;
    /**
     * Initialize a new instance of the class InboundSecurityRuleOperations class.
     * @param client Reference to the service client
     */
    constructor(client) {
        this.client = client;
    }
    /**
     * Creates or updates the specified Network Virtual Appliance Inbound Security Rules.
     * @param resourceGroupName The name of the resource group.
     * @param networkVirtualApplianceName The name of the Network Virtual Appliance.
     * @param ruleCollectionName The name of security rule collection.
     * @param parameters Parameters supplied to the create or update Network Virtual Appliance Inbound
     *                   Security Rules operation.
     * @param options The options parameters.
     */
    async beginCreateOrUpdate(resourceGroupName, networkVirtualApplianceName, ruleCollectionName, parameters, 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,
                networkVirtualApplianceName,
                ruleCollectionName,
                parameters,
                options,
            },
            spec: createOrUpdateOperationSpec,
        });
        const poller = await createHttpPoller(lro, {
            restoreFrom: options?.resumeFrom,
            intervalInMs: options?.updateIntervalInMs,
            resourceLocationConfig: "azure-async-operation",
        });
        await poller.poll();
        return poller;
    }
    /**
     * Creates or updates the specified Network Virtual Appliance Inbound Security Rules.
     * @param resourceGroupName The name of the resource group.
     * @param networkVirtualApplianceName The name of the Network Virtual Appliance.
     * @param ruleCollectionName The name of security rule collection.
     * @param parameters Parameters supplied to the create or update Network Virtual Appliance Inbound
     *                   Security Rules operation.
     * @param options The options parameters.
     */
    async beginCreateOrUpdateAndWait(resourceGroupName, networkVirtualApplianceName, ruleCollectionName, parameters, options) {
        const poller = await this.beginCreateOrUpdate(resourceGroupName, networkVirtualApplianceName, ruleCollectionName, parameters, options);
        return poller.pollUntilDone();
    }
    /**
     * Retrieves the available specified Network Virtual Appliance Inbound Security Rules Collection.
     * @param resourceGroupName The name of the resource group.
     * @param networkVirtualApplianceName The name of the Network Virtual Appliance.
     * @param ruleCollectionName The name of security rule collection.
     * @param options The options parameters.
     */
    get(resourceGroupName, networkVirtualApplianceName, ruleCollectionName, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            networkVirtualApplianceName,
            ruleCollectionName,
            options,
        }, getOperationSpec);
    }
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const createOrUpdateOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkVirtualAppliances/{networkVirtualApplianceName}/inboundSecurityRules/{ruleCollectionName}",
    httpMethod: "PUT",
    responses: {
        200: {
            bodyMapper: Mappers.InboundSecurityRule,
        },
        201: {
            bodyMapper: Mappers.InboundSecurityRule,
        },
        202: {
            bodyMapper: Mappers.InboundSecurityRule,
        },
        204: {
            bodyMapper: Mappers.InboundSecurityRule,
        },
        default: {
            bodyMapper: Mappers.CloudError,
        },
    },
    requestBody: Parameters.parameters54,
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.ruleCollectionName1,
        Parameters.networkVirtualApplianceName,
    ],
    headerParameters: [Parameters.accept, Parameters.contentType],
    mediaType: "json",
    serializer,
};
const getOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkVirtualAppliances/{networkVirtualApplianceName}/inboundSecurityRules/{ruleCollectionName}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.InboundSecurityRule,
        },
        default: {
            bodyMapper: Mappers.CloudError,
        },
    },
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.ruleCollectionName1,
        Parameters.networkVirtualApplianceName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
//# sourceMappingURL=inboundSecurityRuleOperations.js.map