"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.ApiManagementServiceSkusImpl = 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 ApiManagementServiceSkus operations. */
class ApiManagementServiceSkusImpl {
    /**
     * Initialize a new instance of the class ApiManagementServiceSkus class.
     * @param client Reference to the service client
     */
    constructor(client) {
        this.client = client;
    }
    /**
     * Gets all available SKU for a given API Management service
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param options The options parameters.
     */
    listAvailableServiceSkus(resourceGroupName, serviceName, options) {
        const iter = this.listAvailableServiceSkusPagingAll(resourceGroupName, serviceName, options);
        return {
            next() {
                return iter.next();
            },
            [Symbol.asyncIterator]() {
                return this;
            },
            byPage: (settings) => {
                if (settings === null || settings === void 0 ? void 0 : settings.maxPageSize) {
                    throw new Error("maxPageSize is not supported by this operation.");
                }
                return this.listAvailableServiceSkusPagingPage(resourceGroupName, serviceName, options, settings);
            },
        };
    }
    listAvailableServiceSkusPagingPage(resourceGroupName, serviceName, options, settings) {
        return tslib_1.__asyncGenerator(this, arguments, function* listAvailableServiceSkusPagingPage_1() {
            let result;
            let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken;
            if (!continuationToken) {
                result = yield tslib_1.__await(this._listAvailableServiceSkus(resourceGroupName, serviceName, options));
                let page = result.value || [];
                continuationToken = result.nextLink;
                (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken);
                yield yield tslib_1.__await(page);
            }
            while (continuationToken) {
                result = yield tslib_1.__await(this._listAvailableServiceSkusNext(resourceGroupName, serviceName, continuationToken, options));
                continuationToken = result.nextLink;
                let page = result.value || [];
                (0, pagingHelper_js_1.setContinuationToken)(page, continuationToken);
                yield yield tslib_1.__await(page);
            }
        });
    }
    listAvailableServiceSkusPagingAll(resourceGroupName, serviceName, options) {
        return tslib_1.__asyncGenerator(this, arguments, function* listAvailableServiceSkusPagingAll_1() {
            var _a, e_1, _b, _c;
            try {
                for (var _d = true, _e = tslib_1.__asyncValues(this.listAvailableServiceSkusPagingPage(resourceGroupName, serviceName, options)), _f; _f = yield tslib_1.__await(_e.next()), _a = _f.done, !_a; _d = true) {
                    _c = _f.value;
                    _d = false;
                    const page = _c;
                    yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues(page)));
                }
            }
            catch (e_1_1) { e_1 = { error: e_1_1 }; }
            finally {
                try {
                    if (!_d && !_a && (_b = _e.return)) yield tslib_1.__await(_b.call(_e));
                }
                finally { if (e_1) throw e_1.error; }
            }
        });
    }
    /**
     * Gets all available SKU for a given API Management service
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param options The options parameters.
     */
    _listAvailableServiceSkus(resourceGroupName, serviceName, options) {
        return this.client.sendOperationRequest({ resourceGroupName, serviceName, options }, listAvailableServiceSkusOperationSpec);
    }
    /**
     * ListAvailableServiceSkusNext
     * @param resourceGroupName The name of the resource group. The name is case insensitive.
     * @param serviceName The name of the API Management service.
     * @param nextLink The nextLink from the previous successful call to the ListAvailableServiceSkus
     *                 method.
     * @param options The options parameters.
     */
    _listAvailableServiceSkusNext(resourceGroupName, serviceName, nextLink, options) {
        return this.client.sendOperationRequest({ resourceGroupName, serviceName, nextLink, options }, listAvailableServiceSkusNextOperationSpec);
    }
}
exports.ApiManagementServiceSkusImpl = ApiManagementServiceSkusImpl;
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const listAvailableServiceSkusOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/skus",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.ResourceSkuResults,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.serviceName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
const listAvailableServiceSkusNextOperationSpec = {
    path: "{nextLink}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.ResourceSkuResults,
        },
        default: {
            bodyMapper: Mappers.ErrorResponse,
        },
    },
    urlParameters: [
        Parameters.$host,
        Parameters.resourceGroupName,
        Parameters.subscriptionId,
        Parameters.nextLink,
        Parameters.serviceName,
    ],
    headerParameters: [Parameters.accept],
    serializer,
};
//# sourceMappingURL=apiManagementServiceSkus.js.map