forked from awsdocs/aws-doc-sdk-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbatch-put-asset-property-value.js
More file actions
45 lines (42 loc) · 1.23 KB
/
batch-put-asset-property-value.js
File metadata and controls
45 lines (42 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// 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);
}