Panduan API Referensi AWS SDK for JavaScript V3 menjelaskan secara rinci semua API operasi untuk AWS SDK for JavaScript versi 3 (V3).
Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.
Amazon Personalisasi contoh menggunakan SDK for JavaScript (v3)
Contoh kode berikut menunjukkan cara melakukan tindakan dan menerapkan skenario umum dengan menggunakan AWS SDK for JavaScript (v3) dengan Amazon Personalize.
Tindakan adalah 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.
Topik
Tindakan
Contoh kode berikut menunjukkan cara menggunakanCreateBatchInferenceJob
.
- SDKuntuk JavaScript (v3)
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. // Get service clients module and commands using ES6 syntax. import { CreateBatchInferenceJobCommand } from "@aws-sdk/client-personalize"; import { personalizeClient } from "./libs/personalizeClients.js"; // Or, create the client here. // const personalizeClient = new PersonalizeClient({ region: "REGION"}); // Set the batch inference job's parameters. export const createBatchInferenceJobParam = { jobName: "JOB_NAME", jobInput: { s3DataSource: { path: "INPUT_PATH", }, }, jobOutput: { s3DataDestination: { path: "OUTPUT_PATH", }, }, roleArn: "ROLE_ARN", solutionVersionArn: "SOLUTION_VERSION_ARN", numResults: 20, }; export const run = async () => { try { const response = await personalizeClient.send( new CreateBatchInferenceJobCommand(createBatchInferenceJobParam), ); console.log("Success", response); return response; // For unit tests. } catch (err) { console.log("Error", err); } }; run();
-
Untuk API detailnya, lihat CreateBatchInferenceJobdi AWS SDK for JavaScript APIReferensi.
-
Contoh kode berikut menunjukkan cara menggunakanCreateBatchSegmentJob
.
- SDKuntuk JavaScript (v3)
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. // Get service clients module and commands using ES6 syntax. import { CreateBatchSegmentJobCommand } from "@aws-sdk/client-personalize"; import { personalizeClient } from "./libs/personalizeClients.js"; // Or, create the client here. // const personalizeClient = new PersonalizeClient({ region: "REGION"}); // Set the batch segment job's parameters. export const createBatchSegmentJobParam = { jobName: "NAME", jobInput: { s3DataSource: { path: "INPUT_PATH", }, }, jobOutput: { s3DataDestination: { path: "OUTPUT_PATH", }, }, roleArn: "ROLE_ARN", solutionVersionArn: "SOLUTION_VERSION_ARN", numResults: 20, }; export const run = async () => { try { const response = await personalizeClient.send( new CreateBatchSegmentJobCommand(createBatchSegmentJobParam), ); console.log("Success", response); return response; // For unit tests. } catch (err) { console.log("Error", err); } }; run();
-
Untuk API detailnya, lihat CreateBatchSegmentJobdi AWS SDK for JavaScript APIReferensi.
-
Contoh kode berikut menunjukkan cara menggunakanCreateCampaign
.
- SDKuntuk JavaScript (v3)
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. // Get service clients module and commands using ES6 syntax. import { CreateCampaignCommand } from "@aws-sdk/client-personalize"; import { personalizeClient } from "./libs/personalizeClients.js"; // Or, create the client here. // const personalizeClient = new PersonalizeClient({ region: "REGION"}); // Set the campaign's parameters. export const createCampaignParam = { solutionVersionArn: "SOLUTION_VERSION_ARN" /* required */, name: "NAME" /* required */, minProvisionedTPS: 1 /* optional integer */, }; export const run = async () => { try { const response = await personalizeClient.send( new CreateCampaignCommand(createCampaignParam), ); console.log("Success", response); return response; // For unit tests. } catch (err) { console.log("Error", err); } }; run();
-
Untuk API detailnya, lihat CreateCampaigndi AWS SDK for JavaScript APIReferensi.
-
Contoh kode berikut menunjukkan cara menggunakanCreateDataset
.
- SDKuntuk JavaScript (v3)
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. // Get service clients module and commands using ES6 syntax. import { CreateDatasetCommand } from "@aws-sdk/client-personalize"; import { personalizeClient } from "./libs/personalizeClients.js"; // Or, create the client here. // const personalizeClient = new PersonalizeClient({ region: "REGION"}); // Set the dataset's parameters. export const createDatasetParam = { datasetGroupArn: "DATASET_GROUP_ARN" /* required */, datasetType: "DATASET_TYPE" /* required */, name: "NAME" /* required */, schemaArn: "SCHEMA_ARN" /* required */, }; export const run = async () => { try { const response = await personalizeClient.send( new CreateDatasetCommand(createDatasetParam), ); console.log("Success", response); return response; // For unit tests. } catch (err) { console.log("Error", err); } }; run();
-
Untuk API detailnya, lihat CreateDatasetdi AWS SDK for JavaScript APIReferensi.
-
Contoh kode berikut menunjukkan cara menggunakanCreateDatasetExportJob
.
- SDKuntuk JavaScript (v3)
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. // Get service clients module and commands using ES6 syntax. import { CreateDatasetExportJobCommand } from "@aws-sdk/client-personalize"; import { personalizeClient } from "./libs/personalizeClients.js"; // Or, create the client here. // const personalizeClient = new PersonalizeClient({ region: "REGION"}); // Set the export job parameters. export const datasetExportJobParam = { datasetArn: "DATASET_ARN" /* required */, jobOutput: { s3DataDestination: { path: "S3_DESTINATION_PATH" /* required */, //kmsKeyArn: 'ARN' /* include if your bucket uses AWS KMS for encryption }, }, jobName: "NAME" /* required */, roleArn: "ROLE_ARN" /* required */, }; export const run = async () => { try { const response = await personalizeClient.send( new CreateDatasetExportJobCommand(datasetExportJobParam), ); console.log("Success", response); return response; // For unit tests. } catch (err) { console.log("Error", err); } }; run();
-
Untuk API detailnya, lihat CreateDatasetExportJobdi AWS SDK for JavaScript APIReferensi.
-
Contoh kode berikut menunjukkan cara menggunakanCreateDatasetGroup
.
- SDKuntuk JavaScript (v3)
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. // Get service clients module and commands using ES6 syntax. import { CreateDatasetGroupCommand } from "@aws-sdk/client-personalize"; import { personalizeClient } from "./libs/personalizeClients.js"; // Or, create the client here. // const personalizeClient = new PersonalizeClient({ region: "REGION"}); // Set the dataset group parameters. export const createDatasetGroupParam = { name: "NAME" /* required */, }; export const run = async (createDatasetGroupParam) => { try { const response = await personalizeClient.send( new CreateDatasetGroupCommand(createDatasetGroupParam), ); console.log("Success", response); return "Run successfully"; // For unit tests. } catch (err) { console.log("Error", err); } }; run(createDatasetGroupParam);
Buat grup dataset domain.
// Get service clients module and commands using ES6 syntax. import { CreateDatasetGroupCommand } from "@aws-sdk/client-personalize"; import { personalizeClient } from "./libs/personalizeClients.js"; // Or, create the client here. // const personalizeClient = new PersonalizeClient({ region: "REGION"}); // Set the domain dataset group parameters. export const domainDatasetGroupParams = { name: "NAME" /* required */, domain: "DOMAIN" /* required for a domain dsg, specify ECOMMERCE or VIDEO_ON_DEMAND */, }; export const run = async () => { try { const response = await personalizeClient.send( new CreateDatasetGroupCommand(domainDatasetGroupParams), ); console.log("Success", response); return response; // For unit tests. } catch (err) { console.log("Error", err); } }; run();
-
Untuk API detailnya, lihat CreateDatasetGroupdi AWS SDK for JavaScript APIReferensi.
-
Contoh kode berikut menunjukkan cara menggunakanCreateDatasetImportJob
.
- SDKuntuk JavaScript (v3)
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. // Get service clients module and commands using ES6 syntax. import { CreateDatasetImportJobCommand } from "@aws-sdk/client-personalize"; import { personalizeClient } from "./libs/personalizeClients.js"; // Or, create the client here. // const personalizeClient = new PersonalizeClient({ region: "REGION"}); // Set the dataset import job parameters. export const datasetImportJobParam = { datasetArn: "DATASET_ARN" /* required */, dataSource: { /* required */ dataLocation: "S3_PATH", }, jobName: "NAME" /* required */, roleArn: "ROLE_ARN" /* required */, }; export const run = async () => { try { const response = await personalizeClient.send( new CreateDatasetImportJobCommand(datasetImportJobParam), ); console.log("Success", response); return response; // For unit tests. } catch (err) { console.log("Error", err); } }; run();
-
Untuk API detailnya, lihat CreateDatasetImportJobdi AWS SDK for JavaScript APIReferensi.
-
Contoh kode berikut menunjukkan cara menggunakanCreateEventTracker
.
- SDKuntuk JavaScript (v3)
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. // Get service clients module and commands using ES6 syntax. import { CreateEventTrackerCommand } from "@aws-sdk/client-personalize"; import { personalizeClient } from "./libs/personalizeClients.js"; // Or, create the client here. // const personalizeClient = new PersonalizeClient({ region: "REGION"}); // Set the event tracker's parameters. export const createEventTrackerParam = { datasetGroupArn: "DATASET_GROUP_ARN" /* required */, name: "NAME" /* required */, }; export const run = async () => { try { const response = await personalizeClient.send( new CreateEventTrackerCommand(createEventTrackerParam), ); console.log("Success", response); return response; // For unit tests. } catch (err) { console.log("Error", err); } }; run();
-
Untuk API detailnya, lihat CreateEventTrackerdi AWS SDK for JavaScript APIReferensi.
-
Contoh kode berikut menunjukkan cara menggunakanCreateFilter
.
- SDKuntuk JavaScript (v3)
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. // Get service clients module and commands using ES6 syntax. import { CreateFilterCommand } from "@aws-sdk/client-personalize"; import { personalizeClient } from "./libs/personalizeClients.js"; // Or, create the client here. // const personalizeClient = new PersonalizeClient({ region: "REGION"}); // Set the filter's parameters. export const createFilterParam = { datasetGroupArn: "DATASET_GROUP_ARN" /* required */, name: "NAME" /* required */, filterExpression: "FILTER_EXPRESSION" /*required */, }; export const run = async () => { try { const response = await personalizeClient.send( new CreateFilterCommand(createFilterParam), ); console.log("Success", response); return response; // For unit tests. } catch (err) { console.log("Error", err); } }; run();
-
Untuk API detailnya, lihat CreateFilterdi AWS SDK for JavaScript APIReferensi.
-
Contoh kode berikut menunjukkan cara menggunakanCreateRecommender
.
- SDKuntuk JavaScript (v3)
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. // Get service clients module and commands using ES6 syntax. import { CreateRecommenderCommand } from "@aws-sdk/client-personalize"; import { personalizeClient } from "./libs/personalizeClients.js"; // Or, create the client here. // const personalizeClient = new PersonalizeClient({ region: "REGION"}); // Set the recommender's parameters. export const createRecommenderParam = { name: "NAME" /* required */, recipeArn: "RECIPE_ARN" /* required */, datasetGroupArn: "DATASET_GROUP_ARN" /* required */, }; export const run = async () => { try { const response = await personalizeClient.send( new CreateRecommenderCommand(createRecommenderParam), ); console.log("Success", response); return response; // For unit tests. } catch (err) { console.log("Error", err); } }; run();
-
Untuk API detailnya, lihat CreateRecommenderdi AWS SDK for JavaScript APIReferensi.
-
Contoh kode berikut menunjukkan cara menggunakanCreateSchema
.
- SDKuntuk JavaScript (v3)
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. // Get service clients module and commands using ES6 syntax. import { CreateSchemaCommand } from "@aws-sdk/client-personalize"; import { personalizeClient } from "./libs/personalizeClients.js"; // Or, create the client here. // const personalizeClient = new PersonalizeClient({ region: "REGION"}); import fs from "node:fs"; const schemaFilePath = "SCHEMA_PATH"; let mySchema = ""; try { mySchema = fs.readFileSync(schemaFilePath).toString(); } catch (err) { mySchema = "TEST"; // For unit tests. } // Set the schema parameters. export const createSchemaParam = { name: "NAME" /* required */, schema: mySchema /* required */, }; export const run = async () => { try { const response = await personalizeClient.send( new CreateSchemaCommand(createSchemaParam), ); console.log("Success", response); return response; // For unit tests. } catch (err) { console.log("Error", err); } }; run();
Buat skema dengan domain.
// Get service clients module and commands using ES6 syntax. import { CreateSchemaCommand } from "@aws-sdk/client-personalize"; import { personalizeClient } from "./libs/personalizeClients.js"; // Or, create the client here. // const personalizeClient = new PersonalizeClient({ region: "REGION"}); import fs from "node:fs"; const schemaFilePath = "SCHEMA_PATH"; let mySchema = ""; try { mySchema = fs.readFileSync(schemaFilePath).toString(); } catch (err) { mySchema = "TEST"; // for unit tests. } // Set the domain schema parameters. export const createDomainSchemaParam = { name: "NAME" /* required */, schema: mySchema /* required */, domain: "DOMAIN" /* required for a domain dataset group, specify ECOMMERCE or VIDEO_ON_DEMAND */, }; export const run = async () => { try { const response = await personalizeClient.send( new CreateSchemaCommand(createDomainSchemaParam), ); console.log("Success", response); return response; // For unit tests. } catch (err) { console.log("Error", err); } }; run();
-
Untuk API detailnya, lihat CreateSchemadi AWS SDK for JavaScript APIReferensi.
-
Contoh kode berikut menunjukkan cara menggunakanCreateSolution
.
- SDKuntuk JavaScript (v3)
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. // Get service clients module and commands using ES6 syntax. import { CreateSolutionCommand } from "@aws-sdk/client-personalize"; import { personalizeClient } from "./libs/personalizeClients.js"; // Or, create the client here. // const personalizeClient = new PersonalizeClient({ region: "REGION"}); // Set the solution parameters. export const createSolutionParam = { datasetGroupArn: "DATASET_GROUP_ARN" /* required */, recipeArn: "RECIPE_ARN" /* required */, name: "NAME" /* required */, }; export const run = async () => { try { const response = await personalizeClient.send( new CreateSolutionCommand(createSolutionParam), ); console.log("Success", response); return response; // For unit tests. } catch (err) { console.log("Error", err); } }; run();
-
Untuk API detailnya, lihat CreateSolutiondi AWS SDK for JavaScript APIReferensi.
-
Contoh kode berikut menunjukkan cara menggunakanCreateSolutionVersion
.
- SDKuntuk JavaScript (v3)
-
catatan
Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS
. // Get service clients module and commands using ES6 syntax. import { CreateSolutionVersionCommand } from "@aws-sdk/client-personalize"; import { personalizeClient } from "./libs/personalizeClients.js"; // Or, create the client here. // const personalizeClient = new PersonalizeClient({ region: "REGION"}); // Set the solution version parameters. export const solutionVersionParam = { solutionArn: "SOLUTION_ARN" /* required */, }; export const run = async () => { try { const response = await personalizeClient.send( new CreateSolutionVersionCommand(solutionVersionParam), ); console.log("Success", response); return response; // For unit tests. } catch (err) { console.log("Error", err); } }; run();
-
Untuk API detailnya, lihat CreateSolutionVersiondi AWS SDK for JavaScript APIReferensi.
-