@fjedi/zabbix-client
Version:
Zabbix Javascript API Client
39 lines (38 loc) • 1.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ZabbixAPI = void 0;
const ZabbixCommunicator_1 = require("./ZabbixCommunicator");
class ZabbixAPI {
socket;
reloginInterceptor;
constructor(socket) {
this.socket = socket;
}
getHttpSocket() {
return this.socket.getHttp();
}
getSocket() {
return this.socket;
}
setReloginInterceptor(interceptor) {
this.reloginInterceptor = interceptor;
}
async login(username, password) {
return await this.method("user.login").call({
username,
password,
});
}
async logout() {
const result = await this.method("user.logout").call([]);
this.socket.setToken(null);
if (this.reloginInterceptor) {
this.getHttpSocket().interceptors.request.eject(this.reloginInterceptor);
}
return result;
}
method(method) {
return new ZabbixCommunicator_1.ZabbixCommunicator(this.socket, method);
}
}
exports.ZabbixAPI = ZabbixAPI;