UNPKG

raas-client

Version:
63 lines 4.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const raas_core_1 = require("raas-core"); const common_1 = require("./common"); class Installation { constructor(connection, emitter) { this.connection = connection; this.emitter = emitter; this.listenToInstallationChanges(); } listenToInstallationChanges() { this.connection.onNotification(raas_core_1.Messages.Client.InstallationAddedNotification.type, installation => { this.emitter.emit('installationAdded', installation); }); this.connection.onNotification(raas_core_1.Messages.Client.InstallingServerNotification.type, installingServer => { this.emitter.emit('installingServer', installingServer); }); this.connection.onNotification(raas_core_1.Messages.Client.InstallingServerMessageNotification.type, data => { this.emitter.emit('installingServerMessage', data); }); this.connection.onNotification(raas_core_1.Messages.Client.InstallingServerFailedNotification.type, data => { this.emitter.emit('installingServerFailedMessage', data); }); this.connection.onNotification(raas_core_1.Messages.Client.InstallingServerCancelledNotification.type, installingServer => { this.emitter.emit('installingServerCancelled', installingServer); }); this.connection.onNotification(raas_core_1.Messages.Client.InstallingServerCompletedNotification.type, data => { this.emitter.emit('installingServerCompleted', data); }); this.connection.onNotification(raas_core_1.Messages.Client.InstalledServerDeletedNotification.type, insallation => { this.emitter.emit('installedServerDeleted', insallation); }); this.connection.onNotification(raas_core_1.Messages.Client.InstalledServerUpdatedNotification.type, installation => { this.emitter.emit('installedServerUpdated', installation); }); } addInstalledServer(request, timeout = 20000) { return this.send(raas_core_1.Messages.Server.AddInstalledServerRequest.type, request, 'installationAdded', (param) => param.id === request.id, timeout, common_1.ErrorMessages.ADDINSTALLEDSERVER_TIMEOUT); } installServer(request, timeout = 60000) { return this.send(raas_core_1.Messages.Server.InstallServerRequest.type, request, 'installingServerCompleted', (param) => param.installing.installServerRequest.id === request.id, timeout, common_1.ErrorMessages.INSTALLSERVER_TIMEOUT); } cancelInstallation(installing, timeout = 2000) { return this.send(raas_core_1.Messages.Server.CancelServerInstallationRequest.type, installing, 'installingServerCancelled', (param) => param.installServerRequest.id === installing.id, timeout, common_1.ErrorMessages.CANCELINSTALLION_TIMEOUT); } deleteInstallation(installation, timeout = 2000) { return this.send(raas_core_1.Messages.Server.DeleteServerInstallationRequest.type, installation, 'installedServerDeleted', (param) => param.id === installation.id, timeout, common_1.ErrorMessages.DELETEINSTALLION_TIMEOUT); } updateInstallation(installation, timeout = 2000) { return this.send(raas_core_1.Messages.Server.UpdateServerInstallationRequest.type, installation, 'installedServerUpdated', (param) => param.id === installation.id, timeout, common_1.ErrorMessages.UPDATEINSTALLATION_TIMEOUT); } getAllInstalledServers(timeout = 2000) { return common_1.Common.sendSimpleRequest(this.connection, raas_core_1.Messages.Server.GetInstalledServersRequest.type, null, timeout, common_1.ErrorMessages.GETALLINSTALLEDSERVERS_TIMEOUT); } getAllInstallingServers(timeout = 2000) { return common_1.Common.sendSimpleRequest(this.connection, raas_core_1.Messages.Server.GetInstallingServersRequest.type, null, timeout, common_1.ErrorMessages.GETALLINSTALLINGSERVERS_TIMEOUT); } send(messageType, payload, id, listener, timeout, timeoutMessage) { return common_1.Common.sendRequestSync(this.connection, messageType, payload, this.emitter, id, listener, timeout, timeoutMessage); } } exports.Installation = Installation; //# sourceMappingURL=installation.js.map