wazuh-kibana-app/public/services/group-handler.js

82 lines
1.8 KiB
JavaScript
Raw Normal View History

2018-12-10 15:42:51 +00:00
/*
* Wazuh app - Group handler service
2019-01-14 16:36:47 +00:00
* Copyright (C) 2015-2019 Wazuh, Inc.
2018-12-10 15:42:51 +00:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Find more information about this on the LICENSE file.
*/
export class GroupHandler {
constructor(apiReq) {
this.apiReq = apiReq;
}
2019-01-17 14:50:31 +00:00
async removeGroup(group) {
try {
const result = await this.apiReq.request(
'DELETE',
`/agents/groups/${group}`,
{}
);
return result;
} catch (error) {
return Promise.reject(error);
}
}
2018-12-10 15:42:51 +00:00
async removeAgentFromGroup(group, agentId) {
try {
2018-12-28 08:57:04 +00:00
const result = await this.apiReq.request(
'DELETE',
`/agents/${agentId}/group/${group}`,
{}
);
return result;
2018-12-10 15:42:51 +00:00
} catch (error) {
return Promise.reject(error);
}
}
async addAgentToGroup(group, agentId) {
try {
2018-12-28 08:57:04 +00:00
const result = await this.apiReq.request(
'PUT',
`/agents/${agentId}/group/${group}`,
{}
);
return result;
2018-12-10 15:42:51 +00:00
} catch (error) {
return Promise.reject(error);
}
}
2019-01-08 16:49:23 +00:00
async sendConfiguration(group, content) {
try {
const result = await this.apiReq.request(
'POST',
`/agents/groups/${group}/files/agent.conf`,
2019-01-08 16:49:23 +00:00
{ content, origin: 'xmleditor' }
);
return result;
} catch (error) {
return Promise.reject(error);
}
}
2019-01-17 14:50:31 +00:00
async createGroup(name) {
try {
const result = await this.apiReq.request(
'PUT',
`/agents/groups/${name}`,
{ }
);
return result;
} catch (error) {
return Promise.reject(error);
}
}
2018-12-10 15:42:51 +00:00
}