Há mais AWS SDK exemplos disponíveis no GitHub repositório AWS Doc SDK Examples
As traduções são geradas por tradução automática. Em caso de conflito entre o conteúdo da tradução e da versão original em inglês, a versão em inglês prevalecerá.
Use ImportMigrationTask
com um AWS SDK
O código de exemplo a seguir mostra como usar ImportMigrationTask
.
- Java
-
- SDKpara Java 2.x
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no Repositório de exemplos de código da AWS
. import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.migrationhub.MigrationHubClient; import software.amazon.awssdk.services.migrationhub.model.CreateProgressUpdateStreamRequest; import software.amazon.awssdk.services.migrationhub.model.ImportMigrationTaskRequest; 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 ImportMigrationTask { public static void main(String[] args) { final String usage = """ Usage: <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(); importMigrTask(migrationClient, migrationTask, progressStream); migrationClient.close(); } public static void importMigrTask(MigrationHubClient migrationClient, String migrationTask, String progressStream) { try { CreateProgressUpdateStreamRequest progressUpdateStreamRequest = CreateProgressUpdateStreamRequest.builder() .progressUpdateStreamName(progressStream) .dryRun(false) .build(); migrationClient.createProgressUpdateStream(progressUpdateStreamRequest); ImportMigrationTaskRequest migrationTaskRequest = ImportMigrationTaskRequest.builder() .migrationTaskName(migrationTask) .progressUpdateStream(progressStream) .dryRun(false) .build(); migrationClient.importMigrationTask(migrationTaskRequest); } catch (MigrationHubException e) { System.out.println(e.getMessage()); System.exit(1); } } }
-
Para API obter detalhes, consulte ImportMigrationTaskem AWS SDK for Java 2.x APIReferência.
-
DescribeMigrationTask
ListApplications