-
Notifications
You must be signed in to change notification settings - Fork 2
Log entry & remote inductions implementation #3
Comments
If we take JSON POSTed for log entries and inductions, do we need to/should we take canuse requests as JSON as well?
|
Given we won't be making a POST request (presumably, as we're not creating new data only getting existing stuff) to the If it makes things easier we could look at changing this? |
If it's OK as is then it can stay :) |
Fulfils part of leedshackspace#3 Returns 201 CREATED for a successful log insertion, and tries to return a sane error message (for debugging client side) when there is a problem, as well as an appropriate HTTP status code.
Fulfils part of leedshackspace#3 Returns 201 CREATED for a successful log insertion, and tries to return a sane error message (for debugging client side) when there is a problem, as well as an appropriate HTTP status code.
If you'd like to keep the API close to RESTful principles, for the
If you wanted it to be even more RESTful, you could model your permissions as a subresource of the machine, and define the URL as follows:
This would return a 200 OK if the card had any permissions defined (and return details of those permissions), and a 404 if there were no permissions defined for the card. You could then add somebody as an inductee by POSTing to the same endpoint (and if the inductor card ID wasn't permitted, a 403) |
Perhaps the "log" implementation could be as follows, with JSON POSTed to a new flask endpoint?
The server assumes that the start time is x seconds prior to the submission time, to simplify the node programming (it's expected the Python server will know the time, but it's more of a pain to get time from NTP on the access node).
It would follow that the new permissions (from the induction) would be similar:
Where inductor-card-uid is the UID of a card which is canInduct = true and inductee-card-uid is presumably a UID of a card which is canUse = false for the current machine. Return 200 for all OK and inserted, or another status code for a failure? 403, "user cannot induct on this machine" for example.
The python side would create a new entry in the user table if it doesn't exist, with a generic username. Perhaps this can in future be updated from SPACEDATA.
The text was updated successfully, but these errors were encountered: