BuildingTemplate

Each building within BuildingDepot has a BuildingTemplate as a foundation. The BuildingTemplate helps define the structure of the building. The user has to assign a set of tags to the BuildingTemplate on creation which can be used later on for all the sensors within that building. BuildingTemplate can be defined in the CentralService at http://www.example.com:81/central/buildingtemplate.

Create a Building Template

This request creates a Building Template with the name, description and tagtypes to be used in the buildingtemplate specified by the user.

POST /api/template
JSON Parameters:
 
  • name (string) – Name of the BuildingTemplate
  • description (string) – Description for the BuildingTemplate
  • tag_types (list) – List of TagTypes available in system
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/template

{
  "data":{
      "name":"Test_Building_Template",
      "description":"New Building Template",
      "tag_types":["floor","room","corridor"]
  }
}

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 of the TagTypes doesn't exist"
}

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

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

Get BuildingTemplate Details

This request retrieves name, description and tagtypes used in the buildingtemplate specified in the request.

GET /api/template/<name>
Parameters:
  • name (string) – Name of the BuildingTemplate
Returns:
  • success (string) – Returns ‘True’ if data is retrieved successfully otherwise ‘False’
  • name (string) – Name of the BuildingTemplate
  • description (string) – Description for the BuildingTemplate
  • tag_types (list) – List of TagTypes assigned for the BuildingTemplate
Status Codes:

Example request:

GET /api/template/Test_Building_Template

Accept: application/json; charset=utf-8

Example response:

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

  {   "success": "True",
      "name": "Test_Building_Template",
      "description":"New Building Template",
      "tags": ["floor","room","corridor"]
  }

**Example response** (for failure):
HTTP/1.1 200 OK
Content-Type: application/json

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

Delete Building Template

This request deletes the requested BuildingTemplate and the Tagtypes assigned to it.

DELETE /api/template/<name>
Parameters:
  • name (string) – Name of the BuildingTemplate
Returns:
  • success (string) – Returns ‘True’ if the Building Template is successfully deleted otherwise ‘False’
Status Codes:

Example request:

DELETE /api/template/Test_Building_Template
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": " BuildingTemplate does not exist"
}

{
  "success": "False",
  "error": " BuildingTemplate is in use"
}