-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Expand file tree
/
Copy pathlist-asset-models.js
More file actions
45 lines (42 loc) · 1.26 KB
/
list-asset-models.js
File metadata and controls
45 lines (42 loc) · 1.26 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.listAssetModels]
import {
ListAssetModelsCommand,
IoTSiteWiseClient,
} from "@aws-sdk/client-iotsitewise";
import { parseArgs } from "node:util";
/**
* List asset models.
* @param {{ assetModelTypes : array }}
*/
export const main = async ({ assetModelTypes = [] }) => {
const client = new IoTSiteWiseClient({});
try {
const result = await client.send(
new ListAssetModelsCommand({
assetModelTypes: assetModelTypes, // The model types to list
}),
);
console.log("Asset model types retrieved successfully.");
return result;
} catch (caught) {
if (caught instanceof Error && caught.name === "IoTSiteWiseError") {
console.warn(
`${caught.message}. There was a problem listing the asset model types.`,
);
} else {
throw caught;
}
}
};
// snippet-end:[iotsitewise.JavaScript.Basics.listAssetModels]
import { fileURLToPath } from "node:url";
// Call function if run directly
if (process.argv[1] === fileURLToPath(import.meta.url)) {
const options = {
assetModelTypes: [],
};
const { values } = parseArgs({ options });
main(values);
}