Skip to content

Commit

Permalink
Remove old APIs from client, promote RMv2 and Members v2 to productiv…
Browse files Browse the repository at this point in the history
…e services (#35)

* Add support for new RMv2 + Members v2 APIs
* Keep previous RMv1 projects 'get' functionality under archived
* Major restructure of Client config
* Removal of Auth client

Co-authored-by: Dean Oren <[email protected]>
  • Loading branch information
do87 and Dean Oren authored Oct 28, 2022
1 parent 8559ecd commit 1ab18c6
Show file tree
Hide file tree
Showing 32 changed files with 452 additions and 1,813 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@ test:
@go test $(TEST) || exit 1
@echo $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4

coverage:
@go test ./... -coverprofile cover.out
@go tool cover -func cover.out | grep total:
@rm cover.out

quality:
@goreportcard-cli -v ./...
22 changes: 6 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ To install the latest stable release, run:
go get github.com/SchwarzIT/community-stackit-go-client@latest
```

## Usage Example

## Usage example

To get started, a Service Account[^1] and a Customer Account[^2] must be in place

If you're not sure how to get this information, please contact [STACKIT support](https://support.stackit.cloud)
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
Expand All @@ -35,9 +34,8 @@ import (
func main() {
ctx := context.Background()
c, err := client.New(ctx, &client.Config{
ServiceAccountID: os.Getenv("STACKIT_SERVICE_ACCOUNT_ID"),
Token: os.Getenv("STACKIT_SERVICE_ACCOUNT_TOKEN"),
OrganizationID: os.Getenv("STACKIT_ORGANIZATION_ID"),
ServiceAccountEmail: os.Getenv("STACKIT_SERVICE_ACCOUNT_EMAIL"),
ServiceAccountToken: os.Getenv("STACKIT_SERVICE_ACCOUNT_TOKEN"),
})
if err != nil {
panic(err)
Expand All @@ -64,7 +62,7 @@ func main() {
Further usage examples can be found in [`terraform-provider-stackit`](https://github.com/SchwarzIT/terraform-provider-stackit)


## Auto retry
### Enabling auto-retry

The client can automatically retry failed calls using `pkg/retry`

Expand All @@ -75,11 +73,3 @@ c, _ := client.New(context.Background(), &client.Config{})
c.SetRetry(retry.New())
```


[^1]: In order to use the client, a Service Account and Token must be created using [Service Account API](https://api.stackit.schwarz/service-account/openapi.v1.html#operation/post-projects-projectId-service-accounts-v2)<br />
After creation, assign roles to the Service Account using [Membership API](https://api.stackit.schwarz/membership-service/openapi.v1.html#operation/post-organizations-organizationId-projects-projectId-roles-roleName-service-accounts)<br />
If your Service Account needs to operate outside the scope of your project, you may need to contact STACKIT to assign further permissions

<br />

[^2]: The Customer Account ID is also referred to as Organization ID
135 changes: 0 additions & 135 deletions auth.go

This file was deleted.

199 changes: 0 additions & 199 deletions auth_test.go

This file was deleted.

Loading

0 comments on commit 1ab18c6

Please sign in to comment.