UNPKG

balena-cli

Version:

The official balena Command Line Interface

54 lines (52 loc) 2.12 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"); const helpers_1 = require("../../utils/helpers"); 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']; console.log((0, lazy_1.getVisuals)().table.horizontal(keys.map((key) => (0, helpers_1.defaultValues)(key, 'N/a')), fields)); } } 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