Resolusi Entitas AWS contoh menggunakan SDK untuk JavaScript (v3) - AWS SDK untuk JavaScript

Panduan Referensi API AWS SDK untuk JavaScript V3 menjelaskan secara rinci semua operasi API untuk AWS SDK untuk JavaScript versi 3 (V3).

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

Resolusi Entitas AWS contoh menggunakan SDK untuk JavaScript (v3)

Contoh kode berikut menunjukkan cara melakukan tindakan dan mengimplementasikan skenario umum dengan menggunakan AWS SDK untuk JavaScript (v3) with Resolusi Entitas AWS.

Tindakan merupakan kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Sementara tindakan menunjukkan cara memanggil fungsi layanan individual, Anda dapat melihat tindakan dalam konteks dalam skenario terkait.

Setiap contoh menyertakan tautan ke kode sumber lengkap, di mana Anda dapat menemukan instruksi tentang cara mengatur dan menjalankan kode dalam konteks.

Memulai

Contoh kode berikut menunjukkan cara untuk mulai menggunakan Resolusi Entitas AWS.

SDK untuk JavaScript (v3)
catatan

Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode AWS.

import { fileURLToPath } from "node:url"; import { EntityResolutionClient, ListMatchingWorkflowsCommand, } from "@aws-sdk/client-entityresolution"; export const main = async () => { const region = "eu-west-1"; const erClient = new EntityResolutionClient({ region: region }); try { const command = new ListMatchingWorkflowsCommand({}); const response = await erClient.send(command); const workflowSummaries = response.workflowSummaries; for (const workflowSummary of workflowSummaries) { console.log(`Attribute name: ${workflowSummaries[0].workflowName} `); } if (workflowSummaries.length === 0) { console.log("No matching workflows found."); } } catch (error) { console.error( `An error occurred in listing the workflow summaries: ${error.message} \n Exiting program.`, ); return; } };

Tindakan

Contoh kode berikut menunjukkan cara menggunakanCheckWorkflowStatus.

SDK untuk JavaScript (v3)
catatan

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 { GetMatchingJobCommand, 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 ({ workflowName, jobId }) => { const getMatchingJobParams = { workflowName: `${data.inputs.workflowName}`, jobId: `${data.inputs.jobId}`, }; try { const command = new GetMatchingJobCommand(getMatchingJobParams); const response = await erClient.send(command); console.log(`Job status: ${response.status}`); } catch (error) { console.log("error ", error.message); } };

Contoh kode berikut menunjukkan cara menggunakanCreateMatchingWorkflow.

SDK untuk JavaScript (v3)
catatan

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 { CreateMatchingWorkflowCommand, 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 createMatchingWorkflowParams = { roleArn: `${data.inputs.roleArn}`, workflowName: `${data.inputs.workflowName}`, description: "Created by using the AWS SDK for JavaScript (v3).", inputSourceConfig: [ { inputSourceARN: `${data.inputs.JSONinputSourceARN}`, schemaName: `${data.inputs.schemaNameJson}`, applyNormalization: false, }, { inputSourceARN: `${data.inputs.CSVinputSourceARN}`, schemaName: `${data.inputs.schemaNameCSV}`, applyNormalization: false, }, ], outputSourceConfig: [ { outputS3Path: `s3://${data.inputs.myBucketName}/eroutput`, output: [ { name: "id", }, { name: "name", }, { name: "email", }, { name: "phone", }, ], applyNormalization: false, }, ], resolutionTechniques: { resolutionType: "ML_MATCHING" }, }; try { const command = new CreateMatchingWorkflowCommand( createMatchingWorkflowParams, ); const response = await erClient.send(command); console.log( `Workflow created successfully.\n The workflow ARN is: ${response.workflowArn}`, ); } catch (caught) { console.error(caught.message); throw caught; } };

Contoh kode berikut menunjukkan cara menggunakanCreateSchemaMapping.

SDK untuk JavaScript (v3)
catatan

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 { CreateSchemaMappingCommand, 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 createSchemaMappingParamsJson = { schemaName: `${data.inputs.schemaNameJson}`, mappedInputFields: [ { fieldName: "id", type: "UNIQUE_ID", }, { fieldName: "name", type: "NAME", }, { fieldName: "email", type: "EMAIL_ADDRESS", }, ], }; const createSchemaMappingParamsCSV = { schemaName: `${data.inputs.schemaNameCSV}`, mappedInputFields: [ { fieldName: "id", type: "UNIQUE_ID", }, { fieldName: "name", type: "NAME", }, { fieldName: "email", type: "EMAIL_ADDRESS", }, { fieldName: "phone", type: "PROVIDER_ID", subType: "STRING", }, ], }; try { const command = new CreateSchemaMappingCommand( createSchemaMappingParamsJson, ); const response = await erClient.send(command); console.log("The JSON schema mapping name is ", response.schemaName); } catch (error) { console.log("error ", error.message); } };

Contoh kode berikut menunjukkan cara menggunakanDeleteMatchingWorkflow.

SDK untuk JavaScript (v3)
catatan

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 { DeleteMatchingWorkflowCommand, 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 () => { try { const deleteWorkflowParams = { workflowName: `${data.inputs.workflowName}`, }; const command = new DeleteMatchingWorkflowCommand(deleteWorkflowParams); const response = await erClient.send(command); console.log("Workflow deleted successfully!", response); } catch (error) { console.log("error ", error); } };

Contoh kode berikut menunjukkan cara menggunakanDeleteSchemaMapping.

SDK untuk JavaScript (v3)
catatan

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); } };

