User

The Users of BuildingDepot have either of the two roles SuperUser and Default User through which we maintain the access control. The Super User is the admin of BuildingDepot who has permission to add,remove,read,write,delete any entity. The Default User has limited access and does not have permission to add,remove any building and dataservice related entity.Only the SuperUser can add another user and the SuperUser by default in every Building Depot installation is admin@buildingdepot.org. A new User can be added by the SuperUser in the CentralService at http://www.example.com:81/api/user.

Add a new User

This request creates a new User in the Central Service. Only the SuperUser can add a new user

POST /api/user
JSON Parameters:
  • first_name (string) – First Name of the User

  • last_name (string) – Last Name of the User

  • email (string) – email of the User

  • role (string) – role of the User * super (string) – super- Has access to all the entities in Building Depot * default (string) – default - limited access to entities in Building Depot

Returns:
  • success (string) – Returns ‘True’ if data is posted successfully otherwise ‘False’

  • error (string) – An additional value that will be present only if the request fails specifying the cause for failure

Status Codes:

Example request:

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

{
  "data":{
      "first_name": "New"
      "last_name":"User",
      "email":"newuser@gmail.com",
      "role":"super"
  }
}

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": "User already exists"
}

{
  "success": "False",
  "error": " Missing parameters"
}

{
  "success": "False",
  "error": " Missing data"
}

Get User Details

This request retrieves first name, last_name, email and role of the User specified in the request.

GET /api/user/<email>
Parameters:
  • email (string) – Email of the User

Returns:
  • success (string) – Returns ‘True’ if data is retrieved successfully otherwise ‘False’

  • first_name (string) – First Name of the User

  • last_name (string) – Last Name of the User

  • email (string) – Email of the User

  • role (string) – role of the User

Status Codes:

Example request:

GET /api/user/newuser@gmail.com HTTP/1.1
Accept: application/json; charset=utf-8

Example response:

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

{   "success": "True",
      "first_name": "New"
      "last_name":"User",
      "email":"newuser@gmail.com",
      "role":"super"
}

Example response (for failure):

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

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

Remove User

This request deletes the requested User from Building Depot.Only the Super user can delete the User in BuildingDepot.

DELETE /api/user/<email>
Parameters:
  • email (string) – email of the User

Returns:
  • success (string) – Returns ‘True’ if the User is successfully deleted otherwise ‘False’

Status Codes:

Example request:

DELETE /api/User/newuser@gmail.com HTTP/1.1
Accept: application/json; charset=utf-8

Example response:

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": " User does not exist"
}