Farmbot-Web-App/batch_updates.md

78 lines
2.4 KiB
Markdown
Raw Permalink Normal View History

2018-07-10 07:31:25 -06:00
# Support Table
Not all resources support the experimental resource API.
2018-07-18 09:13:21 -06:00
|Resource | Delete | Update / Insert|
|-----------------------|---------|----------------|
| FarmEvent | :heart: | :broken_heart: |
| FarmwareInstallation | :heart: | :broken_heart: |
| Image | :heart: | :broken_heart: |
| Log | :heart: | :broken_heart: |
| Peripheral | :heart: | :broken_heart: |
| PinBinding | :heart: | :broken_heart: |
| PlantTemplate | :heart: | :broken_heart: |
| Point | :heart: | :broken_heart: |
| Regimen | :heart: | :broken_heart: |
| SavedGarden | :heart: | :broken_heart: |
| Sensor | :heart: | :broken_heart: |
| SensorReading | :heart: | :broken_heart: |
| Sequence | :heart: | :broken_heart: |
| Tool | :heart: | :broken_heart: |
| WebcamFeed | :heart: | :broken_heart: |
# Step 1: Send the Update
2018-07-18 09:13:21 -06:00
Send an MQTT message in the format of:
```
bot/device_<id>/resources_v0/<action>/<resource type>/<Transaction UUID>/<resource_id or 0>
```
2018-07-18 09:13:21 -06:00
Example 1-1:
2018-07-10 07:31:25 -06:00
```
2018-07-18 09:13:21 -06:00
bot/device_3/resources_v0/destroy/Sequence/2/123-456
2018-07-10 07:31:25 -06:00
```
2018-07-18 09:13:21 -06:00
NOTES:
2018-07-18 09:13:21 -06:00
* `<Transaction UUID>` can be any user defined string. Ensure that the string is unique. We recommend using UUIDs.
* `<resource_id>` This is the `.id` property of the resource you are deleting.
2018-07-18 11:46:10 -06:00
* `<action>` Only `destroy` is supported as of July 2018.
2018-07-18 09:13:21 -06:00
* `<resource type>` See "resource" column of table above. **Case sensitive**.
**For deletion messages** the body of the message is unimportant and is discarded by the server.
2018-07-24 07:04:40 -06:00
# Step 2(A): Handle Failure
2018-07-18 09:13:21 -06:00
If your message is malformed or the server was unable to complete the request, you will receive an error message on the following MQTT channel:
```
2018-07-24 07:04:40 -06:00
bot/device_<id>/from_api
2018-07-18 09:13:21 -06:00
```
The message will take the same format as RPC errors:
```
{
"kind": "rpc_error",
"args": { "label": "THE UUID YOU GAVE THE SERVER" },
"body": [
{
"kind": "explanation",
"args": { "message": "Human readable explanation message" }
}
]
}
```
2018-07-24 07:04:40 -06:00
# Step 2(B): Handle Success
If successful, an `rpc_ok` CeleryScript node will be streamed to the following MQTT channel:
```
bot/device_<id>/from_api
```
**This is not a JSON resource.** It is merely an indication that the server has accepted the request and processed it. The resource itself will be streamed over the `auto_sync`* channel.