"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const axiosClient_1 = require("../../api/axiosClient");
let _getRequestAbortController = new AbortController();
const EventsAPI = {
    makeBaseURI() {
        return '/v2/events';
    },
    abort() {
        _getRequestAbortController.abort();
        /*
         * The AbortController.signal can only be aborted once per instance.
         * Therefore in order for other requests to be also abortable we need
         * to create a new instance when this event occurs
         */
        _getRequestAbortController = new AbortController();
    },
    createParams({ clusterId, hostIds, infraEnvId, severities, deletedHosts = true, clusterLevel = true, message, limit = 10, offset = 0, }) {
        let params = '?';
        params += 'order=descending&';
        params += clusterId ? `cluster_id=${clusterId}&` : '';
        params += (hostIds === null || hostIds === void 0 ? void 0 : hostIds.length) ? `host_ids=${hostIds.join(',')}&` : '';
        params += infraEnvId ? `infra_env_id=${infraEnvId}&` : '';
        params += (severities === null || severities === void 0 ? void 0 : severities.length) ? `severities=${severities === null || severities === void 0 ? void 0 : severities.join(',')}&` : '';
        params += deletedHosts ? `deleted_hosts=${deletedHosts.toString()}&` : '';
        params += clusterLevel ? `cluster_level=${clusterLevel.toString()}&` : '';
        params += message ? `message=${encodeURIComponent(message)}&` : '';
        params += `limit=${limit}&`;
        params += `offset=${offset}`;
        return params;
    },
    list(options) {
        return axiosClient_1.client.get(`${EventsAPI.makeBaseURI()}${EventsAPI.createParams(options)}`, {
            signal: _getRequestAbortController.signal,
        });
    },
};
exports.default = EventsAPI;
//# sourceMappingURL=EventsAPI.js.map