Statistics
| Branch: | Tag: | Revision:

root / docs / source / devguide.rst @ ca461a84

History | View | Annotate | Download (54.6 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. Pithos will store sharing permissions per object and enforce corresponding authorization policies. 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.5 (July 19, 2011)        Object update from another object's data.
29
\                          Support object truncate.
30
\                          Create object using a standard HTML form.
31
\                          Purge container/object history.
32
\                          List other accounts that share objects with a user.
33
\                          List shared containers/objects.
34
0.4 (July 01, 2011)        Object permissions and account groups.
35
\                          Control versioning behavior and container quotas with container policy directives.
36
\                          Support updating/deleting individual metadata with ``POST``.
37
\                          Create object using hashmap.
38
0.3 (June 14, 2011)        Large object support with ``X-Object-Manifest``.
39
\                          Allow for publicly available objects via ``https://hostname/public``.
40
\                          Support time-variant account/container listings. 
41
\                          Add source version when duplicating with ``PUT``/``COPY``.
42
\                          Request version in object ``HEAD``/``GET`` requests (list versions with ``GET``).
43
0.2 (May 31, 2011)         Add object meta listing and filtering in containers.
44
\                          Include underlying storage characteristics in container meta.
45
\                          Support for partial object updates through ``POST``.
46
\                          Expose object hashmaps through ``GET``.
47
\                          Support for multi-range object ``GET`` requests.
48
0.1 (May 17, 2011)         Initial release. Based on OpenStack Object Storage Developer Guide API v1 (Apr. 15, 2011).
49
=========================  ================================
50

    
51
The Pithos API
52
--------------
53

    
54
The URI requests supported by the Pithos API follow one of the following forms:
55

    
56
* Top level: ``https://hostname/v1/``
57
* Account level: ``https://hostname/v1/<account>``
58
* Container level: ``https://hostname/v1/<account>/<container>``
59
* Object level: ``https://hostname/v1/<account>/<container>/<object>``
60

    
61
All requests must include an ``X-Auth-Token`` - as a header, or a parameter. The process of obtaining the token is still to be determined (**TBD**).
62

    
63
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.
64

    
65
=========================  ================================
66
Return Code                Description
67
=========================  ================================
68
400 (Bad Request)          The request is invalid
69
401 (Unauthorized)         Request not allowed
70
404 (Not Found)            The requested resource was not found
71
503 (Service Unavailable)  The request cannot be completed because of an internal error
72
=========================  ================================
73

    
74
Top Level
75
^^^^^^^^^
76

    
77
List of operations:
78

    
79
=========  ==================
80
Operation  Description
81
=========  ==================
82
GET        Authentication (for compatibility with the OOS API) or list allowed accounts
83
=========  ==================
84

    
85
GET
86
"""
87

    
88
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.
89

    
90
================  =====================
91
Return Code       Description
92
================  =====================
93
204 (No Content)  The request succeeded
94
================  =====================
95

    
96
If an ``X-Auth-Token`` is already present, the operation will be interpreted as a request to list other accounts that share objects to the user.
97

    
98
======================  =========================
99
Request Parameter Name  Value
100
======================  =========================
101
limit                   The amount of results requested (default is 10000)
102
marker                  Return containers with name lexicographically after marker
103
format                  Optional extended reply type (can be ``json`` or ``xml``)
104
======================  =========================
105

    
106
The reply is a list of account names.
107
If a ``format=xml`` or ``format=json`` argument is given, extended information on the containers will be returned, serialized in the chosen format.
108
For each account, the information will include the following (names will be in lower case and with hyphens replaced with underscores):
109

    
110
===========================  ============================
111
Name                         Description
112
===========================  ============================
113
name                         The name of the account
114
last_modified                The last container modification date (regardless of ``until``)
115
===========================  ============================
116

    
117
Example ``format=json`` reply:
118

    
119
::
120

    
121
  [{"name": "user", "last_modified": "2011-07-19T10:48:16"}, ...]
122

    
123
Example ``format=xml`` reply:
124

    
125
::
126

    
127
  <?xml version="1.0" encoding="UTF-8"?>
128
  <accounts>
129
    <account>
130
      <name>user</name>
131
      <last_modified>2011-07-19T10:48:16</last_modified>
132
    </account>
133
    <account>...</account>
134
  </accounts>
135

    
136
===========================  =====================
137
Return Code                  Description
138
===========================  =====================
139
200 (OK)                     The request succeeded
140
204 (No Content)             The account has no containers (only for non-extended replies)
141
===========================  =====================
142

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

    
145
Account Level
146
^^^^^^^^^^^^^
147

    
148
List of operations:
149

    
150
=========  ==================
151
Operation  Description
152
=========  ==================
153
HEAD       Retrieve account metadata
154
GET        List containers
155
POST       Update account metadata
156
=========  ==================
157

    
158
HEAD
159
""""
160

    
161
======================  ===================================
162
Request Parameter Name  Value
163
======================  ===================================
164
until                   Optional timestamp
165
======================  ===================================
166

    
167
Cross-user requests are not allowed to use ``until`` and only include the account modification date in the reply.
168

    
169
==========================  =====================
170
Reply Header Name           Value
171
==========================  =====================
172
X-Account-Container-Count   The total number of containers
173
X-Account-Object-Count      The total number of objects (**TBD**)
174
X-Account-Bytes-Used        The total number of bytes stored
175
X-Account-Bytes-Remaining   The total number of bytes remaining (**TBD**)
176
X-Account-Last-Login        The last login (**TBD**)
177
X-Account-Until-Timestamp   The last account modification date until the timestamp provided
178
X-Account-Group-*           Optional user defined groups
179
X-Account-Meta-*            Optional user defined metadata
180
Last-Modified               The last account modification date (regardless of ``until``)
181
==========================  =====================
182

    
183
|
184

    
185
================  =====================
186
Return Code       Description
187
================  =====================
188
204 (No Content)  The request succeeded
189
================  =====================
190

    
191

    
192
GET
193
"""
194

    
195
====================  ===========================
196
Request Header Name   Value
197
====================  ===========================
198
If-Modified-Since     Retrieve if account has changed since provided timestamp
199
If-Unmodified-Since   Retrieve if account has not changed since provided timestamp
200
====================  ===========================
201

    
202
|
203

    
204
======================  =========================
205
Request Parameter Name  Value
206
======================  =========================
207
limit                   The amount of results requested (default is 10000)
208
marker                  Return containers with name lexicographically after marker
209
format                  Optional extended reply type (can be ``json`` or ``xml``)
210
shared                  Show only shared containers (no value parameter)
211
until                   Optional timestamp
212
======================  =========================
213

    
214
The reply is a list of container names. Account headers (as in a ``HEAD`` request) will also be included.
215
Cross-user requests are not allowed to use ``until`` and only include the account/container modification dates in the reply.
216

    
217
If a ``format=xml`` or ``format=json`` argument is given, extended information on the containers will be returned, serialized in the chosen format.
218
For each container, the information will include all container metadata (names will be in lower case and with hyphens replaced with underscores):
219

    
220
===========================  ============================
221
Name                         Description
222
===========================  ============================
223
name                         The name of the container
224
count                        The number of objects inside the container
225
bytes                        The total size of the objects inside the container
226
last_modified                The last container modification date (regardless of ``until``)
227
x_container_until_timestamp  The last container modification date until the timestamp provided
228
x_container_policy_*         Container behavior and limits
229
x_container_meta_*           Optional user defined metadata
230
===========================  ============================
231

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

    
234
===========================  =====================
235
Return Code                  Description
236
===========================  =====================
237
200 (OK)                     The request succeeded
238
204 (No Content)             The account has no containers (only for non-extended replies)
239
304 (Not Modified)           The account has not been modified
240
412 (Precondition Failed)    The condition set can not be satisfied
241
===========================  =====================
242

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

    
245

    
246
POST
247
""""
248

    
249
======================  ============================================
250
Request Parameter Name  Value
251
======================  ============================================
252
update                  Do not replace metadata/groups (no value parameter)
253
======================  ============================================
254

    
255
|
256

    
257
====================  ===========================
258
Request Header Name   Value
259
====================  ===========================
260
X-Account-Group-*     Optional user defined groups
261
X-Account-Meta-*      Optional user defined metadata
262
====================  ===========================
263

    
264
No reply content/headers.
265

    
266
The operation will overwrite all user defined metadata, except if ``update`` is defined.
267
To create a group, include an ``X-Account-Group-*`` header with the name in the key and a comma separated list of user names in the value. If no ``X-Account-Group-*`` header is present, no changes will be applied to groups. The ``update`` parameter also applies to groups. To delete a specific group, use ``update`` and an empty header value.
268

    
269
================  ===============================
270
Return Code       Description
271
================  ===============================
272
202 (Accepted)    The request has been accepted
273
================  ===============================
274

    
275

    
276
Container Level
277
^^^^^^^^^^^^^^^
278

    
279
List of operations:
280

    
281
=========  ============================
282
Operation  Description
283
=========  ============================
284
HEAD       Retrieve container metadata
285
GET        List objects
286
PUT        Create/update container
287
POST       Update container metadata
288
DELETE     Delete container
289
=========  ============================
290

    
291

    
292
HEAD
293
""""
294

    
295
======================  ===================================
296
Request Parameter Name  Value
297
======================  ===================================
298
until                   Optional timestamp
299
======================  ===================================
300

    
301
Cross-user requests are not allowed to use ``until`` and only include the container modification date in the reply.
302

    
303
===========================  ===============================
304
Reply Header Name            Value
305
===========================  ===============================
306
X-Container-Object-Count     The total number of objects in the container
307
X-Container-Bytes-Used       The total number of bytes of all objects stored
308
X-Container-Block-Size       The block size used by the storage backend
309
X-Container-Block-Hash       The hash algorithm used for block identifiers in object hashmaps
310
X-Container-Until-Timestamp  The last container modification date until the timestamp provided
311
X-Container-Object-Meta      A list with all meta keys used by objects
312
X-Container-Policy-*         Container behavior and limits
313
X-Container-Meta-*           Optional user defined metadata
314
Last-Modified                The last container modification date (regardless of ``until``)
315
===========================  ===============================
316

    
317
The keys returned in ``X-Container-Object-Meta`` are all the unique strings after the ``X-Object-Meta-`` prefix, formatted as a comma-separated list. See container ``PUT`` for a reference of policy directives.
318

    
319
================  ===============================
320
Return Code       Description
321
================  ===============================
322
204 (No Content)  The request succeeded
323
================  ===============================
324

    
325

    
326
GET
327
"""
328

    
329
====================  ===========================
330
Request Header Name   Value
331
====================  ===========================
332
If-Modified-Since     Retrieve if container has changed since provided timestamp
333
If-Unmodified-Since   Retrieve if container has not changed since provided timestamp
334
====================  ===========================
335

    
336
|
337

    
338
======================  ===================================
339
Request Parameter Name  Value
340
======================  ===================================
341
limit                   The amount of results requested (default is 10000)
342
marker                  Return containers with name lexicographically after marker
343
prefix                  Return objects starting with prefix
344
delimiter               Return objects up to the delimiter (discussion follows)
345
path                    Assume ``prefix=path`` and ``delimiter=/``
346
format                  Optional extended reply type (can be ``json`` or ``xml``)
347
meta                    Return objects having the specified meta keys (can be a comma separated list)
348
shared                  Show only shared objects (no value parameter)
349
until                   Optional timestamp
350
======================  ===================================
351

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

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

    
356
The reply is a list of object names. Container headers (as in a ``HEAD`` request) will also be included.
357
Cross-user requests are not allowed to use ``until`` and include the following limited set of headers in the reply:
358

    
359
===========================  ===============================
360
Reply Header Name            Value
361
===========================  ===============================
362
X-Container-Block-Size       The block size used by the storage backend
363
X-Container-Block-Hash       The hash algorithm used for block identifiers in object hashmaps
364
X-Container-Object-Meta      A list with all meta keys used by allowed objects (**TBD**)
365
Last-Modified                The last container modification date
366
===========================  ===============================
367

    
368
If a ``format=xml`` or ``format=json`` argument is given, extended information on the objects will be returned, serialized in the chosen format.
369
For each object, the information will include all object metadata (names will be in lower case and with hyphens replaced with underscores):
370

    
371
==========================  ======================================
372
Name                        Description
373
==========================  ======================================
374
name                        The name of the object
375
hash                        The ETag of the object
376
bytes                       The size of the object
377
content_type                The MIME content type of the object
378
content_encoding            The encoding of the object (optional)
379
content-disposition         The presentation style of the object (optional)
380
last_modified               The last object modification date (regardless of version)
381
x_object_version            The object's version identifier
382
x_object_version_timestamp  The object's version timestamp
383
x_object_modified_by        The user that committed the object's version
384
x_object_manifest           Object parts prefix in ``<container>/<object>`` form (optional)
385
x_object_sharing            Object permissions (optional)
386
x_object_shared_by          Object inheriting permissions (optional)
387
x_object_public             Object's publicly accessible URI (optional)
388
x_object_meta_*             Optional user defined metadata
389
==========================  ======================================
390

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

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

    
398
===========================  ===============================
399
Return Code                  Description
400
===========================  ===============================
401
200 (OK)                     The request succeeded
402
204 (No Content)             The account has no containers (only for non-extended replies)
403
304 (Not Modified)           The container has not been modified
404
412 (Precondition Failed)    The condition set can not be satisfied
405
===========================  ===============================
406

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

    
409

    
410
PUT
411
"""
412

    
413
====================  ================================
414
Request Header Name   Value
415
====================  ================================
416
X-Container-Policy-*  Container behavior and limits
417
X-Container-Meta-*    Optional user defined metadata
418
====================  ================================
419
 
420
No reply content/headers.
421

    
422
If no policy is defined, the container will be created with the default values.
423
Available policy directives:
424

    
425
* ``versioning``: Set to ``auto``, ``manual`` or ``none`` (default is ``manual``)
426
* ``quota``: Size limit in KB (default is ``0`` - unlimited)
427
 
428
================  ===============================
429
Return Code       Description
430
================  ===============================
431
201 (Created)     The container has been created
432
202 (Accepted)    The request has been accepted
433
================  ===============================
434

    
435

    
436
POST
437
""""
438

    
439
======================  ============================================
440
Request Parameter Name  Value
441
======================  ============================================
442
update                  Do not replace metadata/policy (no value parameter)
443
======================  ============================================
444

    
445
|
446

    
447
====================  ================================
448
Request Header Name   Value
449
====================  ================================
450
X-Container-Policy-*  Container behavior and limits
451
X-Container-Meta-*    Optional user defined metadata
452
====================  ================================
453

    
454
No reply content/headers.
455

    
456
The operation will overwrite all user defined metadata, except if ``update`` is defined.
457
To change policy, include an ``X-Container-Policy-*`` header with the name in the key. If no ``X-Container-Policy-*`` header is present, no changes will be applied to policy. The ``update`` parameter also applies to policy - deleted values will revert to defaults. To delete/revert a specific policy directive, use ``update`` and an empty header value. See container ``PUT`` for a reference of policy directives.
458

    
459
================  ===============================
460
Return Code       Description
461
================  ===============================
462
202 (Accepted)    The request has been accepted
463
================  ===============================
464

    
465

    
466
DELETE
467
""""""
468

    
469
======================  ===================================
470
Request Parameter Name  Value
471
======================  ===================================
472
until                   Optional timestamp
473
======================  ===================================
474

    
475
If ``until`` is defined, the container is "purged" up to that time (the history of all objects up to then is deleted).
476

    
477
No reply content/headers.
478

    
479
================  ===============================
480
Return Code       Description
481
================  ===============================
482
204 (No Content)  The request succeeded
483
409 (Conflict)    The container is not empty
484
================  ===============================
485

    
486

    
487
Object Level
488
^^^^^^^^^^^^
489

    
490
List of operations:
491

    
492
=========  =================================
493
Operation  Description
494
=========  =================================
495
HEAD       Retrieve object metadata
496
GET        Read object data
497
PUT        Write object data or copy/move object
498
COPY       Copy object
499
MOVE       Move object
500
POST       Update object metadata/data
501
DELETE     Delete object
502
=========  =================================
503

    
504

    
505
HEAD
506
""""
507

    
508
======================  ===================================
509
Request Parameter Name  Value
510
======================  ===================================
511
version                 Optional version identifier
512
======================  ===================================
513

    
514
|
515

    
516
==========================  ===============================
517
Reply Header Name           Value
518
==========================  ===============================
519
ETag                        The ETag of the object
520
Content-Length              The size of the object
521
Content-Type                The MIME content type of the object
522
Last-Modified               The last object modification date (regardless of version)
523
Content-Encoding            The encoding of the object (optional)
524
Content-Disposition         The presentation style of the object (optional)
525
X-Object-Version            The object's version identifier
526
X-Object-Version-Timestamp  The object's version timestamp
527
X-Object-Modified-By        The user that comitted the object's version
528
X-Object-Manifest           Object parts prefix in ``<container>/<object>`` form (optional)
529
X-Object-Sharing            Object permissions (optional)
530
X-Object-Shared-By          Object inheriting permissions (optional)
531
X-Object-Public             Object's publicly accessible URI (optional)
532
X-Object-Meta-*             Optional user defined metadata
533
==========================  ===============================
534

    
535
|
536

    
537
================  ===============================
538
Return Code       Description
539
================  ===============================
540
200 (No Content)  The request succeeded
541
================  ===============================
542

    
543

    
544
GET
545
"""
546

    
547
====================  ================================
548
Request Header Name   Value
549
====================  ================================
550
Range                 Optional range of data to retrieve
551
If-Range              Retrieve the missing part if entity is unchanged; otherwise, retrieve the entire new entity (used together with Range header)
552
If-Match              Retrieve if ETags match
553
If-None-Match         Retrieve if ETags don't match
554
If-Modified-Since     Retrieve if object has changed since provided timestamp
555
If-Unmodified-Since   Retrieve if object has not changed since provided timestamp
556
====================  ================================
557

    
558
|
559

    
560
======================  ===================================
561
Request Parameter Name  Value
562
======================  ===================================
563
format                  Optional extended reply type (can be ``json`` or ``xml``)
564
version                 Optional version identifier or ``list`` (specify a format if requesting a list)
565
======================  ===================================
566

    
567
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.
568

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

    
571
Example ``format=json`` reply:
572

    
573
::
574

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

    
577
Example ``format=xml`` reply:
578

    
579
::
580

    
581
  <?xml version="1.0" encoding="UTF-8"?>
582
  <object name="file" bytes="24223726" block_size="131072" block_hash="sha1">
583
    <hash>7295c41da03d7f916440b98e32c4a2a39351546c</hash>
584
    <hash>...</hash>
585
  </object>
586

    
587
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.
588

    
589
Example ``format=json`` reply:
590

    
591
::
592

    
593
  {"versions": [[23, 1307700892], [28, 1307700898], ...]}
594

    
595
Example ``format=xml`` reply:
596

    
597
::
598

    
599
  <?xml version="1.0" encoding="UTF-8"?>
600
  <object name="file">
601
    <version timestamp="1307700892">23</version>
602
    <version timestamp="1307700898">28</version>
603
    <version timestamp="...">...</version>
604
  </object>
605

    
606
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.
607

    
608
==========================  ===============================
609
Reply Header Name           Value
610
==========================  ===============================
611
ETag                        The ETag of the object
612
Content-Length              The size of the data returned
613
Content-Type                The MIME content type of the object
614
Content-Range               The range of data included (only on a single range request)
615
Last-Modified               The last object modification date (regardless of version)
616
Content-Encoding            The encoding of the object (optional)
617
Content-Disposition         The presentation style of the object (optional)
618
X-Object-Version            The object's version identifier
619
X-Object-Version-Timestamp  The object's version timestamp
620
X-Object-Modified-By        The user that comitted the object's version
621
X-Object-Manifest           Object parts prefix in ``<container>/<object>`` form (optional)
622
X-Object-Sharing            Object permissions (optional)
623
X-Object-Shared-By          Object inheriting permissions (optional)
624
X-Object-Public             Object's publicly accessible URI (optional)
625
X-Object-Meta-*             Optional user defined metadata
626
==========================  ===============================
627

    
628
|
629

    
630
===========================  ==============================
631
Return Code                  Description
632
===========================  ==============================
633
200 (OK)                     The request succeeded
634
206 (Partial Content)        The range request succeeded
635
304 (Not Modified)           The object has not been modified
636
412 (Precondition Failed)    The condition set can not be satisfied
637
416 (Range Not Satisfiable)  The requested range is out of limits
638
===========================  ==============================
639

    
640

    
641
PUT
642
"""
643

    
644
====================  ================================
645
Request Header Name   Value
646
====================  ================================
647
ETag                  The MD5 hash of the object (optional to check written data)
648
Content-Length        The size of the data written
649
Content-Type          The MIME content type of the object
650
Transfer-Encoding     Set to ``chunked`` to specify incremental uploading (if used, ``Content-Length`` is ignored)
651
X-Copy-From           The source path in the form ``/<container>/<object>``
652
X-Move-From           The source path in the form ``/<container>/<object>``
653
X-Source-Version      The source version to copy from
654
Content-Encoding      The encoding of the object (optional)
655
Content-Disposition   The presentation style of the object (optional)
656
X-Object-Manifest     Object parts prefix in ``<container>/<object>`` form (optional)
657
X-Object-Sharing      Object permissions (optional)
658
X-Object-Public       Object is publicly accessible (optional)
659
X-Object-Meta-*       Optional user defined metadata
660
====================  ================================
661

    
662
|
663

    
664
======================  ===================================
665
Request Parameter Name  Value
666
======================  ===================================
667
format                  Optional extended request type (can be ``json``) to create the object by suppling its hashmap instead
668
======================  ===================================
669

    
670
The request is the object's data (or part of it), except if a hashmap is provided with the ``format`` parameter.  If format is used and all different parts are stored in the server, the object is created, otherwise the server returns Conflict (409) with the list of the missing parts. 
671

    
672
Hashmaps expose the underlying storage format of the object.
673

    
674
Example ``format=json`` request:
675

    
676
::
677

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

    
680
Example ``format=xml`` request:
681

    
682
::
683

    
684
  <?xml version="1.0" encoding="UTF-8"?>
685
  <object name="file" bytes="24223726" block_size="131072" block_hash="sha1">
686
    <hash>7295c41da03d7f916440b98e32c4a2a39351546c</hash>
687
    <hash>...</hash>
688
  </object>
689

    
690
==========================  ===============================
691
Reply Header Name           Value
692
==========================  ===============================
693
ETag                        The MD5 hash of the object (on create)
694
==========================  ===============================
695

    
696
The ``X-Object-Sharing`` header may include either a ``read=...`` comma-separated user/group list, or a ``write=...`` comma-separated user/group list, or both separated by a semicolon (``;``). Groups are specified as ``<account>:<group>``. To publish the object, set ``X-Object-Public`` to ``true``. To unpublish, set to ``false``, or use an empty header value.
697

    
698
===========================  ==============================
699
Return Code                  Description
700
===========================  ==============================
701
201 (Created)                The object has been created
702
409 (Conflict)               The object can not be created from the provided hashmap, or there are conflicting permissions (a list of missing hashes, or a conflicting sharing path will be included in the reply - in JSON format)
703
411 (Length Required)        Missing ``Content-Length`` or ``Content-Type`` in the request
704
422 (Unprocessable Entity)   The MD5 checksum of the data written to the storage system does not match the (optionally) supplied ETag value
705
===========================  ==============================
706

    
707

    
708
COPY
709
""""
710

    
711
====================  ================================
712
Request Header Name   Value
713
====================  ================================
714
Destination           The destination path in the form ``/<container>/<object>``
715
Content-Type          The MIME content type of the object (optional)
716
Content-Encoding      The encoding of the object (optional)
717
Content-Disposition   The presentation style of the object (optional)
718
X-Source-Version      The source version to copy from
719
X-Object-Manifest     Object parts prefix in ``<container>/<object>`` form (optional)
720
X-Object-Sharing      Object permissions (optional)
721
X-Object-Public       Object is publicly accessible (optional)
722
X-Object-Meta-*       Optional user defined metadata
723
====================  ================================
724

    
725
Refer to ``PUT``/``POST`` for a description of request headers. Metadata is also copied, updated with any values defined. Sharing/publishing options are not copied.
726

    
727
No reply content/headers.
728

    
729
===========================  ==============================
730
Return Code                  Description
731
===========================  ==============================
732
201 (Created)                The object has been created
733
409 (Conflict)               There are conflicting permissions (a conflicting sharing path will be included in the reply - in JSON format)
734
===========================  ==============================
735

    
736

    
737
MOVE
738
""""
739

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

    
742

    
743
POST
744
""""
745

    
746
======================  ============================================
747
Request Parameter Name  Value
748
======================  ============================================
749
update                  Do not replace metadata (no value parameter)
750
======================  ============================================
751

    
752
|
753

    
754
====================  ================================
755
Request Header Name   Value
756
====================  ================================
757
Content-Length        The size of the data written (optional, to update)
758
Content-Type          The MIME content type of the object (optional, to update)
759
Content-Range         The range of data supplied (optional, to update)
760
Transfer-Encoding     Set to ``chunked`` to specify incremental uploading (if used, ``Content-Length`` is ignored)
761
Content-Encoding      The encoding of the object (optional)
762
Content-Disposition   The presentation style of the object (optional)
763
X-Source-Object       Update with data from the object at path ``/<container>/<object>`` (optional, to update)
764
X-Source-Version      The source version to update from (optional, to update)
765
X-Object-Bytes        The updated object's final size (optional, when updating)
766
X-Object-Manifest     Object parts prefix in ``<container>/<object>`` form (optional)
767
X-Object-Sharing      Object permissions (optional)
768
X-Object-Public       Object is publicly accessible (optional)
769
X-Object-Meta-*       Optional user defined metadata
770
====================  ================================
771

    
772
The ``Content-Encoding``, ``Content-Disposition``, ``X-Object-Manifest`` 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.
773

    
774
To change permissions, include an ``X-Object-Sharing`` header (as defined in ``PUT``). To publish, include an ``X-Object-Public`` header, with a value of ``true``. If no such headers are defined, no changes will be applied to sharing/public. Use empty values to remove permissions/unpublish (unpublishing also works with ``false`` as a header value). Sharing options are applied to the object - not its versions.
775

    
776
To update an object's data:
777

    
778
* Either set ``Content-Type`` to ``application/octet-stream``, or provide an object with ``X-Source-Object``. If ``Content-Type`` has some other value, it will be ignored and only the metadata will be updated.
779
* If the data is supplied in the request (using ``Content-Type`` instead of ``X-Source-Object``), a valid ``Content-Length`` header is required - except if using chunked transfers (set ``Transfer-Encoding`` to ``chunked``).
780
* Set ``Content-Range`` as specified in RFC2616, with the following differences:
781

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

    
786
Optionally, truncate the updated object to the desired length with the ``X-Object-Bytes`` header.
787

    
788
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.
789

    
790
No reply content. No reply headers if only metadata is updated.
791

    
792
==========================  ===============================
793
Reply Header Name           Value
794
==========================  ===============================
795
ETag                        The new ETag of the object (data updated)
796
==========================  ===============================
797

    
798
|
799

    
800
===========================  ==============================
801
Return Code                  Description
802
===========================  ==============================
803
202 (Accepted)               The request has been accepted (not a data update)
804
204 (No Content)             The request succeeded (data updated)
805
409 (Conflict)               There are conflicting permissions (a conflicting sharing path will be included in the reply - in JSON format)
806
411 (Length Required)        Missing ``Content-Length`` in the request
807
416 (Range Not Satisfiable)  The supplied range is invalid
808
===========================  ==============================
809

    
810
The ``POST`` method can also be used for creating an object via a standard HTML form. If the request ``Content-Type`` is ``multipart/form-data``, none of the above headers will be processed. The form should have exactly two fields, as in the following example. ::
811

    
812
  <form method="post" action="https://pithos.dev.grnet.gr/v1/user/folder/EXAMPLE.txt" enctype="multipart/form-data">
813
    <input type="hidden" name="X-Auth-Token" value="0000">
814
    <input type="file" name="X-Object-Data">
815
    <input type="submit">
816
  </form>
817

    
818
This will create/override the object with the given name, as if using ``PUT``. The ``Content-Type`` of the object will be set to the value of the corresponding header sent in the part of the request containing the data. Metadata, sharing and other object attributes can not be set this way.
819

    
820
==========================  ===============================
821
Reply Header Name           Value
822
==========================  ===============================
823
ETag                        The MD5 hash of the object
824
==========================  ===============================
825

    
826
|
827

    
828
===========================  ==============================
829
Return Code                  Description
830
===========================  ==============================
831
201 (Created)                The object has been created
832
===========================  ==============================
833

    
834

    
835
DELETE
836
""""""
837

    
838
======================  ===================================
839
Request Parameter Name  Value
840
======================  ===================================
841
until                   Optional timestamp
842
======================  ===================================
843

    
844
If ``until`` is defined, the object is "purged" up to that time (the history up to then is deleted).
845

    
846
No reply content/headers.
847

    
848
===========================  ==============================
849
Return Code                  Description
850
===========================  ==============================
851
204 (No Content)             The request succeeded
852
===========================  ==============================
853

    
854
Sharing and Public Objects
855
^^^^^^^^^^^^^^^^^^^^^^^^^^
856

    
857
Read and write control in Pithos is managed by setting appropriate permissions with the ``X-Object-Sharing`` header. The permissions are applied using prefix-based inheritance. Thus, each set of authorization directives is applied to all objects sharing the same prefix with the object where the corresponding ``X-Object-Sharing`` header is defined. For simplicity, nested/overlapping permissions are not allowed. Setting ``X-Object-Sharing`` will fail, if the object is already "covered", or another object with a longer common-prefix name already has permissions. When retrieving an object, the ``X-Object-Shared-By`` header reports where it gets its permissions from. If not present, the object is the actual source of authorization directives.
858

    
859
A user may ``GET`` another account or container. The result will include a limited reply, containing only the allowed containers or objects respectively. A top-level request with an authentication token, will return a list of allowed accounts, so the user can easily find out which other users share objects.
860

    
861
Objects that are marked as public, via the ``X-Object-Public`` meta, are also available at the corresponding URI returned 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):
862

    
863
==========================  ===============================
864
Reply Header Name           Value
865
==========================  ===============================
866
ETag                        The ETag of the object
867
Content-Length              The size of the data returned
868
Content-Type                The MIME content type of the object
869
Content-Range               The range of data included (only on a single range request)
870
Last-Modified               The last object modification date (regardless of version)
871
Content-Encoding            The encoding of the object (optional)
872
Content-Disposition         The presentation style of the object (optional)
873
==========================  ===============================
874

    
875
Public objects are not included and do not influence cross-user listings. They are, however, readable by all users.
876

    
877
Summary
878
^^^^^^^
879

    
880
List of differences from the OOS API:
881

    
882
* Support for ``X-Account-Meta-*`` style headers at the account level. Use ``POST`` to update.
883
* Support for ``X-Container-Meta-*`` style headers at the container level. Can be set when creating via ``PUT``. Use ``POST`` to update.
884
* Header ``X-Container-Object-Meta`` at the container level and parameter ``meta`` in container listings.
885
* Container policies to manage behavior and limits.
886
* Headers ``X-Container-Block-*`` at the container level, exposing the underlying storage characteristics.
887
* All metadata replies, at all levels, include latest modification information.
888
* At all levels, a ``GET`` request may use ``If-Modified-Since`` and ``If-Unmodified-Since`` headers.
889
* 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.
890
* Option to include only shared containers/objects in listings.
891
* Object metadata allowed, in addition to ``X-Object-Meta-*``: ``Content-Encoding``, ``Content-Disposition``, ``X-Object-Manifest``. 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.
892
* Multi-range object ``GET`` support as outlined in RFC2616.
893
* Object hashmap retrieval through ``GET`` and the ``format`` parameter.
894
* Object create via hashmap through ``PUT`` and the ``format`` parameter.
895
* Object create using ``POST`` to support standard HTML forms.
896
* Partial object updates through ``POST``, using the ``Content-Length``, ``Content-Type``, ``Content-Range`` and ``Transfer-Encoding`` headers. Use another object's data to update with ``X-Source-Object`` and ``X-Source-Version``. Truncate with ``X-Object-Bytes``.
897
* Object ``MOVE`` support.
898
* Time-variant account/container listings via the ``until`` parameter.
899
* Object versions - parameter ``version`` in ``HEAD``/``GET`` (list versions with ``GET``), ``X-Object-Version-*`` meta in replies, ``X-Source-Version`` in ``PUT``/``COPY``.
900
* Sharing/publishing with ``X-Object-Sharing``, ``X-Object-Public`` at the object level. Cross-user operations are allowed - controlled by sharing directives. Permissions may include groups defined with ``X-Account-Group-*`` at the account level. These apply to the object - not its versions.
901
* Support for prefix-based inheritance when enforcing permissions. Parent object carrying the authorization directives is reported in ``X-Object-Shared-By``.
902
* Large object support with ``X-Object-Manifest``.
903
* Trace the user that created/modified an object with ``X-Object-Modified-By``.
904
* Purge container/object history with the ``until`` parameter in ``DELETE``.
905

    
906
Clarifications/suggestions:
907

    
908
* 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.
909
* 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.
910
* A ``GET`` reply for a level will include all headers of the corresponding ``HEAD`` request.
911
* 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.
912
* The ``Accept`` header may be used in requests instead of the ``format`` parameter to specify the desired reply format. The parameter overrides the header (**TBD**).
913
* Container/object lists use a ``200`` return code if the reply is of type json/xml. The reply will include an empty json/xml.
914
* In headers, dates are formatted according to RFC 1123. In extended information listings, dates are formatted according to ISO 8601.
915
* 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.
916
* A copy/move using ``PUT``/``COPY``/``MOVE`` will always update metadata, keeping all old values except the ones redefined in the request headers.
917
* 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.
918

    
919
The Pithos Client
920
-----------------
921

    
922
User Experience
923
^^^^^^^^^^^^^^^
924

    
925
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.
926

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

    
929
* 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.
930
* The ``trash`` element, which contains files that have been marked for deletion, but can still be recovered.
931
* The ``shared`` element, which contains all objects shared by the user to other users of the system.
932
* The ``others`` element, which contains all objects that other users share with the user.
933
* 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.).
934
* 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.
935

    
936
Objects in Pithos can be:
937

    
938
* Assigned custom tags.
939
* Moved to trash and then deleted.
940
* Shared with specific permissions.
941
* Made public (shared with non-Pithos users).
942
* Restored from previous versions.
943

    
944
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. 
945

    
946
Conventions and Metadata Specification
947
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
948

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

    
951
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 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.
952

    
953
The metadata specification is summarized in the following table.
954

    
955
===========================  ==============================
956
Metadata Name                Value
957
===========================  ==============================
958
X-Object-Meta-*              Use for other tags that apply to the object
959
===========================  ==============================
960

    
961
Recommended Practices and Examples
962
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
963

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

    
966
* Get account information ::
967

    
968
    curl -X HEAD -D - \
