/*
 * 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 { __asyncDelegator, __asyncGenerator, __asyncValues, __await } from "tslib";
import { setContinuationToken } from "../pagingHelper";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
/// <reference lib="esnext.asynciterable" />
/** Class containing CertificateOrdersDiagnostics operations. */
export class CertificateOrdersDiagnosticsImpl {
    /**
     * Initialize a new instance of the class CertificateOrdersDiagnostics class.
     * @param client Reference to the service client
     */
    constructor(client) {
        this.client = client;
    }
    /**
     * Description for Microsoft.CertificateRegistration to get the list of detectors for this RP.
     * @param resourceGroupName Name of the resource group to which the resource belongs.
     * @param certificateOrderName The certificate order name for which the response is needed.
     * @param options The options parameters.
     */
    listAppServiceCertificateOrderDetectorResponse(resourceGroupName, certificateOrderName, options) {
        const iter = this.listAppServiceCertificateOrderDetectorResponsePagingAll(resourceGroupName, certificateOrderName, 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.listAppServiceCertificateOrderDetectorResponsePagingPage(resourceGroupName, certificateOrderName, options, settings);
            }
        };
    }
    listAppServiceCertificateOrderDetectorResponsePagingPage(resourceGroupName, certificateOrderName, options, settings) {
        return __asyncGenerator(this, arguments, function* listAppServiceCertificateOrderDetectorResponsePagingPage_1() {
            let result;
            let continuationToken = settings === null || settings === void 0 ? void 0 : settings.continuationToken;
            if (!continuationToken) {
                result = yield __await(this._listAppServiceCertificateOrderDetectorResponse(resourceGroupName, certificateOrderName, options));
                let page = result.value || [];
                continuationToken = result.nextLink;
                setContinuationToken(page, continuationToken);
                yield yield __await(page);
            }
            while (continuationToken) {
                result = yield __await(this._listAppServiceCertificateOrderDetectorResponseNext(resourceGroupName, certificateOrderName, continuationToken, options));
                continuationToken = result.nextLink;
                let page = result.value || [];
                setContinuationToken(page, continuationToken);
                yield yield __await(page);
            }
        });
    }
    listAppServiceCertificateOrderDetectorResponsePagingAll(resourceGroupName, certificateOrderName, options) {
        return __asyncGenerator(this, arguments, function* listAppServiceCertificateOrderDetectorResponsePagingAll_1() {
            var _a, e_1, _b, _c;
            try {
                for (var _d = true, _e = __asyncValues(this.listAppServiceCertificateOrderDetectorResponsePagingPage(resourceGroupName, certificateOrderName, options)), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
                    _c = _f.value;
                    _d = false;
                    const page = _c;
                    yield __await(yield* __asyncDelegator(__asyncValues(page)));
                }
            }
            catch (e_1_1) { e_1 = { error: e_1_1 }; }
            finally {
                try {
                    if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
                }
                finally { if (e_1) throw e_1.error; }
            }
        });
    }
    /**
     * Description for Microsoft.CertificateRegistration to get the list of detectors for this RP.
     * @param resourceGroupName Name of the resource group to which the resource belongs.
     * @param certificateOrderName The certificate order name for which the response is needed.
     * @param options The options parameters.
     */
    _listAppServiceCertificateOrderDetectorResponse(resourceGroupName, certificateOrderName, options) {
        return this.client.sendOperationRequest({ resourceGroupName, certificateOrderName, options }, listAppServiceCertificateOrderDetectorResponseOperationSpec);
    }
    /**
     * Description for Microsoft.CertificateRegistration call to get a detector response from App Lens.
     * @param resourceGroupName Name of the resource group to which the resource belongs.
     * @param certificateOrderName The certificate order name for which the response is needed.
     * @param detectorName The detector name which needs to be run.
     * @param options The options parameters.
     */
    getAppServiceCertificateOrderDetectorResponse(resourceGroupName, certificateOrderName, detectorName, options) {
        return this.client.sendOperationRequest({ resourceGroupName, certificateOrderName, detectorName, options }, getAppServiceCertificateOrderDetectorResponseOperationSpec);
    }
    /**
     * ListAppServiceCertificateOrderDetectorResponseNext
     * @param resourceGroupName Name of the resource group to which the resource belongs.
     * @param certificateOrderName The certificate order name for which the response is needed.
     * @param nextLink The nextLink from the previous successful call to the
     *                 ListAppServiceCertificateOrderDetectorResponse method.
     * @param options The options parameters.
     */
    _listAppServiceCertificateOrderDetectorResponseNext(resourceGroupName, certificateOrderName, nextLink, options) {
        return this.client.sendOperationRequest({ resourceGroupName, certificateOrderName, nextLink, options }, listAppServiceCertificateOrderDetectorResponseNextOperationSpec);
    }
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const listAppServiceCertificateOrderDetectorResponseOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{certificateOrderName}/detectors",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.DetectorResponseCollection
        },
        default: {
            bodyMapper: Mappers.DefaultErrorResponse
        }
    },
    queryParameters: [Parameters.apiVersion],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.certificateOrderName
    ],
    headerParameters: [Parameters.accept],
    serializer
};
const getAppServiceCertificateOrderDetectorResponseOperationSpec = {
    path: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CertificateRegistration/certificateOrders/{certificateOrderName}/detectors/{detectorName}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.DetectorResponse
        },
        default: {
            bodyMapper: Mappers.DefaultErrorResponse
        }
    },
    queryParameters: [
        Parameters.apiVersion,
        Parameters.startTime,
        Parameters.endTime,
        Parameters.timeGrain
    ],
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.certificateOrderName,
        Parameters.detectorName
    ],
    headerParameters: [Parameters.accept],
    serializer
};
const listAppServiceCertificateOrderDetectorResponseNextOperationSpec = {
    path: "{nextLink}",
    httpMethod: "GET",
    responses: {
        200: {
            bodyMapper: Mappers.DetectorResponseCollection
        },
        default: {
            bodyMapper: Mappers.DefaultErrorResponse
        }
    },
    urlParameters: [
        Parameters.$host,
        Parameters.subscriptionId,
        Parameters.resourceGroupName,
        Parameters.certificateOrderName,
        Parameters.nextLink
    ],
    headerParameters: [Parameters.accept],
    serializer
};
//# sourceMappingURL=certificateOrdersDiagnostics.js.map