Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add request to retrieve agents information by name #42

Merged
merged 1 commit into from
Dec 20, 2017

Conversation

mgmacias95
Copy link
Contributor

Hello,

In this PR I implement the API call requested in issue #24: GET/agents/name/:agent_name. With this new API call, the user will be able to retrieve agent information by its name:

$ curl -u foo:bar -k http://127.0.0.1:55000/agents?pretty
{
   "error": 0,
   "data": {
      "totalItems": 2,
      "items": [
         {
            "status": "Active",
            "name": "node01",
            "ip": "127.0.0.1",
            "dateAdd": "2017-12-05 09:46:17",
            "version": "Wazuh v3.1.0-alpha1",
            "manager_host": "node01",
            "os": {
               "platform": "centos",
               "version": "7",
               "name": "CentOS Linux"
            },
            "id": "000"
         },
         {
            "status": "Active",
            "name": "centos",
            "ip": "192.168.56.105",
            "dateAdd": "2017-12-05 09:46:17",
            "version": "Wazuh v3.0.0-rc2",
            "manager_host": "node01",
            "os": {
               "platform": "centos",
               "version": "7",
               "name": "CentOS Linux"
            },
            "id": "001"
         }
      ]
   }
}
$ curl -u foo:bar -k http://127.0.0.1:55000/agents/name/centos?pretty
{
   "error": 0,
   "data": {
      "status": "Active",
      "group": "default",
      "name": "centos",
      "ip": "192.168.56.105",
      "dateAdd": "2017-12-05 09:46:17",
      "version": "Wazuh v3.0.0-rc2",
      "manager_host": "node01",
      "lastKeepAlive": "2017-12-05 09:42:43",
      "os": {
         "major": "7",
         "name": "CentOS Linux",
         "uname": "Linux manager 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64",
         "platform": "centos",
         "version": "7",
         "codename": "Core",
         "arch": "x86_64"
      },
      "id": "001"
   }
}
$ curl -u foo:bar -k http://127.0.0.1:55000/agents/name/node01?pretty
{
   "error": 0,
   "data": {
      "status": "Active",
      "name": "node01",
      "ip": "127.0.0.1",
      "dateAdd": "2017-12-05 09:46:17",
      "version": "Wazuh v3.1.0-alpha1",
      "manager_host": "node01",
      "lastKeepAlive": "9999-12-31 23:59:59",
      "os": {
         "major": "7",
         "name": "CentOS Linux",
         "uname": "Linux node01 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64",
         "platform": "centos",
         "version": "7",
         "codename": "Core",
         "arch": "x86_64"
      },
      "id": "000"
   }
}

It's also possible to select fields to be returned, just like the GET/agents/:agent_id request:

# curl -u foo:bar -k "http://127.0.0.1:55000/agents/name/node01?pretty&select=os_platform,id"
{
   "error": 0,
   "data": {
      "os": {
         "platform": "centos"
      },
      "id": "000"
   }
}
# curl -u foo:bar -k "http://127.0.0.1:55000/agents/name/centos?pretty&select=id,group"
{
   "error": 0,
   "data": {
      "group": "default",
      "id": "001"
   }
}

Best regards,
Marta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant