UNPKG

polyv-live-cli

Version:

CLI tool for managing PolyV live streaming services.

52 lines 2.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WebAppHandler = void 0; const base_handler_1 = require("./base.handler"); const errors_1 = require("../utils/errors"); const api_command_1 = require("../utils/api-command"); const webapp_service_1 = require("../services/webapp-service"); class WebAppHandler extends base_handler_1.BaseHandler { constructor(authConfig, serviceConfig) { super(); this.service = new webapp_service_1.WebAppServiceSdk(authConfig, serviceConfig); } async listPermissions(options) { this.show(await this.service.listPermissions(), options.output); } async listRoles(options) { this.show(await this.service.listRoles((0, api_command_1.apiParams)(options)), options.output); } async getRole(options) { this.requireFields(options, ['roleId']); this.show(await this.service.getRole(options.roleId), options.output); } async createRole(options) { this.requireFields(options, ['name', 'roleType', 'permissionIds']); await (0, api_command_1.confirmWrite)(options.force, `Create WebApp role "${options.name}"?`); await this.service.createRole((0, api_command_1.apiParams)(options)); this.show({ success: true }, options.output); } async updateRole(options) { this.requireFields(options, ['roleId', 'name', 'roleType']); await (0, api_command_1.confirmWrite)(options.force, `Update WebApp role ${options.roleId}?`); await this.service.updateRole((0, api_command_1.apiParams)(options)); this.show({ success: true, roleId: options.roleId }, options.output); } async deleteRole(options) { this.requireFields(options, ['roleId']); await (0, api_command_1.confirmWrite)(options.force, `Delete WebApp role ${options.roleId}?`); await this.service.deleteRole(options.roleId); this.show({ success: true, roleId: options.roleId }, 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.WebAppHandler = WebAppHandler; //# sourceMappingURL=webapp.handler.js.map