Ada lebih banyak contoh AWS SDK yang tersedia di repo Contoh SDK AWS Doc. GitHub
Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Gunakan DeleteSchemaMapping dengan AWS SDK
Contoh kode berikut menunjukkan cara menggunakanDeleteSchemaMapping.
Contoh tindakan adalah kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Anda dapat melihat tindakan ini dalam konteks dalam contoh kode berikut:
- Java
-
- SDK untuk Java 2.x
-
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode AWS.
/**
* Deletes the schema mapping asynchronously.
*
* @param schemaName the name of the schema to delete
* @return a {@link CompletableFuture} that completes when the schema mapping is deleted successfully,
* or throws a {@link RuntimeException} if the deletion fails
*/
public CompletableFuture<DeleteSchemaMappingResponse> deleteSchemaMappingAsync(String schemaName) {
DeleteSchemaMappingRequest request = DeleteSchemaMappingRequest.builder()
.schemaName(schemaName)
.build();
return getResolutionAsyncClient().deleteSchemaMapping(request)
.whenComplete((response, exception) -> {
if (response != null) {
// Successfully deleted the schema mapping, log the success message.
logger.info("Schema mapping '{}' deleted successfully.", schemaName);
} else {
// Ensure exception is not null before accessing its cause.
if (exception == null) {
throw new CompletionException("An unknown error occurred while deleting the schema mapping.", null);
}
Throwable cause = exception.getCause();
if (cause instanceof ResourceNotFoundException) {
throw new CompletionException("The schema mapping was not found to delete: " + schemaName, cause);
}
// Wrap other AWS exceptions in a CompletionException.
throw new CompletionException("Failed to delete schema mapping: " + schemaName, exception);
}
});
}
- JavaScript
-
- SDK untuk JavaScript (v3)
-
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode AWS.
//The default inputs for this demo are read from the ../inputs.json.
import { fileURLToPath } from "node:url";
import {
DeleteSchemaMappingCommand,
EntityResolutionClient,
} from "@aws-sdk/client-entityresolution";
import data from "../inputs.json" with { type: "json" };
const region = "eu-west-1";
const erClient = new EntityResolutionClient({ region: region });
export const main = async () => {
const deleteSchemaMapping = {
schemaName: `${data.inputs.schemaNameJson}`,
};
try {
const command = new DeleteSchemaMappingCommand(deleteSchemaMapping);
const response = await erClient.send(command);
console.log("Schema mapping deleted successfully. ", response);
} catch (error) {
console.log("error ", error);
}
};