44import cloud .stackit .sdk .iaas .api .IaasApi ;
55import cloud .stackit .sdk .iaas .model .*;
66import java .io .IOException ;
7- import java .util .Map ;
7+ import java .util .Collections ;
88import java .util .Objects ;
99import java .util .UUID ;
1010import java .util .concurrent .TimeUnit ;
@@ -36,7 +36,7 @@ public static void main(String[] args) throws IOException {
3636 .name ("java-sdk-example-network-01" )
3737 .dhcp (true )
3838 .routed (false )
39- .labels (Map . ofEntries ( Map . entry ( "foo" , "bar" ) ))
39+ .labels (Collections . singletonMap ( "foo" , "bar" ))
4040 .addressFamily (
4141 new CreateNetworkAddressFamily ()
4242 .ipv4 (
@@ -50,7 +50,7 @@ public static void main(String[] args) throws IOException {
5050 newNetwork .getNetworkId (),
5151 new PartialUpdateNetworkPayload ()
5252 .dhcp (false )
53- .labels (Map . ofEntries ( Map . entry ( "foo" , "bar-updated" ) )));
53+ .labels (Collections . singletonMap ( "foo" , "bar-updated" )));
5454
5555 /* fetch the network we just created */
5656 Network fetchedNetwork = iaasApi .getNetwork (projectId , newNetwork .getNetworkId ());
@@ -83,7 +83,7 @@ public static void main(String[] args) throws IOException {
8383 /* get an image */
8484 UUID imageId =
8585 images .getItems ()
86- .getFirst ( )
86+ .get ( 0 )
8787 .getId (); // we just use a random image id in our example
8888 assert imageId != null ;
8989 Image fetchedImage = iaasApi .getImage (projectId , imageId );
@@ -119,7 +119,7 @@ public static void main(String[] args) throws IOException {
119119 assert newKeypair .getName () != null ;
120120 iaasApi .updateKeyPair (
121121 newKeypair .getName (),
122- new UpdateKeyPairPayload ().labels (Map . ofEntries ( Map . entry ( "foo" , "bar" ) )));
122+ new UpdateKeyPairPayload ().labels (Collections . singletonMap ( "foo" , "bar" )));
123123
124124 /* fetch the keypair we just created / updated */
125125 Keypair fetchedKeypair = iaasApi .getKeyPair (newKeypair .getName ());
@@ -144,7 +144,7 @@ public static void main(String[] args) throws IOException {
144144
145145 /* fetch details about a machine type */
146146 MachineType fetchedMachineType =
147- iaasApi .getMachineType (projectId , machineTypes .getItems ().getFirst ( ).getName ());
147+ iaasApi .getMachineType (projectId , machineTypes .getItems ().get ( 0 ).getName ());
148148 System .out .println ("\n Fetched machine type: " );
149149 System .out .println ("* Name: " + fetchedMachineType .getName ());
150150 System .out .println ("* Description: " + fetchedMachineType .getDescription ());
@@ -163,7 +163,7 @@ public static void main(String[] args) throws IOException {
163163 .name ("java-sdk-example-server-01" )
164164 .machineType ("t2i.1" )
165165 .imageId (imageId )
166- .labels (Map . ofEntries ( Map . entry ( "foo" , "bar" ) ))
166+ .labels (Collections . singletonMap ( "foo" , "bar" ))
167167 // add the keypair we created above
168168 .keypairName (newKeypair .getName ())
169169 // add the server to the network we created above
@@ -188,7 +188,7 @@ public static void main(String[] args) throws IOException {
188188 projectId ,
189189 newServer .getId (),
190190 new UpdateServerPayload ()
191- .labels (Map . ofEntries ( Map . entry ( "foo" , "bar-updated" ) )));
191+ .labels (Collections . singletonMap ( "foo" , "bar-updated" )));
192192
193193 /* list all servers */
194194 ServerListResponse servers = iaasApi .listServers (projectId , false , null );
0 commit comments