Skip to content

Commit b3fad00

Browse files
feat(authorization): add multi API version support (#5499)
relates to STACKITSDK-330 Co-authored-by: Ruben Hoenle <Ruben.Hoenle@stackit.cloud>
1 parent 39f7ef7 commit b3fad00

File tree

65 files changed

+9154
-47
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+9154
-47
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@
104104
- `v1api`: New package which should be used for communication with the STACKIT mariadb API in the future
105105
- **Deprecation:** The contents in the root of this SDK module including the `wait` package are marked as deprecated and will be removed after 2026-09-30. Switch to the new `v0api` package instead.
106106
- **Dependencies:** Bump STACKIT SDK core module from `v0.21.1` to `v0.22.0`
107+
- `authorization`: [v0.13.0](services/authorization/CHANGELOG.md#v0130)
108+
- **Feature:** Introduction of multi API version support for the authorization SDK module. For more details please see the announcement on GitHub: https://github.com/stackitcloud/stackit-sdk-go/discussions/5062
109+
- `v2api`: New package which should be used for communication with the STACKIT authorization API in the future
110+
- **Deprecation:** The contents in the root of this SDK module including the `wait` package are marked as deprecated and will be removed after 2026-09-30. Switch to the new `v2api` package instead.
111+
- **Dependencies:** Bump STACKIT SDK core module from `v0.21.1` to `v0.22.0`
107112

108113
## Release (2026-02-20)
109114
- `core`: [v0.21.1](core/CHANGELOG.md#v0211)

examples/authorization/authorization.go

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import (
55
"fmt"
66
"os"
77

8-
"github.com/stackitcloud/stackit-sdk-go/core/utils"
9-
"github.com/stackitcloud/stackit-sdk-go/services/authorization"
8+
authorization "github.com/stackitcloud/stackit-sdk-go/services/authorization/v2api"
109
)
1110

1211
func main() {
@@ -22,53 +21,53 @@ func main() {
2221
}
2322

2423
// Get the available permissions for the project resource type
25-
getPermissionsResp, err := client.ListPermissions(context.Background()).ResourceType("project").Execute()
24+
getPermissionsResp, err := client.DefaultAPI.ListPermissions(context.Background()).ResourceType("project").Execute()
2625
if err != nil {
2726
fmt.Fprintf(os.Stderr, "Error when calling `GetPermissions`: %v\n", err)
2827
} else {
29-
availablePermissions := *getPermissionsResp.Permissions
28+
availablePermissions := getPermissionsResp.Permissions
3029
if len(availablePermissions) > 0 {
31-
fmt.Printf("Example of available permission: %v\n", *availablePermissions[0].Name)
30+
fmt.Printf("Example of available permission: %v\n", availablePermissions[0].Name)
3231
}
3332
}
3433

3534
// Get the memberships of your user
36-
getMembershipsResp, err := client.ListUserMemberships(context.Background(), yourEmail).Execute()
35+
getMembershipsResp, err := client.DefaultAPI.ListUserMemberships(context.Background(), yourEmail).Execute()
3736
if err != nil {
3837
fmt.Fprintf(os.Stderr, "Error when calling `ListUserMemberships`: %v\n", err)
3938
} else {
40-
userMemberships := *getMembershipsResp.Items
39+
userMemberships := getMembershipsResp.Items
4140
fmt.Printf("Number of memberships: %v\n", len(userMemberships))
4241

4342
if len(userMemberships) > 0 {
4443
fmt.Printf("Example of a membership of user %s: \nResource type - %s\nResource id - %s\nRole - %s\n",
45-
*userMemberships[0].Subject,
46-
*userMemberships[0].ResourceType,
47-
*userMemberships[0].ResourceId,
48-
*userMemberships[0].Role,
44+
userMemberships[0].Subject,
45+
userMemberships[0].ResourceType,
46+
userMemberships[0].ResourceId,
47+
userMemberships[0].Role,
4948
)
5049
}
5150
}
5251

5352
// Get the members of your project
54-
getMembersResp, err := client.ListMembers(context.Background(), "project", projectId).Execute()
53+
getMembersResp, err := client.DefaultAPI.ListMembers(context.Background(), "project", projectId).Execute()
5554
if err != nil {
5655
fmt.Fprintf(os.Stderr, "Error when calling `GetMembers`: %v\n", err)
5756
} else {
58-
fmt.Printf("Number of members: %v\n", len(*getMembersResp.Members))
57+
fmt.Printf("Number of members: %v\n", len(getMembersResp.Members))
5958
}
6059

6160
// Add a member to your project or add an additional role to an existing member
6261
updateMemberPayload := authorization.AddMembersPayload{
63-
Members: &[]authorization.Member{
62+
Members: []authorization.Member{
6463
{
65-
Role: utils.Ptr("project.member"),
66-
Subject: utils.Ptr(emailToBeAdded),
64+
Role: "project.member",
65+
Subject: emailToBeAdded,
6766
},
6867
},
69-
ResourceType: utils.Ptr("project"),
68+
ResourceType: "project",
7069
}
71-
_, err = client.AddMembers(context.Background(), projectId).AddMembersPayload(updateMemberPayload).Execute()
70+
_, err = client.DefaultAPI.AddMembers(context.Background(), projectId).AddMembersPayload(updateMemberPayload).Execute()
7271
if err != nil {
7372
fmt.Fprintf(os.Stderr, "Error when calling `UpdateMembers`: %v\n", err)
7473
} else {
@@ -77,15 +76,15 @@ func main() {
7776

7877
// Remove a role from a member of your project
7978
deleteMemberPayload := authorization.RemoveMembersPayload{
80-
Members: &[]authorization.Member{
79+
Members: []authorization.Member{
8180
{
82-
Role: utils.Ptr("project.member"),
83-
Subject: utils.Ptr(emailToBeAdded),
81+
Role: "project.member",
82+
Subject: emailToBeAdded,
8483
},
8584
},
86-
ResourceType: utils.Ptr("project"),
85+
ResourceType: "project",
8786
}
88-
_, err = client.RemoveMembers(context.Background(), projectId).RemoveMembersPayload(deleteMemberPayload).Execute()
87+
_, err = client.DefaultAPI.RemoveMembers(context.Background(), projectId).RemoveMembersPayload(deleteMemberPayload).Execute()
8988
if err != nil {
9089
fmt.Fprintf(os.Stderr, "Error when calling `DeleteMembers`: %v\n", err)
9190
} else {

examples/authorization/go.mod

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ module github.com/stackitcloud/stackit-sdk-go/examples/authorization
22

33
go 1.21
44

5-
require (
6-
github.com/stackitcloud/stackit-sdk-go/core v0.21.1
7-
github.com/stackitcloud/stackit-sdk-go/services/authorization v0.12.0
8-
)
5+
// This is not needed in production. This is only here to point the golangci linter to the local version instead of the last release on GitHub.
6+
replace github.com/stackitcloud/stackit-sdk-go/services/authorization => ../../services/authorization
7+
8+
require github.com/stackitcloud/stackit-sdk-go/services/authorization v0.12.0
99

1010
require (
1111
github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
1212
github.com/google/uuid v1.6.0 // indirect
13+
github.com/stackitcloud/stackit-sdk-go/core v0.22.0 // indirect
1314
)

examples/authorization/go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
44
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
55
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
66
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
7-
github.com/stackitcloud/stackit-sdk-go/core v0.21.1 h1:Y/PcAgM7DPYMNqum0MLv4n1mF9ieuevzcCIZYQfm3Ts=
8-
github.com/stackitcloud/stackit-sdk-go/core v0.21.1/go.mod h1:osMglDby4csGZ5sIfhNyYq1bS1TxIdPY88+skE/kkmI=
9-
github.com/stackitcloud/stackit-sdk-go/services/authorization v0.12.0 h1:HxPgBu04j5tj6nfZ2r0l6v4VXC0/tYOGe4sA5Addra8=
10-
github.com/stackitcloud/stackit-sdk-go/services/authorization v0.12.0/go.mod h1:uYI9pHAA2g84jJN25ejFUxa0/JtfpPZqMDkctQ1BzJk=
7+
github.com/stackitcloud/stackit-sdk-go/core v0.22.0 h1:6rViz7GnNwXSh51Lur5xuDzO8EWSZfN9J0HvEkBKq6c=
8+
github.com/stackitcloud/stackit-sdk-go/core v0.22.0/go.mod h1:osMglDby4csGZ5sIfhNyYq1bS1TxIdPY88+skE/kkmI=

services/authorization/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## v0.13.0
2+
- **Feature:** Introduction of multi API version support for the authorization SDK module. For more details please see the announcement on GitHub: https://github.com/stackitcloud/stackit-sdk-go/discussions/5062
3+
- `v2api`: New package which should be used for communication with the STACKIT authorization API in the future
4+
- **Deprecation:** The contents in the root of this SDK module including the `wait` package are marked as deprecated and will be removed after 2026-09-30. Switch to the new `v2api` package instead.
5+
- **Dependencies:** Bump STACKIT SDK core module from `v0.21.1` to `v0.22.0`
6+
17
## v0.12.0
28
- **Breaking change:** removed operation `GetAssignableSubjects` and related models `AssignableSubject`, `ListAssignableSubjectsResponse`
39

services/authorization/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.12.0
1+
v0.13.0

0 commit comments

Comments
 (0)