Sono disponibili altri esempi AWS SDK nel repository AWS Doc SDK Examples. GitHub
Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.
Utilizzare ListSchemaMappings con un AWS SDK
Gli esempi di codice seguenti mostrano come utilizzare ListSchemaMappings.
Gli esempi di operazioni sono estratti di codice da programmi più grandi e devono essere eseguiti nel contesto. È possibile visualizzare questa operazione nel contesto nel seguente esempio di codice:
- Java
-
- SDK per Java 2.x
-
/**
* Lists the schema mappings associated with the current AWS account. This method uses an asynchronous paginator to
* retrieve the schema mappings, and prints the name of each schema mapping to the console.
*/
public void ListSchemaMappings() {
ListSchemaMappingsRequest mappingsRequest = ListSchemaMappingsRequest.builder()
.build();
ListSchemaMappingsPublisher paginator = getResolutionAsyncClient().listSchemaMappingsPaginator(mappingsRequest);
// Iterate through the pages of results
CompletableFuture<Void> future = paginator.subscribe(response -> {
response.schemaList().forEach(schemaMapping ->
logger.info("Schema Mapping Name: " + schemaMapping.schemaName())
);
});
// Wait for the asynchronous operation to complete
future.join();
}
- JavaScript
-
- SDK per JavaScript (v3)
-
//The default inputs for this demo are read from the ../inputs.json.
import { fileURLToPath } from "node:url";
import {
ListSchemaMappingsCommand,
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 () => {
async function getInfo() {
const listSchemaMappingsParams = {
workflowName: `${data.inputs.workflowName}`,
jobId: `${data.inputs.jobId}`,
};
try {
const command = new ListSchemaMappingsCommand(listSchemaMappingsParams);
const response = await erClient.send(command);
const noOfSchemas = response.schemaList.length;
for (let i = 0; i < noOfSchemas; i++) {
console.log(
`Schema Mapping Name: ${response.schemaList[i].schemaName} `,
);
}
} catch (caught) {
console.error(caught.message);
throw caught;
}
}