969
         -H "X-Auth-Token: 0000" \
970
         https://pithos.dev.grnet.gr/v1/user
971

    
972
* List available containers ::
973

    
974
    curl -X GET -D - \
975
         -H "X-Auth-Token: 0000" \
976
         https://pithos.dev.grnet.gr/v1/user
977

    
978
* Get container information ::
979

    
980
    curl -X HEAD -D - \
981
         -H "X-Auth-Token: 0000" \
982
         https://pithos.dev.grnet.gr/v1/user/pithos
983

    
984
* Add a new container ::
985

    
986
    curl -X PUT -D - \
987
         -H "X-Auth-Token: 0000" \
988
         https://pithos.dev.grnet.gr/v1/user/test
989

    
990
* Delete a container ::
991

    
992
    curl -X DELETE -D - \
993
         -H "X-Auth-Token: 0000" \
994
         https://pithos.dev.grnet.gr/v1/user/test
995

    
996
* List objects in a container ::
997

    
998
    curl -X GET -D - \
999
         -H "X-Auth-Token: 0000" \
1000
         https://pithos.dev.grnet.gr/v1/user/pithos
1001

    
1002
* List objects in a container (extended reply) ::
1003

    
1004
    curl -X GET -D - \
1005
         -H "X-Auth-Token: 0000" \
