UNPKG

polyv-live-cli

Version:

CLI tool for managing PolyV live streaming services.

38 lines 1.83 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RobotHandler = void 0; const base_handler_1 = require("./base.handler"); const errors_1 = require("../utils/errors"); const api_command_1 = require("../utils/api-command"); const robot_service_1 = require("../services/robot-service"); class RobotHandler extends base_handler_1.BaseHandler { constructor(authConfig, serviceConfig) { super(); this.service = new robot_service_1.RobotServiceSdk(authConfig, serviceConfig); } async listRobots(options) { this.show(await this.service.listRobots((0, api_command_1.apiParams)(options)), options.output); } async batchSaveRobots(options) { this.requireFields(options, ['robots']); await (0, api_command_1.confirmWrite)(options.force, `Save ${options.robots.length} robot(s)?`); this.show(await this.service.batchSaveRobots((0, api_command_1.apiParams)(options)), options.output); } async batchDeleteRobots(options) { this.requireFields(options, ['ids']); await (0, api_command_1.confirmWrite)(options.force, `Delete ${options.ids.length} robot(s)?`); await this.service.batchDeleteRobots((0, api_command_1.apiParams)(options)); this.show({ success: true, ids: options.ids }, options.output); } show(data, output = 'table') { this.displayData(data, output); } requireFields(options, fields) { const missing = fields.filter((field) => options[field] === undefined || options[field] === ''); if (missing.length > 0) { throw new errors_1.PolyVValidationError(`Missing required option(s): ${missing.join(', ')}`, 'options', options, 'validation_failed'); } } } exports.RobotHandler = RobotHandler; //# sourceMappingURL=robot.handler.js.map