44import cloud .stackit .sdk .iaas .api .IaasApi ;
55import cloud .stackit .sdk .iaas .model .*;
66import java .io .IOException ;
7+ import java .util .Collections ;
78import java .util .Map ;
89import java .util .Objects ;
910import java .util .UUID ;
@@ -36,7 +37,7 @@ public static void main(String[] args) throws IOException {
3637 .name ("java-sdk-example-network-01" )
3738 .dhcp (true )
3839 .routed (false )
39- .labels (Map . ofEntries ( Map . entry ( "foo" , "bar" ) ))
40+ .labels (Collections . singletonMap ( "foo" , "bar" ))
4041 .addressFamily (
4142 new CreateNetworkAddressFamily ()
4243 .ipv4 (
@@ -50,7 +51,7 @@ public static void main(String[] args) throws IOException {
5051 newNetwork .getNetworkId (),
5152 new PartialUpdateNetworkPayload ()
5253 .dhcp (false )
53- .labels (Map . ofEntries ( Map . entry ( "foo" , "bar-updated" ) )));
54+ .labels (Collections . singletonMap ( "foo" , "bar-updated" )));
5455
5556 /* fetch the network we just created */
5657 Network fetchedNetwork = iaasApi .getNetwork (projectId , newNetwork .getNetworkId ());
@@ -83,7 +84,7 @@ public static void main(String[] args) throws IOException {
8384 /* get an image */
8485 UUID imageId =
8586 images .getItems ()
86- .getFirst ( )
87+ .get ( 0 )
8788 .getId (); // we just use a random image id in our example
8889 assert imageId != null ;
8990 Image fetchedImage = iaasApi .getImage (projectId , imageId );
@@ -119,7 +120,7 @@ public static void main(String[] args) throws IOException {
119120 assert newKeypair .getName () != null ;
120121 iaasApi .updateKeyPair (
121122 newKeypair .getName (),
122- new UpdateKeyPairPayload ().labels (Map . ofEntries ( Map . entry ( "foo" , "bar" ) )));
123+ new UpdateKeyPairPayload ().labels (Collections . singletonMap ( "foo" , "bar" )));
123124
124125 /* fetch the keypair we just created / updated */
125126 Keypair fetchedKeypair = iaasApi .getKeyPair (newKeypair .getName ());
@@ -144,7 +145,7 @@ public static void main(String[] args) throws IOException {
144145
145146 /* fetch details about a machine type */
146147 MachineType fetchedMachineType =
147- iaasApi .getMachineType (projectId , machineTypes .getItems ().getFirst ( ).getName ());
148+ iaasApi .getMachineType (projectId , machineTypes .getItems ().get ( 0 ).getName ());
148149 System .out .println ("\n Fetched machine type: " );
149150 System .out .println ("* Name: " + fetchedMachineType .getName ());
150151 System .out .println ("* Description: " + fetchedMachineType .getDescription ());
@@ -163,7 +164,7 @@ public static void main(String[] args) throws IOException {
163164 .name ("java-sdk-example-server-01" )
164165 .machineType ("t2i.1" )
165166 .imageId (imageId )
166- .labels (Map . ofEntries ( Map . entry ( "foo" , "bar" ) ))
167+ .labels (Collections . singletonMap ( "foo" , "bar" ))
167168 // add the keypair we created above
168169 .keypairName (newKeypair .getName ())
169170 // add the server to the network we created above
@@ -188,7 +189,7 @@ public static void main(String[] args) throws IOException {
188189 projectId ,
189190 newServer .getId (),
190191 new UpdateServerPayload ()
191- .labels (Map . ofEntries ( Map . entry ( "foo" , "bar-updated" ) )));
192+ .labels (Collections . singletonMap ( "foo" , "bar-updated" )));
192193
193194 /* list all servers */
194195 ServerListResponse servers = iaasApi .listServers (projectId , false , null );
0 commit comments