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 API calls for multigroups #159

Merged
merged 4 commits into from
Sep 13, 2018
Merged

Add API calls for multigroups #159

merged 4 commits into from
Sep 13, 2018

Conversation

mgmacias95
Copy link
Contributor

Hi team,

This PR adds the following:

  • Parameter replace in PUT/agents/:agent_id/group/:group_id:
    • With replace parameter it replaces current agent group by group_id.
    • By default, it creates a multigroup with current agent group and group_id.
  • API call DELETE/agents/:agent_id/group/:group_id which removes group group_id from current agent's multigroup (or sets it to default if it belongs to a single one).

Example:

# curl -u foo:bar "localhost:55000/agents/groups?pretty"
{
   "error": 0,
   "data": {
      "totalItems": 2,
      "items": [
         {
            "count": 1,
            "mergedSum": "f1a9e24e02ba4cc5ea80a9d3feb3bb9a",
            "configSum": "ab73af41699f13fdd81903b5f23d8d00",
            "name": "default"
         },
         {
            "count": 0,
            "mergedSum": "0361f2c015a0fc2e6e7331789fd1cfee",
            "configSum": "ab73af41699f13fdd81903b5f23d8d00",
            "name": "dmz"
         }
      ]
   }
}
# curl -u foo:bar -XPUT "localhost:55000/agents/001/group/dmz?pretty&replace"
{
   "error": 0,
   "data": "Group 'dmz' set to agent '001'."
}
# curl -u foo:bar "localhost:55000/agents/groups?pretty"
{
   "error": 0,
   "data": {
      "totalItems": 2,
      "items": [
         {
            "count": 0,
            "mergedSum": "f1a9e24e02ba4cc5ea80a9d3feb3bb9a",
            "configSum": "ab73af41699f13fdd81903b5f23d8d00",
            "name": "default"
         },
         {
            "count": 1,
            "mergedSum": "0361f2c015a0fc2e6e7331789fd1cfee",
            "configSum": "ab73af41699f13fdd81903b5f23d8d00",
            "name": "dmz"
         }
      ]
   }
}
# curl -u foo:bar -XPUT "localhost:55000/agents/001/group/default?pretty"
{
   "error": 0,
   "data": "Group 'default' added to agent '001'."
}
# curl -u foo:bar "localhost:55000/agents/groups?pretty"
{
   "error": 0,
   "data": {
      "totalItems": 2,
      "items": [
         {
            "count": 1,
            "mergedSum": "f1a9e24e02ba4cc5ea80a9d3feb3bb9a",
            "configSum": "ab73af41699f13fdd81903b5f23d8d00",
            "name": "default"
         },
         {
            "count": 1,
            "mergedSum": "0361f2c015a0fc2e6e7331789fd1cfee",
            "configSum": "ab73af41699f13fdd81903b5f23d8d00",
            "name": "dmz"
         }
      ]
   }
}
# curl -u foo:bar -XDELETE "localhost:55000/agents/001/group/dmz?pretty"
{
   "error": 0,
   "data": "Group 'dmz' unset for agent '001'."
}
# curl -u foo:bar "localhost:55000/agents/groups?pretty"
{
   "error": 0,
   "data": {
      "totalItems": 2,
      "items": [
         {
            "count": 1,
            "mergedSum": "f1a9e24e02ba4cc5ea80a9d3feb3bb9a",
            "configSum": "ab73af41699f13fdd81903b5f23d8d00",
            "name": "default"
         },
         {
            "count": 0,
            "mergedSum": "0361f2c015a0fc2e6e7331789fd1cfee",
            "configSum": "ab73af41699f13fdd81903b5f23d8d00",
            "name": "dmz"
         }
      ]
   }
}

Best regards,
Marta

@mgmacias95 mgmacias95 changed the base branch from master to 3.7 September 13, 2018 06:24
@jesuslinares jesuslinares merged commit 28758fa into 3.7 Sep 13, 2018
@jesuslinares jesuslinares deleted the dev-3.7-multigroups-api branch September 13, 2018 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants