git clone --recursive https://github.com/mhep-transition/mhep-django
Or, if you've already cloned mhep-django
, run:
git submodule update --init --recursive
-
Install Vagrant 2.0.1+
-
Install Virtualbox 5.2.18
It should create a new Ubuntu 18.04 VM and configure everything.
With the vagrant box running, run:
vagrant ssh
Once connected to the box, simply run:
make run
This will start the Django server.
Browse to localhost:9090
An administrative interface is available at localhost:9090/admin, the username is localadmin
, password localadmin
- List assessments
- List assessments for organisation
- Get assessment
- Create assessment
- Create assessment for organisation
- Update a field on assessment
- Delete assessment
- List organisations
- List libraries
- Create a library
- Update a library
- Delete a library
- Create item in library
- Update item in library
- Delete item in library
All endpoints start with /api/v1
e.g. http://localhost:9090/api/v1/assessments/
.
GET /assessments/
List all assessments the current user has access to.
ℹ️ porting notes: replaces previous assessment/list
route.
GET /assessments/
Returns:
HTTP 200 OK
Content-Type: application/json
[
{
"id": "1",
"name": "Example assessment",
"description": "Example description",
"openbem_version": "10.1.1",
"status": "In progress",
"created_at": "2019-08-15T15:25:37.634182Z",
"updated_at": "2019-08-21T10:40:58.830425Z",
"author": "localadmin",
"userid": "1",
"mdate": "1566384058",
}
]
GET /organisations/:id/assessments/
List all assessments that belong to an organisation.
ℹ️ porting notes: replaces previous assessment/list
with orgid
param.
GET /organisations/1/assessments/
Returns:
HTTP 200 OK
Content-Type: application/json
[
{
"id": "1",
"name": "Example assessment",
"description": "Example description",
"openbem_version": "10.1.1",
"status": "In progress",
"created_at": "2019-08-15T15:25:37.634182Z",
"updated_at": "2019-08-21T10:40:58.830425Z",
"author": "localadmin",
"userid": "1",
"mdate": "1566384058",
}
]
GET /assessments/:id/
ℹ️ porting notes: replaces previous route assessment/get
> curl http://localhost:9090/api/v1/assessments/1
Returns:
HTTP 200 OK
Content-Type: application/json
{
"id": "1",
"name": "Example assessment",
"description": "Example description",
"openbem_version": "10.1.1",
"status": "In progress",
"created_at": "2019-08-15T15:25:37.634182Z",
"updated_at": "2019-08-21T10:40:58.830425Z",
"author": "localadmin",
"userid": "1",
"mdate": "1566384058",
"data": {
"master": {
"scenario_name": "Master",
"household": {
"3a_heatinghours_weekday_on1_hours": 6,
"3a_heatinghours_weekday_on1_mins": 45,
...
}
POST /assessments/
ℹ️ porting notes: replaces previous assessment/create
route.
> curl -v \
-H "Content-Type: application/json" \
http://localhost:9090/api/v1/assessments/ \
--data @- << EOF
{
"name": "Example assessment",
"description": "Example description",
"openbem_version": "10.1.1"
}
EOF
Returns:
HTTP 201 Created
Content-Type: application/json
{
"id": 6,
"name": "Example assesment",
"description": "Example description",
"openbem_version": "10.1.1",
"status": "In progress",
"created_at": "2019-06-01T16:35:34Z",
"updated_at": "2019-06-01T16:35:34Z",
"mdate": "1559406934",
"author": "janedoe",
"userid": "2",
}
POST /organisations/:id/assessments/
ℹ️ porting notes: replaces previous assessment/create
with org
param.
> curl -v \
-H "Content-Type: application/json" \
http://localhost:9090/api/v1/organisations/1/assessments/ \
--data @- << EOF
{
"name": "Example assessment",
"description": "Example description",
"openbem_version": "10.1.1"
}
EOF
Returns:
HTTP 201 Created
Content-Type: application/json
{
"id": 6,
"name": "Example assesment",
"description": "Example description",
"openbem_version": "10.1.1",
"status": "In progress",
"created_at": "2019-06-01T16:35:34Z",
"updated_at": "2019-06-01T16:35:34Z",
"mdate": "1559406934",
"author": "janedoe",
"userid": "2",
}
PATCH /assessments/:id/
Content-Type: application/json
ℹ️ porting notes: replaces previous routes:
assessment/setdata
assessment/setnameanddescription
assessment/setopenBEMversion
assessment/setstatus
> curl -v \
-X PATCH \
-H "Content-Type: application/json" \
http://localhost:9090/api/v1/assessments/1/ \
--data @- << EOF
{
"data": {
"master": {
"scenario_name": "Master",
"household": {
"3a_heatinghours_weekday_on1_hours": 6,
"3a_heatinghours_weekday_on1_mins": 45,
...
}
}
Returns:
HTTP 204 No content
> curl -v \
-X PATCH \
-H "Content-Type: application/json" \
http://localhost:9090/api/v1/assessments/1/ \
--data @- << EOF
{
"status": "Complete",
}
EOF
DELETE /assessments/:id/
ℹ️ porting notes: replaces previous assessment/delete
route.
> curl -v \
-X DELETE \
http://localhost:9090/api/v1/assessments/1/
Returns:
HTTP 204 No content
GET /organisations/
List all organisations the current user is a member of.
ℹ️ porting notes: replaces previous assessment/getorganisations
route.
GET /organisations/
Returns:
HTTP 200 OK
Content-Type: application/json
[
{
"id": "1",
"name": "Chigley Community Energy",
"assessments": 0,
"members": [
{
"userid": "2",
"name": "janedoe",
"last_active": "2019-06-03T16:35:00+00:00"
}
]
},
{
"id": "2",
"name": "Sandford Assessment CIC",
"assessments": 1,
"members": [
{
"userid": "2",
"name": "janedoe",
"last_login": "2019-06-03T16:35:00+00:00"
},
{
"userid": "3",
"name": "michael2",
"last_login": "2019-06-03T16:35:00+00:00"
}
]
}
]
GET /libraries/
List all libraries and their library items that belong to me.
ℹ️ porting notes: replaces previous route assessment/loaduserlibraries
"writeable": True
hardcoded
> curl http://localhost:9090/api/v1/libraries/
Returns:
HTTP 200 OK
Content-Type: application/json
[
{
"id": 1,
"name": "StandardLibrary - localadmin",
"type": "elements",
"items": {
"SWU_01": {
"tags": ["Wall"],
"name": "225mm uninsulated brick wall",
"description": "225mm uninslated solid brick wall, plaster internally",
"location": "",
"source": "Salford University on site monitoring\/ SAP table 1e, p.195",
"uvalue": 1.9,
"kvalue": 135,
"g": 0,
"gL": 0,
"ff": 0
},
"SWU_02": {
"tags": ["Wall"],
"name": "some other type of wall",
"description": "with another description",
"location": "",
"source": "Salford University on site monitoring\/ SAP table 1e, p.195",
"uvalue": 1.9,
"kvalue": 135,
"g": 0,
"gL": 0,
"ff": 0
}
}
},
{
"name": "StandardLibrary - localadmin",
"type": "draught_proofing_measures",
"items": {
"DP_01": {
"name": "Basic Draught-proofing Measures",
"q50": 12,
"description": "This may include DIY draught-proofing measures to doors...",
"performance": "Dependent on existing. 8-12 ...",
"maintenance": "Minimal. Ensure any draught-proofing strips are replaced..."
},
"DP_02": {
"name": "Another draught proofing measure",
"q50": 12,
"description": "This may include DIY draught-proofing measures to doors...",
"performance": "Dependent on existing. 8-12 ...",
"maintenance": "Minimal. Ensure any draught-proofing strips are replaced..."
}
}
}
]
POST /libraries/
ℹ️ porting notes: replaces previous assessment/newlibrary
route. It can also add data in a
single request, where the previous route required the subsequent use of savelibrary
> curl -v \
-H "Content-Type: application/json" \
http://localhost:9090/api/v1/libraries/ \
--data @- << EOF
{
"name": "StandardLibrary - user",
"type": "draught_proofing_measures",
"data": {
"DP_01": {
"name": "Basic Draught-proofing Measures",
"q50": 12,
"description": "This may include DIY draught-proofing measures to doors...",
"performance": "Dependent on existing. 8-12 ...",
"maintenance": "Minimal. Ensure any draught-proofing strips are replaced..."
},
"DP_02": {
"name": "Another draught proofing measure",
"q50": 12,
"description": "This may include DIY draught-proofing measures to doors...",
"performance": "Dependent on existing. 8-12 ...",
"maintenance": "Minimal. Ensure any draught-proofing strips are replaced..."
}
}
Returns:
HTTP 204 No content
PATCH /libraries/:id/
Content-Type: application/json
ℹ️ porting notes: replaces previous assessment/savelibrary
route.
> curl -v \
-X PATCH \
-H "Content-Type: application/json" \
http://localhost:9090/api/v1/libraries/1/ \
--data @- << EOF
{
"data": {},
}
EOF
Returns:
HTTP 204 No content
DELETE /librarys/:id/
ℹ️ porting notes: replaces previous assessment/deletelibrary
route.
> curl -v \
-X DELETE \
http://localhost:9090/api/v1/libraries/1/
Returns:
HTTP 204 HTTP 204 No content
POST /libraries/:id/items/
ℹ️ porting notes: replaces previous assessment/additemtolibrary
route.
> curl -v \
-H "Content-Type: application/json" \
http://localhost:9090/api/v1/libraries/1/items/ \
--data @- << EOF
{
"tag": "SWIN_04",
"item": {
"name": "100-140mm External Wall Insulation EWI on filled cavity wall.",
"source": "URBED/ SAP table 1e, p.195",
"uvalue": 0.15,
"kvalue": 110,
"tags": ["Wall"]
}
}
EOF
Returns:
HTTP 204 No content
PUT /libraries/:id/items/:tag/
ℹ️ porting notes: replaces previous assessment/edititeminlibrary
route.
> curl -v \
-X PUT \
-H "Content-Type: application/json" \
http://localhost:9090/api/v1/libraries/1/item/SWIN_04/ \
--data @- << EOF
{
"name": "100-140mm External Wall Insulation EWI on filled cavity wall.",
"source": "URBED/ SAP table 1e, p.195",
"uvalue": 0.15,
"kvalue": 110,
"tags": ["Wall"]
}
EOF
Returns:
HTTP 204 No content
DELETE /libraries/:id/items/:tag/
ℹ️ porting notes: replaces previous assessment/deletelibraryitem
route.
> curl -v -X DELETE \
http://localhost:9090/api/v1/libraries/1/item/SWIN_04/
Returns:
HTTP 204 No content
In this first release, where we have no concept of an organisation, the following endpoints have been hardcoded to return certain values.
GET /organisations/
List all organisations the logged in user is part of
ℹ️ porting notes: replaces previous assessment/getorganisations
route.
> curl http://localhost:9090/api/v1/organisations/
Returns:
HTTP 200 OK
Content-Type: application/json
[
{
"id": "1",
"name": "Carbon Coop",
"assessments": 0,
"members": [
{
"userid": "1",
"name": "localadmin",
"last_login": "2019-06-03T16:35:00+00:00"
}
]
}
]
POST /organisations/
ℹ️ porting notes: replaces previous assessment/neworganisation
route.
> curl -v \
-H "Content-Type: application/json" \
http://localhost:9090/api/v1/organisations/ \
--data @- << EOF
{
"name": "Example organisation"
}
EOF
Returns:
HTTP 400 Bad Request
Content-Type: application/json
{
"detail": "function not implemented"
}
GET /organisations/:id/assessments/
List all assessments belonging to the organisation.
ℹ️ porting notes: replaces previous assessment/list
route, passing orgid
.
> curl http://localhost:9090/api/v1/organisations/1/assessments/
Returns:
HTTP 200 OK
Content-Type: application/json
[]
POST /organisations/:id/assessments/
ℹ️ porting notes: replaces previous assessment/create
route, passing orgid
.
> curl -v \
-H "Content-Type: application/json" \
http://localhost:9090/api/v1/organisations/1/assessments/ \
--data @- << EOF
{
"name": "Example assessment",
"description": "Example description",
"openbem_version": "10.1.1"
}
EOF
Returns:
HTTP 400 Bad Request