ListCreatedArtifacts 搭配 a AWS SDK 使用 - AWS SDK 程式碼範例

文件 AWS SDK AWS 範例 SDK 儲存庫中有更多可用的 GitHub 範例。

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

ListCreatedArtifacts 搭配 a AWS SDK 使用

下列程式碼範例示範如何使用 ListCreatedArtifacts

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.CreatedArtifact; import software.amazon.awssdk.services.migrationhub.model.ListCreatedArtifactsRequest; import software.amazon.awssdk.services.migrationhub.model.ListCreatedArtifactsResponse; import software.amazon.awssdk.services.migrationhub.model.MigrationHubException; import java.util.List; /** * To run this Java V2 code example, ensure that you have setup your development * environment, including your credentials. * * For information, see this documentation topic: * * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html */ public class ListCreatedArtifacts { public static void main(String[] args) { Region region = Region.US_WEST_2; MigrationHubClient migrationClient = MigrationHubClient.builder() .region(region) .build(); listArtifacts(migrationClient); migrationClient.close(); } public static void listArtifacts(MigrationHubClient migrationClient) { try { ListCreatedArtifactsRequest listCreatedArtifactsRequest = ListCreatedArtifactsRequest.builder() .maxResults(10) .migrationTaskName("SampleApp5") .progressUpdateStream("ProgressSteamB") .build(); ListCreatedArtifactsResponse response = migrationClient.listCreatedArtifacts(listCreatedArtifactsRequest); List<CreatedArtifact> apps = response.createdArtifactList(); for (CreatedArtifact artifact : apps) { System.out.println("APp Id is " + artifact.description()); System.out.println("The name is " + artifact.name()); } } catch (MigrationHubException e) { System.out.println(e.getMessage()); System.exit(1); } } }