"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const randomTextGenerator_1 = __importDefault(require("../../utils/randomTextGenerator"));
const collectionResource_1 = __importDefault(require("../base/collectionResource"));
const environment_1 = __importDefault(require("./environment"));
class Environments extends collectionResource_1.default {
    constructor(clientSession, projectId) {
        super(clientSession, 'environments', 'environment');
        if (projectId) {
            this._api = `projects/${projectId}/environments`;
            this._projectId = projectId;
        }
        else {
            this._api = 'environments';
        }
    }
    // eslint-disable-next-line @typescript-eslint/naming-convention
    environment(id) {
        if (!this._projectId) {
            throw new Error('No ProjectID found. Individual environments require a projectId.');
        }
        return new environment_1.default(id, this._clientSession, this._api, this._projectId);
    }
    _buildDefaults(resource) {
        var _a, _b, _c, _d, _e, _f;
        const randomTextGenerator = new randomTextGenerator_1.default(this._settings.get('runId'));
        return {
            description: (_a = resource.description) !== null && _a !== void 0 ? _a : randomTextGenerator.getFakeText('fakeDescription'),
            name: (_b = resource.name) !== null && _b !== void 0 ? _b : randomTextGenerator.getFakeText('fakeName'),
            envTypeId: (_c = resource.envTypeId) !== null && _c !== void 0 ? _c : this._settings.get('envTypeId'),
            envTypeConfigId: (_d = resource.envTypeConfigId) !== null && _d !== void 0 ? _d : this._settings.get('envTypeConfigId'),
            datasetIds: (_e = resource.datasetIds) !== null && _e !== void 0 ? _e : [],
            envType: (_f = resource.envType) !== null && _f !== void 0 ? _f : this._settings.get('envType')
        };
    }
    //eslint-disable-next-line @typescript-eslint/no-explicit-any
    async create(body = {}, applyDefault = true) {
        if (!this._projectId) {
            throw new Error('CreateEnvironments requires a parent Project resource.');
        }
        return super.create(body, applyDefault);
    }
    async listProjectEnvironments(queryParams = undefined) {
        if (!this._projectId) {
            throw new Error('ListProjectEnvironments requires a parent Project resource.');
        }
        return super.get(queryParams);
    }
}
exports.default = Environments;
//# sourceMappingURL=environments.js.map