4
4
import cloud .stackit .sdk .iaas .api .IaasApi ;
5
5
import cloud .stackit .sdk .iaas .model .*;
6
6
import java .io .IOException ;
7
- import java .util .Map ;
7
+ import java .util .Collections ;
8
8
import java .util .Objects ;
9
9
import java .util .UUID ;
10
10
import java .util .concurrent .TimeUnit ;
@@ -36,7 +36,7 @@ public static void main(String[] args) throws IOException {
36
36
.name ("java-sdk-example-network-01" )
37
37
.dhcp (true )
38
38
.routed (false )
39
- .labels (Map . ofEntries ( Map . entry ( "foo" , "bar" ) ))
39
+ .labels (Collections . singletonMap ( "foo" , "bar" ))
40
40
.addressFamily (
41
41
new CreateNetworkAddressFamily ()
42
42
.ipv4 (
@@ -50,7 +50,7 @@ public static void main(String[] args) throws IOException {
50
50
newNetwork .getNetworkId (),
51
51
new PartialUpdateNetworkPayload ()
52
52
.dhcp (false )
53
- .labels (Map . ofEntries ( Map . entry ( "foo" , "bar-updated" ) )));
53
+ .labels (Collections . singletonMap ( "foo" , "bar-updated" )));
54
54
55
55
/* fetch the network we just created */
56
56
Network fetchedNetwork = iaasApi .getNetwork (projectId , newNetwork .getNetworkId ());
@@ -83,7 +83,7 @@ public static void main(String[] args) throws IOException {
83
83
/* get an image */
84
84
UUID imageId =
85
85
images .getItems ()
86
- .getFirst ( )
86
+ .get ( 0 )
87
87
.getId (); // we just use a random image id in our example
88
88
assert imageId != null ;
89
89
Image fetchedImage = iaasApi .getImage (projectId , imageId );
@@ -119,7 +119,7 @@ public static void main(String[] args) throws IOException {
119
119
assert newKeypair .getName () != null ;
120
120
iaasApi .updateKeyPair (
121
121
newKeypair .getName (),
122
- new UpdateKeyPairPayload ().labels (Map . ofEntries ( Map . entry ( "foo" , "bar" ) )));
122
+ new UpdateKeyPairPayload ().labels (Collections . singletonMap ( "foo" , "bar" )));
123
123
124
124
/* fetch the keypair we just created / updated */
125
125
Keypair fetchedKeypair = iaasApi .getKeyPair (newKeypair .getName ());
@@ -144,7 +144,7 @@ public static void main(String[] args) throws IOException {
144
144
145
145
/* fetch details about a machine type */
146
146
MachineType fetchedMachineType =
147
- iaasApi .getMachineType (projectId , machineTypes .getItems ().getFirst ( ).getName ());
147
+ iaasApi .getMachineType (projectId , machineTypes .getItems ().get ( 0 ).getName ());
148
148
System .out .println ("\n Fetched machine type: " );
149
149
System .out .println ("* Name: " + fetchedMachineType .getName ());
150
150
System .out .println ("* Description: " + fetchedMachineType .getDescription ());
@@ -163,7 +163,7 @@ public static void main(String[] args) throws IOException {
163
163
.name ("java-sdk-example-server-01" )
164
164
.machineType ("t2i.1" )
165
165
.imageId (imageId )
166
- .labels (Map . ofEntries ( Map . entry ( "foo" , "bar" ) ))
166
+ .labels (Collections . singletonMap ( "foo" , "bar" ))
167
167
// add the keypair we created above
168
168
.keypairName (newKeypair .getName ())
169
169
// add the server to the network we created above
@@ -188,7 +188,7 @@ public static void main(String[] args) throws IOException {
188
188
projectId ,
189
189
newServer .getId (),
190
190
new UpdateServerPayload ()
191
- .labels (Map . ofEntries ( Map . entry ( "foo" , "bar-updated" ) )));
191
+ .labels (Collections . singletonMap ( "foo" , "bar-updated" )));
192
192
193
193
/* list all servers */
194
194
ServerListResponse servers = iaasApi .listServers (projectId , false , null );
0 commit comments