ListMigrationTasks搭配使用 AWS SDK - AWS SDK代码示例

AWS 文档 AWS SDK示例 GitHub 存储库中还有更多SDK示例

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

ListMigrationTasks搭配使用 AWS SDK

以下代码示例演示如何使用 ListMigrationTasks

Java
SDK适用于 Java 2.x
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库中进行设置和运行。

import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.migrationhub.MigrationHubClient; import software.amazon.awssdk.services.migrationhub.model.ListMigrationTasksRequest; import software.amazon.awssdk.services.migrationhub.model.ListMigrationTasksResponse; import software.amazon.awssdk.services.migrationhub.model.MigrationTaskSummary; import software.amazon.awssdk.services.migrationhub.model.MigrationHubException; import java.util.List; /** * Before running this Java V2 code example, set up your development * environment, including your credentials. * * For more information, see the following documentation topic: * * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html */ public class ListMigrationTasks { public static void main(String[] args) { Region region = Region.US_WEST_2; MigrationHubClient migrationClient = MigrationHubClient.builder() .region(region) .build(); listMigrTasks(migrationClient); migrationClient.close(); } public static void listMigrTasks(MigrationHubClient migrationClient) { try { ListMigrationTasksRequest listMigrationTasksRequest = ListMigrationTasksRequest.builder() .maxResults(10) .build(); ListMigrationTasksResponse response = migrationClient.listMigrationTasks(listMigrationTasksRequest); List<MigrationTaskSummary> migrationList = response.migrationTaskSummaryList(); for (MigrationTaskSummary migration : migrationList) { System.out.println("Migration task name is " + migration.migrationTaskName()); System.out.println("The Progress update stream is " + migration.progressUpdateStream()); } } catch (MigrationHubException e) { System.out.println(e.getMessage()); System.exit(1); } } }
  • 有关API详细信息,请参阅 “AWS SDK for Java 2.x API参考 ListMigrationTasks” 中的。