aboutsummaryrefslogtreecommitdiff
path: root/doc/book/build/javascript.md
blob: ff009ffecba4cc8e68a0bcdb21ac0e5d18f372a8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
+++
title = "Javascript"
weight = 10
+++

## S3

*Coming soon*.

Some refs:
  - Minio SDK
    - [Reference](https://docs.min.io/docs/javascript-client-api-reference.html)

  - Amazon aws-sdk-js
    - [Installation](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/getting-started.html)
    - [Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html)
    - [Example](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/s3-example-creating-buckets.html)

## K2V

*Coming soon*

## Administration

Install the SDK with:

```bash
npm install --save git+https://git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-js.git
```

A short example:

```javascript
const garage = require('garage_administration_api_v0garage_v0_8_0');

const api = new garage.ApiClient("http://127.0.0.1:3903/v0");
api.authentications['bearerAuth'].accessToken = "s3cr3t";

const [node, layout, key, bucket] = [
  new garage.NodesApi(api),
  new garage.LayoutApi(api),
  new garage.KeyApi(api),
  new garage.BucketApi(api),
];

node.getNodes().then((data) => {
  console.log(`nodes: ${Object.values(data.knownNodes).map(n => n.hostname)}`)
}, (error) => {
  console.error(error);
});
```

See also:
 - [sdk repository](https://git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-js)
 - [examples](https://git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-generator/src/branch/main/example/javascript)