Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
- **Feature:** Add method to create inquiries: `InquiriesCreateInquiry`
- **Feature:** Add `sort` property to `ApiListCatalogProductsRequest`
- **Feature:** Add payload `ApproveSubscriptionPayload` for `ApiApproveSubscriptionRequest`
- `postgresflex`: [v1.0.0](services/postgresflex/CHANGELOG.md#v100-2025-02-24)
- **Breaking Change:** The region is no longer specified within the client configuration. Instead, the region must be passed as a parameter to any region-specific request.

## Release (2025-02-21)
> [!WARNING]
Expand Down
6 changes: 2 additions & 4 deletions examples/postgresflex/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ module github.com/stackitcloud/stackit-sdk-go/examples/postgresflex

go 1.21

require (
github.com/stackitcloud/stackit-sdk-go/core v0.16.0
github.com/stackitcloud/stackit-sdk-go/services/postgresflex v0.18.0
)
require github.com/stackitcloud/stackit-sdk-go/services/postgresflex v0.18.0

require (
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/stackitcloud/stackit-sdk-go/core v0.16.0 // indirect
)
20 changes: 10 additions & 10 deletions examples/postgresflex/postgresflex.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"os"

"github.com/stackitcloud/stackit-sdk-go/core/config"
"github.com/stackitcloud/stackit-sdk-go/services/postgresflex"
"github.com/stackitcloud/stackit-sdk-go/services/postgresflex/wait"
)
Expand All @@ -14,17 +13,18 @@ func main() {
// Specify the project ID
projectId := "PROJECT_ID"

// Specify the region
region := "REGION"

// Create a new API client, that uses default authentication and configuration
postgresflexClient, err := postgresflex.NewAPIClient(
config.WithRegion("eu01"),
)
postgresflexClient, err := postgresflex.NewAPIClient()
if err != nil {
fmt.Fprintf(os.Stderr, "Creating API client: %v\n", err)
os.Exit(1)
}

// Get the postgresql instances for your project
getInstancesResp, err := postgresflexClient.ListInstances(context.Background(), projectId).Execute()
getInstancesResp, err := postgresflexClient.ListInstances(context.Background(), projectId, region).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `ListInstances`: %v\n", err)
os.Exit(1)
Expand All @@ -44,7 +44,7 @@ func main() {
Username: &username,
Roles: &[]string{"login"},
}
_, err = postgresflexClient.CreateUser(context.Background(), projectId, instanceId).CreateUserPayload(createUserPayload).Execute()
_, err = postgresflexClient.CreateUser(context.Background(), projectId, region, instanceId).CreateUserPayload(createUserPayload).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `CreateUser`: %v\n", err)
os.Exit(1)
Expand All @@ -53,27 +53,27 @@ func main() {
fmt.Printf("Created user \"%s\" associated to instance \"%s\".\n", username, *items[0].Name)

// Delete an instance
err = postgresflexClient.DeleteInstance(context.Background(), projectId, instanceId).Execute()
err = postgresflexClient.DeleteInstance(context.Background(), projectId, region, instanceId).Execute()

if err != nil {
fmt.Fprintf(os.Stderr, "Error when delete PostgreSQL Flex instance: %v", err)
}

_, err = wait.DeleteInstanceWaitHandler(context.Background(), postgresflexClient, projectId, instanceId).WaitWithContext(context.Background())
_, err = wait.DeleteInstanceWaitHandler(context.Background(), postgresflexClient, projectId, region, instanceId).WaitWithContext(context.Background())
if err != nil {
fmt.Fprintf(os.Stderr, "Error when waiting for PostgreSQL Flex instance deletion: %v", err)
}

fmt.Printf("Deleted PostgreSQL Flex instance \"%s\".\n", instanceId)

// Force delete an instance
err = postgresflexClient.ForceDeleteInstance(context.Background(), projectId, instanceId).Execute()
err = postgresflexClient.ForceDeleteInstance(context.Background(), projectId, region, instanceId).Execute()

if err != nil {
fmt.Fprintf(os.Stderr, "Error when force delete PostgreSQL Flex instance: %v", err)
}

_, err = wait.ForceDeleteInstanceWaitHandler(context.Background(), postgresflexClient, projectId, instanceId).WaitWithContext(context.Background())
_, err = wait.ForceDeleteInstanceWaitHandler(context.Background(), postgresflexClient, projectId, region, instanceId).WaitWithContext(context.Background())
if err != nil {
fmt.Fprintf(os.Stderr, "Error when waiting for PostgreSQL Flex instance force deletion: %v", err)
}
Expand Down
16 changes: 8 additions & 8 deletions examples/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"net/http"
"os"

"github.com/stackitcloud/stackit-sdk-go/core/config"
"github.com/stackitcloud/stackit-sdk-go/core/runtime"
"github.com/stackitcloud/stackit-sdk-go/services/postgresflex"
)
Expand All @@ -15,30 +14,31 @@ func main() {
// Specify the project ID
projectId := "PROJECT_ID"

// Specify the region
region := "REGION"

// Create a new API client, that uses default authentication and configuration
postgresflexClient, err := postgresflex.NewAPIClient(
config.WithRegion("eu01"),
)
postgresflexClient, err := postgresflex.NewAPIClient()
if err != nil {
fmt.Fprintf(os.Stderr, "Creating API client: %v\n", err)
os.Exit(1)
}

// Get the MongoDB Flex instances for your project and capture the HTTP response using the context
// Get the PostgreSQL Flex instances for your project and capture the HTTP response using the context
var httpResp *http.Response
ctxWithHTTPResp := runtime.WithCaptureHTTPResponse(context.Background(), &httpResp)
getInstancesResp, err := postgresflexClient.ListInstances(ctxWithHTTPResp, projectId).Execute()
getInstancesResp, err := postgresflexClient.ListInstances(ctxWithHTTPResp, projectId, region).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `ListInstances`: %v\n", err)
os.Exit(1)
}
fmt.Printf("Number of instances: %v\n\n", len(*getInstancesResp.Items))
fmt.Printf("HTTP response: %+v\n\n", *httpResp)

// Get the MongoDB Flex instances for your project and capture the HTTP request using the context
// Get the PostgreSQL Flex instances for your project and capture the HTTP request using the context
var httpReq *http.Request
ctxWithHTTPReq := runtime.WithCaptureHTTPRequest(context.Background(), &httpReq)
getInstancesResp, err = postgresflexClient.ListInstances(ctxWithHTTPReq, projectId).Execute()
getInstancesResp, err = postgresflexClient.ListInstances(ctxWithHTTPReq, projectId, region).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `ListInstances`: %v\n", err)
os.Exit(1)
Expand Down
3 changes: 3 additions & 0 deletions services/postgresflex/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v1.0.0 (2025-02-24)
- **Breaking Change:** The region is no longer specified within the client configuration. Instead, the region must be passed as a parameter to any region-specific request.

## v0.18.0 (2025-02-21)
- **New:** Minimal go version is now Go 1.21

Expand Down
Loading
Loading