"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.StaticMembersImpl = void 0;
const tslib_1 = require("tslib");
const pagingHelper_js_1 = require("../pagingHelper.js");
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"));
/// <reference lib="esnext.asynciterable" />
/** Class containing StaticMembers operations. */
class StaticMembersImpl {
    client;
    /**
     * Initialize a new instance of the class StaticMembers class.
     * @param client Reference to the service client
     */
    constructor(client) {
        this.client = client;
    }
    /**
     * Lists the specified static member.
     * @param resourceGroupName The name of the resource group.
     * @param networkManagerName The name of the network manager.
     * @param networkGroupName The name of the network group.
     * @param options The options parameters.
     */
    list(resourceGroupName, networkManagerName, networkGroupName, options) {
        const iter = this.listPagingAll(resourceGroupName, networkManagerName, networkGroupName, 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, networkManagerName, networkGroupName, options, settings);
            },
        };
    }
    async *listPagingPage(resourceGroupName, networkManagerName, networkGroupName, options, settings) {
        let result;
        let continuationToken = settings?.continuationToken;
        if (!continuationToken) {
            result = await this._list(resourceGroupName, networkManagerName, networkGroupName, options);
            let page = result.value || [];
            continuationToken = result.nextLink;
            (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken);
            yield page;
        }
        while (continuationToken) {
            result = await this._listNext(resourceGroupName, networkManagerName, networkGroupName, continuationToken, options);
            continuationToken = result.nextLink;
            let page = result.value || [];
            (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken);
            yield page;
        }
    }
    async *listPagingAll(resourceGroupName, networkManagerName, networkGroupName, options) {
        for await (const page of this.listPagingPage(resourceGroupName, networkManagerName, networkGroupName, options)) {
            yield* page;
        }
    }
    /**
     * Gets the specified static member.
     * @param resourceGroupName The name of the resource group.
     * @param networkManagerName The name of the network manager.
     * @param networkGroupName The name of the network group.
     * @param staticMemberName The name of the static member.
     * @param options The options parameters.
     */
    get(resourceGroupName, networkManagerName, networkGroupName, staticMemberName, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            networkManagerName,
            networkGroupName,
            staticMemberName,
            options,
        }, getOperationSpec);
    }
    /**
     * Creates or updates a static member.
     * @param resourceGroupName The name of the resource group.
     * @param networkManagerName The name of the network manager.
     * @param networkGroupName The name of the network group.
     * @param staticMemberName The name of the static member.
     * @param parameters Parameters supplied to the specify the static member to create
     * @param options The options parameters.
     */
    createOrUpdate(resourceGroupName, networkManagerName, networkGroupName, staticMemberName, parameters, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            networkManagerName,
            networkGroupName,
            staticMemberName,
            parameters,
            options,
        }, createOrUpdateOperationSpec);
    }
    /**
     * Deletes a static member.
     * @param resourceGroupName The name of the resource group.
     * @param networkManagerName The name of the network manager.
     * @param networkGroupName The name of the network group.
     * @param staticMemberName The name of the static member.
     * @param options The options parameters.
     */
    delete(resourceGroupName, networkManagerName, networkGroupName, staticMemberName, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            networkManagerName,
            networkGroupName,
            staticMemberName,
            options,
        }, deleteOperationSpec);
    }
    /**
     * Lists the specified static member.
     * @param resourceGroupName The name of the resource group.
     * @param networkManagerName The name of the network manager.
     * @param networkGroupName The name of the network group.
     * @param options The options parameters.
     */
    _list(resourceGroupName, networkManagerName, networkGroupName, options) {
        return this.client.sendOperationRequest({ resourceGroupName, networkManagerName, networkGroupName, options }, listOperationSpec);
    }
    /**
     * ListNext
     * @param resourceGroupName The name of the resource group.
     * @param networkManagerName The name of the network manager.
     * @param networkGroupName The name of the network group.
     * @param nextLink The nextLink from the previous successful call to the List method.
     * @param options The options parameters.
     */
    _listNext(resourceGroupName, networkManagerName, networkGroupName, nextLink, options) {
        return this.client.sendOperationRequest({
            resourceGroupName,
            networkManagerName,
            networkGroupName,
            nextLink,
            options,
        }, listNextOperationSpec);
    }
}
exports.StaticMembersImpl = StaticMembersImpl;
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const getOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkManagers/{networkManagerName}/networkGroups/{networkGroupName}/staticMembers/{staticMemberName}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.StaticMember,
        },
        default: {
            bodyMapper: Mappers.CloudError,
        },
    },
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.networkManagerName,
        Parameters.networkGroupName,
        Parameters.staticMemberName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const createOrUpdateOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkManagers/{networkManagerName}/networkGroups/{networkGroupName}/staticMembers/{staticMemberName}",
    httpMethod: "PUT",
    responses: {
        200: {
            bodyMapper: Mappers.StaticMember,
        },
        201: {
            bodyMapper: Mappers.StaticMember,
        },
        default: {
            bodyMapper: Mappers.CloudError,
        },
    },
    requestBody: Parameters.parameters40,
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.networkManagerName,
        Parameters.networkGroupName,
        Parameters.staticMemberName,
    ],
    headerParameters: [Parameters.accept, Parameters.contentType],
    mediaType: "json",
    serializer,
};
const deleteOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkManagers/{networkManagerName}/networkGroups/{networkGroupName}/staticMembers/{staticMemberName}",
    httpMethod: "DELETE",
    responses: {
        200: {},
        204: {},
        default: {
            bodyMapper: Mappers.CloudError,
        },
    },
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.networkManagerName,
        Parameters.networkGroupName,
        Parameters.staticMemberName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const listOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkManagers/{networkManagerName}/networkGroups/{networkGroupName}/staticMembers",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.StaticMemberListResult,
        },
        default: {
            bodyMapper: Mappers.CloudError,
        },
    },
    queryParameters: [
        Parameters.apiVersion,
        Parameters.top,
        Parameters.skipToken1,
    ],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.networkManagerName,
        Parameters.networkGroupName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const listNextOperationSpec = {
    path: "{nextLink}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.StaticMemberListResult,
        },
        default: {
            bodyMapper: Mappers.CloudError,
        },
    },
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.nextLink,
        Parameters.networkManagerName,
        Parameters.networkGroupName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
//# sourceMappingURL=staticMembers.js.map