55 "fmt"
66 "os"
77
8- "github.com/stackitcloud/stackit-sdk-go/core/config"
98 "github.com/stackitcloud/stackit-sdk-go/core/utils"
109 "github.com/stackitcloud/stackit-sdk-go/services/ske"
1110 "github.com/stackitcloud/stackit-sdk-go/services/ske/wait"
@@ -15,10 +14,11 @@ func main() {
1514 // Specify the project ID
1615 projectId := "PROJECT_ID"
1716
17+ // Specify the region
18+ region := "REGION"
19+
1820 // Create a new API client, that uses default authentication and configuration
19- skeClient , err := ske .NewAPIClient (
20- config .WithRegion ("eu01" ),
21- )
21+ skeClient , err := ske .NewAPIClient ()
2222 if err != nil {
2323 fmt .Fprintf (os .Stderr , "Creating API client: %v\n " , err )
2424 os .Exit (1 )
@@ -33,7 +33,7 @@ func main() {
3333 // }
3434
3535 // Get the ske clusters for your project
36- getClustersResp , err := skeClient .ListClusters (context .Background (), projectId ).Execute ()
36+ getClustersResp , err := skeClient .ListClusters (context .Background (), projectId , region ).Execute ()
3737 if err != nil {
3838 fmt .Fprintf (os .Stderr , "Error when calling `GetClusters`: %v\n " , err )
3939 } else {
@@ -42,7 +42,7 @@ func main() {
4242
4343 var availableVersion string
4444 // Get the ske provider options
45- getOptionsResp , err := skeClient .ListProviderOptions (context .Background ()).Execute ()
45+ getOptionsResp , err := skeClient .ListProviderOptions (context .Background (), region ).Execute ()
4646 if err != nil {
4747 fmt .Fprintf (os .Stderr , "Error when calling `GetOptions`: %v\n " , err )
4848 } else {
@@ -77,47 +77,47 @@ func main() {
7777 },
7878 }
7979 clusterName := "cl-name"
80- createClusterResp , err := skeClient .CreateOrUpdateCluster (context .Background (), projectId , clusterName ).CreateOrUpdateClusterPayload (createInstancePayload ).Execute ()
80+ createClusterResp , err := skeClient .CreateOrUpdateCluster (context .Background (), projectId , region , clusterName ).CreateOrUpdateClusterPayload (createInstancePayload ).Execute ()
8181 if err != nil {
8282 fmt .Fprintf (os .Stderr , "Error when calling `CreateCluster`: %v\n " , err )
8383 } else {
8484 fmt .Printf ("Triggered creation of cluster with name \" %s\" .\n " , * createClusterResp .Name )
8585 }
8686
8787 // Wait for cluster creation to complete
88- _ , err = wait .CreateOrUpdateClusterWaitHandler (context .Background (), skeClient , projectId , clusterName ).WaitWithContext (context .Background ())
88+ _ , err = wait .CreateOrUpdateClusterWaitHandler (context .Background (), skeClient , projectId , region , clusterName ).WaitWithContext (context .Background ())
8989 if err != nil {
9090 fmt .Fprintf (os .Stderr , "Error when calling `CreateOrUpdateCluster`: %v\n " , err )
9191 } else {
9292 fmt .Printf ("Cluster created.\n " )
9393 }
9494
9595 // Start cluster credential rotation
96- _ , err = skeClient .StartCredentialsRotationExecute (context .Background (), projectId , clusterName )
96+ _ , err = skeClient .StartCredentialsRotationExecute (context .Background (), projectId , region , clusterName )
9797 if err != nil {
9898 fmt .Fprintf (os .Stderr , "Error when calling `StartCredentialsRotation`: %v\n " , err )
9999 } else {
100100 fmt .Printf ("Triggered start of cluster credentials rotation.\n " )
101101 }
102102
103103 // Wait for cluster credential rotation to be prepared
104- _ , err = wait .StartCredentialsRotationWaitHandler (context .Background (), skeClient , projectId , clusterName ).WaitWithContext (context .Background ())
104+ _ , err = wait .StartCredentialsRotationWaitHandler (context .Background (), skeClient , projectId , region , clusterName ).WaitWithContext (context .Background ())
105105 if err != nil {
106106 fmt .Fprintf (os .Stderr , "Error when calling `StartRotateCredentials`: %v\n " , err )
107107 } else {
108108 fmt .Printf ("Cluster credentials ready to rotate.\n " )
109109 }
110110
111111 // Complete cluster credential rotation
112- _ , err = skeClient .CompleteCredentialsRotationExecute (context .Background (), projectId , clusterName )
112+ _ , err = skeClient .CompleteCredentialsRotationExecute (context .Background (), projectId , region , clusterName )
113113 if err != nil {
114114 fmt .Fprintf (os .Stderr , "Error when calling `CompleteCredentialsRotation`: %v\n " , err )
115115 } else {
116116 fmt .Printf ("Triggered completion of cluster credentials rotation.\n " )
117117 }
118118
119119 // Wait for cluster credential rotation to be completed
120- _ , err = wait .CompleteCredentialsRotationWaitHandler (context .Background (), skeClient , projectId , clusterName ).WaitWithContext (context .Background ())
120+ _ , err = wait .CompleteCredentialsRotationWaitHandler (context .Background (), skeClient , projectId , region , clusterName ).WaitWithContext (context .Background ())
121121 if err != nil {
122122 fmt .Fprintf (os .Stderr , "Error when calling `CompleteRotateCredentials`: %v\n " , err )
123123 } else {
0 commit comments