Gunakan ListMigrationTasks dengan AWS SDK - AWS SDKContoh Kode

Ada lebih banyak AWS SDK contoh yang tersedia di GitHub repo SDKContoh AWS Dokumen.

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

Gunakan ListMigrationTasks dengan AWS SDK

Contoh kode berikut menunjukkan cara menggunakanListMigrationTasks.

Java
SDKuntuk Java 2.x
catatan

Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode 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); } } }