// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 // snippet-start:[iotsitewise.JavaScript.Basics.getAssetPropertyValue] import { GetAssetPropertyValueCommand, IoTSiteWiseClient, } from "@aws-sdk/client-iotsitewise"; import { parseArgs } from "node:util"; /** * Describe an asset property value. * @param {{ entryId : string }} */ export const main = async ({ entryId }) => { const client = new IoTSiteWiseClient({}); try { const result = await client.send( new GetAssetPropertyValueCommand({ entryId: entryId, // The ID of the Gateway to describe. }), ); console.log("Asset property information retrieved successfully."); return result; } catch (caught) { if (caught instanceof Error && caught.name === "ResourceNotFound") { console.warn( `${caught.message}. The asset property entry could not be found. Please check the entry id.`, ); } else { throw caught; } } }; // snippet-end:[iotsitewise.JavaScript.Basics.getAssetPropertyValue] import { fileURLToPath } from "node:url"; // Call function if run directly if (process.argv[1] === fileURLToPath(import.meta.url)) { const options = { entryId: { type: "string", }, }; const { values } = parseArgs({ options }); main(values); }