Skip to content

Commit bb8cf2b

Browse files
committed
fix: adapt example to new regional api
1 parent a23e6f4 commit bb8cf2b

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

examples/objectstorage/objectstorage.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,31 @@ import (
55
"fmt"
66
"os"
77

8-
"github.com/stackitcloud/stackit-sdk-go/core/config"
98
"github.com/stackitcloud/stackit-sdk-go/services/objectstorage"
109
)
1110

1211
func main() {
1312
// Specify the project ID
1413
projectId := "PROJECT_ID"
14+
region := "eu01"
1515

1616
// Create a new API client, that uses default authentication and configuration
17-
objectStorageClient, err := objectstorage.NewAPIClient(
18-
config.WithRegion("eu01"),
19-
)
17+
objectStorageClient, err := objectstorage.NewAPIClient()
2018
if err != nil {
2119
fmt.Fprintf(os.Stderr, "Creating API client: %v\n", err)
2220
os.Exit(1)
2321
}
2422

2523
// Get the object storage buckets for your project
26-
getBucketsResp, err := objectStorageClient.ListBuckets(context.Background(), projectId).Execute()
24+
getBucketsResp, err := objectStorageClient.ListBuckets(context.Background(), projectId, region).Execute()
2725
if err != nil {
2826
fmt.Fprintf(os.Stderr, "Error when calling `GetBuckets`: %v\n", err)
2927
} else {
3028
fmt.Printf("Number of buckets: %v\n", len(*getBucketsResp.Buckets))
3129
}
3230

3331
// Create an object storage bucket
34-
createBucketResp, err := objectStorageClient.CreateBucket(context.Background(), projectId, "example-bucket").Execute()
32+
createBucketResp, err := objectStorageClient.CreateBucket(context.Background(), projectId, region, "example-bucket").Execute()
3533
if err != nil {
3634
fmt.Fprintf(os.Stderr, "Error when calling `CreateBucket`: %v\n", err)
3735
} else {

0 commit comments

Comments
 (0)