Usergroups

Usergroups are as the name suggests a group of users formed using the id’s with which they are registered in BuildingDepot. Usergroups when combined with SensorGroups help in bringing about the Access Control functions that BuildingDepot provides.UserGroups can be defined in the CentralService at http://www.example.com:81/api/usergroup.

Create UserGroup

This request creates a new UserGroup with the name and description as specified by the user.

Example request:

POST /api/user_group HTTP/1.1
Accept: application/json; charset=utf-8

{
  "data": {
          "name": "Test User Group",
          "description": "Description for User Group"
      }
}

Example response (for success):

HTTP/1.1 200 OK
Content-Type: application/json

{
  "success": "True"
}

Example response (for failure):

HTTP/1.1 200 OK
Content-Type: application/json

{
  "success": "False",
  "error": "No Name"
}

Get UserGroup Details

This request retrieves the details of a UserGroup

Example request:

GET /api/user_group/Test HTTP/1.1
Accept: application/json; charset=utf-8

Example response (for success):

HTTP/1.1 200 OK
Content-Type: application/json

{
  "success" : "true",
  "name":"Test",
  "description":"A UserGroup for Test"
}

Example response (for failure):

HTTP/1.1 200 OK
Content-Type: application/json

{
  "success": "False",
  "error": "Usergroup does not exist"
}

Delete UserGroup

This request deletes the UserGroup

Example request:

DELETE /api/user_group/<name> HTTP/1.1
Accept: application/json; charset=utf-8

Example response (for success):

HTTP/1.1 200 OK
Content-Type: application/json

{
  "success": "True"
}

Example response (for failure):

HTTP/1.1 200 OK
Content-Type: application/json

{
  "success": "False",
  "error": "Usergroup does not exist"
}

Add users to UserGroup

This request adds the users specified in the request to the usergroup

Note: The list of users sent in this request will overwrite the previous list

Example request:

POST /api/user_group/Test/users HTTP/1.1
Accept: application/json; charset=utf-8

{
  "data":{
      "users":[
           {
              "user_id":"synergy@gmail.com",
              "manager": true
           },
           {
              "user_id":"test@gmail.com",
              "manager": false
           }
         ]
  }
}

Example response (for success):

HTTP/1.1 200 OK
Content-Type: application/json

{
  "success": "True"
}

Example response (for failure):

HTTP/1.1 200 OK
Content-Type: application/json

{
  "success": "False",
  "error": "One or more users not registered"
}

Get list of users in UserGroup

This request retrieves the list of users that are in the specified UserGroup

Example request:

GET /api/user_group/Test/users HTTP/1.1
Accept: application/json; charset=utf-8

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "users": [
             {
                "user_id":"synergy@gmail.com",
                "manager": true
             },
             {
                "user_id":"test@gmail.com",
                "manager": false
             }
           ]
}