"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Subjects = void 0;
const utils_js_1 = require("./utils.cjs");
/**
 * Subjects
 * @description Subjects are entities that consume resources you wish to meter. These can range from users, servers, and services to devices. The design of subjects is intentionally generic, enabling flexible application across various metering scenarios. Meters are aggregating events for each subject..
 */
class Subjects {
    client;
    constructor(client) {
        this.client = client;
    }
    /**
     * Upsert one or multiple subjects
     * If the subject does not exist, it will be created, otherwise it will be updated.
     *
     * @param subjects - The subjects to upsert
     * @param signal - An optional abort signal
     * @returns The upserted subjects
     */
    async upsert(subjects, options) {
        const resp = await this.client.POST('/api/v1/subjects', {
            body: Array.isArray(subjects) ? subjects : [subjects],
            ...options,
        });
        return (0, utils_js_1.transformResponse)(resp);
    }
    /**
     * Get a subject by ID or key
     * @param idOrKey - The ID or key of the subject
     * @param signal - An optional abort signal
     * @returns The subject
     */
    async get(idOrKey, options) {
        const resp = await this.client.GET('/api/v1/subjects/{subjectIdOrKey}', {
            params: {
                path: {
                    subjectIdOrKey: idOrKey,
                },
            },
            ...options,
        });
        return (0, utils_js_1.transformResponse)(resp);
    }
    /**
     * List subjects
     * @param signal - An optional abort signal
     * @returns The subjects
     */
    async list(options) {
        const resp = await this.client.GET('/api/v1/subjects', {
            ...options,
        });
        return (0, utils_js_1.transformResponse)(resp);
    }
    /**
     * Delete a subject by ID or key
     * @param idOrKey - The ID or key of the subject
     * @param signal - An optional abort signal
     * @returns The deleted subject
     */
    async delete(idOrKey, options) {
        const resp = await this.client.DELETE('/api/v1/subjects/{subjectIdOrKey}', {
            params: {
                path: {
                    subjectIdOrKey: idOrKey,
                },
            },
            ...options,
        });
        return (0, utils_js_1.transformResponse)(resp);
    }
}
exports.Subjects = Subjects;
//# sourceMappingURL=subjects.cjs.map