UNPKG

skysync-cli

Version:

SkySync Command Line Interface

82 lines (81 loc) 3.13 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; const command_1 = require("../../util/command"); const util_1 = require("../auditCategories/util"); module.exports = { command: 'add', desc: 'Add a Transfer Audit Category', builder: yargs => { yargs.options({ 'name': { desc: 'Audit Category name', type: 'string', demandOption: true, }, 'description': { desc: 'Audit Category description', type: 'string', }, 'action': { desc: 'Action', type: 'string', }, 'level': { desc: 'Log level', type: 'string', }, 'priority': { desc: 'Priority', type: 'number', }, 'options-input': { alias: 'in', desc: 'Read JSON options from stdin', type: 'boolean' }, 'auditType': { alias: 'type', desc: 'Audit Type code to which this audit category applies', type: 'number' } }); }, handler: argv => { command_1.runCommand(argv, (client, output) => __awaiter(void 0, void 0, void 0, function* () { let auditCategory = { name: argv.name, description: argv.description, action: argv.action, level: argv.level, priority: argv.priority, filter: { rules: [{ filter: { name: 'audit_type', select: null, op: 'eq', value: argv.auditType }, type: 'filter_context' }] } }; if (argv.optionsInput) { auditCategory = yield command_1.readJsonInput(); auditCategory.name = argv.name; } auditCategory = yield client.transferAuditCategories.add(auditCategory, { fields: 'all' }); output.writeItem(auditCategory, util_1.outputFormat); })); } };