Statistics
| Branch: | Tag: | Revision:

root / docs / source / devguide.rst @ 104626e3

History | View | Annotate | Download (42 kB)

1
Pithos v2 Developer Guide
2
=========================
3

    
4
Introduction
5
------------
6

    
7
Pithos is a storage service implemented by GRNET (http://www.grnet.gr). Data is stored as objects, organized in containers, belonging to an account. This hierarchy of storage layers has been inspired by the OpenStack Object Storage (OOS) API and similar CloudFiles API by Rackspace. The Pithos API follows the OOS API as closely as possible. One of the design requirements has been to be able to use Pithos with clients built for the OOS, without changes.
8

    
9
However, to be able to take full advantage of the Pithos infrastructure, client software should be aware of the extensions that differentiate Pithos from OOS. Pithos objects can be updated, or appended to. Automatic version management, allows taking account and container listings back in time, as well as reading previous instances of objects.
10

    
11
The storage backend of Pithos is block oriented, permitting efficient, deduplicated data placement. The block structure of objects is exposed at the API layer, in order to encourage external software to implement advanced data management operations.
12

    
13
This document's goals are:
14

    
15
* Define the Pithos ReST API that allows the storage and retrieval of data and metadata via HTTP calls
16
* Specify metadata semantics and user interface guidelines for a common experience across client software implementations
17

    
18
The present document is meant to be read alongside the OOS API documentation. Thus, it is suggested that the reader is familiar with associated technologies, the OOS API as well as the first version of the Pithos API. This document refers to the second version of Pithos. Information on the first version of the storage API can be found at http://code.google.com/p/gss.
19

    
20
Whatever marked as to be determined (**TBD**), should not be considered by implementors.
21

    
22
Document Revisions
23
^^^^^^^^^^^^^^^^^^
24

    
25
=========================  ================================
26
Revision                   Description
27
=========================  ================================
28
0.4 (June 22, 2011)        Support updating/deleting individual metadata with ``POST``.
29
0.3 (June 14, 2011)        Large object support with ``X-Object-Manifest``.
30
\                          Allow for publicly available objects via ``https://hostname/public``.
31
\                          Support time-variant account/container listings. 
32
\                          Add source version when duplicating with PUT/COPY.
33
\                          Request version in object HEAD/GET requests (list versions with GET).
34
0.2 (May 31, 2011)         Add object meta listing and filtering in containers.
35
\                          Include underlying storage characteristics in container meta.
36
\                          Support for partial object updates through POST.
37
\                          Expose object hashmaps through GET.
38
\                          Support for multi-range object GET requests.
39
0.1 (May 17, 2011)         Initial release. Based on OpenStack Object Storage Developer Guide API v1 (Apr. 15, 2011).
40
=========================  ================================
41

    
42
The Pithos API
43
--------------
44

    
45
The URI requests supported by the Pithos API follow one of the following forms:
46

    
47
* Top level: ``https://hostname/v1/``
48
* Account level: ``https://hostname/v1/<account>``
49
* Container level: ``https://hostname/v1/<account>/<container>``
50
* Object level: ``https://hostname/v1/<account>/<container>/<object>``
51

    
52
All requests must include an ``X-Auth-Token``. The process of obtaining the token is still to be determined (**TBD**).
53

    
54
The allowable request operations and respective return codes per level are presented in the remainder of this chapter. Common to all requests are the following return codes.
55

    
56
=========================  ================================
57
Return Code                Description
58
=========================  ================================
59
400 (Bad Request)          The request is invalid
60
401 (Unauthorized)         Request not allowed
61
404 (Not Found)            The requested resource was not found
62
503 (Service Unavailable)  The request cannot be completed because of an internal error
63
=========================  ================================
64

    
65
Top Level
66
^^^^^^^^^
67

    
68
List of operations:
69

    
70
=========  ==================
71
Operation  Description
72
=========  ==================
73
GET        Authentication. This is kept for compatibility with the OOS API
74
=========  ==================
75

    
76
GET
77
"""
78

    
79
If the ``X-Auth-User`` and ``X-Auth-Key`` headers are given, a dummy ``X-Auth-Token`` and ``X-Storage-Url`` will be replied, which can be used as a guest token/namespace for testing Pithos.
80

    
81
================  =====================
82
Return Code       Description
83
================  =====================
84
204 (No Content)  The request succeeded
85
================  =====================
86

    
87

    
88
Account Level
89
^^^^^^^^^^^^^
90

    
91
List of operations:
92

    
93
=========  ==================
94
Operation  Description
95
=========  ==================
96
HEAD       Retrieve account metadata
97
GET        List containers
98
POST       Update account metadata
99
=========  ==================
100

    
101
HEAD
102
""""
103

    
104
======================  ===================================
105
Request Parameter Name  Value
106
======================  ===================================
107
until                   Optional timestamp
108
======================  ===================================
109

    
110
|
111

    
112
==========================  =====================
113
Reply Header Name           Value
114
==========================  =====================
115
X-Account-Container-Count   The total number of containers
116
X-Account-Object-Count      The total number of objects (**TBD**)
117
X-Account-Bytes-Used        The total number of bytes stored
118
X-Account-Bytes-Remaining   The total number of bytes remaining (**TBD**)
119
X-Account-Last-Login        The last login (**TBD**)
120
X-Account-Until-Timestamp   The last account modification date until the timestamp provided
121
X-Account-Meta-*            Optional user defined metadata
122
Last-Modified               The last account modification date (regardless of ``until``)
123
==========================  =====================
124

    
125
|
126

    
127
================  =====================
128
Return Code       Description
129
================  =====================
130
204 (No Content)  The request succeeded
131
================  =====================
132

    
133

    
134
GET
135
"""
136

    
137
====================  ===========================
138
Request Header Name   Value
139
====================  ===========================
140
If-Modified-Since     Retrieve if account has changed since provided timestamp
141
If-Unmodified-Since   Retrieve if account has not changed since provided timestamp
142
====================  ===========================
143

    
144
|
145

    
146
======================  =========================
147
Request Parameter Name  Value
148
======================  =========================
149
limit                   The amount of results requested (default is 10000)
150
marker                  Return containers with name lexicographically after marker
151
format                  Optional extended reply type (can be ``json`` or ``xml``)
152
until                   Optional timestamp
153
======================  =========================
154

    
155
The reply is a list of container names. Account headers (as in a ``HEAD`` request) will also be included.
156
If a ``format=xml`` or ``format=json`` argument is given, extended information on the containers will be returned, serialized in the chosen format.
157
For each container, the information will include all container metadata (names will be in lower case and with hyphens replaced with underscores):
158

    
159
===========================  ============================
160
Name                         Description
161
===========================  ============================
162
name                         The name of the container
163
count                        The number of objects inside the container
164
bytes                        The total size of the objects inside the container
165
last_modified                The last container modification date (regardless of ``until``)
166
x_container_until_timestamp  The last container modification date until the timestamp provided
167
x_container_meta_*           Optional user defined metadata
168
===========================  ============================
169

    
170
For examples of container details returned in JSON/XML formats refer to the OOS API documentation.
171

    
172
===========================  =====================
173
Return Code                  Description
174
===========================  =====================
175
200 (OK)                     The request succeeded
176
204 (No Content)             The account has no containers (only for non-extended replies)
177
304 (Not Modified)           The account has not been modified
178
412 (Precondition Failed)    The condition set can not be satisfied
179
===========================  =====================
180

    
181
Will use a ``200`` return code if the reply is of type json/xml.
182

    
183

    
184
POST
185
""""
186

    
187
======================  ============================================
188
Request Parameter Name  Value
189
======================  ============================================
190
update                  Do not replace metadata (no value parameter)
191
======================  ============================================
192

    
193
|
194

    
195
====================  ===========================
196
Request Header Name   Value
197
====================  ===========================
198
X-Account-Meta-*      Optional user defined metadata
199
====================  ===========================
200

    
201
No reply content/headers.
202

    
203
The operation will overwrite all user defined metadata, except if ``update`` is defined.
204

    
205
================  ===============================
206
Return Code       Description
207
================  ===============================
208
202 (Accepted)    The request has been accepted
209
================  ===============================
210

    
211

    
212
Container Level
213
^^^^^^^^^^^^^^^
214

    
215
List of operations:
216

    
217
=========  ============================
218
Operation  Description
219
=========  ============================
220
HEAD       Retrieve container metadata
221
GET        List objects
222
PUT        Create/update container
223
POST       Update container metadata
224
DELETE     Delete container
225
=========  ============================
226

    
227

    
228
HEAD
229
""""
230

    
231
======================  ===================================
232
Request Parameter Name  Value
233
======================  ===================================
234
until                   Optional timestamp
235
======================  ===================================
236

    
237
|
238

    
239
===========================  ===============================
240
Reply Header Name            Value
241
===========================  ===============================
242
X-Container-Object-Count     The total number of objects in the container
243
X-Container-Bytes-Used       The total number of bytes of all objects stored
244
X-Container-Block-Size       The block size used by the storage backend
245
X-Container-Block-Hash       The hash algorithm used for block identifiers in object hashmaps
246
X-Container-Until-Timestamp  The last container modification date until the timestamp provided
247
X-Container-Object-Meta      A list with all meta keys used by objects
248
X-Container-Meta-*           Optional user defined metadata
249
Last-Modified                The last container modification date (regardless of ``until``)
250
===========================  ===============================
251

    
252
The keys returned in ``X-Container-Object-Meta`` are all the unique strings after the ``X-Object-Meta-`` prefix.
253

    
254
================  ===============================
255
Return Code       Description
256
================  ===============================
257
204 (No Content)  The request succeeded
258
================  ===============================
259

    
260

    
261
GET
262
"""
263

    
264
====================  ===========================
265
Request Header Name   Value
266
====================  ===========================
267
If-Modified-Since     Retrieve if container has changed since provided timestamp
268
If-Unmodified-Since   Retrieve if container has not changed since provided timestamp
269
====================  ===========================
270

    
271
|
272

    
273
======================  ===================================
274
Request Parameter Name  Value
275
======================  ===================================
276
limit                   The amount of results requested (default is 10000)
277
marker                  Return containers with name lexicographically after marker
278
prefix                  Return objects starting with prefix
279
delimiter               Return objects up to the delimiter (discussion follows)
280
path                    Assume ``prefix=path`` and ``delimiter=/``
281
format                  Optional extended reply type (can be ``json`` or ``xml``)
282
meta                    Return objects having the specified meta keys (can be a comma separated list)
283
until                   Optional timestamp
284
======================  ===================================
285

    
286
The ``path`` parameter overrides ``prefix`` and ``delimiter``. When using ``path``, results will include objects ending in ``delimiter``.
287

    
288
The keys given with ``meta`` will be matched with the strings after the ``X-Object-Meta-`` prefix.
289

    
290
The reply is a list of object names. Container headers (as in a ``HEAD`` request) will also be included.
291
If a ``format=xml`` or ``format=json`` argument is given, extended information on the objects will be returned, serialized in the chosen format.
292
For each object, the information will include all object metadata (names will be in lower case and with hyphens replaced with underscores):
293

    
294
==========================  ======================================
295
Name                        Description
296
==========================  ======================================
297
name                        The name of the object
298
hash                        The ETag of the object
299
bytes                       The size of the object
300
content_type                The MIME content type of the object
301
content_encoding            The encoding of the object (optional)
302
content-disposition         The presentation style of the object (optional)
303
last_modified               The last object modification date (regardless of version)
304
x_object_version            The object's version identifier
305
x_object_version_timestamp  The object's version timestamp
306
x_object_modified_by        The user that committed the object's version
307
x_object_manifest           Object parts prefix in ``<container>/<object>`` form (optional)
308
x_object_public             Object is publicly accessible (optional) (**TBD**)
309
x_object_meta_*             Optional user defined metadata
310
==========================  ======================================
311

    
312
Extended replies may also include virtual directory markers in separate sections of the ``json`` or ``xml`` results.
313
Virtual directory markers are only included when ``delimiter`` is explicitly set. They correspond to the substrings up to and including the first occurrence of the delimiter.
314
In JSON results they appear as dictionaries with only a ``"subdir"`` key. In XML results they appear interleaved with ``<object>`` tags as ``<subdir name="..." />``.
315
In case there is an object with the same name as a virtual directory marker, the object will be returned.
316

    
317
For examples of object details returned in JSON/XML formats refer to the OOS API documentation.
318

    
319
===========================  ===============================
320
Return Code                  Description
321
===========================  ===============================
322
200 (OK)                     The request succeeded
323
204 (No Content)             The account has no containers (only for non-extended replies)
324
304 (Not Modified)           The container has not been modified
325
412 (Precondition Failed)    The condition set can not be satisfied
326
===========================  ===============================
327

    
328
Will use a ``200`` return code if the reply is of type json/xml.
329

    
330

    
331
PUT
332
"""
333

    
334
====================  ================================
335
Request Header Name   Value
336
====================  ================================
337
X-Container-Meta-*    Optional user defined metadata
338
====================  ================================
339
 
340
No reply content/headers.
341
 
342
================  ===============================
343
Return Code       Description
344
================  ===============================
345
201 (Created)     The container has been created
346
202 (Accepted)    The request has been accepted
347
================  ===============================
348

    
349

    
350
POST
351
""""
352

    
353
======================  ============================================
354
Request Parameter Name  Value
355
======================  ============================================
356
update                  Do not replace metadata (no value parameter)
357
======================  ============================================
358

    
359
|
360

    
361
====================  ================================
362
Request Header Name   Value
363
====================  ================================
364
X-Container-Meta-*    Optional user defined metadata
365
====================  ================================
366

    
367
No reply content/headers.
368

    
369
The operation will overwrite all user defined metadata, except if ``update`` is defined.
370

    
371
================  ===============================
372
Return Code       Description
373
================  ===============================
374
202 (Accepted)    The request has been accepted
375
================  ===============================
376

    
377

    
378
DELETE
379
""""""
380

    
381
No request parameters/headers.
382

    
383
No reply content/headers.
384

    
385
================  ===============================
386
Return Code       Description
387
================  ===============================
388
204 (No Content)  The request succeeded
389
409 (Conflict)    The container is not empty
390
================  ===============================
391

    
392

    
393
Object Level
394
^^^^^^^^^^^^
395

    
396
List of operations:
397

    
398
=========  =================================
399
Operation  Description
400
=========  =================================
401
HEAD       Retrieve object metadata
402
GET        Read object data
403
PUT        Write object data or copy/move object
404
COPY       Copy object
405
MOVE       Move object
406
POST       Update object metadata/data
407
DELETE     Delete object
408
=========  =================================
409

    
410

    
411
HEAD
412
""""
413

    
414
======================  ===================================
415
Request Parameter Name  Value
416
======================  ===================================
417
version                 Optional version identifier
418
======================  ===================================
419

    
420
|
421

    
422
==========================  ===============================
423
Reply Header Name           Value
424
==========================  ===============================
425
ETag                        The ETag of the object
426
Content-Length              The size of the object
427
Content-Type                The MIME content type of the object
428
Last-Modified               The last object modification date (regardless of version)
429
Content-Encoding            The encoding of the object (optional)
430
Content-Disposition         The presentation style of the object (optional)
431
X-Object-Version            The object's version identifier
432
X-Object-Version-Timestamp  The object's version timestamp
433
X-Object-Modified-By        The user that comitted the object's version
434
X-Object-Manifest           Object parts prefix in ``<container>/<object>`` form (optional)
435
X-Object-Public             Object is publicly accessible (optional) (**TBD**)
436
X-Object-Meta-*             Optional user defined metadata
437
==========================  ===============================
438

    
439
|
440

    
441
================  ===============================
442
Return Code       Description
443
================  ===============================
444
200 (No Content)  The request succeeded
445
================  ===============================
446

    
447

    
448
GET
449
"""
450

    
451
====================  ================================
452
Request Header Name   Value
453
====================  ================================
454
Range                 Optional range of data to retrieve
455
If-Match              Retrieve if ETags match
456
If-None-Match         Retrieve if ETags don't match
457
If-Modified-Since     Retrieve if object has changed since provided timestamp
458
If-Unmodified-Since   Retrieve if object has not changed since provided timestamp
459
====================  ================================
460

    
461
|
462

    
463
======================  ===================================
464
Request Parameter Name  Value
465
======================  ===================================
466
format                  Optional extended reply type (can be ``json`` or ``xml``)
467
version                 Optional version identifier or ``list`` (specify a format if requesting a list)
468
======================  ===================================
469

    
470
The reply is the object's data (or part of it), except if a hashmap is requested with the ``format`` parameter, or a version list with ``version=list`` (in which case an extended reply format must be specified). Object headers (as in a ``HEAD`` request) are always included.
471

    
472
Hashmaps expose the underlying storage format of the object. Note that each hash is computed after trimming trailing null bytes of the corresponding block.
473

    
474
Example ``format=json`` reply:
475

    
476
::
477

    
478
  {"block_hash": "sha1", "hashes": ["7295c41da03d7f916440b98e32c4a2a39351546c", ...], "block_size": 131072, "bytes": 242}
479

    
480
Example ``format=xml`` reply:
481

    
482
::
483

    
484
  <?xml version="1.0" encoding="UTF-8"?>
485
  <object name="file" bytes="24223726" block_size="131072" block_hash="sha1">
486
    <hash>7295c41da03d7f916440b98e32c4a2a39351546c</hash>
487
    <hash>...</hash>
488
  </object>
489

    
490
Version lists include the version identifier and timestamp for each available object version. Version identifiers can be arbitrary strings, so use the timestamp to find newer versions.
491

    
492
Example ``format=json`` reply:
493

    
494
::
495

    
496
  {"versions": [[23, 1307700892], [28, 1307700898], ...]}
497

    
498
Example ``format=xml`` reply:
499

    
500
::
501

    
502
  <?xml version="1.0" encoding="UTF-8"?>
503
  <object name="file">
504
    <version timestamp="1307700892">23</version>
505
    <version timestamp="1307700898">28</version>
506
    <version timestamp="...">...</version>
507
  </object>
508

    
509
The ``Range`` header may include multiple ranges, as outlined in RFC2616. Then the ``Content-Type`` of the reply will be ``multipart/byteranges`` and each part will include a ``Content-Range`` header.
510

    
511
==========================  ===============================
512
Reply Header Name           Value
513
==========================  ===============================
514
ETag                        The ETag of the object
515
Content-Length              The size of the data returned
516
Content-Type                The MIME content type of the object
517
Content-Range               The range of data included (only on a single range request)
518
Last-Modified               The last object modification date (regardless of version)
519
Content-Encoding            The encoding of the object (optional)
520
Content-Disposition         The presentation style of the object (optional)
521
X-Object-Version            The object's version identifier
522
X-Object-Version-Timestamp  The object's version timestamp
523
X-Object-Modified-By        The user that comitted the object's version
524
X-Object-Manifest           Object parts prefix in ``<container>/<object>`` form (optional)
525
X-Object-Public             Object is publicly accessible (optional) (**TBD**)
526
X-Object-Meta-*             Optional user defined metadata
527
==========================  ===============================
528

    
529
|
530

    
531
===========================  ==============================
532
Return Code                  Description
533
===========================  ==============================
534
200 (OK)                     The request succeeded
535
206 (Partial Content)        The range request succeeded
536
304 (Not Modified)           The object has not been modified
537
412 (Precondition Failed)    The condition set can not be satisfied
538
416 (Range Not Satisfiable)  The requested range is out of limits
539
===========================  ==============================
540

    
541

    
542
PUT
543
"""
544

    
545
====================  ================================
546
Request Header Name   Value
547
====================  ================================
548
ETag                  The MD5 hash of the object (optional to check written data)
549
Content-Length        The size of the data written
550
Content-Type          The MIME content type of the object
551
Transfer-Encoding     Set to ``chunked`` to specify incremental uploading (if used, ``Content-Length`` is ignored)
552
X-Copy-From           The source path in the form ``/<container>/<object>``
553
X-Move-From           The source path in the form ``/<container>/<object>``
554
X-Source-Version      The source version to copy from
555
Content-Encoding      The encoding of the object (optional)
556
Content-Disposition   The presentation style of the object (optional)
557
X-Object-Manifest     Object parts prefix in ``<container>/<object>`` form (optional)
558
X-Object-Public       Object is publicly accessible (optional) (**TBD**)
559
X-Object-Meta-*       Optional user defined metadata
560
====================  ================================
561

    
562
|
563

    
564
==========================  ===============================
565
Reply Header Name           Value
566
==========================  ===============================
567
ETag                        The MD5 hash of the object (on create)
568
==========================  ===============================
569

    
570
|
571

    
572
===========================  ==============================
573
Return Code                  Description
574
===========================  ==============================
575
201 (Created)                The object has been created
576
411 (Length Required)        Missing ``Content-Length`` or ``Content-Type`` in the request
577
422 (Unprocessable Entity)   The MD5 checksum of the data written to the storage system does not match the (optionally) supplied ETag value
578
===========================  ==============================
579

    
580

    
581
COPY
582
""""
583

    
584
====================  ================================
585
Request Header Name   Value
586
====================  ================================
587
Destination           The destination path in the form ``/<container>/<object>``
588
Content-Type          The MIME content type of the object (optional)
589
Content-Encoding      The encoding of the object (optional)
590
Content-Disposition   The presentation style of the object (optional)
591
X-Source-Version      The source version to copy from
592
X-Object-Manifest     Object parts prefix in ``<container>/<object>`` form (optional)
593
X-Object-Public       Object is publicly accessible (optional) (**TBD**)
594
X-Object-Meta-*       Optional user defined metadata
595
====================  ================================
596

    
597
Refer to ``POST`` for a description of request headers. Metadata is also copied, updated with any values defined.
598

    
599
No reply content/headers.
600

    
601
===========================  ==============================
602
Return Code                  Description
603
===========================  ==============================
604
201 (Created)                The object has been created
605
===========================  ==============================
606

    
607

    
608
MOVE
609
""""
610

    
611
Same as ``COPY``, without the ``X-Source-Version`` request header. The ``MOVE`` operation is always applied on the latest version.
612

    
613

    
614
POST
615
""""
616

    
617
======================  ============================================
618
Request Parameter Name  Value
619
======================  ============================================
620
update                  Do not replace metadata (no value parameter)
621
======================  ============================================
622

    
623
|
624

    
625
====================  ================================
626
Request Header Name   Value
627
====================  ================================
628
Content-Length        The size of the data written (optional, to update)
629
Content-Type          The MIME content type of the object (optional, to update)
630
Content-Range         The range of data supplied (optional, to update)
631
Transfer-Encoding     Set to ``chunked`` to specify incremental uploading (if used, ``Content-Length`` is ignored)
632
Content-Encoding      The encoding of the object (optional)
633
Content-Disposition   The presentation style of the object (optional)
634
X-Object-Manifest     Object parts prefix in ``<container>/<object>`` form (optional)
635
X-Object-Public       Object is publicly accessible (optional) (**TBD**)
636
X-Object-Meta-*       Optional user defined metadata
637
====================  ================================
638

    
639
The ``Content-Encoding``, ``Content-Disposition``, ``X-Object-Manifest``, ``X-Object-Public`` (**TBD**) and ``X-Object-Meta-*`` headers are considered to be user defined metadata. An operation without the ``update`` parameter will overwrite all previous values and remove any keys not supplied. When using ``update`` any metadata with an empty value will be deleted.
640

    
641
To update an object's data:
642

    
643
* Set ``Content-Type`` to ``application/octet-stream``. If ``Content-Type`` has some other value, it will be ignored and only the metadata will be updated.
644
* Supply ``Content-Length`` (except if using chunked transfers), ``Content-Type`` and ``Content-Range`` headers.
645
* Set ``Content-Range`` as specified in RFC2616, with the following differences:
646

    
647
  * Client software MAY omit ``last-byte-pos`` of if the length of the range being transferred is unknown or difficult to determine.
648
  * Client software SHOULD not specify the ``instance-length`` (use a ``*``), unless there is a reason for performing a size check at the server.
649
* If ``Content-Range`` used has a ``byte-range-resp-spec = *``, data supplied will be appended to the object.
650

    
651
A data update will trigger an ETag change. The new ETag will not correspond to the object's MD5 sum (**TBD**) and will be included in reply headers.
652

    
653
No reply content. No reply headers if only metadata is updated.
654

    
655
==========================  ===============================
656
Reply Header Name           Value
657
==========================  ===============================
658
ETag                        The new ETag of the object (data updated)
659
==========================  ===============================
660

    
661
|
662

    
663
===========================  ==============================
664
Return Code                  Description
665
===========================  ==============================
666
202 (Accepted)               The request has been accepted (not a data update)
667
204 (No Content)             The request succeeded (data updated)
668
411 (Length Required)        Missing ``Content-Length`` in the request
669
416 (Range Not Satisfiable)  The supplied range is invalid
670
===========================  ==============================
671

    
672

    
673
DELETE
674
""""""
675

    
676
No request parameters/headers.
677

    
678
No reply content/headers.
679

    
680
===========================  ==============================
681
Return Code                  Description
682
===========================  ==============================
683
204 (No Content)             The request succeeded
684
===========================  ==============================
685

    
686
Public Objects
687
^^^^^^^^^^^^^^
688

    
689
Objects that are marked as public, via the ``X-Object-Public`` meta (**TBD**), are also available at the corresponding URI ``https://hostname/public/<account>/<container>/<object>`` for ``HEAD`` or ``GET``. Requests for public objects do not need to include an ``X-Auth-Token``. Pithos will ignore request parameters and only include the following headers in the reply (all ``X-Object-*`` meta is hidden).
690

    
691
==========================  ===============================
692
Reply Header Name           Value
693
==========================  ===============================
694
ETag                        The ETag of the object
695
Content-Length              The size of the data returned
696
Content-Type                The MIME content type of the object
697
Content-Range               The range of data included (only on a single range request)
698
Last-Modified               The last object modification date (regardless of version)
699
Content-Encoding            The encoding of the object (optional)
700
Content-Disposition         The presentation style of the object (optional)
701
==========================  ===============================
702

    
703
Summary
704
^^^^^^^
705

    
706
List of differences from the OOS API:
707

    
708
* Support for ``X-Account-Meta-*`` style headers at the account level. Use ``POST`` to update.
709
* Support for ``X-Container-Meta-*`` style headers at the account level. Can be set when creating via ``PUT``. Use ``POST`` to update.
710
* Header ``X-Container-Object-Meta`` at the container level and parameter ``meta`` in container listings.
711
* Headers ``X-Container-Block-*`` at the container level, exposing the underlying storage characteristics.
712
* All metadata replies, at all levels, include latest modification information.
713
* At all levels, a ``GET`` request may use ``If-Modified-Since`` and ``If-Unmodified-Since`` headers.
714
* Container/object lists include all associated metadata if the reply is of type json/xml. Some names are kept to their OOS API equivalents for compatibility. 
715
* Object metadata allowed, in addition to ``X-Object-Meta-*``: ``Content-Encoding``, ``Content-Disposition``, ``X-Object-Manifest``, ``X-Object-Public`` (**TBD**). These are all replaced with every update operation, except if using the ``update`` parameter (in which case individual keys can also be deleted). Deleting meta by providing empty values also works when copying/moving an object.
716
* Multi-range object GET support as outlined in RFC2616.
717
* Object hashmap retrieval through GET and the ``format`` parameter.
718
* Partial object updates through POST, using the ``Content-Length``, ``Content-Type``, ``Content-Range`` and ``Transfer-Encoding`` headers.
719
* Object ``MOVE`` support.
720
* Time-variant account/container listings via the ``until`` parameter.
721
* Object versions - parameter ``version`` in HEAD/GET (list versions with GET), ``X-Object-Version-*`` meta in replies, ``X-Source-Version`` in PUT/COPY.
722
* Publicly accessible objects via ``https://hostname/public``. Control with ``X-Object-Public`` (**TBD**).
723
* Large object support with ``X-Object-Manifest``.
724
* Trace the user that created/modified an object with ``X-Object-Modified-By``.
725

    
726
Clarifications/suggestions:
727

    
728
* Authentication is done by another system. The token is used in the same way, but it is obtained differently. The top level ``GET`` request is kept compatible with the OOS API and allows for guest/testing operations.
729
* Some processing is done in the variable part of all ``X-*-Meta-*`` headers. If it includes underscores, they will be converted to dashes and the first letter of all intra-dash strings will be capitalized.
730
* A ``GET`` reply for a level will include all headers of the corresponding ``HEAD`` request.
731
* To avoid conflicts between objects and virtual directory markers in container listings, it is recommended that object names do not end with the delimiter used.
732
* The ``Accept`` header may be used in requests instead of the ``format`` parameter to specify the desired reply format. The parameter overrides the header.
733
* Container/object lists use a ``200`` return code if the reply is of type json/xml. The reply will include an empty json/xml.
734
* In headers, dates are formatted according to RFC 1123. In extended information listings, dates are formatted according to ISO 8601.
735
* The ``Last-Modified`` header value always reflects the actual latest change timestamp, regardless of time control parameters and version requests. Time precondition checks with ``If-Modified-Since`` and ``If-Unmodified-Since`` headers are applied to this value.
736
* A copy/move using ``PUT``/``COPY``/``MOVE`` will always update metadata, keeping all old values except the ones redefined in the request headers.
737
* A ``HEAD`` or ``GET`` for an ``X-Object-Manifest`` object, will include modified ``Content-Length`` and ``ETag`` headers, according to the characteristics of the objects under the specified prefix. The ``Etag`` will be the MD5 hash of the corresponding ETags concatenated. In extended container listings there is no metadata processing.
738

    
739
The Pithos Client
740
-----------------
741

    
742
User Experience
743
^^^^^^^^^^^^^^^
744

    
745
Hopefully this API will allow for a multitude of client implementations, each supporting a different device or operating system. All clients will be able to manipulate containers and objects - even software only designed for OOS API compatibility. But a Pithos interface should not be only about showing containers and folders. There are some extra user interface elements and functionalities that should be common to all implementations.
746

    
747
Upon entrance to the service, a user is presented with the following elements - which can be represented as folders or with other related icons:
748

    
749
* The ``home`` element, which is used as the default entry point to the user's "files". Objects under ``home`` are represented in the usual hierarchical organization of folders and files.
750
* The ``trash`` element, which contains files that have been marked for deletion, but can still be recovered.
751
* The ``shared`` element, which contains all objects shared by the user to other users of the system.
752
* The ``others`` element, which contains all objects that other users share with the user.
753
* The ``tags`` element, which lists the names of tags the user has defined. This can be an entry point to list all files that have been assigned a specific tag or manage tags in general (remove a tag completely, rename a tag etc.).
754
* The ``groups`` element, which contains the names of groups the user has defined. Each group consists of a user list. Group creation, deletion, and manipulation is carried out by actions originating here.
755

    
756
Objects in Pithos can be:
757

    
758
* Assigned custom tags.
759
* Moved to trash and then deleted.
760
* Shared with specific permissions.
761
* Made public (shared with non-Pithos users).
762
* Restored from previous versions.
763

    
764
Some of these functions are performed by the client software and some by the Pithos server. Client-driven functionality is based on specific metadata that should be handled equally across implementations. These metadata names are discussed in the next chapter. 
765

    
766
Conventions and Metadata Specification
767
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
768

    
769
Pithos clients should use the ``pithos`` container for all Pithos objects. Object names use the ``/`` delimiter to impose a hierarchy of folders and files.
770

    
771
At the object level, tags are implemented by managing metadata keys. The client software should allow the user to use any string as a tag (except ``trash``) and then set the corresponding ``X-Object-Meta-<tag>`` key at the server. The API extensions provided, allow for listing all tags in a container and filtering object listings based on one or more tags. The tag list is sufficient for implementing the ``tags`` element, either as a special, virtual folder (as done in the first version of Pithos), or as an application menu.
772

    
773
To manage the deletion of files use the same API and the ``X-Object-Meta-Trash`` key. The string ``trash`` can not be used as a tag. The ``trash`` element should be presented as a folder, although with no hierarchy.
774

    
775
The metadata specification is summarized in the following table.
776

    
777
===========================  ==============================
778
Metadata Name                Value
779
===========================  ==============================
780
X-Object-Meta-Trash          Set to ``true`` if the object has been moved to the trash
781
X-Object-Meta-*              Use for other tags that apply to the object
782
===========================  ==============================
783

    
784
Recommended Practices and Examples
785
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
786

    
787
Assuming an authentication token is obtained (**TBD**), the following high-level operations are available - shown with ``curl``:
788

    
789
* Get account information ::
790

    
791
    curl -X HEAD -D - \
792
         -H "X-Auth-Token: 0000" \
793
         https://pithos.dev.grnet.gr/v1/user
794

    
795
* List available containers ::
796

    
797
    curl -X GET -D - \
798
         -H "X-Auth-Token: 0000" \
799
         https://pithos.dev.grnet.gr/v1/user
800

    
801
* Get container information ::
802

    
803
    curl -X HEAD -D - \
804
         -H "X-Auth-Token: 0000" \
805
         https://pithos.dev.grnet.gr/v1/user/pithos
806

    
807
* Add a new container ::
808

    
809
    curl -X PUT -D - \
810
         -H "X-Auth-Token: 0000" \
811
         https://pithos.dev.grnet.gr/v1/user/test
812

    
813
* Delete a container ::
814

    
815
    curl -X DELETE -D - \
816
         -H "X-Auth-Token: 0000" \
817
         https://pithos.dev.grnet.gr/v1/user/test
818

    
819
* List objects in a container ::
820

    
821
    curl -X GET -D - \
822
         -H "X-Auth-Token: 0000" \
823
         https://pithos.dev.grnet.gr/v1/user/pithos
824

    
825
* List objects in a container (extended reply) ::
826

    
827
    curl -X GET -D - \
828
         -H "X-Auth-Token: 0000" \
829
         https://pithos.dev.grnet.gr/v1/user/pithos?format=json
830

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

    
833
* List metadata keys used by objects in a container
834

    
835
  Will be in the ``X-Container-Object-Meta`` reply header, included in container information or object list (``HEAD`` or ``GET``).
836

    
837
* List objects in a container having a specific meta defined ::
838

    
839
    curl -X GET -D - \
840
         -H "X-Auth-Token: 0000" \
841
         https://pithos.dev.grnet.gr/v1/user/pithos?meta=trash
842

    
843
  This is the recommended way of tagging/retrieving objects in trash.
844

    
845
* Retrieve an object ::
846

    
847
    curl -X GET -D - \
848
         -H "X-Auth-Token: 0000" \
849
         https://pithos.dev.grnet.gr/v1/user/pithos/README.txt
850

    
851
* Retrieve an object (specific ranges of data) ::
852

    
853
    curl -X GET -D - \
854
         -H "X-Auth-Token: 0000" \
855
         -H "Range: bytes=0-9" \
856
         https://pithos.dev.grnet.gr/v1/user/pithos/README.txt
857

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

    
860
* Add a new object (folder type) (**TBD**) ::
861

    
862
    curl -X PUT -D - \
863
         -H "X-Auth-Token: 0000" \
864
         -H "Content-Type: application/folder" \
865
         https://pithos.dev.grnet.gr/v1/user/pithos/folder
866

    
867
* Add a new object ::
868

    
869
    curl -X PUT -D - \
870
         -H "X-Auth-Token: 0000" \
871
         -H "Content-Type: text/plain" \
872
         -T EXAMPLE.txt
873
         https://pithos.dev.grnet.gr/v1/user/pithos/folder/EXAMPLE.txt
874

    
875
* Update an object ::
876

    
877
    curl -X POST -D - \
878
         -H "X-Auth-Token: 0000" \
879
         -H "Content-Length: 10" \
880
         -H "Content-Type: application/octet-stream" \
881
         -H "Content-Range: bytes 10-19/*" \
882
         -d "0123456789" \
883
         https://pithos.dev.grnet.gr/v1/user/folder/EXAMPLE.txt
884

    
885
  This will update bytes 10-19 with the data specified.
886

    
887
* Update an object (append) ::
888

    
889
    curl -X POST -D - \
890
         -H "X-Auth-Token: 0000" \
891
         -H "Content-Length: 10" \
892
         -H "Content-Type: application/octet-stream" \
893
         -H "Content-Range: bytes */*" \
894
         -d "0123456789" \
895
         https://pithos.dev.grnet.gr/v1/user/folder/EXAMPLE.txt
896

    
897
* Add object metadata ::
898

    
899
    curl -X POST -D - \
900
         -H "X-Auth-Token: 0000" \
901
         -H "X-Object-Meta-First: first_meta_value" \
902
         -H "X-Object-Meta-Second: second_meta_value" \
903
         https://pithos.dev.grnet.gr/v1/user/folder/EXAMPLE.txt
904

    
905
* Delete object metadata ::
906

    
907
    curl -X POST -D - \
908
         -H "X-Auth-Token: 0000" \
909
         -H "X-Object-Meta-First: first_meta_value" \
910
         https://pithos.dev.grnet.gr/v1/user/folder/EXAMPLE.txt
911

    
912
  Metadata can only be "set". To delete ``X-Object-Meta-Second``, reset all metadata.
913

    
914
* Delete an object ::
915

    
916
    curl -X DELETE -D - \
917
         -H "X-Auth-Token: 0000" \
918
         https://pithos.dev.grnet.gr/v1/user/folder/EXAMPLE.txt
919