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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
- **Feature:** Add new `ConflictError` model for responses with 409 status code
- `v1betaapi`:
- **Feature:** Add new `ConflictError` model for responses with 409 status code
- `vpn`:
- [v0.1.0](services/vpn/CHANGELOG.md#v010)
- Initial onboarding of STACKIT Java SDK for STACKIT VPN service


## Release (2026-10-16)

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

6 changes: 6 additions & 0 deletions examples/vpn/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies {
implementation project (':services:vpn')
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
}

ext.mainClassName = 'cloud.stackit.sdk.vpn.examples.VpnExample'
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
package cloud.stackit.sdk.vpn.examples;

import cloud.stackit.sdk.core.exception.ApiException;
import cloud.stackit.sdk.vpn.v1api.api.VpnApi;
import cloud.stackit.sdk.vpn.v1api.model.ConnectionList;
import cloud.stackit.sdk.vpn.v1api.model.ConnectionResponse;
import cloud.stackit.sdk.vpn.v1api.model.CreateGatewayConnectionPayload;
import cloud.stackit.sdk.vpn.v1api.model.CreateGatewayPayload;
import cloud.stackit.sdk.vpn.v1api.model.CreateGatewayPayloadAvailabilityZones;
import cloud.stackit.sdk.vpn.v1api.model.GatewayList;
import cloud.stackit.sdk.vpn.v1api.model.GatewayResponse;
import cloud.stackit.sdk.vpn.v1api.model.GatewayStatus;
import cloud.stackit.sdk.vpn.v1api.model.Region;
import cloud.stackit.sdk.vpn.v1api.model.RoutingType;
import cloud.stackit.sdk.vpn.v1api.model.TunnelConfiguration;
import cloud.stackit.sdk.vpn.v1api.model.TunnelConfigurationPhase1;
import cloud.stackit.sdk.vpn.v1api.model.TunnelConfigurationPhase2;
import cloud.stackit.sdk.vpn.v1api.model.UpdateGatewayConnectionPayload;
import cloud.stackit.sdk.vpn.v1api.model.UpdateGatewayPayload;
import cloud.stackit.sdk.vpn.v1api.model.UpdateGatewayPayloadAvailabilityZones;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.Collections;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

public final class VpnExample {
private static final Region REGION = Region.fromValue("eu01");

private VpnExample() {}

@SuppressWarnings({
"PMD.CyclomaticComplexity",
"PMD.AvoidUsingHardCodedIP",
"PMD.SystemPrintln",
"PMD.AvoidThrowingRawExceptionTypes"
})
public static void main(String[] args) throws IOException, ApiException, InterruptedException {
/*
* Credentials are read from the credentialsFile in `~/.stackit/credentials.json` or the env
* STACKIT_SERVICE_ACCOUNT_KEY_PATH / STACKIT_SERVICE_ACCOUNT_KEY
* */

VpnApi vpnApi = new VpnApi();

// the id of your STACKIT project, read from env var for this example
String projectId = System.getenv("STACKIT_PROJECT_ID");
if (projectId == null || projectId.isEmpty()) {
System.err.println("Environment variable 'STACKIT_PROJECT_ID' not found.");
return;
}

try {
/*
* ///////////////////////////////////////////////////////
* // G A T E W A Y S //
* ///////////////////////////////////////////////////////
* */

/* create a gateway in the project */
GatewayResponse gatewayResponse =
vpnApi.createGateway(
projectId,
REGION,
new CreateGatewayPayload()
.displayName("example-vpn-gateway")
.planId("p500")
.routingType(RoutingType.ROUTE_BASED)
.availabilityZones(
new CreateGatewayPayloadAvailabilityZones()
.tunnel1("eu01-1")
.tunnel2("eu01-2")));

Objects.requireNonNull(gatewayResponse.getId());

/* wait for the gateway creation to complete */
UUID gatewayId = gatewayResponse.getId();
Objects.requireNonNull(gatewayId);
System.out.println(vpnApi.getGateway(projectId, REGION, gatewayId).getState());
while (Objects.equals(
vpnApi.getGateway(projectId, REGION, gatewayId).getState(),
GatewayStatus.PENDING)) {
System.out.println("Waiting for gateway creation to complete ...");
TimeUnit.SECONDS.sleep(5);
}
System.out.println("Gateway created with the ID: " + gatewayId.toString());

// Delay because of API service: If the Gateway is updated directly after the creation,
// it will throw an Error 409 "Internal conflict - please retry again later or contact
// support if the issue persists"
TimeUnit.SECONDS.sleep(10);

/* update the gateway we just created (send complete resource because of the PUT endpoint) */
vpnApi.updateGateway(
projectId,
REGION,
gatewayId,
new UpdateGatewayPayload()
.displayName("example-vpn-gateway-updated")
.planId("p500")
.routingType(RoutingType.ROUTE_BASED)
.availabilityZones(
new UpdateGatewayPayloadAvailabilityZones()
.tunnel1("eu01-1")
.tunnel2("eu01-2"))
.labels(Collections.singletonMap("some-gateway-label", "updated")));

/* fetch the gateway we just created */
GatewayResponse fetchedGateway = vpnApi.getGateway(projectId, REGION, gatewayId);
System.out.println("\nFetched gateway: ");
System.out.println("* Gateway name: " + fetchedGateway.getDisplayName());
System.out.println("* Id: " + fetchedGateway.getId());

/* list all available gateways in the project */
GatewayList gateways = vpnApi.listGateways(projectId, REGION, null);
System.out.println("\nAvailable gateways: ");
for (GatewayResponse gateway : gateways.getGateways()) {
System.out.println("* " + gateway.getDisplayName());
}

/*
* ///////////////////////////////////////////////////////
* // C O N N E C T I O N S //
* ///////////////////////////////////////////////////////
* */

/* create a connection in the gateway */
TunnelConfiguration tunnelConfiguration =
new TunnelConfiguration()
.remoteAddress("198.51.100.10")
.preSharedKey("Example-super-secret-key-tunnel-0123")
.phase1(
new TunnelConfigurationPhase1()
.dhGroups(
Collections.singletonList(
TunnelConfigurationPhase1.DhGroupsEnum
.ECP384))
.encryptionAlgorithms(
Collections.singletonList(
TunnelConfigurationPhase1
.EncryptionAlgorithmsEnum
.AES256))
.integrityAlgorithms(
Collections.singletonList(
TunnelConfigurationPhase1
.IntegrityAlgorithmsEnum
.SHA2_384)))
.phase2(
new TunnelConfigurationPhase2()
.dhGroups(
Collections.singletonList(
TunnelConfigurationPhase2.DhGroupsEnum
.ECP384))
.encryptionAlgorithms(
Collections.singletonList(
TunnelConfigurationPhase2
.EncryptionAlgorithmsEnum
.AES256))
.integrityAlgorithms(
Collections.singletonList(
TunnelConfigurationPhase2
.IntegrityAlgorithmsEnum
.SHA2_384)));

ConnectionResponse connectionResponse =
vpnApi.createGatewayConnection(
projectId,
REGION,
gatewayId,
new CreateGatewayConnectionPayload()
.displayName("example-vpn-connection")
.tunnel1(tunnelConfiguration)
.tunnel2(tunnelConfiguration)
.localSubnets(Collections.singletonList("172.16.0.0/24"))
.remoteSubnets(Collections.singletonList("172.17.0.0/24")));

Objects.requireNonNull(connectionResponse.getId());

UUID connectionId = connectionResponse.getId();
Objects.requireNonNull(connectionId);
System.out.println("Gateway created with the ID:" + connectionId.toString());

/* update the connection we just created */
vpnApi.updateGatewayConnection(
projectId,
REGION,
gatewayId,
connectionId.toString(),
new UpdateGatewayConnectionPayload()
.displayName("example-vpn-connection-updated")
.tunnel1(tunnelConfiguration)
.tunnel2(tunnelConfiguration)
.localSubnets(Collections.singletonList("172.16.0.0/24"))
.remoteSubnets(Collections.singletonList("172.17.0.0/24")));

/* fetch the connection we just created */
ConnectionResponse fetchedConnection =
vpnApi.getGatewayConnection(
projectId, REGION, gatewayId, connectionId.toString());
System.out.println("\nFetched connection: ");
System.out.println("* Connection name: " + fetchedConnection.getDisplayName());
System.out.println("* Id: " + fetchedConnection.getId());

/* list all available connection in the project */
ConnectionList connections =
vpnApi.listGatewayConnections(projectId, REGION, gatewayId, null);
System.out.println("\nAvailable connections: ");
for (ConnectionResponse connection : connections.getConnections()) {
System.out.println("* " + connection.getDisplayName());
}

/* delete the connection */
vpnApi.deleteGatewayConnection(projectId, REGION, gatewayId, connectionId.toString());
System.out.println("Deleted connection: " + connectionId.toString());

/*
* ///////////////////////////////////////////////////////
* // D E L E T I O N //
* ///////////////////////////////////////////////////////
* */

/* delete the gateway we created */
vpnApi.deleteGateway(projectId, REGION, gatewayId);
System.out.println("Started gateway deletion: " + gatewayId);

/* wait for gateway deletion to complete */
while (true) {
try {
vpnApi.getGateway(projectId, REGION, gatewayId);
System.out.println("Waiting for gateway deletion to complete...");
TimeUnit.SECONDS.sleep(5);
} catch (ApiException e) {
if (e.getCode() == HttpURLConnection.HTTP_NOT_FOUND) {
System.out.println("Successfully deleted");
break;
}
}
}

} catch (ApiException | InterruptedException e) {
throw new RuntimeException(e);
}
}
}
3 changes: 3 additions & 0 deletions services/vpn/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

## v0.1.0
- Initial onboarding of STACKIT Java SDK for STACKIT VPN service
80 changes: 80 additions & 0 deletions services/vpn/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# STACKIT Java SDK for STACKIT VPN API

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.

## Installation from Maven Central (recommended)

The release artifacts for this SDK submodule are available on [Maven Central](https://central.sonatype.com/artifact/cloud.stackit.sdk/vpn).

### Maven users

Add this dependency to your project's POM:

```xml
<dependency>
<groupId>cloud.stackit.sdk</groupId>
<artifactId>vpn</artifactId>
<version><SDK_VERSION></version>
<scope>compile</scope>
</dependency>
```

### Gradle users

Add this dependency to your project's build file:

```groovy
repositories {
mavenCentral()
}

dependencies {
implementation "cloud.stackit.sdk:vpn:<SDK_VERSION>"
}
```

## Installation from local build

Building the API client library requires:
1. Java SDK (version 11 to 21 should be supported) installed on your system

To install the API client library to your local Maven repository, simply execute:

```shell
./gradlew services:vpn:publishToMavenLocal
```

### Maven users

Add this dependency to your project's POM:

```xml
<dependency>
<groupId>cloud.stackit.sdk</groupId>
<artifactId>vpn</artifactId>
<version><SDK_VERSION></version>
<scope>compile</scope>
</dependency>
```

### Gradle users

Add this dependency to your project's build file:

```groovy
repositories {
mavenLocal()
}

dependencies {
implementation "cloud.stackit.sdk:vpn:<SDK_VERSION>"
}
```

## Getting Started

See the [vpn examples](https://github.com/stackitcloud/stackit-sdk-java/tree/main/examples/vpn/src/main/java/cloud/stackit/sdk/vpn/examples).

## Recommendation

It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues.
1 change: 1 addition & 0 deletions services/vpn/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
19 changes: 19 additions & 0 deletions services/vpn/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

ext {
jakarta_annotation_version = "1.3.5"
}

dependencies {
implementation "com.google.code.findbugs:jsr305:3.0.2"
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0'
implementation 'com.google.code.gson:gson:2.9.1'
implementation 'io.gsonfire:gson-fire:1.9.0'
implementation 'jakarta.ws.rs:jakarta.ws.rs-api:2.1.6'
implementation 'org.openapitools:jackson-databind-nullable:0.2.12'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.18.0'
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.3'
testImplementation 'org.mockito:mockito-core:3.12.4'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.3'
}
1 change: 1 addition & 0 deletions services/vpn/oas_commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bead0331c9760ab4d2ff87614ae3ad156bc46758
Loading
Loading