Skip to content

Commit

Permalink
Merge pull request #112 from synergylabs/develop
Browse files Browse the repository at this point in the history
Updates the changes to BDv3.2.9 Documentation.
  • Loading branch information
sud335 authored Jul 12, 2021
2 parents cc3869f + c154704 commit 0c472bd
Show file tree
Hide file tree
Showing 45 changed files with 763 additions and 50 deletions.
86 changes: 56 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,69 @@ To install BD, run the install.sh script in the Installation folder. The default

1. Extract the package and cd into the folder**:

$ tar -xzf buildingdepot-3.#.#.tar.gz

$ cd buildingdepot-3.#.#/

```shell
$ tar -xzf buildingdepot-3.#.#.tar.gz
$ cd buildingdepot-3.#.#/
```

2. Run the installer (if running installer using sudo, please consider adding -H flag)

$ ./install.sh

```shell
$ ./install.sh
```
This will install BuildingDepot in the default installation location /srv/buildingdepot with the following directory structure:

buildingdepot
|-- CentralService - CentralService
|-- DataService - DataService
|-- CentralReplica - The central replica that is present at every DataService
+-- venv - Python Virtual Environment
- buildingdepot
- CentralService - CentralService
- DataService - DataService
- CentralReplica - The central replica that is present at every DataService
- venv - Python Virtual Environment

* Note:
This installer installs the BD DataService, CentralService, MongoDB, InfluxDB and Redis on the same machine.The installer also requires requires Mail Transfer Agent or use Gmail APIs. The installer has an optional requirement to use SSL certificates.

Upgrade to New BD Version
=========================
To updgrade to new version of BD for an existing installation,
run the upgrade_to_latest_BD.sh script in the scripts folder. The
default installation location is /srv.

1. Extract the new package and cd into the folder:

```shell
$ tar -xzf buildingdepot-3.#.#.tar.gz
$ cd buildingdepot-3.#.#/
```

2. cd into the scripts folder:
```shell
$ cd scripts/
```

3. Run the installer (if running installer using sudo, please consider adding -H flag)
```shell
$ ./install.sh
```

Configuration
=============

The BD Installer configures BD with some default values.

The CentralService can be accessed on port 81 and the DataService on port 82.

CentralService

To access the CentralService, go to

URL - https://<host>:81

DataService

To access the DataService, go to

URL - https://<host>:82

What's installed
===============
Expand Down Expand Up @@ -70,22 +114,4 @@ What's installed
* redis
* influxdb
* pymongo

Configuration
=============

The BD Installer configures BD with some default values.

The CentralService can be accessed on port 81 and the DataService on port 82.

CentralService

To access the CentralService, go to

URL - https://<host>:81

DataService

To access the DataService, go to

URL - https://<host>:82
* firebase-admin
2 changes: 1 addition & 1 deletion benchmarking-tools/functional-testing-tool/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 Shreyas Nagare
Copyright (c) 2021 Carnegie Mellon University

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
11 changes: 6 additions & 5 deletions buildingdepot/CentralService/app/rest_api/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@


def register_view(app_obj):

tagtype_view = tagtype.TagTypeService.as_view('tagtype_api')
# add/change tagtypes
app_obj.add_url_rule('/api/tagtype', view_func=tagtype_view, methods=['POST'])
Expand All @@ -29,7 +28,8 @@ def register_view(app_obj):
# post creates/modifies building templates
# get returns information on a specified building template.
# delete deletes the template
app_obj.add_url_rule('/api/template/<name>/tags', view_func=template_tagtypes_view, methods=['GET', 'DELETE', 'POST', 'PUT'])
app_obj.add_url_rule('/api/template/<name>/tags', view_func=template_tagtypes_view,
methods=['GET', 'DELETE', 'POST', 'PUT'])

building_view = building.BuildingService.as_view('building_api')
# post creates/modifies buildings
Expand All @@ -42,7 +42,8 @@ def register_view(app_obj):
# get a list of tags associated with a specified building
# post changes/adds tags to a specified building
# delete removes a tag from a specified building
app_obj.add_url_rule('/api/building/<building_name>/tags', view_func=building_tags_view, methods=['POST', 'GET', 'DELETE'])
app_obj.add_url_rule('/api/building/<building_name>/tags', view_func=building_tags_view,
methods=['POST', 'GET', 'DELETE'])

dataservice_view = dataservice.DataserviceService.as_view('dataservice_api')
# post changes/adds a data service to a central service
Expand Down Expand Up @@ -127,7 +128,8 @@ def register_view(app_obj):
# Push a notification to a mite owner that the user making this request wants permission to their mites
app_obj.add_url_rule('/api/permission/request', view_func=permission_request_view, methods=['GET', 'POST'])

