improve golang example
This commit is contained in:
parent
5cedde9b9f
commit
eb29f67298
1 changed files with 29 additions and 0 deletions
|
@ -54,4 +54,33 @@ func main() {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
fmt.Printf(strings.Join(msg.Message, "\n"))
|
fmt.Printf(strings.Join(msg.Message, "\n"))
|
||||||
|
|
||||||
|
// Key
|
||||||
|
// -- create
|
||||||
|
key := "openapi-key"
|
||||||
|
keyInfo, r, err := client.KeyApi.AddKey(ctx).AddKeyRequest(garage.AddKeyRequest{Name: *garage.NewNullableString(&key) }).Execute()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "Error when calling `KeyApi.AddKey`\n")
|
||||||
|
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
fmt.Printf("AWS_ACCESS_KEY_ID=%s\nAWS_SECRET_ACCESS_KEY=%s\n", *keyInfo.AccessKeyId, *keyInfo.SecretAccessKey.Get())
|
||||||
|
|
||||||
|
// Bucket
|
||||||
|
// -- create
|
||||||
|
global_name := "global-ns-openapi-bucket"
|
||||||
|
local_name := "local-ns-openapi-bucket"
|
||||||
|
bucketInfo, r, err := client.BucketApi.CreateBucket(ctx).CreateBucketRequest(garage.CreateBucketRequest{
|
||||||
|
GlobalAlias: &global_name,
|
||||||
|
LocalAlias: &garage.CreateBucketRequestLocalAlias {
|
||||||
|
AccessKeyId: keyInfo.AccessKeyId,
|
||||||
|
Alias: &local_name,
|
||||||
|
},
|
||||||
|
}).Execute()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "Error when calling `BucketApi.CreateBucket`\n")
|
||||||
|
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
fmt.Printf("Bucket id: %s\n", *bucketInfo.Id)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue