"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OtherClusterConfigurator = void 0;
const tslib_1 = require("tslib");
const inversify_1 = require("inversify");
const codiac_common_1 = require("@codiac.io/codiac-common");
const codiac_ops_common_1 = require("@codiac.io/codiac-ops-common");
const codiac_relay_1 = require("../../apis/codiac-relay");
const contracts_1 = require("../../apis/codiac-api/contracts");
const ops_1 = require("../../ops");
const resource_configurator_base_1 = require("../shared/resource-configurator-base");
let OtherClusterConfigurator = class OtherClusterConfigurator extends resource_configurator_base_1.ResourceConfiguratorBase {
    constructor(codiacUser, genRelayClient, ui, styler, logger) {
        super(codiacUser, genRelayClient, ui, styler, logger);
    }
    get cloudProvider() {
        return contracts_1.CloudProviderEnum.other;
    }
    /* ***********************************************************************************
     *   _____ _           _
     *  /  __ \ |         | |
     *  | /  \/ |_   _ ___| |_ ___ _ __
     *  | |   | | | | / __| __/ _ \ '__|
     *  | \__/\ | |_| \__ \ ||  __/ |
     *   \____/_|\__,_|___/\__\___|_|
     *
     * ***********************************************************************************/
    defineCluster(initial, defaults) {
        var _a, _b, _c;
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            const w = {};
            w.provider = this.cloudProvider;
            w.privateOwner = this.codiacUser.tenantCode;
            [initial, defaults] = yield this.applyClusterDefaults(w, initial, defaults);
            w.name = yield this.promptForName(initial === null || initial === void 0 ? void 0 : initial.name);
            w.providerSubscription = (yield this._ui.prompt('providerSubscription', 'Cluster label (providerSubscription):', true, initial === null || initial === void 0 ? void 0 : initial.providerSubscription));
            w.locationName = (yield this._ui.prompt('locationName', 'Location (e.g. on-prem, datacenter-1):', true, initial === null || initial === void 0 ? void 0 : initial.locationName));
            w.nodeSpec = (yield this._ui.prompt('nodeSpec', 'Node spec (descriptive label, e.g. custom):', true, initial === null || initial === void 0 ? void 0 : initial.nodeSpec));
            const nodeQtyRaw = yield this._ui.prompt('nodeQty', 'Node count:', true, (_b = (_a = initial === null || initial === void 0 ? void 0 : initial.startingNodeCount) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : '1');
            w.startingNodeCount = parseInt(nodeQtyRaw, 10);
            // Free-text version prompt — no version list available for self-managed clusters.
            w.k8sVersion = (yield this._ui.prompt('k8sVersion', 'Kubernetes version (e.g. 1.29.0):', true, initial === null || initial === void 0 ? void 0 : initial.k8sVersion));
            // Not applicable for self-managed clusters.
            w.providerGroup = '';
            const spec = Object.assign({ name: w.name, provider: w.provider, providerSubscription: w.providerSubscription, locationName: w.locationName, providerGroup: w.providerGroup, nodeCount: w.nodeCount, ingressDef: w.ingressDef, privateOwner: w.privateOwner, nodeSpec: w.nodeSpec, startingNodeCount: w.startingNodeCount, identitySpec: (_c = w.identitySpec) !== null && _c !== void 0 ? _c : { type: contracts_1.SecurityAccountTypeEnum.servicePrincipal, name: '' } }, this.createAuditable());
            if (w.k8sVersion)
                spec.k8sVersion = w.k8sVersion;
            if (w.subnet)
                spec.subnet = w.subnet;
            return { spec, defaults };
        });
    }
    /**
     * Cluster capture is not applicable for self-managed clusters.
     * Use `cod cluster credentials-set` to register connection credentials instead.
     */
    defineClusterCaptureParams(_initial, _rootMap, _defaults) {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            throw new Error('Cluster capture is not supported for self-managed clusters. ' +
                'Use `cod cluster credentials-set` to register connection credentials instead.');
        });
    }
    promptForIngressSpec(_current) {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            throw new Error('Method not implemented.');
        });
    }
};
OtherClusterConfigurator = tslib_1.__decorate([
    (0, inversify_1.injectable)(),
    tslib_1.__param(0, (0, inversify_1.inject)(codiac_ops_common_1.UserNameTenantCode)),
    tslib_1.__param(1, (0, inversify_1.inject)(codiac_relay_1.RelayClient)),
    tslib_1.__param(2, (0, inversify_1.inject)(ops_1.INTERFACES_CLI.IUserInputProvider)),
    tslib_1.__param(3, (0, inversify_1.inject)(ops_1.INTERFACES_CLI.IOutputStyler)),
    tslib_1.__param(4, (0, inversify_1.inject)(codiac_common_1.INTERFACES.IBetterLogger)),
    tslib_1.__metadata("design:paramtypes", [codiac_ops_common_1.UserNameTenantCode,
        codiac_relay_1.RelayClient, Object, Object, Object])
], OtherClusterConfigurator);
exports.OtherClusterConfigurator = OtherClusterConfigurator;
//# sourceMappingURL=other-cluster-configurator.js.map