permission_uuid_request_view = permission_uuid.PermissionRequestUUIDService.as_view('permission_request_uuid_service')
permission_uuid_request_view = permission_uuid.PermissionRequestUUIDService.as_view(
'permission_request_uuid_service')
# Get or create UUIDs for permission request RabbitMQ queues
app_obj.add_url_rule('/api/permission/request/uuid', view_func=permission_uuid_request_view, methods=['GET'])

Expand All @@ -143,7 +145,6 @@ def register_view(app_obj):
app_obj.add_url_rule('/api/user', view_func=users_view, methods=['POST'])
app_obj.add_url_rule('/api/user/<email>', view_func=users_view, methods=['GET', 'DELETE'])


notifications_view = notification.NotificationClientIdService.as_view('notification_client_id_service')
# Create, get or modify an ID used in the notification system
app_obj.add_url_rule('/api/notification/id', view_func=notifications_view, methods=['POST', 'PUT'])
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified buildingdepot/Documentation/build/doctrees/dataservice.doctree
Binary file not shown.
Binary file modified buildingdepot/Documentation/build/doctrees/environment.pickle
Binary file not shown.
Binary file modified buildingdepot/Documentation/build/doctrees/index.doctree
Binary file not shown.
Binary file modified buildingdepot/Documentation/build/doctrees/install.doctree
Binary file not shown.
Binary file modified buildingdepot/Documentation/build/doctrees/source/index.doctree
Binary file not shown.
2 changes: 1 addition & 1 deletion buildingdepot/Documentation/build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 49b10210519526625d27371a2e8b6a48
config: c6a7958682c2949e04c6169ca87cceed
tags: 645f666f9bcd5a90fca523b33c5a78b7
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ This OAuth token will have to be sent in the headers of all the requests made to
sensorgroup.rst
usergroup.rst
permission.rst
permissionRequests.rst
user.rst


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
.. CentralService API Documentation
Permission Requests
###################

A Permission Request can be sent to obtain access to a particular sensor entity owned by a user of BuildingDepot.
Once the permission request is sent to the user, on approval the Permission APIs should be used to create a permission
pair between the user and the sensor resources.
The Permissions are created between SensorGroups and UserGroups in Building Depot which come together to form the access control lists.
Here we select a User Group and a Sensor Group and a permission value with which we want to associate these both.
There are three levels of permission defined in BuildingDepot which are ‘d/r’ (deny read) ,’r’ (read), ‘r/w’ (read write) and 'r/w/p' (read write permission).
If there are multiple permission mappings between a user and a sensor then the one that is most restrictive is chosen.
Permissions can be defined in the CentralService at http://www.example.com:81/api/permission.
Note: Firebase or RabbitMQ needs to be installed during the BD installation for this to work.

Create Permission Requests
**************************

This request creates a new Permission Request for a sensor entity owned by a user.

.. http:post:: /api/permission/request
:JSON Parameters:
* **data** `(dictionary)` -- Contains the permission value for sensorgroup and usergroup
* **target_sensors** `(string)` -- List of Targeted sensors
* **timestamp** `(string)` -- Name of the user_group
* **permission** `(string)` -- Permission level
* **r** `(string)` -- Read - Will give read only access to the sensors
* **rw** `(string)` -- Read-Write - Will give read and write access to the sensors
* **dr** `(string)` -- Deny-read - Will deny any access to the sensors
* **rwp** `(string)` -- Read-Write-Permission - Highest level of permission that can be assigned. Will give read and write access to the sensors. In addition to this the user will be able to add/remove tags from the sensor.

: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 200: Success
:status 401: Unauthorized Credentials

.. compound::

**Example request**:

.. sourcecode:: http

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

{
"data":{
"target_sensors":[6cf53d24-e3a3-41bd-b2b5-8f109694f628, 6cf53d24-e3a3-41bd-b2b5-8f109694f629],
"timestamp":"1626105964",
"permission":"r"
}
}

**Example response** (for success):

.. sourcecode:: http

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

{
"success": "True"
}

**Example response** (for failure):

.. sourcecode:: http

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

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

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

{
"success": "False",
"error": " Permission value does not exist"
}

Read Permission Requests
************************

This request retrieves Permission Request for a user.

.. http:get:: /api/permission/request
:returns:
* **success** `(string)` -- Returns 'True' if a permission exists between the sensor and user group otherwise 'False'
* **permission_requests** `(string)` -- Contains the permission level that are attached to this SensorGroup and UserGroup

:status 200: Success
:status 401: Unauthorized Credentials

.. compound::

**Example request**:

.. sourcecode:: http

GET /api/permission/request HTTP/1.1
Accept: application/json; charset=utf-8

**Example response**:

.. sourcecode:: http

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

{
"success": "True"
"permission_requests": [{ "requester_name": Admin, "requester_email": [email protected], "requested_sensors": [6cf53d24-e3a3-41bd-b2b5-8f109694f628, 6cf53d24-e3a3-41bd-b2b5-8f109694f629] }]
}

