Open EvanSimpson opened 10 years ago
Granted if we are doing all this under a /api/
route, we might as well use Accept headers to denote distinguishing API versions.
Is /user/
also a JSON-based API?
router.get('/v1/tessels', Tessels.list); // list details for all of user's Tessels
The list of tessels should be exposed as part of a user's profile, if not user/me/tessels
.
// Remote control routes
router.put('/v1/run/:device_id', remote.run); // tessel run
router.put('/v1/push/:device_id', remote.push); // tessel push
router.get('/v1/listen/:device_id', remote.listen); // tessel listen
router.get('/v1/network/:device_id', remote.network); // tessel wifi -l
Pretty un REST-ful. I'd propose
PUT /v1/tessel/:device_id/code (with a flag for flash: true or flash: false)
GET /v1/tessel/:device_id/networks
GET /v1/tessel/:device_id/log (does this tail?)
Also, specify that :device_id
404 when not authenticated.
/user/
would be JSON, yes.
How would you propose distinguishing a run from a push?
The should /user/
be /api/user/
?
Run has flash=false and push has flash=true. Then there's a runimmediate=true attribute too maybe?
Also: http://www.lexicalscope.com/blog/2012/03/12/how-are-rest-apis-versioned/ and application/vnd.tessel.remote.v1
We can drop the /v1/
and put everything under /api/
I think run/push are deliberate enough that runimmediate would always be true.
Updated routes.
router.post('/api/user/tessel', Tessels.create); // create new remote Tessel
router.get('/api/user/tessel/:device_id', Tessels.details); // list details for one Tessel
router.put('/api/user/tessel/:device_id', Tessels.update); // update Tessel nickname/ allowed users
router.delete('/api/user/tessel/:device_id', Tessels.delete); // delete remote Tessel
All these should be /api/tessel
.
That's really overloading PUT and GET.
All of those should not be at /api/user/tessel/...
, but /api/tessel/...
.
Nevermind - see your other suggestions now.
Versioning is to be handled in the Accept Header.
Message protocol
Potential Command Codes
0x01 Push 0x02 Run 0x03 - 0x06 Reserved 0x07 Network status 0x08 Get logs 0x09 - 0xFF Reserved