Skip to content

Commit

Permalink
add docs for things
Browse files Browse the repository at this point in the history
  • Loading branch information
luto committed Feb 24, 2024
1 parent f6629c7 commit 95c9292
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions docs/THINGS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Things

MOS allows admins to maintain a list of Things (=devices, machines, permissions, ...)
and attach uses to them, e.g. user "ripper" is allowed to use thing "laser".
Additionally, things may report being used, e.g. "ripper" used "laser" for 60
seconds.

## Auth

Most endpoints require authentication. Ask Vorstand for a token and provide it
in the `X-TOKEN` header.

## Getting key IDs allowed to operate a Thing

```
$ curl https://metalab.at/things/keys/prusaxl -H "X-TOKEN: XXX"
00-000000000001,luto
00-000000000002,ripper
```

## Reporting usage of a thing

```
$ curl https://metalab.at/things/usage/prusaxl -H "X-TOKEN: XXX" -XPOST -d 'user=luto&kind=LOGIN'
```

`kind` may be:

* `LOGIN`, user started using a machine
* `LOGOUT`, user stopped using a machine
* `USAGE_MEMBER`, user used the machine for X seconds, for a member
* `USAGE_NONMEMBER`, user used the machine for X seconds, for a non-member

Additionally, supply `usage_seconds=` for `USAGE_` kinds.

## Getting stats for a Thing

```
$ curl https://metalab.at/things/stats/laser
[["2024-02-24", 1], ["2024-02-24", 1]]
```

Format: `[[date of usage, usage in seconds],...]`.

0 comments on commit 95c9292

Please sign in to comment.