Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Dean Oren committed Jan 16, 2023
1 parent 5e526f5 commit 87df23e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 32 deletions.
54 changes: 24 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,52 +10,46 @@ The client is community-supported and not an official STACKIT release, it is mai

To install the latest stable release, run:

```
```bash
go get github.com/SchwarzIT/community-stackit-go-client@latest
```

## Usage Example


In order to use the client, a STACKIT Service Account [must be created](https://api.stackit.schwarz/service-account/openapi.v1.html#operation/post-projects-projectId-service-accounts-v2) and have relevant roles [assigned to it](https://api.stackit.schwarz/membership-service/openapi.v1.html#operation/post-organizations-organizationId-projects-projectId-roles-roleName-service-accounts).<br />
For further assistance, please contact [STACKIT support](https://support.stackit.cloud)

```Go
package main

import (
"context"
"fmt"
"os"
"context"
"fmt"
"os"

client "github.com/SchwarzIT/community-stackit-go-client"
"github.com/SchwarzIT/community-stackit-go-client/pkg/validate"
client "github.com/SchwarzIT/community-stackit-go-client"
"github.com/SchwarzIT/community-stackit-go-client/pkg/validate"
)

func main() {
ctx := context.Background()
c, err := client.New(ctx, client.Config{
ServiceAccountEmail: os.Getenv("STACKIT_SERVICE_ACCOUNT_EMAIL"),
ServiceAccountToken: os.Getenv("STACKIT_SERVICE_ACCOUNT_TOKEN"),
})
if err != nil {
panic(err)
}

projectID := "123-456-789"
bucketName := "bucket"

res, err := c.ObjectStorage.Bucket.CreateWithResponse(ctx, projectID, bucketName)
if agg := validate.Response(res, err); agg != nil {
panic(err)
}

process := res.WaitHandler(ctx, c.ObjectStorage.Bucket, projectID, bucketName)
if _, err := process.WaitWithContext(ctx); err != nil {
panic(err)
}

fmt.Printf("bucket '%s' created successfully", bucketName)
ctx := context.Background()
c, err := client.New(ctx, client.Config{
ServiceAccountEmail: os.Getenv("STACKIT_SERVICE_ACCOUNT_EMAIL"),
ServiceAccountToken: os.Getenv("STACKIT_SERVICE_ACCOUNT_TOKEN"),
})
if err != nil {
panic(err)
}

res, err := c.ElasticSearch.Offerings.GetWithResponse(ctx, "{project-id}")
if aggregatedError := validate.Response(res, err, "JSON200"); aggregatedError != nil {
panic(aggregatedError)
}

fmt.Println("Received the following offerings:")
for _, o := range res.JSON200.Offerings {
fmt.Printf("- %s\n", o.Name)
}
}
```

Expand Down
3 changes: 1 addition & 2 deletions examples/elasticsearch/offerings.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ func main() {
panic(err)
}

projectID := "123-456-789"
res, err := c.ElasticSearch.Offerings.GetWithResponse(ctx, projectID)
res, err := c.ElasticSearch.Offerings.GetWithResponse(ctx, "{project-id}")
if aggregatedError := validate.Response(res, err, "JSON200"); aggregatedError != nil {
panic(aggregatedError)
}
Expand Down

0 comments on commit 87df23e

Please sign in to comment.