Statistics
| Branch: | Tag: | Revision:

root / docs / source / devguide.rst @ a6eb13e9

History | View | Annotate | Download (41.8 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_manifest           Object parts prefix in ``<container>/<object>`` form (optional)
307
x_object_public             Object is publicly accessible (optional) (**TBD**)
308
x_object_meta_*             Optional user defined metadata
309
==========================  ======================================
310

    
311
Extended replies may also include virtual directory markers in separate sections of the ``json`` or ``xml`` results.
312
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.
313
In JSON results they appear as dictionaries with only a ``"subdir"`` key. In XML results they appear interleaved with ``<object>`` tags as ``<subdir name="..." />``.
314
In case there is an object with the same name as a virtual directory marker, the object will be returned.
315

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

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

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

    
329

    
330
PUT
331
"""
332

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

    
348

    
349
POST
350
""""
351

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

    
358
|
359

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

    
366
No reply content/headers.
367

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

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

    
376

    
377
DELETE
378
""""""
379

    
380
No request parameters/headers.
381

    
382
No reply content/headers.
383

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

    
391

    
392
Object Level
393
^^^^^^^^^^^^
394

    
395
List of operations:
396

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

    
409

    
410
HEAD
411
""""
412

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

    
419
|
420

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

    
437
|
438

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

    
445

    
446
GET
447
"""
448

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

    
459
|
460

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

    
468
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.
469

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

    
472
Example ``format=json`` reply:
473

    
474
::
475

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

    
478
Example ``format=xml`` reply:
479

    
480
::
481

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

    
488
Version lists include the version identifier and timestamp for each available object version. Version identifiers are integers, with the only requirement that newer versions have a larger identifier than previous ones.
489

    
490
Example ``format=json`` reply:
491

    
492
::
493

    
494
  {"versions": [[23, 1307700892], [28, 1307700898], ...]}
495

    
496
Example ``format=xml`` reply:
497

    
498
::
499

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

    
507
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.
508

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

    
526
|
527

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

    
538

    
539
PUT
540
"""
541

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

    
559
|
560

    
561
==========================  ===============================
562
Reply Header Name           Value
563
==========================  ===============================
564
ETag                        The MD5 hash of the object (on create)
565
==========================  ===============================
566

    
567
|
568

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

    
577

    
578
COPY
579
""""
580

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

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

    
596
No reply content/headers.
597

    
598
===========================  ==============================
599
Return Code                  Description
600
===========================  ==============================
601
201 (Created)                The object has been created
602
===========================  ==============================
603

    
604

    
605
MOVE
606
""""
607

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

    
610

    
611
POST
612
""""
613

    
614
======================  ============================================
615
Request Parameter Name  Value
616
======================  ============================================
617
update                  Do not replace metadata (no value parameter)
618
======================  ============================================
619

    
620
|
621

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

    
636
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.
637

    
638
To update an object's data:
639

    
640
* 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.
641
* Supply ``Content-Length`` (except if using chunked transfers), ``Content-Type`` and ``Content-Range`` headers.
642
* Set ``Content-Range`` as specified in RFC2616, with the following differences:
643

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

    
648
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.
649

    
650
No reply content. No reply headers if only metadata is updated.
651

    
652
==========================  ===============================
653
Reply Header Name           Value
654
==========================  ===============================
655
ETag                        The new ETag of the object (data updated)
656
==========================  ===============================
657

    
658
|
659

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

    
669

    
670
DELETE
671
""""""
672

    
673
No request parameters/headers.
674

    
675
No reply content/headers.
676

    
677
===========================  ==============================
678
Return Code                  Description
679
===========================  ==============================
680
204 (No Content)             The request succeeded
681
===========================  ==============================
682

    
683
Public Objects
684
^^^^^^^^^^^^^^
685

    
686
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).
687

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

    
700
Summary
701
^^^^^^^
702

    
703
List of differences from the OOS API:
704

    
705
* Support for ``X-Account-Meta-*`` style headers at the account level. Use ``POST`` to update.
706
* Support for ``X-Container-Meta-*`` style headers at the account level. Can be set when creating via ``PUT``. Use ``POST`` to update.
707
* Header ``X-Container-Object-Meta`` at the container level and parameter ``meta`` in container listings.
708
* Headers ``X-Container-Block-*`` at the container level, exposing the underlying storage characteristics.
709
* All metadata replies, at all levels, include latest modification information.
710
* At all levels, a ``GET`` request may use ``If-Modified-Since`` and ``If-Unmodified-Since`` headers.
711
* 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. 
712
* 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.
713
* Multi-range object GET support as outlined in RFC2616.
714
* Object hashmap retrieval through GET and the ``format`` parameter.
715
* Partial object updates through POST, using the ``Content-Length``, ``Content-Type``, ``Content-Range`` and ``Transfer-Encoding`` headers.
716
* Object ``MOVE`` support.
717
* Time-variant account/container listings via the ``until`` parameter.
718
* Object versions - parameter ``version`` in HEAD/GET (list versions with GET), ``X-Object-Version-*`` meta in replies, ``X-Source-Version`` in PUT/COPY.
719
* Publicly accessible objects via ``https://hostname/public``. Control with ``X-Object-Public`` (**TBD**).
720
* Large object support with ``X-Object-Manifest``.
721

    
722
Clarifications/suggestions:
723

    
724
* 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.
725
* 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.
726
* A ``GET`` reply for a level will include all headers of the corresponding ``HEAD`` request.
727
* 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.
728
* The ``Accept`` header may be used in requests instead of the ``format`` parameter to specify the desired reply format. The parameter overrides the header.
729
* Container/object lists use a ``200`` return code if the reply is of type json/xml. The reply will include an empty json/xml.
730
* In headers, dates are formatted according to RFC 1123. In extended information listings, dates are formatted according to ISO 8601.
731
* 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.
732
* A copy/move using ``PUT``/``COPY``/``MOVE`` will always update metadata, keeping all old values except the ones redefined in the request headers.
733
* 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.
734

    
735
The Pithos Client
736
-----------------
737

    
738
User Experience
739
^^^^^^^^^^^^^^^
740

    
741
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.
742

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

    
745
* 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.
746
* The ``trash`` element, which contains files that have been marked for deletion, but can still be recovered.
747
* The ``shared`` element, which contains all objects shared by the user to other users of the system.
748
* The ``others`` element, which contains all objects that other users share with the user.
749
* 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.).
750
* 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.
751

    
752
Objects in Pithos can be:
753

    
754
* Assigned custom tags.
755
* Moved to trash and then deleted.
756
* Shared with specific permissions.
757
* Made public (shared with non-Pithos users).
758
* Restored from previous versions.
759

    
760
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. 
761

    
762
Conventions and Metadata Specification
763
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
764

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

    
767
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.
768

    
769
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.
770

    
771
The metadata specification is summarized in the following table.
772

    
773
===========================  ==============================
774
Metadata Name                Value
775
===========================  ==============================
776
X-Object-Meta-Trash          Set to ``true`` if the object has been moved to the trash
777
X-Object-Meta-*              Use for other tags that apply to the object
778
===========================  ==============================
779

    
780
Recommended Practices and Examples
781
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
782

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

    
785
* Get account information ::
786

    
787
    curl -X HEAD -D - \
