/*
 * 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 { 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 VpnSiteLinks operations. */
export class VpnSiteLinksImpl {
    client;
    /**
     * Initialize a new instance of the class VpnSiteLinks class.
     * @param client Reference to the service client
     */
    constructor(client) {
        this.client = client;
    }
    /**
     * Lists all the vpnSiteLinks in a resource group for a vpn site.
     * @param resourceGroupName The resource group name of the VpnSite.
     * @param vpnSiteName The name of the VpnSite.
     * @param options The options parameters.
     */
    listByVpnSite(resourceGroupName, vpnSiteName, options) {
        const iter = this.listByVpnSitePagingAll(resourceGroupName, vpnSiteName, 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.listByVpnSitePagingPage(resourceGroupName, vpnSiteName, options, settings);
            },
        };
    }
    async *listByVpnSitePagingPage(resourceGroupName, vpnSiteName, options, settings) {
        let result;
        let continuationToken = settings?.continuationToken;
        if (!continuationToken) {
            result = await this._listByVpnSite(resourceGroupName, vpnSiteName, options);
            let page = result.value || [];
            continuationToken = result.nextLink;
            setContinuationToken(page, continuationToken);
            yield page;
        }
        while (continuationToken) {
            result = await this._listByVpnSiteNext(resourceGroupName, vpnSiteName, continuationToken, options);
            continuationToken = result.nextLink;
            let page = result.value || [];
            setContinuationToken(page, continuationToken);
            yield page;
        }
    }
    async *listByVpnSitePagingAll(resourceGroupName, vpnSiteName, options) {
        for await (const page of this.listByVpnSitePagingPage(resourceGroupName, vpnSiteName, options)) {
            yield* page;
        }
    }
    /**
     * Retrieves the details of a VPN site link.
     * @param resourceGroupName The resource group name of the VpnSite.
     * @param vpnSiteName The name of the VpnSite.
     * @param vpnSiteLinkName The name of the VpnSiteLink being retrieved.
     * @param options The options parameters.
     */
    get(resourceGroupName, vpnSiteName, vpnSiteLinkName, options) {
        return this.client.sendOperationRequest({ resourceGroupName, vpnSiteName, vpnSiteLinkName, options }, getOperationSpec);
    }
    /**
     * Lists all the vpnSiteLinks in a resource group for a vpn site.
     * @param resourceGroupName The resource group name of the VpnSite.
     * @param vpnSiteName The name of the VpnSite.
     * @param options The options parameters.
     */
    _listByVpnSite(resourceGroupName, vpnSiteName, options) {
        return this.client.sendOperationRequest({ resourceGroupName, vpnSiteName, options }, listByVpnSiteOperationSpec);
    }
    /**
     * ListByVpnSiteNext
     * @param resourceGroupName The resource group name of the VpnSite.
     * @param vpnSiteName The name of the VpnSite.
     * @param nextLink The nextLink from the previous successful call to the ListByVpnSite method.
     * @param options The options parameters.
     */
    _listByVpnSiteNext(resourceGroupName, vpnSiteName, nextLink, options) {
        return this.client.sendOperationRequest({ resourceGroupName, vpnSiteName, nextLink, options }, listByVpnSiteNextOperationSpec);
    }
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const getOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/vpnSites/{vpnSiteName}/vpnSiteLinks/{vpnSiteLinkName}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.VpnSiteLink,
        },
        default: {
            bodyMapper: Mappers.CloudError,
        },
    },
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.vpnSiteName,
        Parameters.vpnSiteLinkName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const listByVpnSiteOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/vpnSites/{vpnSiteName}/vpnSiteLinks",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.ListVpnSiteLinksResult,
        },
        default: {
            bodyMapper: Mappers.CloudError,
        },
    },
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.vpnSiteName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const listByVpnSiteNextOperationSpec = {
    path: "{nextLink}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.ListVpnSiteLinksResult,
        },
        default: {
            bodyMapper: Mappers.CloudError,
        },
    },
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.nextLink,
        Parameters.vpnSiteName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
//# sourceMappingURL=vpnSiteLinks.js.map