api-v1, generator #2

Merged
quentin merged 15 commits from v0.9.x into main 2023-11-28 15:40:37 +00:00
5 changed files with 37 additions and 5 deletions
Showing only changes of commit 5cedde9b9f - Show all commits

View file

@ -3,7 +3,7 @@ module garage-admin-example
go 1.18
require (
git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang v0.0.0-20231122201735-f442d10b102d // indirect
git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang v0.0.0-20231123092113-ffd9578e975e // indirect
github.com/golang/protobuf v1.4.2 // indirect
golang.org/x/net v0.0.0-20200822124328-c89045814202 // indirect
golang.org/x/oauth2 v0.0.0-20210323180902-22b0adad7558 // indirect

View file

@ -35,6 +35,12 @@ git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang v0.0.0-20221113145120-d012c
git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang v0.0.0-20221113145120-d012cff7c554/go.mod h1:TlSL6QVxozmdRaSgP6Akspi0HCJv4HAkkq3Dldru4GM=
git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang v0.0.0-20231122201735-f442d10b102d h1:GxlTiFj3WwYjULWp/MvW2iETmDf7TpOtEP2Qst2TkwU=
git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang v0.0.0-20231122201735-f442d10b102d/go.mod h1:TlSL6QVxozmdRaSgP6Akspi0HCJv4HAkkq3Dldru4GM=
git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang v0.0.0-20231123075451-d89dcefca5d0 h1:lhvMeTcFi72W1+nBg5LVueuFuNaP+2lIn+1Vg4yZvek=
git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang v0.0.0-20231123075451-d89dcefca5d0/go.mod h1:TlSL6QVxozmdRaSgP6Akspi0HCJv4HAkkq3Dldru4GM=
git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang v0.0.0-20231123090411-96f080c89ec4 h1:c7xX/UITgwb+7+m4uOB7BXg/pA+BB7EHhsXNMr8UMNY=
git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang v0.0.0-20231123090411-96f080c89ec4/go.mod h1:TlSL6QVxozmdRaSgP6Akspi0HCJv4HAkkq3Dldru4GM=
git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang v0.0.0-20231123092113-ffd9578e975e h1:C/D3P1+mWBTHiO3MeiNWB2S1AJ3A/m7OYGX4iS8nbtA=
git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang v0.0.0-20231123092113-ffd9578e975e/go.mod h1:TlSL6QVxozmdRaSgP6Akspi0HCJv4HAkkq3Dldru4GM=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=

View file

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"os"
"strings"
garage "git.deuxfleurs.fr/garage-sdk/garage-admin-sdk-golang"
)
@ -22,10 +23,35 @@ func main() {
// 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, "Error when calling `NodesApi.GetNodes`\n")
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
panic(err)
}
// Process the response
fmt.Fprintf(os.Stdout, "Target hostname: %v\n", resp.KnownNodes[0].Hostname)
fmt.Fprintf(os.Stdout, "First hostname: %v\n", resp.KnownNodes[0].Hostname)
// Layout
capa := int64(1000000000)
change := []garage.NodeRoleChange{
garage.NodeRoleChange{NodeRoleUpdate: &garage.NodeRoleUpdate {
Id: *resp.KnownNodes[0].Id,
Zone: "dc1",
Capacity: *garage.NewNullableInt64(&capa),
Tags: []string{ "fast", "amd64" },
}},
}
staged, r, err := client.LayoutApi.AddLayout(ctx).NodeRoleChange(change).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `LayoutApi.AddLayout`\n")
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
panic(err)
}
msg, r, err := client.LayoutApi.ApplyLayout(ctx).LayoutVersion(*garage.NewLayoutVersion(staged.Version + 1)).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `LayoutApi.ApplyLayout`\n")
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
panic(err)
}
fmt.Printf(strings.Join(msg.Message, "\n"))
}

2
garage

@ -1 +1 @@
Subproject commit 814b3e11d4486b6d4c291b4e47b845521ddfb25c
Subproject commit 68d23cccdfc650cb8fa48fb2871ca4dfe7014d44

@ -1 +1 @@
Subproject commit d89dcefca5d0170cccc8d96c98e1c208549bd5f4
Subproject commit ffd9578e975e886d9075a4f2e710117893de8ac7