**Example response** (for failure):

.. sourcecode:: http

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

{
"success": "False",
"error": " Permission Requests does not exist"
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
<li class="toctree-l2"><a class="reference internal" href="sensorgroup.html">SensorGroups</a></li>
<li class="toctree-l2"><a class="reference internal" href="usergroup.html">Usergroups</a></li>
<li class="toctree-l2"><a class="reference internal" href="permission.html">Permission</a></li>
<li class="toctree-l2"><a class="reference internal" href="permissionRequests.html">Permission Requests</a></li>
<li class="toctree-l2"><a class="reference internal" href="user.html">User</a></li>
</ul>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
<li class="toctree-l2"><a class="reference internal" href="sensorgroup.html">SensorGroups</a></li>
<li class="toctree-l2"><a class="reference internal" href="usergroup.html">Usergroups</a></li>
<li class="toctree-l2"><a class="reference internal" href="permission.html">Permission</a></li>
<li class="toctree-l2"><a class="reference internal" href="permissionRequests.html">Permission Requests</a></li>
<li class="toctree-l2"><a class="reference internal" href="user.html">User</a></li>
</ul>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
<li class="toctree-l2"><a class="reference internal" href="sensorgroup.html">SensorGroups</a></li>
<li class="toctree-l2"><a class="reference internal" href="usergroup.html">Usergroups</a></li>
<li class="toctree-l2"><a class="reference internal" href="permission.html">Permission</a></li>
<li class="toctree-l2"><a class="reference internal" href="permissionRequests.html">Permission Requests</a></li>
<li class="toctree-l2"><a class="reference internal" href="user.html">User</a></li>
</ul>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<li class="toctree-l2"><a class="reference internal" href="sensorgroup.html">SensorGroups</a></li>
<li class="toctree-l2"><a class="reference internal" href="usergroup.html">Usergroups</a></li>
<li class="toctree-l2"><a class="reference internal" href="permission.html">Permission</a></li>
<li class="toctree-l2"><a class="reference internal" href="permissionRequests.html">Permission Requests</a></li>
<li class="toctree-l2"><a class="reference internal" href="user.html">User</a></li>
</ul>
</li>
Expand Down Expand Up @@ -252,6 +253,11 @@ <h1>CentralService APIs<a class="headerlink" href="#centralservice-apis" title="
<li class="toctree-l2"><a class="reference internal" href="permission.html#delete-permission">Delete Permission</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="permissionRequests.html">Permission Requests</a><ul>
<li class="toctree-l2"><a class="reference internal" href="permissionRequests.html#create-permission-requests">Create Permission Requests</a></li>
<li class="toctree-l2"><a class="reference internal" href="permissionRequests.html#read-permission-requests">Read Permission Requests</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="user.html">User</a><ul>
<li class="toctree-l2"><a class="reference internal" href="user.html#add-a-new-user">Add a new User</a></li>
<li class="toctree-l2"><a class="reference internal" href="user.html#get-user-details">Get User Details</a></li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
<li class="toctree-l2"><a class="reference internal" href="sensorgroup.html">SensorGroups</a></li>
<li class="toctree-l2"><a class="reference internal" href="usergroup.html">Usergroups</a></li>
<li class="toctree-l2"><a class="reference internal" href="permission.html">Permission</a></li>
<li class="toctree-l2"><a class="reference internal" href="permissionRequests.html">Permission Requests</a></li>
<li class="toctree-l2"><a class="reference internal" href="user.html">User</a></li>
</ul>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<link rel="search" title="Search" href="../../search.html"/>
<link rel="top" title="BuildingDepot 3.2.9 documentation" href="../../index.html"/>
<link rel="up" title="CentralService APIs" href="index.html"/>
<link rel="next" title="User" href="user.html"/>
<link rel="next" title="Permission Requests" href="permissionRequests.html"/>
<link rel="prev" title="Usergroups" href="usergroup.html"/>


Expand Down Expand Up @@ -112,6 +112,7 @@
<li class="toctree-l3"><a class="reference internal" href="#delete-permission">Delete Permission</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="permissionRequests.html">Permission Requests</a></li>
<li class="toctree-l2"><a class="reference internal" href="user.html">User</a></li>
</ul>
</li>
Expand Down Expand Up @@ -363,7 +364,7 @@ <h2>Delete Permission<a class="headerlink" href="#delete-permission" title="Perm

<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">

<a href="user.html" class="btn btn-neutral float-right" title="User" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="permissionRequests.html" class="btn btn-neutral float-right" title="Permission Requests" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>


<a href="usergroup.html" class="btn btn-neutral" title="Usergroups" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
Expand Down
Loading

0 comments on commit 0c472bd

Please sign in to comment.