edit-icon download-icon

Quick start

Last Updated: Mar 02, 2018

Procedure

  1. Create AcsClient instance.

    1. DefaultProfile profile = DefaultProfile.getProfile(
    2. mpsRegionId, // regionID
    3. accessKeyId, // AccessKey ID of RAM account
    4. accessKeySecret); // Access Key Secret of RAM account
    5. IAcsClient client = new DefaultAcsClient(profile);
  2. Create request, and set parameters.

    1. SubmitJobsRequest request = new SubmitJobsRequest();
  3. Initiate API request, and display the return value.

    1. response = client.getAcsResponse(request);
    2. System.out.println("PipelineName is:" + response.getPipelineList().get(0).getName());
    3. System.out.println("PipelineId is:" + response.getPipelineList().get(0).getId());

Full code

  1. import com.aliyuncs.profile.DefaultProfile;
  2. import com.aliyuncs.DefaultAcsClient;
  3. import com.aliyuncs.IAcsClient;
  4. import com.aliyuncs.exceptions.ClientException;
  5. import com.aliyuncs.exceptions.ServerException;
  6. import com.aliyuncs.mts.model.v20140618.*;
  7. public class Quick {
  8. private static String accessKeyId = "xxx";
  9. private static String accessKeySecret = "xxx";
  10. private static String[] mpsRegionIds = new String[] {
  11. "cn-hangzhou", "cn-beijing","cn-shenzhen", "cn-shanghai",
  12. "cn-hongkong", "us-west-1", "ap-southeast-1", "ap-northeast-1",
  13. "eu-central-1", "ap-south-1"
  14. };
  15. public static void main(String[] args) {
  16. for (String mpsRegionId : mpsRegionIds) {
  17. System.out.println("region id is:" + mpsRegionId);
  18. // Create DefaultAcsClient instance and finish initialization
  19. DefaultProfile profile = DefaultProfile.getProfile(
  20. mpsRegionId, // region ID
  21. accessKeyId, // AccessKey ID of RAM account
  22. accessKeySecret); // Access Key Secret of RAM account
  23. IAcsClient client = new DefaultAcsClient(profile);
  24. // Create API request and set parameters
  25. SearchPipelineRequest request = new SearchPipelineRequest();
  26. // initiate request and handle response or exceptions
  27. SearchPipelineResponse response;
  28. try {
  29. response = client.getAcsResponse(request);
  30. System.out.println("PipelineName is:" + response.getPipelineList().get(0).getName());
  31. System.out.println("PipelineId is:" + response.getPipelineList().get(0).getId());
  32. } catch (ServerException e) {
  33. e.printStackTrace();
  34. } catch (ClientException e) {
  35. e.printStackTrace();
  36. }
  37. }
  38. }
  39. }
Thank you! We've received your feedback.