import { update } from "../../ca-certificate/update/handler.js";
import { captureEvent } from "../../common/analytics/lib.js";
import { authenticate } from "../../common/middleware/authentication.js";
import { fetchAccount } from "../../common/middleware/get-account-param.js";
import { configure } from "../../common/middleware/user-configuration.js";
import { identify } from "../../common/middleware/user-identification.js";
export default {
    desc: "Updates the name of a CA certificate",
    command: "update",
    builder: (yargs) => {
        return yargs
            .usage("$0 ca-certificate update --cert-id <id> --name <name> [options]")
            .option("cert-id", {
            type: "string",
            describe: "The ID of the CA certificate to update",
        })
            .option("name", {
            type: "string",
            describe: "The new name for the CA certificate (must be a valid JavaScript identifier: starts with a letter, _, or $; contains only letters, digits, _, or $)",
        })
            .option("api-key", {
            type: "string",
            describe: "The API Key from Zuplo",
            envVar: "API_KEY",
            alias: "apikey",
        })
            .option("account", {
            type: "string",
            describe: "The account name",
        })
            .option("output", {
            type: "string",
            alias: "o",
            describe: "Output format",
            choices: ["default", "json"],
            default: "default",
        })
            .demandOption(["cert-id", "name"])
            .example([
            [
                "$0 ca-certificate update --cert-id mtlsca_abc123 --name renamed_ca",
                "Rename a CA certificate",
            ],
            [
                "$0 ca-certificate update --cert-id mtlsca_abc123 --name renamed_ca --account my-account",
                "Explicitly specify the account",
            ],
        ])
            .middleware([authenticate, configure, fetchAccount, identify]);
    },
    handler: async (argv) => {
        await captureEvent({ argv, event: "zuplo ca-certificate update" });
        await update(argv);
    },
};
//# sourceMappingURL=update.js.map