Updated api reference
This commit is contained in:
parent
f7fefe300d
commit
96d86dae9e
144
README.md
144
README.md
|
@ -1,4 +1,4 @@
|
||||||
# setup
|
## setup
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cargo install sea-orm-cli
|
cargo install sea-orm-cli
|
||||||
|
@ -6,37 +6,119 @@ sea-orm-cli generate entity -o src/db/models # do this every time you edit the m
|
||||||
cargo build
|
cargo build
|
||||||
```
|
```
|
||||||
|
|
||||||
# api docs
|
## api docs
|
||||||
|
|
||||||
u-token = user token
|
u-token = user token
|
||||||
p-token = pc token
|
p-token = pc token
|
||||||
a-token = u-token or p-token
|
a-token = u-token or p-token
|
||||||
pid = cc:t pc id
|
pid = cc:t pc id
|
||||||
|
|
||||||
GET - /ws (nothing required on first req, see ws docs for more info)
|
| method | path | Description |
|
||||||
|
|--------|-----------------------------------|-------------------------------------------------------------------------|
|
||||||
|
| GET | /ws | nothing required on first req, see ws docs for more info |
|
||||||
|
| POST | /api/user/login | no token (duh), json body with email, pwd, returns json with token |
|
||||||
|
| POST | /api/user/add | u-token in header, json body with full user info |
|
||||||
|
| POST | /api/user/:id/edit | u-token in header, json body with data to replace with |
|
||||||
|
| POST | /api/user/:id/remove | u-token in header, no body required |
|
||||||
|
| GET | /api/user/:id/info | u-token in header, get back json |
|
||||||
|
| GET | /api/cct/ | a-token in header, gets a list of all groups |
|
||||||
|
| GET | /api/cct/:group/ | a-token in header, gets a list of all pid's |
|
||||||
|
| GET | /api/cct/:group/:pid/ | a-token in header, gets a list of all values for that pc |
|
||||||
|
| GET | /api/cct/:group/:pid/:val | a-token in header, gets a value from a pc in a group |
|
||||||
|
| POST | /api/cct/group/add | a-token in header, adds a group |
|
||||||
|
| POST | /api/cct/:group/edit | a-token in header, edits a group |
|
||||||
|
| POST | /api/cct/:group/pc/add | a-token in header, adds a pc to a group |
|
||||||
|
| POST | /api/cct/:group/:pid/edit | a-token in header, edits a pc in a group |
|
||||||
|
| POST | /api/cct/:group/:pid/val/add | a-token in header, adds a value to a pc in a group |
|
||||||
|
| POST | /api/cct/:group/:pid/:val/edit | a-token in header, edits value info in a pc in a group |
|
||||||
|
| POST | /api/cct/:group/:pid/:val/set | a-token in header, sets a value in a pc in a group |
|
||||||
|
|
||||||
POST - /api/user/login (no token (duh), json body with email, pwd, returns json with token)
|
### returned json examples
|
||||||
POST - /api/user/add (u-token in header, json body with full user info)
|
|
||||||
POST - /api/user/:id/edit (u-token in header, json body with data to replace with)
|
|
||||||
POST - /api/user/:id/remove (u-token in header, no body required)
|
|
||||||
GET - /api/user/:id/info (u-token in header, get back json)
|
|
||||||
|
|
||||||
GET - /api/cct/ (a-token in header, gets a list of all groups)
|
- POST /api/user/login
|
||||||
GET - /api/cct/:group/ (a-token in header, gets a list of all pid's)
|
|
||||||
GET - /api/cct/:group/:pid/ (a-token in header, gets a list of all values for that pc)
|
|
||||||
GET - /api/cct/:group/:pid/:val (a-token in header, gets a value from a pc in a group)
|
|
||||||
|
|
||||||
POST - /api/cct/group/add (a-token in header, adds a group)
|
```json
|
||||||
POST - /api/cct/:group/edit (a-token in header, edits a group)
|
{
|
||||||
POST - /api/cct/:group/pc/add (a-token in header, adds a pc to a group)
|
"email": "mcorange@mcorangehq.xyz",
|
||||||
POST - /api/cct/:group/:pid/edit (a-token in header, edits a pc in a group)
|
"password_hash": "rdARTRGFDs"
|
||||||
POST - /api/cct/:group/:pid/val/add (a-token in header, adds a value to a pc in a group)
|
}
|
||||||
POST - /api/cct/:group/:pid/:val/edit (a-token in header, edits value info in a pc in a group)
|
```
|
||||||
POST - /api/cct/:group/:pid/:val/set (a-token in header, sets a value in a pc in a group)
|
|
||||||
|
|
||||||
==========
|
returns:
|
||||||
ws
|
|
||||||
==========
|
```json
|
||||||
|
{
|
||||||
|
"token": "677c4ae4-5c8f-41a7-9ee1-880e3a4305b7",
|
||||||
|
"valid_until": "1730652061630495114", // TODO: not yet implemented
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- GET /api/user/:id/info
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"id": "3536719e-f0cf-44ce-b4d2-3400bba0c220",
|
||||||
|
"username": "MCorange",
|
||||||
|
"email": "mcorange@mcorangehq.xyz",
|
||||||
|
"is_administrator": true,
|
||||||
|
"created_at": "1730651496386373948", // nanoseconds
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- GET /api/cct/
|
||||||
|
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id": "3536719e-f0cf-44ce-b4d2-3400bba0c220",
|
||||||
|
"name": "Keypad",
|
||||||
|
"available_actions": "{\"restart\":{\"lua_command\": \"os.restart()\"}}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
- GET /api/cct/:group/
|
||||||
|
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id": "ea6608dd-5c03-4af8-93e7-3eddd15decbe",
|
||||||
|
"name": "Autocrafter Access Door",
|
||||||
|
"group": "3536719e-f0cf-44ce-b4d2-3400bba0c220",
|
||||||
|
"type": "Keypad",
|
||||||
|
"access_token": "f2ae4755-7a19-4a4e-9f24-b4bfd5a6f588",
|
||||||
|
"created_at": "1730652061630495114"
|
||||||
|
},
|
||||||
|
...
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
- GET /api/cct/:group/:pid/
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"id": "ea6608dd-5c03-4af8-93e7-3eddd15decbe",
|
||||||
|
"name": "Autocrafter Access Door",
|
||||||
|
"group": "3536719e-f0cf-44ce-b4d2-3400bba0c220",
|
||||||
|
"type": "Keypad",
|
||||||
|
"access_token": "f2ae4755-7a19-4a4e-9f24-b4bfd5a6f588",
|
||||||
|
"created_at": "1730652061630495114",
|
||||||
|
"values": {
|
||||||
|
"times_opened": "34543"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
```
|
||||||
|
|
||||||
|
- GET /api/cct/:group/:pid/:val
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"times_opened": "23432"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## ws
|
||||||
|
|
||||||
`ws_msg_t`:
|
`ws_msg_t`:
|
||||||
0: heartbeat ping
|
0: heartbeat ping
|
||||||
|
@ -47,15 +129,15 @@ TODO!
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{ // low level message
|
{ // low level message
|
||||||
"ws_msg_t": 0, // `ws_msg_t`
|
"ws_msg_t": 2, // `ws_msg_t`
|
||||||
"ws_msg": { // high level message
|
"ws_msg": { // high level message
|
||||||
"auth": "Token", // Auth token
|
"auth": "3536719e-f0cf-44ce-b4d2-3400bba0c220", // Auth token
|
||||||
"msg": { // Data field
|
"msg": { // Data field
|
||||||
"keypad": {
|
"Keypad": {
|
||||||
"DoorOpenEv": { // "DataType": "Value, can be a struct or anything"
|
"DoorOpenEv": { // "DataType": "Value, can be a struct or anything"
|
||||||
"user": "uid",
|
"user": "3536719e-f0cf-44ce-b4d2-3400bba0c220",
|
||||||
"timestamp": 123456,
|
"timestamp": 123456,
|
||||||
"door_id": "1234-abcd-1234-abcd"
|
"door_id": "478fb503-dd05-4a1a-9292-8a5822dfed9d"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user