Revision dad708b4 docs/dev-guide.rst

b/docs/dev-guide.rst
44 44
Storage API (Pithos+)
45 45
=====================
46 46

  
47
This is the Pithos+ File Storage API:
47
This is the Pithos+ Object Storage API:
48 48

  
49 49
.. toctree::
50 50
   :maxdepth: 2
51 51

  
52
   File Storage API <pithos-api-guide>
52
   Object Storage API <pithos-api-guide>
53 53

  
54 54
Implementing new clients
55 55
========================
......
218 218
 * Updating a state (either local or remote) implies downloading, uploading or
219 219
   deleting the appropriate file.
220 220

  
221
Recommended Practices and Examples
222
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
223

  
224
Assuming an authentication token is obtained, the following high-level
225
operations are available - shown with ``curl``:
226

  
227
* Get account information ::
228

  
229
    curl -X HEAD -D - \
230
         -H "X-Auth-Token: 0000" \
231
         https://pithos.dev.grnet.gr/v1/user
232

  
233
* List available containers ::
234

  
235
    curl -X GET -D - \
236
         -H "X-Auth-Token: 0000" \
237
         https://pithos.dev.grnet.gr/v1/user
238

  
239
* Get container information ::
240

  
241
    curl -X HEAD -D - \
242
         -H "X-Auth-Token: 0000" \
243
         https://pithos.dev.grnet.gr/v1/user/pithos
244

  
245
* Add a new container ::
246

  
247
    curl -X PUT -D - \
248
         -H "X-Auth-Token: 0000" \
249
         https://pithos.dev.grnet.gr/v1/user/test
250

  
251
* Delete a container ::
252

  
253
    curl -X DELETE -D - \
254
         -H "X-Auth-Token: 0000" \
255
         https://pithos.dev.grnet.gr/v1/user/test
256

  
257
* List objects in a container ::
258

  
259
    curl -X GET -D - \
260
         -H "X-Auth-Token: 0000" \
261
         https://pithos.dev.grnet.gr/v1/user/pithos
262

  
263
* List objects in a container (extended reply) ::
264

  
265
    curl -X GET -D - \
266
         -H "X-Auth-Token: 0000" \
267
         https://pithos.dev.grnet.gr/v1/user/pithos?format=json
268

  
269
  It is recommended that extended replies are cached and subsequent requests
270
  utilize the ``If-Modified-Since`` header.
271

  
272
* List metadata keys used by objects in a container
273

  
274
  Will be in the ``X-Container-Object-Meta`` reply header, included in
275
  container information or object list (``HEAD`` or ``GET``). (**TBD**)
276

  
277
* List objects in a container having a specific meta defined ::
278

  
279
    curl -X GET -D - \
280
         -H "X-Auth-Token: 0000" \
281
         https://pithos.dev.grnet.gr/v1/user/pithos?meta=favorites
282

  
283
* Retrieve an object ::
284

  
285
    curl -X GET -D - \
286
         -H "X-Auth-Token: 0000" \
287
         https://pithos.dev.grnet.gr/v1/user/pithos/README.txt
288

  
289
* Retrieve an object (specific ranges of data) ::
290

  
291
    curl -X GET -D - \
292
         -H "X-Auth-Token: 0000" \
293
         -H "Range: bytes=0-9" \
294
         https://pithos.dev.grnet.gr/v1/user/pithos/README.txt
295

  
296
  This will return the first 10 bytes. To get the first 10, bytes 30-39 and the
297
  last 100 use ``Range: bytes=0-9,30-39,-100``.
298

  
299
* Add a new object (folder type) (**TBD**) ::
300

  
301
    curl -X PUT -D - \
302
         -H "X-Auth-Token: 0000" \
303
         -H "Content-Type: application/directory" \
304
         https://pithos.dev.grnet.gr/v1/user/pithos/folder
305

  
306
* Add a new object ::
307

  
308
    curl -X PUT -D - \
309
         -H "X-Auth-Token: 0000" \
310
         -H "Content-Type: text/plain" \
311
         -T EXAMPLE.txt
312
         https://pithos.dev.grnet.gr/v1/user/pithos/folder/EXAMPLE.txt
313

  
314
* Update an object ::
315

  
316
    curl -X POST -D - \
317
         -H "X-Auth-Token: 0000" \
318
         -H "Content-Length: 10" \
319
         -H "Content-Type: application/octet-stream" \
320
         -H "Content-Range: bytes 10-19/*" \
321
         -d "0123456789" \
322
         https://pithos.dev.grnet.gr/v1/user/folder/EXAMPLE.txt
323

  
324
  This will update bytes 10-19 with the data specified.
325

  
326
* Update an object (append) ::
327

  
328
    curl -X POST -D - \
329
         -H "X-Auth-Token: 0000" \
330
         -H "Content-Length: 10" \
331
         -H "Content-Type: application/octet-stream" \
332
         -H "Content-Range: bytes */*" \
333
         -d "0123456789" \
334
         https://pithos.dev.grnet.gr/v1/user/folder/EXAMPLE.txt
335

  
336
* Update an object (truncate) ::
337

  
338
    curl -X POST -D - \
339
         -H "X-Auth-Token: 0000" \
340
         -H "X-Source-Object: /folder/EXAMPLE.txt" \
341
         -H "Content-Range: bytes 0-0/*" \
342
         -H "X-Object-Bytes: 0" \
343
         https://pithos.dev.grnet.gr/v1/user/folder/EXAMPLE.txt
344

  
345
  This will truncate the object to 0 bytes.
346

  
347
* Add object metadata ::
348

  
349
    curl -X POST -D - \
350
         -H "X-Auth-Token: 0000" \
351
         -H "X-Object-Meta-First: first_meta_value" \
352
         -H "X-Object-Meta-Second: second_meta_value" \
353
         https://pithos.dev.grnet.gr/v1/user/folder/EXAMPLE.txt
354

  
355
* Delete object metadata ::
356

  
357
    curl -X POST -D - \
358
         -H "X-Auth-Token: 0000" \
359
         -H "X-Object-Meta-First: first_meta_value" \
360
         https://pithos.dev.grnet.gr/v1/user/folder/EXAMPLE.txt
361

  
362
  Metadata can only be "set". To delete ``X-Object-Meta-Second``, reset all
363
  metadata.
364

  
365
* Delete an object ::
366

  
367
    curl -X DELETE -D - \
368
         -H "X-Auth-Token: 0000" \
369
         https://pithos.dev.grnet.gr/v1/user/folder/EXAMPLE.txt
370

  

Also available in: Unified diff