UNPKG

polyv-live-cli

Version:

CLI tool for managing PolyV live streaming services.

97 lines 5.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GroupHandler = void 0; const base_handler_1 = require("./base.handler"); const errors_1 = require("../utils/errors"); const api_command_1 = require("../utils/api-command"); const group_service_1 = require("../services/group-service"); class GroupHandler extends base_handler_1.BaseHandler { constructor(authConfig, serviceConfig) { super(); this.service = new group_service_1.GroupServiceSdk(authConfig, serviceConfig); } async listAllocateLog(options) { this.requireFields(options, ['emails']); this.show(await this.service.listAllocateLog((0, api_command_1.apiParams)(options)), options.output); } async setConcurrences(options) { this.requireFields(options, ['email', 'concurrences']); await (0, api_command_1.confirmWrite)(options.force, `Update live concurrences for ${options.email}?`); this.show({ success: true, result: await this.service.setConcurrences((0, api_command_1.apiParams)(options)) }, options.output); } async setFlow(options) { this.requireFields(options, ['email']); await (0, api_command_1.confirmWrite)(options.force, `Update VOD flow for ${options.email}?`); this.show({ success: true, result: await this.service.setFlow((0, api_command_1.apiParams)(options)) }, options.output); } async setLiveDurations(options) { this.requireFields(options, ['email', 'duration']); await (0, api_command_1.confirmWrite)(options.force, `Update live durations for ${options.email}?`); this.show({ success: true, result: await this.service.setLiveDurations((0, api_command_1.apiParams)(options)) }, options.output); } async setSpace(options) { this.requireFields(options, ['email']); await (0, api_command_1.confirmWrite)(options.force, `Update VOD space for ${options.email}?`); this.show({ success: true, result: await this.service.setSpace((0, api_command_1.apiParams)(options)) }, options.output); } async createUser(options) { this.requireFields(options, ['email', 'password', 'contacts', 'phone', 'maxChannels']); await (0, api_command_1.confirmWrite)(options.force, `Create group sub-account ${options.email}?`); this.show(await this.service.createGroupUser((0, api_command_1.apiParams)(options)), options.output); } async listUserPackages(options) { this.show(await this.service.listGroupUserPackages((0, api_command_1.apiParams)(options)), options.output); } async updateUserPackage(options) { this.requireFields(options, ['email']); await (0, api_command_1.confirmWrite)(options.force, `Update package for group user ${options.email}?`); this.show({ success: await this.service.updateGroupUserPackage((0, api_command_1.apiParams)(options)) }, options.output); } async listBillingDaily(options) { this.requireFields(options, ['billingDate']); this.show(await this.service.listBillingDaily((0, api_command_1.apiParams)(options)), options.output); } async listUserBillingDaily(options) { this.requireFields(options, ['startDate', 'endDate']); this.show(await this.service.listGroupUserBillingDaily((0, api_command_1.apiParams)(options)), options.output); } async listAllocationLogs(options) { this.requireFields(options, ['emails']); this.show(await this.service.listAllocationLogs((0, api_command_1.apiParams)(options)), options.output); } async healthCheck(options) { this.show(await this.service.healthCheck(), options.output); } async createIsolation(options) { this.requireFields(options, ['email', 'password']); await (0, api_command_1.confirmWrite)(options.force, `Create isolated group account ${options.email}?`); this.show(await this.service.createIsolation((0, api_command_1.apiParams)(options)), options.output); } async listPackageValidity(options) { this.show(await this.service.getPackageValidityList((0, api_command_1.apiParams)(options)), options.output); } async updatePackageValidity(options) { this.requireFields(options, ['email']); await (0, api_command_1.confirmWrite)(options.force, `Update package validity for ${options.email}?`); this.show({ success: await this.service.updatePackageValidity((0, api_command_1.apiParams)(options)) }, options.output); } async resetAppSecret(options) { this.requireFields(options, ['email']); await (0, api_command_1.confirmWrite)(options.force, `Reset app secret for ${options.email}?`); this.show(await this.service.resetAppSecret({ email: options.email }), options.output); } show(data, output = 'table') { this.displayData(data, output); } requireFields(options, fields) { const missing = fields.filter((field) => { const value = options[field]; return value === undefined || value === null || value === ''; }); if (missing.length > 0) { throw new errors_1.PolyVValidationError(`Missing required option(s): ${missing.join(', ')}`, 'options', options, 'validation_failed'); } } } exports.GroupHandler = GroupHandler; //# sourceMappingURL=group.handler.js.map