文件 AWS SDK AWS 範例 SDK 儲存庫中有更多可用的
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
DescribeApplicationState
搭配 a AWS SDK 使用
下列程式碼範例示範如何使用 DescribeApplicationState
。
- 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.DescribeApplicationStateRequest; import software.amazon.awssdk.services.migrationhub.model.DescribeApplicationStateResponse; 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 DescribeAppState { public static void main(String[] args) { final String usage = """ Usage: DescribeAppState <appId>\s Where: appId - the application id value.\s """; if (args.length != 1) { System.out.println(usage); System.exit(1); } String appId = args[0]; Region region = Region.US_WEST_2; MigrationHubClient migrationClient = MigrationHubClient.builder() .region(region) .build(); describeApplicationState(migrationClient, appId); migrationClient.close(); } public static void describeApplicationState(MigrationHubClient migrationClient, String appId) { try { DescribeApplicationStateRequest applicationStateRequest = DescribeApplicationStateRequest.builder() .applicationId(appId) .build(); DescribeApplicationStateResponse applicationStateResponse = migrationClient .describeApplicationState(applicationStateRequest); System.out.println("The application status is " + applicationStateResponse.applicationStatusAsString()); } catch (MigrationHubException e) { System.out.println(e.getMessage()); System.exit(1); } } }
-
如需 API 詳細資訊,請參閱 DescribeApplicationState AWS SDK for Java 2.x 參考中的 API。
-
DeleteProgressUpdateStream
DescribeMigrationTask