Module: Wazuh::Api::Endpoints::Agents
- Included in:
- Wazuh::Api::Endpoints, V4::Agents
- Defined in:
- lib/wazuh/api/endpoints/agents.rb
Instance Method Summary collapse
-
#add_agent(options = {}) ⇒ Object
Add a new agent.
-
#add_agent_quick(agent_name) ⇒ Object
Adds a new agent with name :agent_name.
-
#add_agent_to_group(agent_id, group_id, options = {}) ⇒ Object
Add agent group Adds an agent to the specified group.
-
#add_agents_to_group(ids, group_id) ⇒ Object
Add a list of agents to a group Adds a list of agents to the specified group.
-
#agent(agent_id, options = {}) ⇒ Sawyer::Resource
Returns various information from an agent.
-
#agent_by_name(agent_name, options = {}) ⇒ Sawyer::Resource
Returns various information from an agent called :agent_name.
-
#agent_config(agent_id, component, configuration) ⇒ Object
Get active configuration.
-
#agent_key(agent_id, options = {}) ⇒ String
Get agent key Returns the key of an agent.
-
#agent_os_summary(options = {}) ⇒ Object
Get OS summary Returns a summary of the OS.
-
#agent_summary ⇒ Object
Get agents summary Returns a summary of the available agents.
-
#agent_sync_status(agent_id) ⇒ Object
Get sync status of agent Returns the sync status in JSON format.
-
#agent_upgrade(agent_id, options = {}) ⇒ Object
Upgrade agent using online repository.
-
#agent_upgrade_custom(agent_id, options = {}) ⇒ Object
Upgrade agent using custom file.
-
#agents_by_group(group_id, options = {}) ⇒ Object
Get agents in a group Returns the list of agents in a group.
-
#agents_by_no_group(options = {}) ⇒ Object
Get agents without group Returns a list with the available agents without group.
-
#all_agents(options = {}) ⇒ Array
Returns a list with the available agents.
-
#create_group(group_id) ⇒ Object
Create a group Creates a new group.
-
#delete_agent(agent_id, options = {}) ⇒ Object
Delete an agent Removes an agent.
-
#delete_agent_by_group(ids) ⇒ Object
Delete a list of groups.
-
#delete_agents(options = {}) ⇒ Object
Delete agents Removes agents, using a list of them or a criterion based on the status or time of the last connection.
-
#distinct_fields_in_agents(options = {}) ⇒ Object
Returns all the different combinations that agents have for the selected fields.
-
#get_file_in_group(group_id, filename, options = {}) ⇒ Object
Get a file in group Returns the specified file belonging to the group parsed to JSON.
-
#group_configuration(group_id, options = {}) ⇒ Object
Get group configuration.
-
#group_files(group_id, options = {}) ⇒ Object
Get group files Returns the files belonging to the group.
-
#groups(options = {}) ⇒ Object
Get groups Returns the list of existing agent groups.
-
#insert_agent(options = {}) ⇒ Object
Insert an agent with an existing id and key.
-
#outdated_agents(options = {}) ⇒ Object
Returns the list of outdated agents.
-
#remove_agent_of_group(agent_id, group_id) ⇒ Object
Remove a single group of an agent Remove the group of the agent but will leave the rest of its group if it belongs to a multigroup.
-
#remove_agents_of_group(ids, groups) ⇒ Object
Remove a single group of multiple agents Remove a list of agents of a group.
-
#remove_all_agent_of_group(agent_id) ⇒ Object
Remove all agent groups.
-
#remove_group(group_id) ⇒ Object
Remove group Removes the group.
-
#restart_agents(options = {}) ⇒ Object
Restarts a list of agents.
-
#restart_all_agents ⇒ Object
Restarts all agents.
-
#restart_an_agents(agent_id, options = {}) ⇒ Object
Restart an agent.
-
#update_group_ossec_configuration(group_id, config) ⇒ Object
Put configuration file (agent.conf) into a group Upload the group configuration (agent.conf).
-
#upgrade_result_from_agent(agent_id, options = {}) ⇒ Object
Returns the upgrade result from an agent.
Instance Method Details
#add_agent(options = {}) ⇒ Object
Add a new agent
176 177 178 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 176 def add_agent( = {}) post '/agents', end |
#add_agent_quick(agent_name) ⇒ Object
Adds a new agent with name :agent_name. This agent will use ANY as IP.
210 211 212 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 210 def add_agent_quick(agent_name) put "/agents/#{agent_name}" end |
#add_agent_to_group(agent_id, group_id, options = {}) ⇒ Object
Add agent group Adds an agent to the specified group.
280 281 282 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 280 def add_agent_to_group(agent_id, group_id, = {}) put "/agents/#{agent_id}/group/#{group_id}", end |
#add_agents_to_group(ids, group_id) ⇒ Object
Add a list of agents to a group Adds a list of agents to the specified group
266 267 268 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 266 def add_agents_to_group(ids, group_id) post "/agents/group/#{group_id}", {ids: ids} end |
#agent(agent_id, options = {}) ⇒ Sawyer::Resource
Returns various information from an agent.
37 38 39 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 37 def agent(agent_id, = {}) get "/agents/#{agent_id}", end |
#agent_by_name(agent_name, options = {}) ⇒ Sawyer::Resource
Returns various information from an agent called :agent_name.
49 50 51 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 49 def agent_by_name(agent_name, = {}) get "/agents/name/#{agent_name}", end |
#agent_config(agent_id, component, configuration) ⇒ Object
Get active configuration
238 239 240 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 238 def agent_config(agent_id, component, configuration) get "/agents/#{agent_id}/config/#{component}/#{configuration}" end |
#agent_key(agent_id, options = {}) ⇒ String
Get agent key Returns the key of an agent.
60 61 62 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 60 def agent_key(agent_id, = {}) get "/agents/#{agent_id}/key" end |
#agent_os_summary(options = {}) ⇒ Object
Get OS summary Returns a summary of the OS.
436 437 438 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 436 def agent_os_summary( = {}) get "/agents/summary/os" end |
#agent_summary ⇒ Object
Get agents summary Returns a summary of the available agents.
444 445 446 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 444 def agent_summary get "/agents/summary" end |
#agent_sync_status(agent_id) ⇒ Object
Get sync status of agent Returns the sync status in JSON format
255 256 257 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 255 def agent_sync_status(agent_id) get "/agent/#{agent_id}/group/is_sync" end |
#agent_upgrade(agent_id, options = {}) ⇒ Object
Upgrade agent using online repository
Upgrade the agent using a WPK file from online repository.
160 161 162 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 160 def agent_upgrade(agent_id, = {}) put "/agents/#{agent_id}/upgrade", end |
#agent_upgrade_custom(agent_id, options = {}) ⇒ Object
Upgrade agent using custom file.
143 144 145 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 143 def agent_upgrade_custom(agent_id, = {}) put "/agents/#{agent_id}/upgrade_custom", end |
#agents_by_group(group_id, options = {}) ⇒ Object
Get agents in a group Returns the list of agents in a group.
321 322 323 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 321 def agents_by_group(group_id, = {}) offset_request('get', "/agents/groups/#{group_id}", ) end |
#agents_by_no_group(options = {}) ⇒ Object
Get agents without group Returns a list with the available agents without group.
336 337 338 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 336 def agents_by_no_group( = {}) get 'agents/no_group', end |
#all_agents(options = {}) ⇒ Array
Returns a list with the available agents.
25 26 27 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 25 def all_agents( = {}) offset_request('get', '/agents', ) end |
#create_group(group_id) ⇒ Object
Create a group Creates a new group.
290 291 292 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 290 def create_group(group_id) put "/agents/groups/#{group_id}" end |
#delete_agent(agent_id, options = {}) ⇒ Object
Delete an agent Removes an agent.
187 188 189 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 187 def delete_agent(agent_id, = {}) delete "/agents/#{agent_id}", end |
#delete_agent_by_group(ids) ⇒ Object
Delete a list of groups
245 246 247 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 245 def delete_agent_by_group(ids) delete '/agents/groups', {ids: ids} end |
#delete_agents(options = {}) ⇒ Object
Delete agents Removes agents, using a list of them or a criterion based on the status or time of the last connection.
201 202 203 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 201 def delete_agents( = {}) delete '/agents', end |
#distinct_fields_in_agents(options = {}) ⇒ Object
Returns all the different combinations that agents have for the selected fields. It also indicates the total number of agents that have each combination.
105 106 107 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 105 def distinct_fields_in_agents( = {}) get '/agents/stats/distinct', end |
#get_file_in_group(group_id, filename, options = {}) ⇒ Object
Get a file in group Returns the specified file belonging to the group parsed to JSON.
304 305 306 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 304 def get_file_in_group(group_id, filename, = {}) get "agents/groups/#{group_id}/files/#{filename}", end |
#group_configuration(group_id, options = {}) ⇒ Object
Get group configuration
346 347 348 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 346 def group_configuration(group_id, = {}) get "/agents/groups/#{group_id}/configuration", end |
#group_files(group_id, options = {}) ⇒ Object
Get group files Returns the files belonging to the group.
360 361 362 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 360 def group_files(group_id, = {}) get "/agents/groups/#{group_id}/files", end |
#groups(options = {}) ⇒ Object
Get groups Returns the list of existing agent groups.
373 374 375 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 373 def groups( = {}) get '/agents/groups', end |
#insert_agent(options = {}) ⇒ Object
Insert an agent with an existing id and key.
227 228 229 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 227 def insert_agent( = {}) post '/agents/insert', end |
#outdated_agents(options = {}) ⇒ Object
Returns the list of outdated agents.
120 121 122 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 120 def outdated_agents( = {}) get '/agents/outdated', end |
#remove_agent_of_group(agent_id, group_id) ⇒ Object
Remove a single group of an agent Remove the group of the agent but will leave the rest of its group if it belongs to a multigroup.
395 396 397 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 395 def remove_agent_of_group(agent_id, group_id) delete "/agents/#{agent_id}/group/#{group_id}" end |
#remove_agents_of_group(ids, groups) ⇒ Object
Remove a single group of multiple agents Remove a list of agents of a group.
405 406 407 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 405 def remove_agents_of_group(ids, groups) delete "/agents/group/#{group_id}", {ids: ids} end |
#remove_all_agent_of_group(agent_id) ⇒ Object
Remove all agent groups. Removes the group of the agent. The agent will automatically revert to the ‘default’ group.
414 415 416 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 414 def remove_all_agent_of_group(agent_id) delete "/agents/#{agent_id}/group" end |
#remove_group(group_id) ⇒ Object
Remove group Removes the group. Agents that were assigned to the removed group will automatically revert to the ‘default’ group.
423 424 425 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 423 def remove_group(group_id) delete "/agents/groups/#{group_id}" end |
#restart_agents(options = {}) ⇒ Object
Restarts a list of agents.
69 70 71 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 69 def restart_agents( = {}) post '/agents/restart', end |
#restart_all_agents ⇒ Object
Restarts all agents.
75 76 77 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 75 def restart_all_agents() put '/agents/restart' end |
#restart_an_agents(agent_id, options = {}) ⇒ Object
Restart an agent.
84 85 86 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 84 def restart_an_agents(agent_id, = {}) put "/agents/#{agent_id}/restart" end |
#update_group_ossec_configuration(group_id, config) ⇒ Object
Put configuration file (agent.conf) into a group Upload the group configuration (agent.conf).
383 384 385 386 387 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 383 def update_group_ossec_configuration(group_id, config) # post "/agents/groups/#{group_id}/configuration" # TODO : use Content-type: application/xml raise "This method not yet implement" end |
#upgrade_result_from_agent(agent_id, options = {}) ⇒ Object
Returns the upgrade result from an agent.
130 131 132 |
# File 'lib/wazuh/api/endpoints/agents.rb', line 130 def upgrade_result_from_agent(agent_id, = {}) get "/agents/#{agent_id}/upgrade_result", end |