This topic describes how to use the SMC Java SDK to call the ModifySourceServerAttribute operation to modify the name and description of a migration source.

Background information

You can modify the name and description of a migration source by calling the ModifySourceServerAttribute operation. For more information, see ModifySourceServerAttribute.

Sample code

The following code can be used to modify the name and description of a migration source:

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.smc.model.v20190601.ModifySourceServerAttributeRequest;
import com.aliyuncs.smc.model.v20190601.ModifySourceServerAttributeResponse;
import com.google.gson.Gson;

public class ModifySourceServerAttribute {
    public static void main(String[] args) {
        // Initialize the AcsClient instance, and set the region ID and your AccessKey pair.
        DefaultProfile profile = DefaultProfile.getProfile("<region-Id>", "<accessKeyId>", "<accessSecret>");
        IAcsClient client = new DefaultAcsClient(profile);

        // Create an API request and configure its parameters.
        ModifySourceServerAttributeRequest request = new ModifySourceServerAttributeRequest();
        // The ID of the migration source.
        request.setSourceId("s-bp152mkfswviw7sd****");
        // The name of the migration source.
        request.setName("MySourceServer");
        // The description of the migration source.
        request.setDescription("This is a source server.") ;

        // Send the request to obtain the return value or handle the exception.
        try {
            ModifySourceServerAttributeResponse response = client.getAcsResponse(request);
            System.out.println(new Gson().toJson(response));
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            e.printStackTrace();
        }
    } 
}

Result

{    
    "RequestId": "78A76F74-CA05-4B34-83D2-60F30311B5AD"
}