github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/docs/easy_url.md (about)

     1  ## Definitions
     2  
     3  "Easy URL" is a user-friendly mapping of AIS native APIs:
     4  
     5  1. GET(object)
     6  2. PUT(object)
     7  3. list-objects(bucket)
     8  4. list-buckets
     9  
    10  The feature is intended to enable (convenient) usage of your Internet Browser (or `curl`, etc. tools) to run commands that look as follows:
    11  
    12  * **GET http(s)://host:port/provider/[bucket[/object]]**
    13  * **PUT http(s)://host:port/provider/[bucket[/object]]**,
    14  
    15  where:
    16  
    17  * `host` and `port` are, as usual, the hostname and listening port of any available AIS gateway (aka "proxy");
    18  * `provider` is one of: (`gs` | `az` | `ais`), where the first 3 encode well-known Amazon S3, Google Cloud, and Microsoft Azure Blob Storage, respectively.
    19  * `bucket` and `object` names are optional and further depend on a given operation (one of the 4 listed above).
    20  
    21  Let's now assume that there is an AIS cluster with gateway at `10.0.0.207:51080`. The following example illustrates all 4 (four) "easy URLs":
    22  
    23  ```console
    24  $ ais create ais://abc
    25  "ais://abc" created
    26  
    27  # 1. destination name is required:
    28  $ curl -L -X PUT 'http://10.0.0.207:51080/ais/abc' -T README.md
    29  Error: missing destination object name in the "easy URL": PUT /ais/abc
    30  
    31  # 2. correct PUT:
    32  $ curl -L -X PUT 'http://10.0.0.207:51080/ais/abc/qq' -T README.md
    33  
    34  # 3. GET(object) as /tmp/qq:
    35  $ curl -L -X GET 'http://10.0.0.207:51080/ais/abc/qq' -o /tmp/qq
    36    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
    37                                   Dload  Upload   Total   Spent    Left  Speed
    38  100   132  100   132    0     0  66000      0 --:--:-- --:--:-- --:--:--  128k
    39  100 10689  100 10689    0     0  3479k      0 --:--:-- --:--:-- --:--:-- 3479k
    40  
    41  # 4. list-objects in a bucket, with `jq` to pretty-print JSON output:
    42  $ curl -L -X GET 'http://10.0.0.207:51080/ais/abc' | jq
    43    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
    44                                   Dload  Upload   Total   Spent    Left  Speed
    45  100   167  100   167    0     0  83500      0 --:--:-- --:--:-- --:--:-- 83500
    46  {
    47    "uuid": "MksSfasdg",
    48    "continuation_token": "",
    49    "entries": [
    50      {
    51        "name": "qq",
    52        "checksum": "fd0f7acc8e278588",
    53        "atime": "24 Aug 22 10:00 EDT",
    54        "size": "10689",
    55        "flags": 64
    56      }
    57    ],
    58    "flags": 0
    59  }
    60  
    61  5. finally, list all Google Cloud buckets (that we have permissions to see):
    62  $ curl -L -X GET 'http://10.0.0.207:51080/gs' | jq
    63    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
    64                                   Dload  Upload   Total   Spent    Left  Speed
    65  100   507  100   507    0     0    533      0 --:--:-- --:--:-- --:--:--   533
    66  [
    67    {
    68      "name": "bucket-111",
    69      "provider": "gcp",
    70      "namespace": {
    71        "uuid": "",
    72        "name": ""
    73      }
    74    },
    75    {
    76      "name": "bucket-222",
    77      "provider": "gcp",
    78      "namespace": {
    79        "uuid": "",
    80        "name": ""
    81      }
    82    },
    83  ...
    84  ...
    85  ]
    86  ```
    87  
    88  > In the examples above, instead of `ais` provider we could as well use `gs` (Google Cloud) or `az`(Azure), etc.
    89  
    90  ## S3 compatibility - and one important distinction
    91  
    92  In addition to its native REST API, AIS provides [S3-compatible API](/docs/s3compat.md) via `/s3` API endpoint.
    93  
    94  For instance, the following performs a GET on an object in Amazon S3 bucket:
    95  
    96  ```console
    97  # first, write it there
    98  $ ais put README.md s3://my-s3-bucket
    99  
   100  # GET the same and place output into /tmp/rr
   101  $ curl -L -X GET 'http://10.0.0.207:51080/s3/my-s3-bucket/README.md' -o /tmp/rr
   102  ```
   103  
   104  Notice that GET URL (above) looks indistinguishable from the "easy URL" examples from the previous section.
   105  
   106  That, in fact, is a mere coincidence - and here's why:
   107  
   108  * `/s3` is an API endpoint rather than a namesake provider;
   109  * as such, `/s3` provides a a whole set of Amazon S3 compatible APIs whereby the output is xml-formated, etc. - as specified in the respective Amazon documentation.
   110  
   111  To illustrate this distinction further, let's take a look at a `list-buckets` example using `/s3` endpoint:
   112  
   113  ```console
   114  $ curl -L -X GET 'http://10.0.0.207:51080/s3'
   115  ```
   116  
   117  ```xml
   118  <ListBucketResult>
   119    <Owner>
   120      <ID>1</ID>
   121      <DisplayName>ListAllMyBucketsResult</DisplayName>
   122    </Owner>
   123    <Buckets>
   124      <Bucket>
   125         <Name>abc</Name>
   126         <CreationDate>2022-08-24T09:59:56-04:00</CreationDate>
   127         <String>Provider: ais</String>
   128      </Bucket>
   129      <Bucket>
   130      ...
   131      </Bucket>
   132  </Buckets>
   133  </ListBucketResult>
   134  ```
   135  
   136  Now, if you compare this with the example from the previous section (where we used GET 'http://10.0.0.207:51080/gs' URL) - the difference must become clear:
   137  
   138  * GET 'http://10.0.0.207:51080/s3' implements Amazon S3 `list-buckets` API; as such it must report all buckets (across all providers and not only `s3`) that can be accessed, read, and written.
   139  * GET 'http://10.0.0.207:51080/gs' provides "easy URL" capability, whereby `gs` explicitly specifies the [backend provider](/docs/providers.md).
   140  
   141  > Note that `/s3` and its subordinate URL paths currently can only "see" buckets that are already present in AIStore BMD, while native API, when given sufficient permissions, can immediately access (read, write, list) any remote buckets, while adding them to the BMD "on the fly".
   142  
   143  > That is one of the limitations of *not* using native API.
   144  
   145  ## References
   146  
   147  - [REST API](/docs/http_api.md)