-
Notifications
You must be signed in to change notification settings - Fork 57
/
remote-svf-props.js
29 lines (25 loc) · 1.21 KB
/
remote-svf-props.js
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
/*
* Example: parsing object properties for all viewables in a Model Derivative URN.
* Usage:
* export APS_CLIENT_ID=<your client id>
* export APS_CLIENT_SECRET=<your client secret>
* export APS_REGION=<your region> # optional, can be one of the following: "US", "EMEA", "APAC"
* node remote-svf-props.js <your model urn>
*/
const { getSvfDerivatives } = require('./shared.js');
const { SvfReader, TwoLeggedAuthenticationProvider } = require('..');
const { APS_CLIENT_ID, APS_CLIENT_SECRET, APS_REGION } = process.env;
async function run(urn) {
const derivatives = await getSvfDerivatives(urn, APS_CLIENT_ID, APS_CLIENT_SECRET, APS_REGION);
const authenticationProvider = new TwoLeggedAuthenticationProvider(APS_CLIENT_ID, APS_CLIENT_SECRET);
for (const derivative of derivatives) {
const reader = await SvfReader.FromDerivativeService(urn, derivative.guid, authenticationProvider);
const propdb = await reader.getPropertyDb();
const props = propdb.getProperties(1);
for (const name of Object.keys(props)) {
console.log(`${name}: ${props[name]}`);
}
console.log(`Children: ${propdb.getChildren(1).join(',')}`);
}
}
run(process.argv[2]);