"use strict";
/*
 * 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.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.NetworkWatchersImpl = void 0;
const tslib_1 = require("tslib");
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"));
const core_lro_1 = require("@azure/core-lro");
const lroImpl_js_1 = require("../lroImpl.js");
/// <reference lib="esnext.asynciterable" />
/** Class containing NetworkWatchers operations. */
class NetworkWatchersImpl {
    client;
    /**
     * Initialize a new instance of the class NetworkWatchers class.
     * @param client Reference to the service client
     */
    constructor(client) {
        this.client = client;
    }
    /**
     * Gets all network watchers by resource group.
     * @param resourceGroupName The name of the resource group.
     * @param options The options parameters.
     */
    list(resourceGroupName, options) {
        const iter = this.listPagingAll(resourceGroupName, 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.listPagingPage(resourceGroupName, options, settings);
            },
        };
    }
    async *listPagingPage(resourceGroupName, options, _settings) {
        let result;
        result = await this._list(resourceGroupName, options);
        yield result.value || [];
    }
    async *listPagingAll(resourceGroupName, options) {
        for await (const page of this.listPagingPage(resourceGroupName, options)) {
            yield* page;
        }
    }
    /**
     * Gets all network watchers by subscription.
     * @param options The options parameters.
     */
    listAll(options) {
        const iter = this.listAllPagingAll(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.listAllPagingPage(options, settings);
            },
        };
    }
    async *listAllPagingPage(options, _settings) {
        let result;
        result = await this._listAll(options);
        yield result.value || [];
    }
    async *listAllPagingAll(options) {
        for await (const page of this.listAllPagingPage(options)) {
            yield* page;
        }
    }
    /**
     * Creates or updates a network watcher in the specified resource group.
     * @param resourceGroupName The name of the resource group.
     * @param networkWatcherName The name of the network watcher.
     * @param parameters Parameters that define the network watcher resource.
     * @param options The options parameters.
     */
    createOrUpdate(resourceGroupName, networkWatcherName, parameters, options) {
        return this.client.sendOperationRequest({ resourceGroupName, networkWatcherName, parameters, options }, createOrUpdateOperationSpec);
    }
    /**
     * Gets the specified network watcher by resource group.
     * @param resourceGroupName The name of the resource group.
     * @param networkWatcherName The name of the network watcher.
     * @param options The options parameters.
     */
    get(resourceGroupName, networkWatcherName, options) {
        return this.client.sendOperationRequest({ resourceGroupName, networkWatcherName, options }, getOperationSpec);
    }
    /**
     * Deletes the specified network watcher resource.
     * @param resourceGroupName The name of the resource group.
     * @param networkWatcherName The name of the network watcher.
     * @param options The options parameters.
     */
    async beginDelete(resourceGroupName, networkWatcherName, 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 = (0, lroImpl_js_1.createLroSpec)({
            sendOperationFn,
            args: { resourceGroupName, networkWatcherName, options },
            spec: deleteOperationSpec,
        });
        const poller = await (0, core_lro_1.createHttpPoller)(lro, {
            restoreFrom: options?.resumeFrom,
            intervalInMs: options?.updateIntervalInMs,
            resourceLocationConfig: "location",
        });
        await poller.poll();
        return poller;
    }
    /**
     * Deletes the specified network watcher resource.
     * @param resourceGroupName The name of the resource group.
     * @param networkWatcherName The name of the network watcher.
     * @param options The options parameters.
     */
    async beginDeleteAndWait(resourceGroupName, networkWatcherName, options) {
        const poller = await this.beginDelete(resourceGroupName, networkWatcherName, options);
        return poller.pollUntilDone();
    }
    /**
     * Updates a network watcher tags.
     * @param resourceGroupName The name of the resource group.
     * @param networkWatcherName The name of the network watcher.
     * @param parameters Parameters supplied to update network watcher tags.
     * @param options The options parameters.
     */
    updateTags(resourceGroupName, networkWatcherName, parameters, options) {
        return this.client.sendOperationRequest({ resourceGroupName, networkWatcherName, parameters, options }, updateTagsOperationSpec);
    }
    /**
     * Gets all network watchers by resource group.
     * @param resourceGroupName The name of the resource group.
     * @param options The options parameters.
     */
    _list(resourceGroupName, options) {
        return this.client.sendOperationRequest({ resourceGroupName, options }, listOperationSpec);
    }
    /**
     * Gets all network watchers by subscription.
     * @param options The options parameters.
     */
    _listAll(options) {
        return this.client.sendOperationRequest({ options }, listAllOperationSpec);
    }
    /**
     * Gets the current network topology by resource group.
     * @param resourceGroupName The name of the resource group.
     * @param networkWatcherName The name of the network watcher.
     * @param parameters Parameters that define the representation of topology.
     * @param options The options parameters.
     */
    getTopology(resourceGroupName, networkWatcherName, parameters, options) {
        return this.client.sendOperationRequest({ resourceGroupName, networkWatcherName, parameters, options }, getTopologyOperationSpec);
    }
    /**
     * Verify IP flow from the specified VM to a location given the currently configured NSG rules.
     * @param resourceGroupName The name of the resource group.
     * @param networkWatcherName The name of the network watcher.
     * @param parameters Parameters that define the IP flow to be verified.
     * @param options The options parameters.
     */
    async beginVerifyIPFlow(resourceGroupName, networkWatcherName, 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 = (0, lroImpl_js_1.createLroSpec)({
            sendOperationFn,
            args: { resourceGroupName, networkWatcherName, parameters, options },
            spec: verifyIPFlowOperationSpec,
        });
        const poller = await (0, core_lro_1.createHttpPoller)(lro, {
            restoreFrom: options?.resumeFrom,
            intervalInMs: options?.updateIntervalInMs,
            resourceLocationConfig: "location",
        });
        await poller.poll();
        return poller;
    }
    /**
     * Verify IP flow from the specified VM to a location given the currently configured NSG rules.
     * @param resourceGroupName The name of the resource group.
     * @param networkWatcherName The name of the network watcher.
     * @param parameters Parameters that define the IP flow to be verified.
     * @param options The options parameters.
     */
    async beginVerifyIPFlowAndWait(resourceGroupName, networkWatcherName, parameters, options) {
        const poller = await this.beginVerifyIPFlow(resourceGroupName, networkWatcherName, parameters, options);
        return poller.pollUntilDone();
    }
    /**
     * Gets the next hop from the specified VM.
     * @param resourceGroupName The name of the resource group.
     * @param networkWatcherName The name of the network watcher.
     * @param parameters Parameters that define the source and destination endpoint.
     * @param options The options parameters.
     */
    async beginGetNextHop(resourceGroupName, networkWatcherName, 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 = (0, lroImpl_js_1.createLroSpec)({
            sendOperationFn,
            args: { resourceGroupName, networkWatcherName, parameters, options },
            spec: getNextHopOperationSpec,
        });
        const poller = await (0, core_lro_1.createHttpPoller)(lro, {
            restoreFrom: options?.resumeFrom,
            intervalInMs: options?.updateIntervalInMs,
            resourceLocationConfig: "location",
        });
        await poller.poll();
        return poller;
    }
    /**
     * Gets the next hop from the specified VM.
     * @param resourceGroupName The name of the resource group.
     * @param networkWatcherName The name of the network watcher.
     * @param parameters Parameters that define the source and destination endpoint.
     * @param options The options parameters.
     */
    async beginGetNextHopAndWait(resourceGroupName, networkWatcherName, parameters, options) {
        const poller = await this.beginGetNextHop(resourceGroupName, networkWatcherName, parameters, options);
        return poller.pollUntilDone();
    }
    /**
     * Gets the configured and effective security group rules on the specified VM.
     * @param resourceGroupName The name of the resource group.
     * @param networkWatcherName The name of the network watcher.
     * @param parameters Parameters that define the VM to check security groups for.
     * @param options The options parameters.
     */
    async beginGetVMSecurityRules(resourceGroupName, networkWatcherName, 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 = (0, lroImpl_js_1.createLroSpec)({
            sendOperationFn,
            args: { resourceGroupName, networkWatcherName, parameters, options },
            spec: getVMSecurityRulesOperationSpec,
        });
        const poller = await (0, core_lro_1.createHttpPoller)(lro, {
            restoreFrom: options?.resumeFrom,
            intervalInMs: options?.updateIntervalInMs,
            resourceLocationConfig: "location",
        });
        await poller.poll();
        return poller;
    }
    /**
     * Gets the configured and effective security group rules on the specified VM.
     * @param resourceGroupName The name of the resource group.
     * @param networkWatcherName The name of the network watcher.
     * @param parameters Parameters that define the VM to check security groups for.
     * @param options The options parameters.
     */
    async beginGetVMSecurityRulesAndWait(resourceGroupName, networkWatcherName, parameters, options) {
        const poller = await this.beginGetVMSecurityRules(resourceGroupName, networkWatcherName, parameters, options);
        return poller.pollUntilDone();
    }
    /**
     * Initiate troubleshooting on a specified resource.
     * @param resourceGroupName The name of the resource group.
     * @param networkWatcherName The name of the network watcher resource.
     * @param parameters Parameters that define the resource to troubleshoot.
     * @param options The options parameters.
     */
    async beginGetTroubleshooting(resourceGroupName, networkWatcherName, 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 = (0, lroImpl_js_1.createLroSpec)({
            sendOperationFn,
            args: { resourceGroupName, networkWatcherName, parameters, options },
            spec: getTroubleshootingOperationSpec,
        });
        const poller = await (0, core_lro_1.createHttpPoller)(lro, {
            restoreFrom: options?.resumeFrom,
            intervalInMs: options?.updateIntervalInMs,
            resourceLocationConfig: "location",
        });
        await poller.poll();
        return poller;
    }
    /**
     * Initiate troubleshooting on a specified resource.
     * @param resourceGroupName The name of the resource group.
     * @param networkWatcherName The name of the network watcher resource.
     * @param parameters Parameters that define the resource to troubleshoot.
     * @param options The options parameters.
     */
    async beginGetTroubleshootingAndWait(resourceGroupName, networkWatcherName, parameters, options) {
        const poller = await this.beginGetTroubleshooting(resourceGroupName, networkWatcherName, parameters, options);
        return poller.pollUntilDone();
    }
    /**
     * Get the last completed troubleshooting result on a specified resource.
     * @param resourceGroupName The name of the resource group.
     * @param networkWatcherName The name of the network watcher resource.
     * @param parameters Parameters that define the resource to query the troubleshooting result.
     * @param options The options parameters.
     */
    async beginGetTroubleshootingResult(resourceGroupName, networkWatcherName, 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 = (0, lroImpl_js_1.createLroSpec)({
            sendOperationFn,
            args: { resourceGroupName, networkWatcherName, parameters, options },
            spec: getTroubleshootingResultOperationSpec,
        });
        const poller = await (0, core_lro_1.createHttpPoller)(lro, {
            restoreFrom: options?.resumeFrom,
            intervalInMs: options?.updateIntervalInMs,
            resourceLocationConfig: "location",
        });
        await poller.poll();
        return poller;
    }
    /**
     * Get the last completed troubleshooting result on a specified resource.
     * @param resourceGroupName The name of the resource group.
     * @param networkWatcherName The name of the network watcher resource.
     * @param parameters Parameters that define the resource to query the troubleshooting result.
     * @param options The options parameters.
     */
    async beginGetTroubleshootingResultAndWait(resourceGroupName, networkWatcherName, parameters, options) {
        const poller = await this.beginGetTroubleshootingResult(resourceGroupName, networkWatcherName, parameters, options);
        return poller.pollUntilDone();
    }
    /**
     * Configures flow log and traffic analytics (optional) on a specified resource.
     * @param resourceGroupName The name of the network watcher resource group.
     * @param networkWatcherName The name of the network watcher resource.
     * @param parameters Parameters that define the configuration of flow log.
     * @param options The options parameters.
     */
    async beginSetFlowLogConfiguration(resourceGroupName, networkWatcherName, 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 = (0, lroImpl_js_1.createLroSpec)({
            sendOperationFn,
            args: { resourceGroupName, networkWatcherName, parameters, options },
            spec: setFlowLogConfigurationOperationSpec,
        });
        const poller = await (0, core_lro_1.createHttpPoller)(lro, {
            restoreFrom: options?.resumeFrom,
            intervalInMs: options?.updateIntervalInMs,
            resourceLocationConfig: "location",
        });
        await poller.poll();
        return poller;
    }
    /**
     * Configures flow log and traffic analytics (optional) on a specified resource.
     * @param resourceGroupName The name of the network watcher resource group.
     * @param networkWatcherName The name of the network watcher resource.
     * @param parameters Parameters that define the configuration of flow log.
     * @param options The options parameters.
     */
    async beginSetFlowLogConfigurationAndWait(resourceGroupName, networkWatcherName, parameters, options) {
        const poller = await this.beginSetFlowLogConfiguration(resourceGroupName, networkWatcherName, parameters, options);
        return poller.pollUntilDone();
    }
    /**
     * Queries status of flow log and traffic analytics (optional) on a specified resource.
     * @param resourceGroupName The name of the network watcher resource group.
     * @param networkWatcherName The name of the network watcher resource.
     * @param parameters Parameters that define a resource to query flow log and traffic analytics
     *                   (optional) status.
     * @param options The options parameters.
     */
    async beginGetFlowLogStatus(resourceGroupName, networkWatcherName, 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 = (0, lroImpl_js_1.createLroSpec)({
            sendOperationFn,
            args: { resourceGroupName, networkWatcherName, parameters, options },
            spec: getFlowLogStatusOperationSpec,
        });
        const poller = await (0, core_lro_1.createHttpPoller)(lro, {
            restoreFrom: options?.resumeFrom,
            intervalInMs: options?.updateIntervalInMs,
            resourceLocationConfig: "location",
        });
        await poller.poll();
        return poller;
    }
    /**
     * Queries status of flow log and traffic analytics (optional) on a specified resource.
     * @param resourceGroupName The name of the network watcher resource group.
     * @param networkWatcherName The name of the network watcher resource.
     * @param parameters Parameters that define a resource to query flow log and traffic analytics
     *                   (optional) status.
     * @param options The options parameters.
     */
    async beginGetFlowLogStatusAndWait(resourceGroupName, networkWatcherName, parameters, options) {
        const poller = await this.beginGetFlowLogStatus(resourceGroupName, networkWatcherName, parameters, options);
        return poller.pollUntilDone();
    }
    /**
     * Verifies the possibility of establishing a direct TCP connection from a virtual machine to a given
     * endpoint including another VM or an arbitrary remote server.
     * @param resourceGroupName The name of the network watcher resource group.
     * @param networkWatcherName The name of the network watcher resource.
     * @param parameters Parameters that determine how the connectivity check will be performed.
     * @param options The options parameters.
     */
    async beginCheckConnectivity(resourceGroupName, networkWatcherName, 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 = (0, lroImpl_js_1.createLroSpec)({
            sendOperationFn,
            args: { resourceGroupName, networkWatcherName, parameters, options },
            spec: checkConnectivityOperationSpec,
        });
        const poller = await (0, core_lro_1.createHttpPoller)(lro, {
            restoreFrom: options?.resumeFrom,
            intervalInMs: options?.updateIntervalInMs,
            resourceLocationConfig: "location",
        });
        await poller.poll();
        return poller;
    }
    /**
     * Verifies the possibility of establishing a direct TCP connection from a virtual machine to a given
     * endpoint including another VM or an arbitrary remote server.
     * @param resourceGroupName The name of the network watcher resource group.
     * @param networkWatcherName The name of the network watcher resource.
     * @param parameters Parameters that determine how the connectivity check will be performed.
     * @param options The options parameters.
     */
    async beginCheckConnectivityAndWait(resourceGroupName, networkWatcherName, parameters, options) {
        const poller = await this.beginCheckConnectivity(resourceGroupName, networkWatcherName, parameters, options);
        return poller.pollUntilDone();
    }
    /**
     * NOTE: This feature is currently in preview and still being tested for stability. Gets the relative
     * latency score for internet service providers from a specified location to Azure regions.
     * @param resourceGroupName The name of the network watcher resource group.
     * @param networkWatcherName The name of the network watcher resource.
     * @param parameters Parameters that determine Azure reachability report configuration.
     * @param options The options parameters.
     */
    async beginGetAzureReachabilityReport(resourceGroupName, networkWatcherName, 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 = (0, lroImpl_js_1.createLroSpec)({
            sendOperationFn,
            args: { resourceGroupName, networkWatcherName, parameters, options },
            spec: getAzureReachabilityReportOperationSpec,
        });
        const poller = await (0, core_lro_1.createHttpPoller)(lro, {
            restoreFrom: options?.resumeFrom,
            intervalInMs: options?.updateIntervalInMs,
            resourceLocationConfig: "location",
        });
        await poller.poll();
        return poller;
    }
    /**
     * NOTE: This feature is currently in preview and still being tested for stability. Gets the relative
     * latency score for internet service providers from a specified location to Azure regions.
     * @param resourceGroupName The name of the network watcher resource group.
     * @param networkWatcherName The name of the network watcher resource.
     * @param parameters Parameters that determine Azure reachability report configuration.
     * @param options The options parameters.
     */
    async beginGetAzureReachabilityReportAndWait(resourceGroupName, networkWatcherName, parameters, options) {
        const poller = await this.beginGetAzureReachabilityReport(resourceGroupName, networkWatcherName, parameters, options);
        return poller.pollUntilDone();
    }
    /**
     * NOTE: This feature is currently in preview and still being tested for stability. Lists all available
     * internet service providers for a specified Azure region.
     * @param resourceGroupName The name of the network watcher resource group.
     * @param networkWatcherName The name of the network watcher resource.
     * @param parameters Parameters that scope the list of available providers.
     * @param options The options parameters.
     */
    async beginListAvailableProviders(resourceGroupName, networkWatcherName, 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 = (0, lroImpl_js_1.createLroSpec)({
            sendOperationFn,
            args: { resourceGroupName, networkWatcherName, parameters, options },
            spec: listAvailableProvidersOperationSpec,
        });
        const poller = await (0, core_lro_1.createHttpPoller)(lro, {
            restoreFrom: options?.resumeFrom,
            intervalInMs: options?.updateIntervalInMs,
            resourceLocationConfig: "location",
        });
        await poller.poll();
        return poller;
    }
    /**
     * NOTE: This feature is currently in preview and still being tested for stability. Lists all available
     * internet service providers for a specified Azure region.
     * @param resourceGroupName The name of the network watcher resource group.
     * @param networkWatcherName The name of the network watcher resource.
     * @param parameters Parameters that scope the list of available providers.
     * @param options The options parameters.
     */
    async beginListAvailableProvidersAndWait(resourceGroupName, networkWatcherName, parameters, options) {
        const poller = await this.beginListAvailableProviders(resourceGroupName, networkWatcherName, parameters, options);
        return poller.pollUntilDone();
    }
    /**
     * Gets Network Configuration Diagnostic data to help customers understand and debug network behavior.
     * It provides detailed information on what security rules were applied to a specified traffic flow and
     * the result of evaluating these rules. Customers must provide details of a flow like source,
     * destination, protocol, etc. The API returns whether traffic was allowed or denied, the rules
     * evaluated for the specified flow and the evaluation results.
     * @param resourceGroupName The name of the resource group.
     * @param networkWatcherName The name of the network watcher.
     * @param parameters Parameters to get network configuration diagnostic.
     * @param options The options parameters.
     */
    async beginGetNetworkConfigurationDiagnostic(resourceGroupName, networkWatcherName, 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 = (0, lroImpl_js_1.createLroSpec)({
            sendOperationFn,
            args: { resourceGroupName, networkWatcherName, parameters, options },
            spec: getNetworkConfigurationDiagnosticOperationSpec,
        });
        const poller = await (0, core_lro_1.createHttpPoller)(lro, {
            restoreFrom: options?.resumeFrom,
            intervalInMs: options?.updateIntervalInMs,
            resourceLocationConfig: "location",
        });
        await poller.poll();
        return poller;
    }
    /**
     * Gets Network Configuration Diagnostic data to help customers understand and debug network behavior.
     * It provides detailed information on what security rules were applied to a specified traffic flow and
     * the result of evaluating these rules. Customers must provide details of a flow like source,
     * destination, protocol, etc. The API returns whether traffic was allowed or denied, the rules
     * evaluated for the specified flow and the evaluation results.
     * @param resourceGroupName The name of the resource group.
     * @param networkWatcherName The name of the network watcher.
     * @param parameters Parameters to get network configuration diagnostic.
     * @param options The options parameters.
     */
    async beginGetNetworkConfigurationDiagnosticAndWait(resourceGroupName, networkWatcherName, parameters, options) {
        const poller = await this.beginGetNetworkConfigurationDiagnostic(resourceGroupName, networkWatcherName, parameters, options);
        return poller.pollUntilDone();
    }
}
exports.NetworkWatchersImpl = NetworkWatchersImpl;
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const createOrUpdateOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}",
    httpMethod: "PUT",
    responses: {
        200: {
            bodyMapper: Mappers.NetworkWatcher,
        },
        201: {
            bodyMapper: Mappers.NetworkWatcher,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    requestBody: Parameters.parameters55,
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.networkWatcherName,
    ],
    headerParameters: [Parameters.accept, Parameters.contentType],
    mediaType: "json",
    serializer,
};
const getOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.NetworkWatcher,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.networkWatcherName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const deleteOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}",
    httpMethod: "DELETE",
    responses: {
        200: {},
        201: {},
        202: {},
        204: {},
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.networkWatcherName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const updateTagsOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}",
    httpMethod: "PATCH",
    responses: {
        200: {
            bodyMapper: Mappers.NetworkWatcher,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    requestBody: Parameters.parameters1,
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.networkWatcherName,
    ],
    headerParameters: [Parameters.accept, Parameters.contentType],
    mediaType: "json",
    serializer,
};
const listOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.NetworkWatcherListResult,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const listAllOperationSpec = {
    path: "/subscriptions/{subscriptionId}/providers/Microsoft.Network/networkWatchers",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.NetworkWatcherListResult,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    queryParameters: [Parameters.apiVersion],
    urlParameters: [Parameters.$host, Parameters.subscriptionId],
    headerParameters: [Parameters.accept],
    serializer,
};
const getTopologyOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/topology",
    httpMethod: "POST",
    responses: {
        200: {
            bodyMapper: Mappers.Topology,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    requestBody: Parameters.parameters56,
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.networkWatcherName,
    ],
    headerParameters: [Parameters.accept, Parameters.contentType],
    mediaType: "json",
    serializer,
};
const verifyIPFlowOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/ipFlowVerify",
    httpMethod: "POST",
    responses: {
        200: {
            bodyMapper: Mappers.VerificationIPFlowResult,
        },
        201: {
            bodyMapper: Mappers.VerificationIPFlowResult,
        },
        202: {
            bodyMapper: Mappers.VerificationIPFlowResult,
        },
        204: {
            bodyMapper: Mappers.VerificationIPFlowResult,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    requestBody: Parameters.parameters57,
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.networkWatcherName,
    ],
    headerParameters: [Parameters.accept, Parameters.contentType],
    mediaType: "json",
    serializer,
};
const getNextHopOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/nextHop",
    httpMethod: "POST",
    responses: {
        200: {
            bodyMapper: Mappers.NextHopResult,
        },
        201: {
            bodyMapper: Mappers.NextHopResult,
        },
        202: {
            bodyMapper: Mappers.NextHopResult,
        },
        204: {
            bodyMapper: Mappers.NextHopResult,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    requestBody: Parameters.parameters58,
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.networkWatcherName,
    ],
    headerParameters: [Parameters.accept, Parameters.contentType],
    mediaType: "json",
    serializer,
};
const getVMSecurityRulesOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/securityGroupView",
    httpMethod: "POST",
    responses: {
        200: {
            bodyMapper: Mappers.SecurityGroupViewResult,
        },
        201: {
            bodyMapper: Mappers.SecurityGroupViewResult,
        },
        202: {
            bodyMapper: Mappers.SecurityGroupViewResult,
        },
        204: {
            bodyMapper: Mappers.SecurityGroupViewResult,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    requestBody: Parameters.parameters59,
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.networkWatcherName,
    ],
    headerParameters: [Parameters.accept, Parameters.contentType],
    mediaType: "json",
    serializer,
};
const getTroubleshootingOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/troubleshoot",
    httpMethod: "POST",
    responses: {
        200: {
            bodyMapper: Mappers.TroubleshootingResult,
        },
        201: {
            bodyMapper: Mappers.TroubleshootingResult,
        },
        202: {
            bodyMapper: Mappers.TroubleshootingResult,
        },
        204: {
            bodyMapper: Mappers.TroubleshootingResult,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    requestBody: Parameters.parameters60,
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.networkWatcherName,
    ],
    headerParameters: [Parameters.accept, Parameters.contentType],
    mediaType: "json",
    serializer,
};
const getTroubleshootingResultOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/queryTroubleshootResult",
    httpMethod: "POST",
    responses: {
        200: {
            bodyMapper: Mappers.TroubleshootingResult,
        },
        201: {
            bodyMapper: Mappers.TroubleshootingResult,
        },
        202: {
            bodyMapper: Mappers.TroubleshootingResult,
        },
        204: {
            bodyMapper: Mappers.TroubleshootingResult,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    requestBody: Parameters.parameters61,
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.networkWatcherName,
    ],
    headerParameters: [Parameters.accept, Parameters.contentType],
    mediaType: "json",
    serializer,
};
const setFlowLogConfigurationOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/configureFlowLog",
    httpMethod: "POST",
    responses: {
        200: {
            bodyMapper: Mappers.FlowLogInformation,
        },
        201: {
            bodyMapper: Mappers.FlowLogInformation,
        },
        202: {
            bodyMapper: Mappers.FlowLogInformation,
        },
        204: {
            bodyMapper: Mappers.FlowLogInformation,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    requestBody: Parameters.parameters62,
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.networkWatcherName,
    ],
    headerParameters: [Parameters.accept, Parameters.contentType],
    mediaType: "json",
    serializer,
};
const getFlowLogStatusOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/queryFlowLogStatus",
    httpMethod: "POST",
    responses: {
        200: {
            bodyMapper: Mappers.FlowLogInformation,
        },
        201: {
            bodyMapper: Mappers.FlowLogInformation,
        },
        202: {
            bodyMapper: Mappers.FlowLogInformation,
        },
        204: {
            bodyMapper: Mappers.FlowLogInformation,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    requestBody: Parameters.parameters63,
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.networkWatcherName,
    ],
    headerParameters: [Parameters.accept, Parameters.contentType],
    mediaType: "json",
    serializer,
};
const checkConnectivityOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/connectivityCheck",
    httpMethod: "POST",
    responses: {
        200: {
            bodyMapper: Mappers.ConnectivityInformation,
        },
        201: {
            bodyMapper: Mappers.ConnectivityInformation,
        },
        202: {
            bodyMapper: Mappers.ConnectivityInformation,
        },
        204: {
            bodyMapper: Mappers.ConnectivityInformation,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    requestBody: Parameters.parameters64,
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.networkWatcherName,
    ],
    headerParameters: [Parameters.accept, Parameters.contentType],
    mediaType: "json",
    serializer,
};
const getAzureReachabilityReportOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/azureReachabilityReport",
    httpMethod: "POST",
    responses: {
        200: {
            bodyMapper: Mappers.AzureReachabilityReport,
        },
        201: {
            bodyMapper: Mappers.AzureReachabilityReport,
        },
        202: {
            bodyMapper: Mappers.AzureReachabilityReport,
        },
        204: {
            bodyMapper: Mappers.AzureReachabilityReport,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    requestBody: Parameters.parameters65,
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.networkWatcherName,
    ],
    headerParameters: [Parameters.accept, Parameters.contentType],
    mediaType: "json",
    serializer,
};
const listAvailableProvidersOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/availableProvidersList",
    httpMethod: "POST",
    responses: {
        200: {
            bodyMapper: Mappers.AvailableProvidersList,
        },
        201: {
            bodyMapper: Mappers.AvailableProvidersList,
        },
        202: {
            bodyMapper: Mappers.AvailableProvidersList,
        },
        204: {
            bodyMapper: Mappers.AvailableProvidersList,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    requestBody: Parameters.parameters66,
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.networkWatcherName,
    ],
    headerParameters: [Parameters.accept, Parameters.contentType],
    mediaType: "json",
    serializer,
};
const getNetworkConfigurationDiagnosticOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/networkConfigurationDiagnostic",
    httpMethod: "POST",
    responses: {
        200: {
            bodyMapper: Mappers.NetworkConfigurationDiagnosticResponse,
        },
        201: {
            bodyMapper: Mappers.NetworkConfigurationDiagnosticResponse,
        },
        202: {
            bodyMapper: Mappers.NetworkConfigurationDiagnosticResponse,
        },
        204: {
            bodyMapper: Mappers.NetworkConfigurationDiagnosticResponse,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    requestBody: Parameters.parameters67,
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.networkWatcherName,
    ],
    headerParameters: [Parameters.accept, Parameters.contentType],
    mediaType: "json",
    serializer,
};
//# sourceMappingURL=networkWatchers.js.map