garage/doc/book/build/golang.md
Quentin Dufour cf23aee183
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
Add a "build" section, doc for SDK
2022-11-13 16:48:52 +01:00

1.6 KiB

+++ title = "Golang" weight = 30 +++

S3

Coming soon

Some refs:

K2V

Coming soon

Administration

Install the SDK with:

go get git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang

A short example:

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: