//snippet-sourcedescription:[UpdateServerCertificate.java demonstrates how to update the name of an IAM server certificate.]
//snippet-keyword:[SDK for Java 2.0]
//snippet-keyword:[Code Sample]
//snippet-service:[iam]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[]
//snippet-sourceauthor:[soo-aws]
/*
 * Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
package com.example.iam;
// snippet-start:[iam.java2.update_server_certificate.complete]
// snippet-start:[iam.java2.update_server_certificate.import]
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.iam.IamClient;
import software.amazon.awssdk.services.iam.model.UpdateServerCertificateRequest;
import software.amazon.awssdk.services.iam.model.UpdateServerCertificateResponse;
 
// snippet-end:[iam.java2.update_server_certificate.import]
/**
 * Updates a server certificate name
 */
public class UpdateServerCertificate {
    public static void main(String[] args) {

        final String USAGE =
            "To run this example, supply the current certificate name and\n" +
            "a new name. Ex:\n\n" +
            "UpdateServerCertificate <current-name> <new-name>\n";

        if (args.length != 2) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String cur_name = args[0];
        String new_name = args[1];

        // snippet-start:[iam.java2.update_server_certificate.main]
        Region region = Region.AWS_GLOBAL;
        IamClient iam = IamClient.builder().region(region).build();

        UpdateServerCertificateRequest request =
            UpdateServerCertificateRequest.builder()
                .serverCertificateName(cur_name)
                .newServerCertificateName(new_name)
                .build();

        UpdateServerCertificateResponse response =
            iam.updateServerCertificate(request);
        // snippet-end:[iam.java2.update_server_certificate.main]

        System.out.printf("Successfully updated server certificate to name %s",
                new_name);
    }
}
 
// snippet-end:[iam.java2.update_server_certificate.complete]

@@ -274,16 +274,26 @@
 cedate:%5B
+03/02/2020
 %5D%0D%0A//sni
@@ -316,10 +316,15 @@
 r:%5Bs
-oo
+cmacdon
 -aws
@@ -347,18 +347,8 @@
 ght 
-2010-2019 
 Amaz
@@ -1167,24 +1167,88 @@
 IamClient;%0D%0A
+import software.amazon.awssdk.services.iam.model.IamException;%0D%0A
 import softw
@@ -1400,17 +1400,16 @@
 ponse;%0D%0A
- 
 %0D%0A// sni
@@ -1641,16 +1641,20 @@
         
+    
 %22To run 
@@ -1709,24 +1709,36 @@
 e and%5Cn%22 +%0D%0A
+            
             
@@ -1758,24 +1758,36 @@
 Ex:%5Cn%5Cn%22 +%0D%0A
+            
             
@@ -1977,18 +1977,17 @@
 ring cur
-_n
+N
 ame = ar
@@ -2012,18 +2012,17 @@
 ring new
-_n
+N
 ame = ar
@@ -2207,32 +2207,53 @@
 on).build();%0D%0A%0D%0A
+        try %7B%0D%0A%0D%0A    
         UpdateSe
@@ -2282,24 +2282,28 @@
  request =%0D%0A
+    
             
@@ -2344,16 +2344,24 @@
 lder()%0D%0A
+        
         
@@ -2394,24 +2394,31 @@
 Name(cur
-_n
+N
 ame)%0D%0A
+        
         
@@ -2454,18 +2454,17 @@
 Name(new
-_n
+N
 ame)%0D%0A  
@@ -2477,16 +2477,24 @@
         
+  
+      
 .build()
@@ -2498,32 +2498,36 @@
 d();%0D%0A%0D%0A        
+  
+  
 UpdateServerCert
@@ -2566,16 +2566,20 @@
         
+    
 iam.upda
@@ -2609,32 +2609,36 @@
 uest);%0D%0A        
+  
+  
 // snippet-end:%5B
@@ -2678,24 +2678,28 @@
 te.main%5D%0D%0A%0D%0A
+    
         Syst
@@ -2790,13 +2790,198 @@
  new
-_name
+Name);%0D%0A%0D%0A        %7D catch (IamException e) %7B%0D%0A             System.err.println(e.awsErrorDetails().errorMessage());%0D%0A             System.exit(1);%0D%0A        %7D%0D%0A        System.out.println(%22Done%22
 );%0D%0A
@@ -2994,11 +2994,8 @@
 %0A%7D%0D%0A
- %0D%0A
 // s

Update UpdateServerCertificate.java