/*
 * 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 PeerExpressRouteCircuitConnections operations. */
export class PeerExpressRouteCircuitConnectionsImpl {
    client;
    /**
     * Initialize a new instance of the class PeerExpressRouteCircuitConnections class.
     * @param client Reference to the service client
     */
    constructor(client) {
        this.client = client;
    }
    /**
     * Gets all global reach peer connections associated with a private peering in an express route
     * circuit.
     * @param resourceGroupName The name of the resource group.
     * @param circuitName The name of the circuit.
     * @param peeringName The name of the peering.
     * @param options The options parameters.
     */
    list(resourceGroupName, circuitName, peeringName, options) {
        const iter = this.listPagingAll(resourceGroupName, circuitName, peeringName, 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, circuitName, peeringName, options, settings);
            },
        };
    }
    async *listPagingPage(resourceGroupName, circuitName, peeringName, options, settings) {
        let result;
        let continuationToken = settings?.continuationToken;
        if (!continuationToken) {
            result = await this._list(resourceGroupName, circuitName, peeringName, options);
            let page = result.value || [];
            continuationToken = result.nextLink;
            setContinuationToken(page, continuationToken);
            yield page;
        }
        while (continuationToken) {
            result = await this._listNext(resourceGroupName, circuitName, peeringName, continuationToken, options);
            continuationToken = result.nextLink;
            let page = result.value || [];
            setContinuationToken(page, continuationToken);
            yield page;
        }
    }
    async *listPagingAll(resourceGroupName, circuitName, peeringName, options) {
        for await (const page of this.listPagingPage(resourceGroupName, circuitName, peeringName, options)) {
            yield* page;
        }
    }
    /**
     * Gets the specified Peer Express Route Circuit Connection from the specified express route circuit.
     * @param resourceGroupName The name of the resource group.
     * @param circuitName The name of the express route circuit.
     * @param peeringName The name of the peering.
     * @param connectionName The name of the peer express route circuit connection.
     * @param options The options parameters.
     */
    get(resourceGroupName, circuitName, peeringName, connectionName, options) {
        return this.client.sendOperationRequest({ resourceGroupName, circuitName, peeringName, connectionName, options }, getOperationSpec);
    }
    /**
     * Gets all global reach peer connections associated with a private peering in an express route
     * circuit.
     * @param resourceGroupName The name of the resource group.
     * @param circuitName The name of the circuit.
     * @param peeringName The name of the peering.
     * @param options The options parameters.
     */
    _list(resourceGroupName, circuitName, peeringName, options) {
        return this.client.sendOperationRequest({ resourceGroupName, circuitName, peeringName, options }, listOperationSpec);
    }
    /**
     * ListNext
     * @param resourceGroupName The name of the resource group.
     * @param circuitName The name of the circuit.
     * @param peeringName The name of the peering.
     * @param nextLink The nextLink from the previous successful call to the List method.
     * @param options The options parameters.
     */
    _listNext(resourceGroupName, circuitName, peeringName, nextLink, options) {
        return this.client.sendOperationRequest({ resourceGroupName, circuitName, peeringName, nextLink, options }, listNextOperationSpec);
    }
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const getOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}/peerConnections/{connectionName}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.PeerExpressRouteCircuitConnection,
        },
        default: {
            bodyMapper: Mappers.CloudError,
        },
    },
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.connectionName,
        Parameters.circuitName,
        Parameters.peeringName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const listOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/expressRouteCircuits/{circuitName}/peerings/{peeringName}/peerConnections",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.PeerExpressRouteCircuitConnectionListResult,
        },
        default: {
            bodyMapper: Mappers.CloudError,
        },
    },
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.circuitName,
        Parameters.peeringName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const listNextOperationSpec = {
    path: "{nextLink}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.PeerExpressRouteCircuitConnectionListResult,
        },
        default: {
            bodyMapper: Mappers.CloudError,
        },
    },
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.nextLink,
        Parameters.circuitName,
        Parameters.peeringName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
//# sourceMappingURL=peerExpressRouteCircuitConnections.js.map