Skip to content

Commit fa4987d

Browse files
feat(mongodbflex): add multi API version support (#5837)
relates to STACKITSDK-344 Co-authored-by: Ruben Hoenle <Ruben.Hoenle@stackit.cloud>
1 parent b200575 commit fa4987d

File tree

180 files changed

+36312
-76
lines changed

Some content is hidden

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

180 files changed

+36312
-76
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,12 @@
200200
- `v2beta1api`: New package which can be used for communication with the iaas v2 beta1 API
201201
- **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 packages for the available API versions instead.
202202
- **Dependencies:** Bump STACKIT SDK core module from `v0.21.1` to `v0.22.0`
203+
- `mongodbflex`: [v1.6.0](services/mongodbflex/CHANGELOG.md#v160)
204+
- **Feature:** Introduction of multi API version support for the mongodbflex SDK module. For more details please see the announcement on GitHub: https://github.com/stackitcloud/stackit-sdk-go/discussions/5062
205+
- `v1api`: New package which can be used for communication with the mongodbflex v1 API
206+
- `v2api`: New package which can be used for communication with the mongodbflex v2 API
207+
- **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 packages for the available API versions instead.
208+
- **Dependencies:** Bump STACKIT SDK core module from `v0.21.1` to `v0.22.0`
203209

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

examples/mongodbflex/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/mongodbflex
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/mongodbflex v1.5.8
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/mongodbflex => ../../services/mongodbflex
7+
8+
require github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.5.8
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/mongodbflex/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/mongodbflex v1.5.8 h1:S7t4wcT6SN8ZzdoY8d6VbF903zFpGjzqrU0FN27rJPg=
10-
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.5.8/go.mod h1:CdrhFUsBO7/iJleCc2yQjDChIbG6YaxKNBQRNCjgcF4=
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=

examples/mongodbflex/mongodbflex.go

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

8-
"github.com/stackitcloud/stackit-sdk-go/core/utils"
9-
"github.com/stackitcloud/stackit-sdk-go/services/mongodbflex"
10-
"github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/wait"
8+
mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api"
9+
"github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api/wait"
1110
)
1211

1312
func main() {
@@ -24,12 +23,12 @@ func main() {
2423
}
2524

2625
// Get the MongoDB Flex instances for your project
27-
getInstancesResp, err := mongodbflexClient.ListInstances(context.Background(), projectId, region).Tag("tag").Execute()
26+
getInstancesResp, err := mongodbflexClient.DefaultAPI.ListInstances(context.Background(), projectId, region).Tag("tag").Execute()
2827
if err != nil {
2928
fmt.Fprintf(os.Stderr, "Error when calling `ListInstances`: %v\n", err)
3029
os.Exit(1)
3130
}
32-
items := *getInstancesResp.Items
31+
items := getInstancesResp.Items
3332
fmt.Printf("Number of instances: %v\n", len(items))
3433

3534
// Create a user associated to an instance
@@ -42,10 +41,10 @@ func main() {
4241
username := "example-user"
4342
createUserPayload := mongodbflex.CreateUserPayload{
4443
Username: &username,
45-
Database: utils.Ptr("default"),
46-
Roles: &[]string{"read"},
44+
Database: "default",
45+
Roles: []string{"read"},
4746
}
48-
_, err = mongodbflexClient.CreateUser(context.Background(), projectId, instanceId, region).CreateUserPayload(createUserPayload).Execute()
47+
_, err = mongodbflexClient.DefaultAPI.CreateUser(context.Background(), projectId, instanceId, region).CreateUserPayload(createUserPayload).Execute()
4948
if err != nil {
5049
fmt.Fprintf(os.Stderr, "Error when calling `CreateUser`: %v\n", err)
5150
os.Exit(1)
@@ -55,18 +54,18 @@ func main() {
5554

5655
// Restore an instance from a backup
5756
restoreInstancePayload := mongodbflex.RestoreInstancePayload{
58-
BackupId: utils.Ptr("BACKUP_ID"),
59-
InstanceId: &instanceId,
57+
BackupId: "BACKUP_ID",
58+
InstanceId: instanceId,
6059
}
61-
_, err = mongodbflexClient.RestoreInstance(context.Background(), projectId, instanceId, region).RestoreInstancePayload(restoreInstancePayload).Execute()
60+
_, err = mongodbflexClient.DefaultAPI.RestoreInstance(context.Background(), projectId, instanceId, region).RestoreInstancePayload(restoreInstancePayload).Execute()
6261
if err != nil {
6362
fmt.Fprintf(os.Stderr, "Error when calling `RestoreInstance`: %v\n", err)
6463
os.Exit(1)
6564
}
6665

6766
fmt.Printf("Restoring instance \"%s\" from backup \"%s\".\n", instanceId, "BACKUP_ID")
6867

69-
_, err = wait.RestoreInstanceWaitHandler(context.Background(), mongodbflexClient, projectId, instanceId, "BACKUP_ID", region).WaitWithContext(context.Background())
68+
_, err = wait.RestoreInstanceWaitHandler(context.Background(), mongodbflexClient.DefaultAPI, projectId, instanceId, "BACKUP_ID", region).WaitWithContext(context.Background())
7069
if err != nil {
7170
fmt.Fprintf(os.Stderr, "Error when waiting for restore to finish: %v\n", err)
7271
os.Exit(1)

services/mongodbflex/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## v1.6.0
2+
- **Feature:** Introduction of multi API version support for the mongodbflex SDK module. For more details please see the announcement on GitHub: https://github.com/stackitcloud/stackit-sdk-go/discussions/5062
3+
- `v1api`: New package which can be used for communication with the mongodbflex v1 API
4+
- `v2api`: New package which can be used for communication with the mongodbflex v2 API
5+
- **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 packages for the available API versions instead.
6+
- **Dependencies:** Bump STACKIT SDK core module from `v0.21.1` to `v0.22.0`
7+
18
## v1.5.8
29
- Bump STACKIT SDK core module from `v0.21.0` to `v0.21.1`
310

services/mongodbflex/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1.5.8
1+
v1.6.0

0 commit comments

Comments
 (0)