Skip to content

Commit 0d9ad03

Browse files
kodek16accek
authored andcommitted
Added filetracker server API docs. (#43)
* Added filetracker server API docs. * Added link to README.md
1 parent 2692339 commit 0d9ad03

File tree

2 files changed

+99
-1
lines changed

2 files changed

+99
-1
lines changed

PROTOCOL.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Filetracker server API
2+
3+
Filetracker server (starting from version 2.0) provides a simple HTTP API for
4+
clients. Filetracker client is the primary consumer of this API, but its simplicity
5+
allows to interact with the server using plain `curl` or Python `requests`.
6+
7+
## API reference
8+
9+
### `GET /files/{path}`
10+
11+
Retrieves a file from the server saved under `{path}`. `{path}` should
12+
be a `/`-delimited sequence of alphanumeric words.
13+
14+
If the file doesn't exist, response will have status code 404.
15+
16+
May return the stream gzip-compressed, setting the appropriate
17+
`Content-Encoding: gzip` header.
18+
19+
Will set `Logical-Size` header to the logical size of the file, which is
20+
the size after decompression if `Content-Encoding: gzip` is set.
21+
22+
Will set `Last-Modified` header to the file modification time ("version")
23+
in RFC 2822 format.
24+
25+
### `HEAD /files/{path}`
26+
27+
Behaves the same as `GET`, but doesn't include the response body.
28+
29+
_CAUTION: some server implementations (notably migration server) may
30+
respond with 307 Temporary Redirect to HEAD requests. You should make sure
31+
to follow it, since this is not the default behavior in some HTTP clients._
32+
33+
### `PUT /files/{path}`
34+
35+
Uploads a file to to the server saving it under `{path}`.
36+
37+
File version must be specified in RFC 2822 format through
38+
`?last_modified=` query parameter. If the server has older file version,
39+
it will be overwritten. If the server has newer version, the operation will
40+
have no effect.
41+
42+
If the operation is successful, the response will have `Last-Modified`
43+
header set to the version of the file under `{path}` on the server
44+
after processing the request.
45+
46+
Payload should be compressed with gzip, and `Content-Encoding: gzip`
47+
header must be set if it is.
48+
49+
`SHA256-Checksum` header should be set to hexadecimal representation
50+
of SHA256 digest of file _before compression_.
51+
52+
`Logical-Size` header should be set to logical file size in bytes
53+
(before compression).
54+
55+
_NOTE: three headers above related to compression are optional, but
56+
performance may suffer if any of them is not set, so this should be only
57+
used while testing._
58+
59+
### `DELETE /files/{path}`
60+
61+
Deletes a file saved under `{path}` from the server.
62+
63+
File version must be specified in RFC 2822 format through
64+
`?last_modified=` query parameter. If the server has older file version,
65+
the file will be deleted. If the server has newer file version, the operation
66+
will have no effect.
67+
68+
If the file doesn't exist, response will have status code 404.
69+
70+
### Concurrency guarantees for the operations above
71+
72+
All single-file operations described above are guaranteed to be
73+
safe to perform concurrently.
74+
75+
Concurrent modifying operations on the same file may be performed in
76+
non-deterministic order, but it's guaranteed that no more that one
77+
modifying operation is performed on the same file at any point in time.
78+
79+
### `GET /list/{path}`
80+
81+
Retrieves a list of paths to all files saved under a directory
82+
(in the usual Unix sense), in no particular order, recursively visiting
83+
subdirectories.
84+
85+
The returned file paths are relative to `{path}` and do not contain leading
86+
slashes.
87+
88+
The response is plain-text, with one line for every file path.
89+
90+
Version cutoff must be specified in RFC 2822 format through
91+
`?last_modified=` query parameter. Only files with modification time
92+
older than this version will be listed.
93+
94+
If `Accepts` request header is set, the response format may be different.
95+
96+
__CAUTION:__ this operation is only guaranteed to return consistent
97+
results in concurrent scenarios if no modifications took place while it's
98+
running that would affect whether some file would appear on the list.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ A simple file storage module for distributed systems.
99
Filetracker has a client-server architecture: the server is the primary
1010
storage, and every client may have its own cache. Client has a Python
1111
API, and can be also invoked from the shell. Interaction between client
12-
and server is based on a simple HTTP API (Filetracker protocol).
12+
and server is based on a simple HTTP API ([Filetracker protocol](PROTOCOL.md)).
1313

1414
Files are stored on the server compressed and deduplicated. A peculiar
1515
versioning scheme is supported: files are versioned by their modification

0 commit comments

Comments
 (0)