Contoh kode berikut menunjukkan cara menggunakanGetMatchingJob.

SDK untuk JavaScript (v3)
catatan

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 { GetMatchingJobCommand, 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 getJobInfoParams = { workflowName: `${data.inputs.workflowName}`, jobId: `${data.inputs.jobId}`, }; try { const command = new GetMatchingJobCommand(getJobInfoParams); const response = await erClient.send(command); console.log(`Job status: ${response.status}`); } catch (error) { console.log("error ", error.message); } } };
  • Untuk detail API, lihat GetMatchingJobdi Referensi AWS SDK untuk JavaScript API.

Contoh kode berikut menunjukkan cara menggunakanGetSchemaMapping.

SDK untuk JavaScript (v3)
catatan

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 { GetSchemaMappingCommand, 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 getSchemaMappingJsonParams = { schemaName: `${data.inputs.schemaNameJson}`, }; try { const command = new GetSchemaMappingCommand(getSchemaMappingJsonParams); const response = await erClient.send(command); console.log(response); console.log( `Schema mapping for the JSON data:\n ${response.mappedInputFields[0]}`, ); console.log("Schema mapping ARN is: ", response.schemaArn); } catch (caught) { console.error(caught.message); throw caught; } };
  • Untuk detail API, lihat GetSchemaMappingdi Referensi AWS SDK untuk JavaScript API.

Contoh kode berikut menunjukkan cara menggunakanListSchemaMappings.

SDK untuk JavaScript (v3)
catatan

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 { 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; } }

Contoh kode berikut menunjukkan cara menggunakanStartMatchingJob.

SDK untuk JavaScript (v3)
catatan

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 { StartMatchingJobCommand, 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 matchingJobOfWorkflowParams = { workflowName: `${data.inputs.workflowName}`, }; try { const command = new StartMatchingJobCommand(matchingJobOfWorkflowParams); const response = await erClient.send(command); console.log(`Job ID: ${response.jobID} \n The matching job was successfully started.`); } catch (caught) { console.error(caught.message); throw caught; } };
  • Untuk detail API, lihat StartMatchingJobdi Referensi AWS SDK untuk JavaScript API.

Contoh kode berikut menunjukkan cara menggunakanTagEntityResource.

SDK untuk JavaScript (v3)
catatan

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 { TagResourceCommand, 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 tagResourceCommandParams = { resourceArn: `${data.inputs.schemaArn}`, tags: { tag1: "tag1Value", tag2: "tag2Value", }, }; try { const command = new TagResourceCommand(tagResourceCommandParams); const response = await erClient.send(command); console.log("Successfully tagged the resource."); } catch (caught) { console.error(caught.message); throw caught; } };
  • Untuk detail API, lihat TagEntityResourcedi Referensi AWS SDK untuk JavaScript API.