Skip to content

Commit 5dcf9b8

Browse files
Generator: Update SDK /services/vpn (#1256)
Co-authored-by: Manuel Vaas <manuel.vaas@stackit.cloud>
1 parent 020605b commit 5dcf9b8

191 files changed

Lines changed: 78467 additions & 1 deletion

File tree

Some content is hidden

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

‎CHANGELOG.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
- **Feature:** Add new `ConflictError` model for responses with 409 status code
3434
- `v1betaapi`:
3535
- **Feature:** Add new `ConflictError` model for responses with 409 status code
36+
- `vpn`:
37+
- [v0.1.0](services/vpn/CHANGELOG.md#v010)
38+
- Initial onboarding of STACKIT Java SDK for STACKIT VPN service
39+
3640

3741
## Release (2026-10-16)
3842

@@ -369,4 +373,3 @@
369373
- Initial onboarding of STACKIT Java SDK for IaaS service
370374
- `resourcemanger`: [v0.1.0](services/resourcemanager/CHANGELOG.md#v010)
371375
- Initial onboarding of STACKIT Java SDK for Resourcemanager service
372-

‎examples/vpn/build.gradle‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dependencies {
2+
implementation project (':services:vpn')
3+
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
4+
}
5+
6+
ext.mainClassName = 'cloud.stackit.sdk.vpn.examples.VpnExample'
Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
package cloud.stackit.sdk.vpn.examples;
2+
3+
import cloud.stackit.sdk.core.exception.ApiException;
4+
import cloud.stackit.sdk.vpn.v1api.api.VpnApi;
5+
import cloud.stackit.sdk.vpn.v1api.model.ConnectionList;
6+
import cloud.stackit.sdk.vpn.v1api.model.ConnectionResponse;
7+
import cloud.stackit.sdk.vpn.v1api.model.CreateGatewayConnectionPayload;
8+
import cloud.stackit.sdk.vpn.v1api.model.CreateGatewayPayload;
9+
import cloud.stackit.sdk.vpn.v1api.model.CreateGatewayPayloadAvailabilityZones;
10+
import cloud.stackit.sdk.vpn.v1api.model.GatewayList;
11+
import cloud.stackit.sdk.vpn.v1api.model.GatewayResponse;
12+
import cloud.stackit.sdk.vpn.v1api.model.GatewayStatus;
13+
import cloud.stackit.sdk.vpn.v1api.model.Region;
14+
import cloud.stackit.sdk.vpn.v1api.model.RoutingType;
15+
import cloud.stackit.sdk.vpn.v1api.model.TunnelConfiguration;
16+
import cloud.stackit.sdk.vpn.v1api.model.TunnelConfigurationPhase1;
17+
import cloud.stackit.sdk.vpn.v1api.model.TunnelConfigurationPhase2;
18+
import cloud.stackit.sdk.vpn.v1api.model.UpdateGatewayConnectionPayload;
19+
import cloud.stackit.sdk.vpn.v1api.model.UpdateGatewayPayload;
20+
import cloud.stackit.sdk.vpn.v1api.model.UpdateGatewayPayloadAvailabilityZones;
21+
import java.io.IOException;
22+
import java.net.HttpURLConnection;
23+
import java.util.Collections;
24+
import java.util.Objects;
25+
import java.util.UUID;
26+
import java.util.concurrent.TimeUnit;
27+
28+
public final class VpnExample {
29+
private static final Region REGION = Region.fromValue("eu01");
30+
31+
private VpnExample() {}
32+
33+
@SuppressWarnings({
34+
"PMD.CyclomaticComplexity",
35+
"PMD.AvoidUsingHardCodedIP",
36+
"PMD.SystemPrintln",
37+
"PMD.AvoidThrowingRawExceptionTypes"
38+
})
39+
public static void main(String[] args) throws IOException, ApiException, InterruptedException {
40+
/*
41+
* Credentials are read from the credentialsFile in `~/.stackit/credentials.json` or the env
42+
* STACKIT_SERVICE_ACCOUNT_KEY_PATH / STACKIT_SERVICE_ACCOUNT_KEY
43+
* */
44+
45+
VpnApi vpnApi = new VpnApi();
46+
47+
// the id of your STACKIT project, read from env var for this example
48+
String projectId = System.getenv("STACKIT_PROJECT_ID");
49+
if (projectId == null || projectId.isEmpty()) {
50+
System.err.println("Environment variable 'STACKIT_PROJECT_ID' not found.");
51+
return;
52+
}
53+
54+
try {
55+
/*
56+
* ///////////////////////////////////////////////////////
57+
* // G A T E W A Y S //
58+
* ///////////////////////////////////////////////////////
59+
* */
60+
61+
/* create a gateway in the project */
62+
GatewayResponse gatewayResponse =
63+
vpnApi.createGateway(
64+
projectId,
65+
REGION,
66+
new CreateGatewayPayload()
67+
.displayName("example-vpn-gateway")
68+
.planId("p500")
69+
.routingType(RoutingType.ROUTE_BASED)
70+
.availabilityZones(
71+
new CreateGatewayPayloadAvailabilityZones()
72+
.tunnel1("eu01-1")
73+
.tunnel2("eu01-2")));
74+
75+
Objects.requireNonNull(gatewayResponse.getId());
76+
77+
/* wait for the gateway creation to complete */
78+
UUID gatewayId = gatewayResponse.getId();
79+
Objects.requireNonNull(gatewayId);
80+
System.out.println(vpnApi.getGateway(projectId, REGION, gatewayId).getState());
81+
while (Objects.equals(
82+
vpnApi.getGateway(projectId, REGION, gatewayId).getState(),
83+
GatewayStatus.PENDING)) {
84+
System.out.println("Waiting for gateway creation to complete ...");
85+
TimeUnit.SECONDS.sleep(5);
86+
}
87+
System.out.println("Gateway created with the ID: " + gatewayId.toString());
88+
89+
// Delay because of API service: If the Gateway is updated directly after the creation,
90+
// it will throw an Error 409 "Internal conflict - please retry again later or contact
91+
// support if the issue persists"
92+
TimeUnit.SECONDS.sleep(10);
93+
94+
/* update the gateway we just created (send complete resource because of the PUT endpoint) */
95+
vpnApi.updateGateway(
96+
projectId,
97+
REGION,
98+
gatewayId,
99+
new UpdateGatewayPayload()
100+
.displayName("example-vpn-gateway-updated")
101+
.planId("p500")
102+
.routingType(RoutingType.ROUTE_BASED)
103+
.availabilityZones(
104+
new UpdateGatewayPayloadAvailabilityZones()
105+
.tunnel1("eu01-1")
106+
.tunnel2("eu01-2"))
107+
.labels(Collections.singletonMap("some-gateway-label", "updated")));
108+
109+
/* fetch the gateway we just created */
110+
GatewayResponse fetchedGateway = vpnApi.getGateway(projectId, REGION, gatewayId);
111+
System.out.println("\nFetched gateway: ");
112+
System.out.println("* Gateway name: " + fetchedGateway.getDisplayName());
113+
System.out.println("* Id: " + fetchedGateway.getId());
114+
115+
/* list all available gateways in the project */
116+
GatewayList gateways = vpnApi.listGateways(projectId, REGION, null);
117+
System.out.println("\nAvailable gateways: ");
118+
for (GatewayResponse gateway : gateways.getGateways()) {
119+
System.out.println("* " + gateway.getDisplayName());
120+
}
121+
122+
/*
123+
* ///////////////////////////////////////////////////////
124+
* // C O N N E C T I O N S //
125+
* ///////////////////////////////////////////////////////
126+
* */
127+
128+
/* create a connection in the gateway */
129+
TunnelConfiguration tunnelConfiguration =
130+
new TunnelConfiguration()
131+
.remoteAddress("198.51.100.10")
132+
.preSharedKey("Example-super-secret-key-tunnel-0123")
133+
.phase1(
134+
new TunnelConfigurationPhase1()
135+
.dhGroups(
136+
Collections.singletonList(
137+
TunnelConfigurationPhase1.DhGroupsEnum
138+
.ECP384))
139+
.encryptionAlgorithms(
140+
Collections.singletonList(
141+
TunnelConfigurationPhase1
142+
.EncryptionAlgorithmsEnum
143+
.AES256))
144+
.integrityAlgorithms(
145+
Collections.singletonList(
146+
TunnelConfigurationPhase1
147+
.IntegrityAlgorithmsEnum
148+
.SHA2_384)))
149+
.phase2(
150+
new TunnelConfigurationPhase2()
151+
.dhGroups(
152+
Collections.singletonList(
153+
TunnelConfigurationPhase2.DhGroupsEnum
154+
.ECP384))
155+
.encryptionAlgorithms(
156+
Collections.singletonList(
157+
TunnelConfigurationPhase2
158+
.EncryptionAlgorithmsEnum
159+
.AES256))
160+
.integrityAlgorithms(
161+
Collections.singletonList(
162+
TunnelConfigurationPhase2
163+
.IntegrityAlgorithmsEnum
164+
.SHA2_384)));
165+
166+
ConnectionResponse connectionResponse =
167+
vpnApi.createGatewayConnection(
168+
projectId,
169+
REGION,
170+
gatewayId,
171+
new CreateGatewayConnectionPayload()
172+
.displayName("example-vpn-connection")
173+
.tunnel1(tunnelConfiguration)
174+
.tunnel2(tunnelConfiguration)
175+
.localSubnets(Collections.singletonList("172.16.0.0/24"))
176+
.remoteSubnets(Collections.singletonList("172.17.0.0/24")));
177+
178+
Objects.requireNonNull(connectionResponse.getId());
179+
180+
UUID connectionId = connectionResponse.getId();
181+
Objects.requireNonNull(connectionId);
182+
System.out.println("Gateway created with the ID:" + connectionId.toString());
183+
184+
/* update the connection we just created */
185+
vpnApi.updateGatewayConnection(
186+
projectId,
187+
REGION,
188+
gatewayId,
189+
connectionId.toString(),
190+
new UpdateGatewayConnectionPayload()
191+
.displayName("example-vpn-connection-updated")
192+
.tunnel1(tunnelConfiguration)
193+
.tunnel2(tunnelConfiguration)
194+
.localSubnets(Collections.singletonList("172.16.0.0/24"))
195+
.remoteSubnets(Collections.singletonList("172.17.0.0/24")));
196+
197+
/* fetch the connection we just created */
198+
ConnectionResponse fetchedConnection =
199+
vpnApi.getGatewayConnection(
200+
projectId, REGION, gatewayId, connectionId.toString());
201+
System.out.println("\nFetched connection: ");
202+
System.out.println("* Connection name: " + fetchedConnection.getDisplayName());
203+
System.out.println("* Id: " + fetchedConnection.getId());
204+
205+
/* list all available connection in the project */
206+
ConnectionList connections =
207+
vpnApi.listGatewayConnections(projectId, REGION, gatewayId, null);
208+
System.out.println("\nAvailable connections: ");
209+
for (ConnectionResponse connection : connections.getConnections()) {
210+
System.out.println("* " + connection.getDisplayName());
211+
}
212+
213+
/* delete the connection */
214+
vpnApi.deleteGatewayConnection(projectId, REGION, gatewayId, connectionId.toString());
215+
System.out.println("Deleted connection: " + connectionId.toString());
216+
217+
/*
218+
* ///////////////////////////////////////////////////////
219+
* // D E L E T I O N //
220+
* ///////////////////////////////////////////////////////
221+
* */
222+
223+
/* delete the gateway we created */
224+
vpnApi.deleteGateway(projectId, REGION, gatewayId);
225+
System.out.println("Started gateway deletion: " + gatewayId);
226+
227+
/* wait for gateway deletion to complete */
228+
while (true) {
229+
try {
230+
vpnApi.getGateway(projectId, REGION, gatewayId);
231+
System.out.println("Waiting for gateway deletion to complete...");
232+
TimeUnit.SECONDS.sleep(5);
233+
} catch (ApiException e) {
234+
if (e.getCode() == HttpURLConnection.HTTP_NOT_FOUND) {
235+
System.out.println("Successfully deleted");
236+
break;
237+
}
238+
}
239+
}
240+
241+
} catch (ApiException | InterruptedException e) {
242+
throw new RuntimeException(e);
243+
}
244+
}
245+
}

‎services/vpn/CHANGELOG.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
## v0.1.0
3+
- Initial onboarding of STACKIT Java SDK for STACKIT VPN service

‎services/vpn/README.md‎

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# STACKIT Java SDK for STACKIT VPN API
2+
3+
This package is part of the STACKIT Java SDK. For additional information, please visit the [GitHub repository](https://github.com/stackitcloud/stackit-sdk-java) of the SDK.
4+
5+
## Installation from Maven Central (recommended)
6+
7+
The release artifacts for this SDK submodule are available on [Maven Central](https://central.sonatype.com/artifact/cloud.stackit.sdk/vpn).
8+
9+
### Maven users
10+
11+
Add this dependency to your project's POM:
12+
13+
```xml
14+
<dependency>
15+
<groupId>cloud.stackit.sdk</groupId>
16+
<artifactId>vpn</artifactId>
17+
<version><SDK_VERSION></version>
18+
<scope>compile</scope>
19+
</dependency>
20+
```
21+
22+
### Gradle users
23+
24+
Add this dependency to your project's build file:
25+
26+
```groovy
27+
repositories {
28+
mavenCentral()
29+
}
30+
31+
dependencies {
32+
implementation "cloud.stackit.sdk:vpn:<SDK_VERSION>"
33+
}
34+
```
35+
36+
## Installation from local build
37+
38+
Building the API client library requires:
39+
1. Java SDK (version 11 to 21 should be supported) installed on your system
40+
41+
To install the API client library to your local Maven repository, simply execute:
42+
43+
```shell
44+
./gradlew services:vpn:publishToMavenLocal
45+
```
46+
47+
### Maven users
48+
49+
Add this dependency to your project's POM:
50+
51+
```xml
52+
<dependency>
53+
<groupId>cloud.stackit.sdk</groupId>
54+
<artifactId>vpn</artifactId>
55+
<version><SDK_VERSION></version>
56+
<scope>compile</scope>
57+
</dependency>
58+
```
59+
60+
### Gradle users
61+
62+
Add this dependency to your project's build file:
63+
64+
```groovy
65+
repositories {
66+
mavenLocal()
67+
}
68+
69+
dependencies {
70+
implementation "cloud.stackit.sdk:vpn:<SDK_VERSION>"
71+
}
72+
```
73+
74+
## Getting Started
75+
76+
See the [vpn examples](https://github.com/stackitcloud/stackit-sdk-java/tree/main/examples/vpn/src/main/java/cloud/stackit/sdk/vpn/examples).
77+
78+
## Recommendation
79+
80+
It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues.

‎services/vpn/VERSION‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.1.0

‎services/vpn/build.gradle‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
ext {
3+
jakarta_annotation_version = "1.3.5"
4+
}
5+
6+
dependencies {
7+
implementation "com.google.code.findbugs:jsr305:3.0.2"
8+
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
9+
implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0'
10+
implementation 'com.google.code.gson:gson:2.9.1'
11+
implementation 'io.gsonfire:gson-fire:1.9.0'
12+
implementation 'jakarta.ws.rs:jakarta.ws.rs-api:2.1.6'
13+
implementation 'org.openapitools:jackson-databind-nullable:0.2.12'
14+
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.18.0'
15+
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
16+
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.3'
17+
testImplementation 'org.mockito:mockito-core:3.12.4'
18+
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.3'
19+
}

‎services/vpn/oas_commit‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bead0331c9760ab4d2ff87614ae3ad156bc46758

0 commit comments

Comments
 (0)