文件 AWS SDK AWS 範例 SDK 儲存庫中有更多可用的
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
DescribeMigrationTask
搭配 a AWS SDK 使用
下列程式碼範例示範如何使用 DescribeMigrationTask
。
- Java
-
- Java 2.x 的 SDK
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.migrationhub.MigrationHubClient; import software.amazon.awssdk.services.migrationhub.model.DescribeMigrationTaskRequest; import software.amazon.awssdk.services.migrationhub.model.DescribeMigrationTaskResponse; import software.amazon.awssdk.services.migrationhub.model.MigrationHubException; /** * 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 DescribeMigrationTask { public static void main(String[] args) { final String usage = """ Usage: DescribeMigrationTask <migrationTask> <progressStream>\s Where: migrationTask - the name of a migration task.\s progressStream - the name of a progress stream.\s """; if (args.length < 2) { System.out.println(usage); System.exit(1); } String migrationTask = args[0]; String progressStream = args[1]; Region region = Region.US_WEST_2; MigrationHubClient migrationClient = MigrationHubClient.builder() .region(region) .build(); describeMigTask(migrationClient, migrationTask, progressStream); migrationClient.close(); } public static void describeMigTask(MigrationHubClient migrationClient, String migrationTask, String progressStream) { try { DescribeMigrationTaskRequest migrationTaskRequestRequest = DescribeMigrationTaskRequest.builder() .progressUpdateStream(progressStream) .migrationTaskName(migrationTask) .build(); DescribeMigrationTaskResponse migrationTaskResponse = migrationClient .describeMigrationTask(migrationTaskRequestRequest); System.out.println("The name is " + migrationTaskResponse.migrationTask().migrationTaskName()); } catch (MigrationHubException e) { System.out.println(e.getMessage()); System.exit(1); } } }
-
如需 API 詳細資訊,請參閱 DescribeMigrationTask AWS SDK for Java 2.x 參考中的 API。
-
DescribeApplicationState
ImportMigrationTask