From 23212fc816cf5f75e1238ae1ccb9827c64fd6d67 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Tue, 17 Aug 2021 14:01:44 -0400 Subject: [PATCH] add some example client/server interactions --- docs/proposed/http-storage-node-protocol.rst | 130 +++++++++++++++++++ 1 file changed, 130 insertions(+) diff --git a/docs/proposed/http-storage-node-protocol.rst b/docs/proposed/http-storage-node-protocol.rst index ad9dd30bc..623cd4f12 100644 --- a/docs/proposed/http-storage-node-protocol.rst +++ b/docs/proposed/http-storage-node-protocol.rst @@ -576,6 +576,136 @@ Just like ``GET /v1/mutable/:storage_index``. Advise the server the data read from the indicated share was corrupt. Just like the immutable version. +Sample Interactions +------------------- + +Immutable Data +~~~~~~~~~~~~~~ + +1. Create a bucket for storage index ``AAAAAAAAAAAAAAAA`` to hold two immutable shares, discovering that share ``1`` was already uploaded:: + + PUT /v1/immutable/AAAAAAAAAAAAAAAA + {"renew-secret": "efgh", "cancel-secret": "ijkl", + "share-numbers": [1, 7], "allocated-size": 48} + + 200 OK + {"already-have": [1], "allocated": [7]} + +#. Upload the content for immutable share ``7``:: + + PUT /v1/immutable/AAAAAAAAAAAAAAAA/7 + Content-Range: bytes 0-15/48 + + + 200 OK + + PUT /v1/immutable/AAAAAAAAAAAAAAAA/7 + Content-Range: bytes 16-31/48 + + + 200 OK + + PUT /v1/immutable/AAAAAAAAAAAAAAAA/7 + Content-Range: bytes 32-47/48 + + + 201 CREATED + +#. Download the content of the previously uploaded immutable share ``7``:: + + GET /v1/immutable/AAAAAAAAAAAAAAAA?share=7&offset=0&size=48 + + 200 OK + + +#. Renew the lease on all immutable shares in bucket ``AAAAAAAAAAAAAAAA``:: + + POST /v1/lease/AAAAAAAAAAAAAAAA + {"renew-secret": "efgh"} + + 204 NO CONTENT + +Mutable Data +~~~~~~~~~~~~ + +1. Create mutable share number ``3`` with ``10`` bytes of data in slot ``BBBBBBBBBBBBBBBB``:: + + POST /v1/mutable/BBBBBBBBBBBBBBBB/read-test-write + { + "secrets": { + "write-enabler": "abcd", + "lease-renew": "efgh", + "lease-cancel": "ijkl" + }, + "test-write-vectors": { + 3: { + "test": [{ + "offset": 0, + "size": 1, + "operator": "eq", + "specimen": "" + }], + "write": [{ + "offset": 0, + "data": "xxxxxxxxxx" + }], + "new-length": 10 + } + }, + "read-vector": [] + } + + 200 OK + { + "success": true, + "data": [] + } + +#. Safely rewrite the contents of a known version of mutble share number ``3`` (or fail):: + + POST /v1/mutable/BBBBBBBBBBBBBBBB/read-test-write + { + "secrets": { + "write-enabler": "abcd", + "lease-renew": "efgh", + "lease-cancel": "ijkl" + }, + "test-write-vectors": { + 3: { + "test": [{ + "offset": 0, + "size": , + "operator": "eq", + "specimen": "" + }], + "write": [{ + "offset": 0, + "data": "yyyyyyyyyy" + }], + "new-length": 10 + } + }, + "read-vector": [] + } + + 200 OK + { + "success": true, + "data": [] + } + +#. Download the contents of share number ``3``:: + + GET /v1/mutable/BBBBBBBBBBBBBBBB?share=3&offset=0&size=10 + + +#. Renew the lease on previously uploaded mutable share in slot ``BBBBBBBBBBBBBBBB``:: + + POST /v1/lease/BBBBBBBBBBBBBBBB + {"renew-secret": "efgh"} + + 204 NO CONTENT + .. _RFC 7469: https://tools.ietf.org/html/rfc7469#section-2.4 .. _RFC 7049: https://tools.ietf.org/html/rfc7049#section-4