Labs/Bespin/ServerAPI: Difference between revisions
Jump to navigation
Jump to search
Bgalbraith (talk | contribs) |
Bgalbraith (talk | contribs) No edit summary |
||
Line 20: | Line 20: | ||
* GET /edit/reset/[path] blows away edits for a specific path | * GET /edit/reset/[path] blows away edits for a specific path | ||
* edit queue is wiped when file is saved. (otherwise someone GETting the file and edits has no way of knowing the original state of the file from which to start applying edit actions) | * edit queue is wiped when file is saved. (otherwise someone GETting the file and edits has no way of knowing the original state of the file from which to start applying edit actions) | ||
== Files == | |||
* GET /file/list/[path] gives a JSON list of files in the directory given by [path]. Path is relative to the projects directory. Directories will have "/" appended to their name. | |||
* GET /file/[path]?mode=[r|rw] to get the contents of a file. (raw text, not a JSON string!) if the file does not exist, an empty body will be returned; use list to determine if a file actually exists. the server will record you as having the file open with the given mode after this call. If mode is not specified, rw is used. | |||
* PUT /file/[path] to save a file, with the file contents as the PUT body. subdirectories will be created as needed. the file will NOT be marked closed until an explicit close call is made. | |||
* DELETE /file/[path] to delete a file. file must not be open by anyone. | |||
* POST (or GET) /file/close/[path] to mark the file closed. The server will discard your edit history. | |||
* GET /file/open/ to list open files. a JSON dictionary of {filename: {mode: [user names]}} will be returned. For example, if subdir1/subdir2/test.py is open readonly by bgalbs and read/write by jbellis, openfiles will return {"subdir1/subdir2/test.py": {"r": ["bgalbs"], "rw": ["jbellis"]}} |
Revision as of 18:23, 19 December 2008
This aims to document the Bespin server API. It is taken from the original Python prototype server and has been updated for the subsequent Java server.
Errors
- "You're not logged in, and this request requires you to be" errors will be HTTP 401 status codes
- Other errors will be HTTP 400 (Bad Request), 404 (Not Found), 500 (Internal Error), or 501 (Not Implemented) with an explanation string
Authentication
- POST (or GET) /register/login/username -- no password necessary
- POST (or GET) /register/logout/
- GET /register/ for debugging, it will tell you who it thinks you are logged in as
Editing
- GET /edit/list/[path] gives a JSON list of edit actions from the last save to the current edit pointer.
- GET /edit/recent/N/[path] gives a JSON list of edit actions, starting after N. edit/recent/1 would skip the first entry.
- PUT /edit/[path], with the serialized JSON object representing the action as the PUT body. (you can start sending do's before your first save.)
- GET /edit/reset/ blows away all edits
- GET /edit/reset/[path] blows away edits for a specific path
- edit queue is wiped when file is saved. (otherwise someone GETting the file and edits has no way of knowing the original state of the file from which to start applying edit actions)
Files
- GET /file/list/[path] gives a JSON list of files in the directory given by [path]. Path is relative to the projects directory. Directories will have "/" appended to their name.
- GET /file/[path]?mode=[r|rw] to get the contents of a file. (raw text, not a JSON string!) if the file does not exist, an empty body will be returned; use list to determine if a file actually exists. the server will record you as having the file open with the given mode after this call. If mode is not specified, rw is used.
- PUT /file/[path] to save a file, with the file contents as the PUT body. subdirectories will be created as needed. the file will NOT be marked closed until an explicit close call is made.
- DELETE /file/[path] to delete a file. file must not be open by anyone.
- POST (or GET) /file/close/[path] to mark the file closed. The server will discard your edit history.
- GET /file/open/ to list open files. a JSON dictionary of {filename: {mode: [user names]}} will be returned. For example, if subdir1/subdir2/test.py is open readonly by bgalbs and read/write by jbellis, openfiles will return {"subdir1/subdir2/test.py": {"r": ["bgalbs"], "rw": ["jbellis"]}}