"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@oclif/core");
const chalk_1 = __importDefault(require("chalk"));
const backup_client_1 = require("../../../lib/backup-client");
const context_banner_1 = require("../../../lib/context-banner");
class BackupPolicyShow extends core_1.Command {
    async run() {
        const { args, flags } = await this.parse(BackupPolicyShow);
        (0, context_banner_1.printContextBanner)();
        const client = backup_client_1.BackupClient.fromConfig();
        const p = await client.getPolicy(args.id);
        if (flags.json) {
            this.log(JSON.stringify(p, null, 2));
            return;
        }
        this.log('');
        this.log(`   ${chalk_1.default.bold('ID:')}        ${p.id}`);
        this.log(`   ${chalk_1.default.bold('Name:')}      ${p.name}`);
        this.log(`   ${chalk_1.default.bold('Cluster:')}   ${p.clusterId}`);
        this.log(`   ${chalk_1.default.bold('Profile:')}   ${p.profile}`);
        this.log(`   ${chalk_1.default.bold('Scope:')}     ${p.scope}`);
        if (p.schedule)
            this.log(`   ${chalk_1.default.bold('Schedule:')}  ${p.schedule}`);
        if (typeof p.retentionDays === 'number')
            this.log(`   ${chalk_1.default.bold('Retention:')} ${p.retentionDays} days`);
        if (p.destinations?.length) {
            this.log(`   ${chalk_1.default.bold('Destinations:')}`);
            for (const d of p.destinations) {
                const prio = d.priority == null ? '' : ` prio=${d.priority}`;
                this.log(`     - ${d.destinationId} (${d.role}${prio})`);
            }
        }
        this.log('');
    }
}
BackupPolicyShow.description = 'Show a backup policy by ID';
BackupPolicyShow.args = {
    id: core_1.Args.string({ required: true, description: 'Policy ID' }),
};
BackupPolicyShow.flags = { json: core_1.Flags.boolean({ default: false }) };
exports.default = BackupPolicyShow;
