SC: 201
The following endpoint adds a paddock belonging to a user. This paddock is saved as an entry in the userPaddock table. The required parameters are as follows:
{
"name": "John's Paddock",
"userEmail": "john.smith@gmail.com"
}
The client must provide the name as well as the email that the paddock belongs to.
- The user belonging to this paddock does not exist
- The paddock already exists for a this user
- The user does not exist
- A string indicating that the paddock has been added
SC: 200
The following endpoint deletes a paddock belonging to a user. This paddock is removed as an entry in the userPaddock table. A paddockId is passed into the endpoint. This tells the endpoint what paddock to delete. The only required parameter is the paddockId. It is passed into the endpoint as a path parameter.
- The paddock being deleted does not exist
- The paddock is not empty (For a paddock to be deleted, all nodes belonging to it must also be deleted)
- A string indicating that the paddock has been deleted
SC: 200
The following endpoint returns all the nodes belonging to a paddock. The nodes are retrieved from the userNode table. paddockId is a mandatory parameter.
- The paddock does not exist
- A list of nodes (each node has a name and a nodeId)
SC: 200 The following endpoint edits the name of a paddock. This endpoint edits the name in the userPaddock table. The following JSON object is a mandatory parameter:
{
"paddockId": 0,
"newName": "string"
}
The client must provide the paddock that is being configured as well as the name it is being given.
Exceptions:
- The paddock does not exist
- The paddock name already exists for that user
SC: 201
The following endpoint adds a ph entry to the phData table. The bridge calls this endpoint by providing the following mandatory parameters:
{
"node_id": "fEecqJ",
"level1": 0,
"level2": 0,
"level3": 0,
"type": "moisture"
}
The bridge must provide a valid nodeId that exists in the nodeMan table. Furthermore the bridge must provide a ph value for all three levels.
Exceptions:
- The node does not exist
- The ph value is greater than 14 or less than 1
SC: 201
The following endpoint adds a moisture entry to the moistureData table. The bridge calls this endpoint by providing the following mandatory parameters:
{
"nodeId": "RFseQW",
"level1": 14,
"level2": 14,
"level3": 14
}
The bridge must provide a valid nodeId that exists in the nodeMan table. Furthermore the bridge must provide a moisture value for all three levels.
Exceptions:
- The node does not exist
- The moisture value is greater than 100 or less than 0
SC: 201
The following endpoint adds a bridge entry to the bridgeMan table. The endpoint gets the master firmware version from the S3 Bucket which contains all the master firmware information. The following mandatory parameters must be provided:
{
"bridgeId": "wRzkT0",
"apiKey": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
}
The computer that is operating firmware installation must provide a valid bridgeId, as well as a valid API key. Note: These parameters are saved in the processor's EEPROM memory.
Exceptions:
- The bridgeId already exists
SC: 200
The following endpoint edits the name of a bridge. The following mandatory parameters must be provided:
{
"bridgeId": "1YGTCO",
"userEmail": "user@example.com",
"name": "string"
}
The client must provide a valid bridgeId as well as an existing user, as well as a name.
Exceptions:
- The bridge name already exists for the following user
- The bridge does not exist
SC: 200
The following endpoint deletes a connection between a user and a bridge. A bridgeId must be provided as a path parameter to choose which bridge to delete. The bridgeId must be a valid bridgeId.
Exceptions:
- The bridge does not exist
- The bridge has not been assigned to a user.
SC: 200
The following endpoint get's all bridges belonging to a user. As a mandatory path parameter the user email must be provided.
Exceptions:
- The user does not exist
Returned:
- list of bridges (each bridge has a bridgeId, name and firmware software version)
The following endpoint creates a user account. The client must provide a user object:
{
"email": "user@example.com",
"first_name": "string",
"last_name": "string",
"password": "string"
}
Firstly the client must provide a users email, a name and a password. Then the endpoint hashes the password entered by the user. Then following this the account is added to the user table.
Exceptions:
- The user already exists
The following endpoint returns an API key to a user via the client interface. This API key is then provided as a header amongst all following request. If incorrect login credentials are brought forward then the API key is not returned. After following this the API key is added to the userKey table where it is stored to authenticate following requests. Finally the API Key is returned to the user.
The following mandatory JSON body must be provided:
{
"email": "user@example.com",
"password": "string"
}
Exceptions:
- Invalid user credentials
The following endpoint adds a bridge to a users account. The following mandatory parameter must be provided:
{
"bridgeId": "dmFNKU",
"userEmail": "user@example.com",
"name": "string"
}
The client must provide a valid bridgeId that is present within the bridgeMan table. Furthermore, the client must provide a users email and finnally a name to give the bridge.
Exceptions:
- The bridge stated in the request does not exist
- User does not exist
- The bridge has already been linked to the user
The following endpoint registers a node associated with a user. The endpoint adds this entry to the userNode table. This is the following mandatory parameters:
{
"node_id": "zJjvZH",
"name": "string",
"email": "user@example.com",
"controller_id": "5miqb7"
}
The client must provide a nodeId that is valid as well as representative of a actual node. It also must provide a valid email of a registered user.
Exceptions:
- The nodeId does not refer to a valid nodeId
- The user does not exist
- The paddock does'nt exist
- The node has already been assigned to a user
The following endpoint returns all paddocks belonging to a user. A mandatory email must be provided as a path parameter.
Exceptions:
- The email provided does not refer to a valid user
The following endpoint severs the connection between the user and the node.A nodeId must be provided as a path parameter.
Exceptions:
- The nodeId does not exist
- The nodeId has already been assigned to a user
THe following endpoint updates the name of a node that has been linked with a user. The following mandatory JSON object must be required:
{
"nodeId": "3WIRzU",
"name": "string"
}
The client must provide a valid nodeId that represents an existing node. Also the client must provide a name that is being used when updating the nodes name.
Exceptions:
- The node does not exist
The following endpoint configures a users firstname and lastname. The following JSON object must be provided:
{
"currEmail": "user@example.com",
"newFirstName": "string",
"newLastName": "string"
}
Exceptions:
- The user does not exist
The following endpoint aims to delete a user from the system. Additioanally, the endpoint deletes all assets that belong to the user such as nodes, paddocks, bridges and keys.
A userEmail field must be provided to inform the API which user to delete.
Exceptions:
- The user does not exist
The following endpoint retrieves the first and last names for a user. An email must provided as a mandatoryu parameter.
Exceptions:
- The user does not exist
The following endpoint adds a device to the nodeMan table.
Exceptions:
- The node already exists
The following endpoint get's either moisture or ph data depending on the request.
Exceptions:
- The node does not exist
- The node does not have an owner
The following endpoint downloads a version number from the S3 Bucket. This version number refers to the master firmware version.
Returns: float
The following endpoint downloads a firmware binary from the S3 Bucket. It is then given to the Bridge.
Returns: FileResponse
The following endpoint uploads a given file to the S3 Bucket.
The following endpoint updates the bridge sw version in the bridge man table.
Exceptions:
- The bridge does not exist
sudo apt update
sudo apt install python3 python3-venv
python3 -m venv venv