2626import java .util .concurrent .TimeUnit ;
2727
2828public final class VpnExample {
29- private static final String REGION = "eu01" ;
29+ private static final Region REGION = Region . fromValue ( "eu01" ) ;
3030
3131 private VpnExample () {}
3232
@@ -50,7 +50,6 @@ public static void main(String[] args) throws IOException, ApiException, Interru
5050 System .err .println ("Environment variable 'STACKIT_PROJECT_ID' not found." );
5151 return ;
5252 }
53- Region region = Region .fromValue (REGION );
5453
5554 try {
5655 /*
@@ -63,7 +62,7 @@ public static void main(String[] args) throws IOException, ApiException, Interru
6362 GatewayResponse gatewayResponse =
6463 vpnApi .createGateway (
6564 projectId ,
66- region ,
65+ REGION ,
6766 new CreateGatewayPayload ()
6867 .displayName ("example-vpn-gateway" )
6968 .planId ("p500" )
@@ -78,9 +77,9 @@ public static void main(String[] args) throws IOException, ApiException, Interru
7877 /* wait for the gateway creation to complete */
7978 UUID gatewayId = gatewayResponse .getId ();
8079 Objects .requireNonNull (gatewayId );
81- System .out .println (vpnApi .getGateway (projectId , region , gatewayId ).getState ());
80+ System .out .println (vpnApi .getGateway (projectId , REGION , gatewayId ).getState ());
8281 while (Objects .equals (
83- vpnApi .getGateway (projectId , region , gatewayId ).getState (),
82+ vpnApi .getGateway (projectId , REGION , gatewayId ).getState (),
8483 GatewayStatus .PENDING )) {
8584 System .out .println ("Waiting for gateway creation to complete ..." );
8685 TimeUnit .SECONDS .sleep (5 );
@@ -95,7 +94,7 @@ public static void main(String[] args) throws IOException, ApiException, Interru
9594 /* update the gateway we just created (send complete resource because of the PUT endpoint) */
9695 vpnApi .updateGateway (
9796 projectId ,
98- region ,
97+ REGION ,
9998 gatewayId ,
10099 new UpdateGatewayPayload ()
101100 .displayName ("example-vpn-gateway-updated" )
@@ -108,13 +107,13 @@ public static void main(String[] args) throws IOException, ApiException, Interru
108107 .labels (Collections .singletonMap ("some-gateway-label" , "updated" )));
109108
110109 /* fetch the gateway we just created */
111- GatewayResponse fetchedGateway = vpnApi .getGateway (projectId , region , gatewayId );
110+ GatewayResponse fetchedGateway = vpnApi .getGateway (projectId , REGION , gatewayId );
112111 System .out .println ("\n Fetched gateway: " );
113112 System .out .println ("* Gateway name: " + fetchedGateway .getDisplayName ());
114113 System .out .println ("* Id: " + fetchedGateway .getId ());
115114
116115 /* list all available gateways in the project */
117- GatewayList gateways = vpnApi .listGateways (projectId , region , null );
116+ GatewayList gateways = vpnApi .listGateways (projectId , REGION , null );
118117 System .out .println ("\n Available gateways: " );
119118 for (GatewayResponse gateway : gateways .getGateways ()) {
120119 System .out .println ("* " + gateway .getDisplayName ());
@@ -167,7 +166,7 @@ public static void main(String[] args) throws IOException, ApiException, Interru
167166 ConnectionResponse connectionResponse =
168167 vpnApi .createGatewayConnection (
169168 projectId ,
170- region ,
169+ REGION ,
171170 gatewayId ,
172171 new CreateGatewayConnectionPayload ()
173172 .displayName ("example-vpn-connection" )
@@ -185,7 +184,7 @@ public static void main(String[] args) throws IOException, ApiException, Interru
185184 /* update the connection we just created */
186185 vpnApi .updateGatewayConnection (
187186 projectId ,
188- region ,
187+ REGION ,
189188 gatewayId ,
190189 connectionId .toString (),
191190 new UpdateGatewayConnectionPayload ()
@@ -198,21 +197,21 @@ public static void main(String[] args) throws IOException, ApiException, Interru
198197 /* fetch the connection we just created */
199198 ConnectionResponse fetchedConnection =
200199 vpnApi .getGatewayConnection (
201- projectId , region , gatewayId , connectionId .toString ());
200+ projectId , REGION , gatewayId , connectionId .toString ());
202201 System .out .println ("\n Fetched connection: " );
203202 System .out .println ("* Connection name: " + fetchedConnection .getDisplayName ());
204203 System .out .println ("* Id: " + fetchedConnection .getId ());
205204
206205 /* list all available connection in the project */
207206 ConnectionList connections =
208- vpnApi .listGatewayConnections (projectId , region , gatewayId , null );
207+ vpnApi .listGatewayConnections (projectId , REGION , gatewayId , null );
209208 System .out .println ("\n Available connections: " );
210209 for (ConnectionResponse connection : connections .getConnections ()) {
211210 System .out .println ("* " + connection .getDisplayName ());
212211 }
213212
214213 /* delete the connection */
215- vpnApi .deleteGatewayConnection (projectId , region , gatewayId , connectionId .toString ());
214+ vpnApi .deleteGatewayConnection (projectId , REGION , gatewayId , connectionId .toString ());
216215 System .out .println ("Deleted connection: " + connectionId .toString ());
217216
218217 /*
@@ -222,13 +221,13 @@ public static void main(String[] args) throws IOException, ApiException, Interru
222221 * */
223222
224223 /* delete the gateway we created */
225- vpnApi .deleteGateway (projectId , region , gatewayId );
224+ vpnApi .deleteGateway (projectId , REGION , gatewayId );
226225 System .out .println ("Started gateway deletion: " + gatewayId );
227226
228227 /* wait for gateway deletion to complete */
229228 while (true ) {
230229 try {
231- vpnApi .getGateway (projectId , region , gatewayId );
230+ vpnApi .getGateway (projectId , REGION , gatewayId );
232231 System .out .println ("Waiting for gateway deletion to complete..." );
233232 TimeUnit .SECONDS .sleep (5 );
234233 } catch (ApiException e ) {
0 commit comments