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), 409 (Conflict), 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]?lastEdit=[n] to save a file, with the file contents as the PUT body. subdirectories will be created as needed. If the lastEdit parameter is excluded, the request will only succeed if the file is *not* open for editing. Otherwise, the lastEdit parameter must include the number of the last edit received by the client at the time the save was requested.
- DELETE /file/[path] to delete a file. file must not be open by anyone.
- POST /file/close/[path] to mark the file closed. The server will discard your edit history.
- GET /file/listopen/ to list open files for the current user. a JSON dictionary of { project: { filename: mode } } will be returned. For example, if subdir1/subdir2/test.py is open read/write, openfiles will return { "subdir1": { "somedir2/test.py": "rw" } }
Settings
- GET /settings/ to list all settings for currently logged in user as json dict
- GET /settings/[setting] to get the value for a single setting as json string
- POST /settings/ with HTTP POST DATA (in standard form post syntax) to set the value for a collection of settings (all values are strings)
- DELETE /settings/[setting] to delete a single setting