788
         -H "X-Auth-Token: 0000" \
789
         https://pithos.dev.grnet.gr/v1/user
790

    
791
* List available containers ::
792

    
793
    curl -X GET -D - \
794
         -H "X-Auth-Token: 0000" \
795
         https://pithos.dev.grnet.gr/v1/user
796

    
797
* Get container information ::
798

    
799
    curl -X HEAD -D - \
800
         -H "X-Auth-Token: 0000" \
801
         https://pithos.dev.grnet.gr/v1/user/pithos
802

    
803
* Add a new container ::
804

    
805
    curl -X PUT -D - \
806
         -H "X-Auth-Token: 0000" \
807
         https://pithos.dev.grnet.gr/v1/user/test
808

    
809
* Delete a container ::
810

    
811
    curl -X DELETE -D - \
812
         -H "X-Auth-Token: 0000" \
813
         https://pithos.dev.grnet.gr/v1/user/test
814

    
815
* List objects in a container ::
816

    
817
    curl -X GET -D - \
818
         -H "X-Auth-Token: 0000" \
819
         https://pithos.dev.grnet.gr/v1/user/pithos
820

    
821
* List objects in a container (extended reply) ::
822

    
823
    curl -X GET -D - \
824
         -H "X-Auth-Token: 0000" \
825
         https://pithos.dev.grnet.gr/v1/user/pithos?format=json
826

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

    
829
* List metadata keys used by objects in a container
830

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

    
833
* List objects in a container having a specific meta defined ::
834

    
835
    curl -X GET -D - \
836
         -H "X-Auth-Token: 0000" \
837
         https://pithos.dev.grnet.gr/v1/user/pithos?meta=trash
838

    
839
  This is the recommended way of tagging/retrieving objects in trash.
840

    
841
* Retrieve an object ::
842

    
843
    curl -X GET -D - \
844
         -H "X-Auth-Token: 0000" \
845
         https://pithos.dev.grnet.gr/v1/user/pithos/README.txt
846

    
847
* Retrieve an object (specific ranges of data) ::
848

    
849
    curl -X GET -D - \
850
         -H "X-Auth-Token: 0000" \
851
         -H "Range: bytes=0-9" \
852
         https://pithos.dev.grnet.gr/v1/user/pithos/README.txt
853

    
854
  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``.
855

    
856
* Add a new object (folder type) (**TBD**) ::
857

    
858
    curl -X PUT -D - \
859
         -H "X-Auth-Token: 0000" \
860
         -H "Content-Type: application/folder" \
861
         https://pithos.dev.grnet.gr/v1/user/pithos/folder
862

    
863
* Add a new object ::
864

    
865
    curl -X PUT -D - \
866
         -H "X-Auth-Token: 0000" \
867
         -H "Content-Type: text/plain" \
868
         -T EXAMPLE.txt
869
         https://pithos.dev.grnet.gr/v1/user/pithos/folder/EXAMPLE.txt
870

    
871
* Update an object ::
872

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

    
881
  This will update bytes 10-19 with the data specified.
882

    
883
* Update an object (append) ::
884

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

    
893
* Add object metadata ::
894

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

    
901
* Delete object metadata ::
902

    
903
    curl -X POST -D - \
904
         -H "X-Auth-Token: 0000" \
905
         -H "X-Object-Meta-First: first_meta_value" \
906
         https://pithos.dev.grnet.gr/v1/user/folder/EXAMPLE.txt
907

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

    
910
* Delete an object ::
911

    
912
    curl -X DELETE -D - \
913
         -H "X-Auth-Token: 0000" \
914
         https://pithos.dev.grnet.gr/v1/user/folder/EXAMPLE.txt
915