Skip to content

Commit 336073b

Browse files
Merge branch 'main' into vp/public-ip-example
2 parents 51fb706 + 039e61a commit 336073b

File tree

152 files changed

+25267
-16
lines changed

Some content is hidden

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

152 files changed

+25267
-16
lines changed

examples/iaas/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.18
44

55
require (
66
github.com/stackitcloud/stackit-sdk-go/core v0.14.0
7-
github.com/stackitcloud/stackit-sdk-go/services/iaas v0.10.0
7+
github.com/stackitcloud/stackit-sdk-go/services/iaas v0.11.0
88
)
99

1010
require (

examples/iaas/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
55
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
66
github.com/stackitcloud/stackit-sdk-go/core v0.14.0 h1:oBwwzrEHDTlZpRoQwmMQpNA8bWciTrtGkiN29nx14Z0=
77
github.com/stackitcloud/stackit-sdk-go/core v0.14.0/go.mod h1:mDX1mSTsB3mP+tNBGcFNx6gH1mGBN4T+dVt+lcw7nlw=
8-
github.com/stackitcloud/stackit-sdk-go/services/iaas v0.10.0 h1:bqZ1CqiQLcu//4zc859XwYT/IZFjnlV9QeemmDbCPxc=
9-
github.com/stackitcloud/stackit-sdk-go/services/iaas v0.10.0/go.mod h1:hEsLOmcqMFG0ftXSYOF8YtDrclkA0E89msGsH69B/BU=
8+
github.com/stackitcloud/stackit-sdk-go/services/iaas v0.11.0 h1:paGh0EOuTwY23ralUw3GBvdn71/DVMyyQ2M8rwfXbCE=
9+
github.com/stackitcloud/stackit-sdk-go/services/iaas v0.11.0/go.mod h1:YfuN+eXuqr846xeRyW2Vf1JM2jU0ikeQa76dDI66RsM=
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"net/http"
7+
"os"
8+
9+
"github.com/stackitcloud/stackit-sdk-go/core/config"
10+
"github.com/stackitcloud/stackit-sdk-go/core/runtime"
11+
"github.com/stackitcloud/stackit-sdk-go/services/iaasalpha"
12+
"github.com/stackitcloud/stackit-sdk-go/services/iaasalpha/wait"
13+
)
14+
15+
func main() {
16+
// Specify the organization ID and project ID
17+
projectId := "PROJECT_ID"
18+
serverId := "SERVER_ID"
19+
nicId := "NIC_ID"
20+
21+
// Create a new API client, that uses default authentication and configuration
22+
iaasalphaClient, err := iaasalpha.NewAPIClient(
23+
config.WithRegion("eu01"),
24+
)
25+
if err != nil {
26+
fmt.Fprintf(os.Stderr, "[iaasalpha API] Creating API client: %v\n", err)
27+
os.Exit(1)
28+
}
29+
30+
// Attach an existing network interface to an existing server
31+
var httpResp *http.Response
32+
ctxWithHTTPResp := runtime.WithCaptureHTTPResponse(context.Background(), &httpResp)
33+
err = iaasalphaClient.AddNICToServer(ctxWithHTTPResp, projectId, serverId, nicId).Execute()
34+
if err != nil {
35+
fmt.Fprintf(os.Stderr, "[iaasalpha API] Error when calling `AddNICToServer`: %v\n", err)
36+
} else {
37+
fmt.Printf("[iaasalpha API] Triggered attachment of nic with ID %q.\n", nicId)
38+
}
39+
requestId := httpResp.Header[wait.XRequestIDHeader][0]
40+
41+
// Wait for attachment of the nic
42+
_, err = wait.ProjectRequestWaitHandler(context.Background(), iaasalphaClient, projectId, requestId).WaitWithContext(context.Background())
43+
if err != nil {
44+
fmt.Fprintf(os.Stderr, "[iaasalpha API] Error when waiting for attachment: %v\n", err)
45+
os.Exit(1)
46+
}
47+
48+
fmt.Printf("[iaasalpha API] Nic %q has been successfully attached to the server %s.\n", nicId, serverId)
49+
50+
err = iaasalphaClient.RemoveNICFromServer(ctxWithHTTPResp, projectId, serverId, nicId).Execute()
51+
if err != nil {
52+
fmt.Fprintf(os.Stderr, "[iaasalpha API] Error when calling `RemoveNICFromServer`: %v\n", err)
53+
} else {
54+
fmt.Printf("[iaasalpha API] Triggered removal of attachment of nic with ID %q.\n", nicId)
55+
}
56+
57+
requestId = httpResp.Header[wait.XRequestIDHeader][0]
58+
59+
// Wait for dettachment of the nic
60+
_, err = wait.ProjectRequestWaitHandler(context.Background(), iaasalphaClient, projectId, requestId).WaitWithContext(context.Background())
61+
if err != nil {
62+
fmt.Fprintf(os.Stderr, "[iaasalpha API] Error when waiting for removal of attachment of NIC: %v\n", err)
63+
os.Exit(1)
64+
}
65+
66+
fmt.Printf("[iaasalpha API] NIC %q has been successfully detacched from the server %s.\n", nicId, serverId)
67+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"net/http"
7+
"os"
8+
9+
"github.com/stackitcloud/stackit-sdk-go/core/config"
10+
"github.com/stackitcloud/stackit-sdk-go/core/runtime"
11+
"github.com/stackitcloud/stackit-sdk-go/services/iaasalpha"
12+
"github.com/stackitcloud/stackit-sdk-go/services/iaasalpha/wait"
13+
)
14+
15+
func main() {
16+
// Specify the organization ID and project ID
17+
projectId := "PROJECT_ID"
18+
serverId := "SERVER_ID"
19+
publicIpId := "PUBLIC_IP_ID"
20+
21+
// Create a new API client, that uses default authentication and configuration
22+
iaasalphaClient, err := iaasalpha.NewAPIClient(
23+
config.WithRegion("eu01"),
24+
)
25+
if err != nil {
26+
fmt.Fprintf(os.Stderr, "[iaasalpha API] Creating API client: %v\n", err)
27+
os.Exit(1)
28+
}
29+
30+
// Attach an existing network interface to an existing server
31+
var httpResp *http.Response
32+
ctxWithHTTPResp := runtime.WithCaptureHTTPResponse(context.Background(), &httpResp)
33+
err = iaasalphaClient.AddPublicIpToServer(ctxWithHTTPResp, projectId, serverId, publicIpId).Execute()
34+
if err != nil {
35+
fmt.Fprintf(os.Stderr, "[iaasalpha API] Error when calling `AddPublicIpToServer`: %v\n", err)
36+
} else {
37+
fmt.Printf("[iaasalpha API] Triggered attachment of public ip with ID %q.\n", publicIpId)
38+
}
39+
requestId := httpResp.Header[wait.XRequestIDHeader][0]
40+
41+
// Wait for attachment of the public ip
42+
_, err = wait.ProjectRequestWaitHandler(context.Background(), iaasalphaClient, projectId, requestId).WaitWithContext(context.Background())
43+
if err != nil {
44+
fmt.Fprintf(os.Stderr, "[iaasalpha API] Error when waiting for attachment: %v\n", err)
45+
os.Exit(1)
46+
}
47+
48+
fmt.Printf("[iaasalpha API] Public IP %q has been successfully attached to the server %s.\n", publicIpId, serverId)
49+
50+
err = iaasalphaClient.RemovePublicIpFromServer(ctxWithHTTPResp, projectId, serverId, publicIpId).Execute()
51+
if err != nil {
52+
fmt.Fprintf(os.Stderr, "[iaasalpha API] Error when calling `RemovePublicIpFromServer`: %v\n", err)
53+
} else {
54+
fmt.Printf("[iaasalpha API] Triggered removal of attachment of public ip with ID %q.\n", publicIpId)
55+
}
56+
57+
requestId = httpResp.Header[wait.XRequestIDHeader][0]
58+
59+
// Wait for dettachment of the public ip
60+
_, err = wait.ProjectRequestWaitHandler(context.Background(), iaasalphaClient, projectId, requestId).WaitWithContext(context.Background())
61+
if err != nil {
62+
fmt.Fprintf(os.Stderr, "[iaasalpha API] Error when waiting for removal of attachment of PublicIp: %v\n", err)
63+
os.Exit(1)
64+
}
65+
66+
fmt.Printf("[iaasalpha API] PublicIp %q has been successfully detacched from the server %s.\n", publicIpId, serverId)
67+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"net/http"
7+
"os"
8+
9+
"github.com/stackitcloud/stackit-sdk-go/core/config"
10+
"github.com/stackitcloud/stackit-sdk-go/core/runtime"
11+
"github.com/stackitcloud/stackit-sdk-go/services/iaasalpha"
12+
"github.com/stackitcloud/stackit-sdk-go/services/iaasalpha/wait"
13+
)
14+
15+
func main() {
16+
// Specify the organization ID and project ID
17+
projectId := "PROJECT_ID"
18+
serverId := "SERVER_ID"
19+
securityGroupId := "SECURITY_GROUP_ID"
20+
21+
// Create a new API client, that uses default authentication and configuration
22+
iaasalphaClient, err := iaasalpha.NewAPIClient(
23+
config.WithRegion("eu01"),
24+
)
25+
if err != nil {
26+
fmt.Fprintf(os.Stderr, "[iaasalpha API] Creating API client: %v\n", err)
27+
os.Exit(1)
28+
}
29+
30+
// Attach an existing network interface to an existing server
31+
var httpResp *http.Response
32+
ctxWithHTTPResp := runtime.WithCaptureHTTPResponse(context.Background(), &httpResp)
33+
err = iaasalphaClient.AddSecurityGroupToServer(ctxWithHTTPResp, projectId, serverId, securityGroupId).Execute()
34+
if err != nil {
35+
fmt.Fprintf(os.Stderr, "[iaasalpha API] Error when calling `AddSecurityGroupToServer`: %v\n", err)
36+
} else {
37+
fmt.Printf("[iaasalpha API] Triggered attachment of security group with ID %q.\n", securityGroupId)
38+
}
39+
requestId := httpResp.Header[wait.XRequestIDHeader][0]
40+
41+
// Wait for attachment of the security group
42+
_, err = wait.ProjectRequestWaitHandler(context.Background(), iaasalphaClient, projectId, requestId).WaitWithContext(context.Background())
43+
if err != nil {
44+
fmt.Fprintf(os.Stderr, "[iaasalpha API] Error when waiting for attachment: %v\n", err)
45+
os.Exit(1)
46+
}
47+
48+
fmt.Printf("[iaasalpha API] Security group %q has been successfully attached to the server %s.\n", securityGroupId, serverId)
49+
50+
err = iaasalphaClient.RemoveSecurityGroupFromServer(ctxWithHTTPResp, projectId, serverId, securityGroupId).Execute()
51+
if err != nil {
52+
fmt.Fprintf(os.Stderr, "[iaasalpha API] Error when calling `RemoveSecurityGroupFromServer`: %v\n", err)
53+
} else {
54+
fmt.Printf("[iaasalpha API] Triggered removal of attachment of security group with ID %q.\n", securityGroupId)
55+
}
56+
57+
requestId = httpResp.Header[wait.XRequestIDHeader][0]
58+
59+
// Wait for dettachment of the security group
60+
_, err = wait.ProjectRequestWaitHandler(context.Background(), iaasalphaClient, projectId, requestId).WaitWithContext(context.Background())
61+
if err != nil {
62+
fmt.Fprintf(os.Stderr, "[iaasalpha API] Error when waiting for removal of attachment of SecurityGroup: %v\n", err)
63+
os.Exit(1)
64+
}
65+
66+
fmt.Printf("[iaasalpha API] SecurityGroup %q has been successfully detacched from the server %s.\n", securityGroupId, serverId)
67+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"net/http"
7+
"os"
8+
9+
"github.com/stackitcloud/stackit-sdk-go/core/config"
10+
"github.com/stackitcloud/stackit-sdk-go/core/runtime"
11+
"github.com/stackitcloud/stackit-sdk-go/services/iaasalpha"
12+
"github.com/stackitcloud/stackit-sdk-go/services/iaasalpha/wait"
13+
)
14+
15+
func main() {
16+
// Specify the organization ID and project ID
17+
projectId := "PROJECT_ID"
18+
serverId := "SERVER_ID"
19+
serviceAccountMail := "SERVICE_ACCOUNT_MAIL"
20+
21+
// Create a new API client, that uses default authentication and configuration
22+
iaasalphaClient, err := iaasalpha.NewAPIClient(
23+
config.WithRegion("eu01"),
24+
)
25+
if err != nil {
26+
fmt.Fprintf(os.Stderr, "[iaasalpha API] Creating API client: %v\n", err)
27+
os.Exit(1)
28+
}
29+
30+
// Attach an existing service account to an existing server
31+
var httpResp *http.Response
32+
ctxWithHTTPResp := runtime.WithCaptureHTTPResponse(context.Background(), &httpResp)
33+
_, err = iaasalphaClient.AddServiceAccountToServer(ctxWithHTTPResp, projectId, serverId, serviceAccountMail).Execute()
34+
if err != nil {
35+
fmt.Fprintf(os.Stderr, "[iaasalpha API] Error when calling `AddServiceAccountToServer`: %v\n", err)
36+
} else {
37+
fmt.Printf("[iaasalpha API] Triggered attachment of service account with mail %q.\n", serviceAccountMail)
38+
}
39+
requestId := httpResp.Header[wait.XRequestIDHeader][0]
40+
41+
// Wait for attachment of the service account
42+
_, err = wait.ProjectRequestWaitHandler(context.Background(), iaasalphaClient, projectId, requestId).WaitWithContext(context.Background())
43+
if err != nil {
44+
fmt.Fprintf(os.Stderr, "[iaasalpha API] Error when waiting for attachment: %v\n", err)
45+
os.Exit(1)
46+
}
47+
48+
fmt.Printf("[iaasalpha API] Service account %q has been successfully attached to the server %s.\n", serviceAccountMail, serverId)
49+
50+
_, err = iaasalphaClient.RemoveServiceAccountFromServer(ctxWithHTTPResp, projectId, serverId, serviceAccountMail).Execute()
51+
if err != nil {
52+
fmt.Fprintf(os.Stderr, "[iaasalpha API] Error when calling `RemoveServiceAccountFromServer`: %v\n", err)
53+
} else {
54+
fmt.Printf("[iaasalpha API] Triggered removal of attachment of service account with mail %q.\n", serviceAccountMail)
55+
}
56+
57+
requestId = httpResp.Header[wait.XRequestIDHeader][0]
58+
59+
// Wait for dettachment of the service account
60+
_, err = wait.ProjectRequestWaitHandler(context.Background(), iaasalphaClient, projectId, requestId).WaitWithContext(context.Background())
61+
if err != nil {
62+
fmt.Fprintf(os.Stderr, "[iaasalpha API] Error when waiting for removal of attachment of service account: %v\n", err)
63+
os.Exit(1)
64+
}
65+
66+
fmt.Printf("[iaasalpha API] Service account %q has been successfully detacched from the server %s.\n", serviceAccountMail, serverId)
67+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"os"
7+
8+
"github.com/stackitcloud/stackit-sdk-go/core/config"
9+
"github.com/stackitcloud/stackit-sdk-go/services/iaasalpha"
10+
"github.com/stackitcloud/stackit-sdk-go/services/iaasalpha/wait"
11+
)
12+
13+
func main() {
14+
// Specify the organization ID and project ID
15+
projectId := "PROJECT_ID"
16+
serverId := "SERVER_ID"
17+
volumeId := "VOLUME_ID"
18+
19+
// Create a new API client, that uses default authentication and configuration
20+
iaasalphaClient, err := iaasalpha.NewAPIClient(
21+
config.WithRegion("eu01"),
22+
)
23+
if err != nil {
24+
fmt.Fprintf(os.Stderr, "[iaasalpha API] Creating API client: %v\n", err)
25+
os.Exit(1)
26+
}
27+
28+
payload := iaasalpha.AddVolumeToServerPayload{}
29+
_, err = iaasalphaClient.AddVolumeToServer(context.Background(), projectId, serverId, volumeId).AddVolumeToServerPayload(payload).Execute()
30+
if err != nil {
31+
fmt.Fprintf(os.Stderr, "[iaasalpha API] Error when calling `AddVolumeToServer`: %v\n", err)
32+
} else {
33+
fmt.Printf("[iaasalpha API] Triggered attachment of volume with ID %q.\n", volumeId)
34+
}
35+
36+
// Wait for attachment of the volume
37+
_, err = wait.AddVolumeToServerWaitHandler(context.Background(), iaasalphaClient, projectId, serverId, volumeId).WaitWithContext(context.Background())
38+
if err != nil {
39+
fmt.Fprintf(os.Stderr, "[iaasalpha API] Error when waiting for attachment: %v\n", err)
40+
os.Exit(1)
41+
}
42+
43+
fmt.Printf("[iaasalpha API] Volume %q has been successfully attached to the server %s.\n", volumeId, serverId)
44+
45+
err = iaasalphaClient.RemoveVolumeFromServer(context.Background(), projectId, serverId, volumeId).Execute()
46+
if err != nil {
47+
fmt.Fprintf(os.Stderr, "[iaasalpha API] Error when calling `RemoveVolumeFromServer`: %v\n", err)
48+
} else {
49+
fmt.Printf("[iaasalpha API] Triggered removal of attachment of volume with ID %q.\n", volumeId)
50+
}
51+
52+
// Wait for dettachment of the volume
53+
_, err = wait.RemoveVolumeFromServerWaitHandler(context.Background(), iaasalphaClient, projectId, serverId, volumeId).WaitWithContext(context.Background())
54+
if err != nil {
55+
fmt.Fprintf(os.Stderr, "[iaasalpha API] Error when waiting for removal of attachment of volume: %v\n", err)
56+
os.Exit(1)
57+
}
58+
59+
fmt.Printf("[iaasalpha API] Volume %q has been successfully detacched from the server %s.\n", volumeId, serverId)
60+
}