1006
         https://pithos.dev.grnet.gr/v1/user/pithos?format=json
1007

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

    
1010
* List metadata keys used by objects in a container
1011

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

    
1014
* List objects in a container having a specific meta defined ::
1015

    
1016
    curl -X GET -D - \
1017
         -H "X-Auth-Token: 0000" \
1018
         https://pithos.dev.grnet.gr/v1/user/pithos?meta=favorites
1019

    
1020
* Retrieve an object ::
1021

    
1022
    curl -X GET -D - \
1023
         -H "X-Auth-Token: 0000" \
1024
         https://pithos.dev.grnet.gr/v1/user/pithos/README.txt
1025

    
1026
* Retrieve an object (specific ranges of data) ::
1027

    
1028
    curl -X GET -D - \
1029
         -H "X-Auth-Token: 0000" \
1030
         -H "Range: bytes=0-9" \
1031
         https://pithos.dev.grnet.gr/v1/user/pithos/README.txt
1032

    
1033
  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``.
1034

    
1035
* Add a new object (folder type) (**TBD**) ::
1036

    
1037
    curl -X PUT -D - \
1038
         -H "X-Auth-Token: 0000" \
1039
         -H "Content-Type: application/folder" \
1040
         https://pithos.dev.grnet.gr/v1/user/pithos/folder
