UNPKG

balena-cli

Version:

The official balena Command Line Interface

56 lines (54 loc) 2.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const core_1 = require("@oclif/core"); const cf = require("../../utils/common-flags"); const lazy_1 = require("../../utils/lazy"); class APIKeyListCmd extends core_1.Command { async run() { const { flags: options } = await this.parse(APIKeyListCmd); const { getApplication } = await Promise.resolve().then(() => require('../../utils/sdk')); const actorId = options.fleet ? (await getApplication((0, lazy_1.getBalenaSdk)(), options.fleet, { $select: 'actor', })).actor.__id : await (0, lazy_1.getBalenaSdk)().auth.getActorId(); const keys = await (0, lazy_1.getBalenaSdk)().pine.get({ resource: 'api_key', options: { $select: ['id', 'created_at', 'name', 'description', 'expiry_date'], $filter: { is_of__actor: actorId, ...(options.user ? { name: { $ne: null, }, } : {}), }, $orderby: 'name asc', }, }); const fields = ['id', 'name', 'created_at', 'description', 'expiry_date']; const _ = await Promise.resolve().then(() => require('lodash')); console.log((0, lazy_1.getVisuals)().table.horizontal(keys.map((key) => _.mapValues(key, (val) => val !== null && val !== void 0 ? val : 'N/a')), fields)); } } APIKeyListCmd.aliases = ['api-keys']; APIKeyListCmd.deprecateAliases = true; APIKeyListCmd.description = (0, lazy_1.stripIndent) ` Print a list of balenaCloud API keys. Print a list of balenaCloud API keys. Print a list of balenaCloud API keys for the current user or for a specific fleet with the \`--fleet\` option. `; APIKeyListCmd.examples = ['$ balena api-key list']; APIKeyListCmd.flags = { user: core_1.Flags.boolean({ char: 'u', description: 'show API keys for your user', }), fleet: cf.fleet, }; APIKeyListCmd.authenticated = true; exports.default = APIKeyListCmd; //# sourceMappingURL=list.js.map