examples/iaasalpha/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.18
44

55
require (
66
github.com/stackitcloud/stackit-sdk-go/core v0.14.0
7-
github.com/stackitcloud/stackit-sdk-go/services/iaasalpha v0.1.10-alpha
7+
github.com/stackitcloud/stackit-sdk-go/services/iaasalpha v0.1.11-alpha
88
)
99

1010
require (

examples/iaasalpha/go.sum

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
44
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
55
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
66
github.com/stackitcloud/stackit-sdk-go/core v0.14.0 h1:oBwwzrEHDTlZpRoQwmMQpNA8bWciTrtGkiN29nx14Z0=
7-
github.com/stackitcloud/stackit-sdk-go/core v0.14.0/go.mod h1:mDX1mSTsB3mP+tNBGcFNx6gH1mGBN4T+dVt+lcw7nlw=
8-
github.com/stackitcloud/stackit-sdk-go/services/iaasalpha v0.1.10-alpha h1:kHFq/7lJ6eS8m27zzAhTANttk6dZ2Jp4fb36D3Dsu+M=
9-
github.com/stackitcloud/stackit-sdk-go/services/iaasalpha v0.1.10-alpha/go.mod h1:nW/6vvumUHA7o1/JOOqsrEOBNrRHombEKB1U4jmg2wU=
7+
github.com/stackitcloud/stackit-sdk-go/core v0.14.0/go.mod h1:mDX1mSTsB3mP+tNBGcFNx6gH1mGBN4T+dVt+lcw7nlw=ackitcloud/stackit-sdk-go/services/iaasalpha v0.1.10-alpha/go.mod h1:nW/6vvumUHA7o1/JOOqsrEOBNrRHombEKB1U4jmg2wU=
8+
github.com/stackitcloud/stackit-sdk-go/services/iaasalpha v0.1.11-alpha h1:uYslPwq0euGkuH6kHIhoXUaB9w+yrrDKLd80eo/5GZU=
9+
github.com/stackitcloud/stackit-sdk-go/services/iaasalpha v0.1.11-alpha/go.mod h1:nW/6vvumUHA7o1/JOOqsrEOBNrRHombEKB1U4jmg2wU=

examples/loadbalancer/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.18
44

55
require (
66
github.com/stackitcloud/stackit-sdk-go/core v0.14.0
7-
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v0.14.0
7+
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v0.16.0
88
)
99

1010
require (

0 commit comments

Comments
 (0)