|
17 | 17 | import software.amazon.awssdk.services.entityresolution.model.CreateSchemaMappingRequest; |
18 | 18 | import software.amazon.awssdk.services.entityresolution.model.CreateSchemaMappingResponse; |
19 | 19 | import software.amazon.awssdk.services.entityresolution.model.DeleteMatchingWorkflowRequest; |
| 20 | +import software.amazon.awssdk.services.entityresolution.model.DeleteSchemaMappingRequest; |
20 | 21 | import software.amazon.awssdk.services.entityresolution.model.GetMatchingJobRequest; |
21 | | -import software.amazon.awssdk.services.entityresolution.model.GetMatchingJobResponse; |
22 | 22 | import software.amazon.awssdk.services.entityresolution.model.GetSchemaMappingRequest; |
23 | 23 | import software.amazon.awssdk.services.entityresolution.model.GetSchemaMappingResponse; |
24 | 24 | import software.amazon.awssdk.services.entityresolution.model.InputSource; |
|
41 | 41 | import java.util.List; |
42 | 42 | import java.util.Map; |
43 | 43 | import java.util.concurrent.CompletableFuture; |
44 | | -import java.util.concurrent.CompletionException; |
45 | 44 |
|
46 | 45 | // snippet-start:[entityres.java2_actions.main] |
47 | 46 | public class EntityResActions { |
@@ -113,8 +112,28 @@ public static S3AsyncClient getS3AsyncClient() { |
113 | 112 | return s3AsyncClient; |
114 | 113 | } |
115 | 114 |
|
116 | | - // snippet-start:[entityres.java2_list_mappings.main] |
| 115 | + // snippet-start:[entityres.java2_delete_mappings.main] |
| 116 | + /** |
| 117 | + * Deletes the schema mapping asynchronously. |
| 118 | + * |
| 119 | + * @param schemaName the name of the schema to delete |
| 120 | + * @return a {@link CompletableFuture} that completes when the schema mapping is deleted successfully, |
| 121 | + * or throws a {@link RuntimeException} if the deletion fails |
| 122 | + */ |
| 123 | + public CompletableFuture<Void> deleteSchemaMappingAsync(String schemaName) { |
| 124 | + DeleteSchemaMappingRequest request = DeleteSchemaMappingRequest.builder() |
| 125 | + .schemaName(schemaName) |
| 126 | + .build(); |
| 127 | + |
| 128 | + return getResolutionAsyncClient().deleteSchemaMapping(request) |
| 129 | + .thenRun(() -> logger.info("Schema mapping '{}' deleted successfully.", schemaName)) |
| 130 | + .exceptionally(ex -> { |
| 131 | + throw new RuntimeException("Failed to delete schema mapping: " + schemaName, ex); |
| 132 | + }); |
| 133 | + } |
| 134 | + // snippet-end:[entityres.java2_delete_mappings.main] |
117 | 135 |
|
| 136 | + // snippet-start:[entityres.java2_list_mappings.main] |
118 | 137 | /** |
119 | 138 | * Lists the schema mappings associated with the current AWS account. This method uses an asynchronous paginator to |
120 | 139 | * retrieve the schema mappings, and prints the name of each schema mapping to the console. |
@@ -162,7 +181,6 @@ public CompletableFuture<Void> deleteMatchingWorkflowAsync(String workflowName) |
162 | 181 | // snippet-end:[entityres.java2_delete_matching_workflow.main] |
163 | 182 |
|
164 | 183 | // snippet-start:[entityres.java2_create_schema.main] |
165 | | - |
166 | 184 | /** |
167 | 185 | * Creates a schema mapping asynchronously. |
168 | 186 | * |
@@ -203,7 +221,6 @@ public CompletableFuture<CreateSchemaMappingResponse> createSchemaMappingAsync(S |
203 | 221 | // snippet-end:[entityres.java2_create_schema.main] |
204 | 222 |
|
205 | 223 | // snippet-start:[entityres.java2_get_schema_mapping.main] |
206 | | - |
207 | 224 | /** |
208 | 225 | * Retrieves the schema mapping asynchronously. |
209 | 226 | * |
|
0 commit comments