Labs/Bespin/ServerAPI: Difference between revisions

Line 24: Line 24:
== Files ==
== 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/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. The list is sorted. Each item in the list is an object with a "name" property. Additionally, the objects have the data described in the /file/stats/ call.
* GET /file/stats/[path] returns a JSON object with the stats for the file. Attributes on the object include size (integer of the file's size at last save), created (date/time of creation in YYYYMMDDTHHMMSS ISO format), modified (date/time of last save, in the same format as created), openedBy (list of usernames that currently have the file open).
* GET /file/at/[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.
* GET /file/at/[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/at/[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.
* PUT /file/at/[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.
canmove, Confirmed users, Bureaucrats and Sysops emeriti
1,093

edits