DataService

The DataService is where all the data related to sensors and the timeseries data of each sensor resides. All the access control related functionality is defined at centralservice is also enforced within the DataService. A new DataService can be defined in the CentralService at http://www.example.com:81/api/dataservice.

Create a new DataService

This request creates a new DataService with description,host and port where the datservice will function.

Example request:

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

{
  "data":{
      "name": "ds3"
      "description":"Test_ds3",
      "host":"127.0.0.3",
      "port":"83"
  }
}

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": " Missing parameters"
}

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

Get DataService Details

This request retrieves name, description, hostname and port to used in the dataservice specified in the request.

Example request:

GET /api/dataservice/ds3 HTTP/1.1
Accept: application/json; charset=utf-8

Example response:

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

{   "success": "True",
      "name": "ds3"
      "description":"Test_ds3",
      "host":"127.0.0.3",
      "port":"83"
}

Example response (for failure):

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

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

Delete DataService

This request deletes the requested DataService from Building Depot.

Example request:

DELETE /api/dataservice/ds3 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": "DataService doesn't exist"
}

{
  "success": "False",
  "error": "Cannot delete DataService, contains buildings."
}

Assign Buildings to DataService

This request assigns a specific building to DataService. Once the building is assigned to a specific DataService, the DataService handles sensor datastreams from the building.

Example request:

POST /api/dataservice/ds1/buildings HTTP/1.1
Accept: application/json; charset=utf-8


{
  "data":{
    "buildings": ["NSH"]
  }
}

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": " Missing parameters"
}

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

{
  "success": "False",
  "error": "DataService doesn't exist"
}

{
  "success": "False",
  "error": "One of the buildings doesn't exist"
}

Get Building Details from DataService

This request retrieves the names of buildings that the specified DataService hosts.

Example request:

GET /api/dataservice/ds1/buildings HTTP/1.1
Accept: application/json; charset=utf-8

Example response:

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

{
  "success": "True",
  "buildings": ["NSH", "GHC"]
}

Example response (for failure):

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

{
  "success": "False",
  "error": " DataService doesn't exist"
}

Remove Buildings from DataService

This request removes specified buildings from a DataService.

Example request:

DELETE /api/dataservice/ds1/buildings HTTP/1.1
Accept: application/json; charset=utf-8

{
  "data":{
    "buildings": ["NSH", "GHC"]
  }
}

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": "Missing parameters"
}

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

{
  "success": "False",
  "error": "DataService doesn't exist"
}

Grant Admin Privileges on DataService

This request grants CRUD (create/read/update/delete) privileges on the DataService to the specified users.

Example request:

POST /api/dataservice/ds1/admins HTTP/1.1
Accept: application/json; charset=utf-8

{
  "data":{
    "admins": ["user1@buildingdepot.org", "user2@buildingdepot.org"]
  }
}

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": " Missing parameters"
}

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

{
  "success": "False",
  "error": "DataService doesn't exist"
}

{
  "success": "False",
  "error": "One of the users doesn\'t exist"
}

Get List of Admins from DataService

This request retrieves the list of users who have the admin privileges on the specified DataService.

Example request:

GET /api/dataservice/ds1/buildings HTTP/1.1
Accept: application/json; charset=utf-8

Example response:

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

{
  "success": "True",
  "admins": ["user1@buildingdepot.org", "user2@buildingdepot.org"]
}

Example response (for failure):

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

{
  "success": "False",
  "error": " DataService doesn't exist"
}

Revoke Admin Privileges on DataService

This request revokes admin privileges on DataService from the specified users.

Example request:

DELETE /api/dataservice/ds1/admins HTTP/1.1
Accept: application/json; charset=utf-8

{
  "data":{
    "admins": ["user1@buildingdepot.org", "user2@buildingdepot.org"]
  }
}

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": "Missing parameters"
}

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

{
  "success": "False",
  "error": "DataService doesn't exist"
}