AWS Entity Resolution SDK for JavaScript(v3)를 사용한 예제 - AWS SDK for JavaScript

AWS SDK for JavaScript V3 API 참조 안내서는 AWS SDK for JavaScript 버전 3(V3)의 모든 API 작업을 자세히 설명합니다.

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

AWS Entity Resolution SDK for JavaScript(v3)를 사용한 예제

다음 코드 예제에서는 AWS SDK for JavaScript (v3)를와 함께 사용하여 작업을 수행하고 일반적인 시나리오를 구현하는 방법을 보여줍니다 AWS Entity Resolution.

작업은 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 작업은 관련 시나리오의 컨텍스트에 따라 표시되며, 개별 서비스 함수를 직접적으로 호출하는 방법을 보여줍니다.

각 예시에는 전체 소스 코드에 대한 링크가 포함되어 있으며, 여기에서 컨텍스트에 맞춰 코드를 설정하고 실행하는 방법에 대한 지침을 찾을 수 있습니다.

시작

다음 코드 예제에서는 AWS Entity Resolution의 사용을 시작하는 방법을 보여 줍니다.

SDK for JavaScript (v3)
참고

GitHub에 더 많은 내용이 있습니다. 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; } };
주제

작업

다음 코드 예시는 CheckWorkflowStatus의 사용 방법을 보여 줍니다.

SDK for JavaScript (v3)
참고

GitHub에 더 많은 내용이 있습니다. 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); } };
  • API 세부 정보는 API 참조의 CheckWorkflowStatusAWS SDK for JavaScript 를 참조하세요.

다음 코드 예시는 CreateMatchingWorkflow의 사용 방법을 보여 줍니다.

SDK for JavaScript (v3)
참고

GitHub에 더 많은 내용이 있습니다. 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; } };

다음 코드 예시는 CreateSchemaMapping의 사용 방법을 보여 줍니다.

SDK for JavaScript (v3)
참고

GitHub에 더 많은 내용이 있습니다. 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); } };
  • API 세부 정보는 API 참조의 CreateSchemaMappingAWS SDK for JavaScript 을 참조하세요.

다음 코드 예시는 DeleteMatchingWorkflow의 사용 방법을 보여 줍니다.

SDK for JavaScript (v3)
참고

GitHub에 더 많은 내용이 있습니다. 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); } };

다음 코드 예시는 DeleteSchemaMapping의 사용 방법을 보여 줍니다.

SDK for JavaScript (v3)
참고

GitHub에 더 많은 내용이 있습니다. 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); } };
  • API 세부 정보는 API 참조의 DeleteSchemaMappingAWS SDK for JavaScript 을 참조하세요.

다음 코드 예시는 GetMatchingJob의 사용 방법을 보여 줍니다.

SDK for JavaScript (v3)
참고

GitHub에 더 많은 내용이 있습니다. 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); } } };
  • API 세부 정보는 API 참조의 GetMatchingJobAWS SDK for JavaScript 을 참조하세요.

다음 코드 예시는 GetSchemaMapping의 사용 방법을 보여 줍니다.

SDK for JavaScript (v3)
참고

GitHub에 더 많은 내용이 있습니다. 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; } };
  • API 세부 정보는 API 참조의 GetSchemaMappingAWS SDK for JavaScript 을 참조하세요.

다음 코드 예시는 ListSchemaMappings의 사용 방법을 보여 줍니다.

SDK for JavaScript (v3)
참고

GitHub에 더 많은 내용이 있습니다. 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; } }
  • API 세부 정보는 API 참조의 ListSchemaMappingsAWS SDK for JavaScript 를 참조하세요.

다음 코드 예시는 StartMatchingJob의 사용 방법을 보여 줍니다.

SDK for JavaScript (v3)
참고

GitHub에 더 많은 내용이 있습니다. 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; } };
  • API 세부 정보는 API 참조의 StartMatchingJobAWS SDK for JavaScript 을 참조하세요.

다음 코드 예시는 TagEntityResource의 사용 방법을 보여 줍니다.

SDK for JavaScript (v3)
참고

GitHub에 더 많은 내용이 있습니다. 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; } };
  • API 세부 정보는 API 참조의 TagEntityResource를 참조하세요. AWS SDK for JavaScript