aboutsummaryrefslogtreecommitdiff
path: root/doc/book/build/golang.md
diff options
context:
space:
mode:
authorAlex <alex@adnab.me>2022-11-16 10:51:04 +0000
committerAlex <alex@adnab.me>2022-11-16 10:51:04 +0000
commitbcc97724707aaa39fd64490cdd81aa5073285f33 (patch)
tree41e0535d0aaf8cfb095576c3c0d41213197dd003 /doc/book/build/golang.md
parentc4e4cc1156e10fb0a840666873efa1e4dfb7c884 (diff)
parentcf23aee1831e464b2a445a1ffb302086f32dd6e5 (diff)
downloadgarage-bcc97724707aaa39fd64490cdd81aa5073285f33.tar.gz
garage-bcc97724707aaa39fd64490cdd81aa5073285f33.zip
Merge pull request 'OpenAPI spec for admin API' (#379) from ecosystem/openapi into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/379
Diffstat (limited to 'doc/book/build/golang.md')
-rw-r--r--doc/book/build/golang.md69
1 files changed, 69 insertions, 0 deletions
diff --git a/doc/book/build/golang.md b/doc/book/build/golang.md
new file mode 100644
index 00000000..a508260e
--- /dev/null
+++ b/doc/book/build/golang.md
@@ -0,0 +1,69 @@
++++
+title = "Golang"
+weight = 30
++++
+
+## S3
+
+*Coming soon*
+
+Some refs:
+ - Minio minio-go-sdk
+ - [Reference](https://docs.min.io/docs/golang-client-api-reference.html)
+
+ - Amazon aws-sdk-go-v2
+ - [Installation](https://aws.github.io/aws-sdk-go-v2/docs/getting-started/)
+ - [Reference](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/s3)
+ - [Example](https://aws.github.io/aws-sdk-go-v2/docs/code-examples/s3/putobject/)
+
+## K2V
+
+*Coming soon*
+
+## Administration
+
+Install the SDK with:
+
+```bash
+go get git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang
+```
+
+A short example:
+
+```go
+package main
+
+import (
+ "context"
+ "fmt"
+ "os"
+ garage "git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang"
+)
+
+func main() {
+ // Set Host and other parameters
+ configuration := garage.NewConfiguration()
+ configuration.Host = "127.0.0.1:3903"
+
+
+ // We can now generate a client
+ client := garage.NewAPIClient(configuration)
+
+ // Authentication is handled through the context pattern
+ ctx := context.WithValue(context.Background(), garage.ContextAccessToken, "s3cr3t")
+
+ // Send a request
+ resp, r, err := client.NodesApi.GetNodes(ctx).Execute()
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Error when calling `NodesApi.GetNodes``: %v\n", err)
+ fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
+ }
+
+ // Process the response
+ fmt.Fprintf(os.Stdout, "Target hostname: %v\n", resp.KnownNodes[resp.Node].Hostname)
+}
+```
+
+See also:
+ - [generated doc](https://git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang)
+ - [examples](https://git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-generator/src/branch/main/example/golang)