// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 // snippet-start:[iotsitewise.JavaScript.Basics.batchPutAssetPropertyValue] import { BatchPutAssetPropertyValueCommand, IoTSiteWiseClient, } from "@aws-sdk/client-iotsitewise"; import { parseArgs } from "node:util"; /** * Batch put asset property values. * @param {{ entries : array }} */ export const main = async ({ entries }) => { const client = new IoTSiteWiseClient({}); try { const result = await client.send( new BatchPutAssetPropertyValueCommand({ entries: entries, }), ); console.log("Asset properties batch put successfully."); return result; } catch (caught) { if (caught instanceof Error && caught.name === "ResourceNotFound") { console.warn(`${caught.message}. A resource could not be found.`); } else { throw caught; } } }; // snippet-end:[iotsitewise.JavaScript.Basics.batchPutAssetPropertyValue] import { fileURLToPath } from "node:url"; // Call function if run directly if (process.argv[1] === fileURLToPath(import.meta.url)) { const options = { entries: { type: "array", }, }; const { values } = parseArgs({ options }); main(values); }