1041

    
1042
* Add a new object ::
1043

    
1044
    curl -X PUT -D - \
1045
         -H "X-Auth-Token: 0000" \
1046
         -H "Content-Type: text/plain" \
1047
         -T EXAMPLE.txt
1048
         https://pithos.dev.grnet.gr/v1/user/pithos/folder/EXAMPLE.txt
1049

    
1050
* Update an object ::
1051

    
1052
    curl -X POST -D - \
1053
         -H "X-Auth-Token: 0000" \
1054
         -H "Content-Length: 10" \
1055
         -H "Content-Type: application/octet-stream" \
1056
         -H "Content-Range: bytes 10-19/*" \
1057
         -d "0123456789" \
1058
         https://pithos.dev.grnet.gr/v1/user/folder/EXAMPLE.txt
1059

    
1060
  This will update bytes 10-19 with the data specified.
1061

    
1062
* Update an object (append) ::
1063

    
1064
    curl -X POST -D - \
1065
         -H "X-Auth-Token: 0000" \
1066
         -H "Content-Length: 10" \
1067
         -H "Content-Type: application/octet-stream" \
1068
         -H "Content-Range: bytes */*" \
1069
         -d "0123456789" \
1070
         https://pithos.dev.grnet.gr/v1/user/folder/EXAMPLE.txt
