D'autres exemples de AWS SDK sont disponibles dans le référentiel AWS Doc SDK Examples GitHub .
Les traductions sont fournies par des outils de traduction automatique. En cas de conflit entre le contenu d'une traduction et celui de la version originale en anglais, la version anglaise prévaudra.
Utilisation ListSchemaMappings avec un AWS SDK
Les exemples de code suivants illustrent comment utiliser ListSchemaMappings.
Les exemples d’actions sont des extraits de code de programmes de plus grande envergure et doivent être exécutés en contexte. Vous pouvez voir cette action en contexte dans l’exemple de code suivant :
- Java
-
- SDK pour 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 pour 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;
}
}