1071

    
1072
* Update an object (truncate) ::
1073

    
1074
    curl -X POST -D - \
1075
         -H "X-Auth-Token: 0000" \
1076
         -H "X-Source-Object: /folder/EXAMPLE.txt" \
1077
         -H "Content-Range: bytes 0-0/*" \
1078
         -H "X-Object-Bytes: 0" \
1079
         https://pithos.dev.grnet.gr/v1/user/folder/EXAMPLE.txt
1080

    
1081
  This will truncate the object to 0 bytes.
1082

    
1083
* Add object metadata ::
1084

    
1085
    curl -X POST -D - \
1086
         -H "X-Auth-Token: 0000" \
1087
         -H "X-Object-Meta-First: first_meta_value" \
1088
         -H "X-Object-Meta-Second: second_meta_value" \
1089
         https://pithos.dev.grnet.gr/v1/user/folder/EXAMPLE.txt
1090

    
1091
* Delete object metadata ::
1092

    
1093
    curl -X POST -D - \
1094
         -H "X-Auth-Token: 0000" \
1095
         -H "X-Object-Meta-First: first_meta_value" \
1096
         https://pithos.dev.grnet.gr/v1/user/folder/EXAMPLE.txt
1097

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

    
1100
* Delete an object ::
1101

    
1102
    curl -X DELETE -D - \
1103
         -H "X-Auth-Token: 0000" \
1104
         https://pithos.dev.grnet.gr/v1/user/folder/EXAMPLE.txt