Reputation: 21
I would like to use listDevices to get all my devices under a registry. Google NodeJS Core IOT API spec
I get an array back which seems to contain a metadata obj/json doc but it's empty.
---
- credentials: []
metadata: {}
id: device001
name: ''
numId: '3038801391636994'
config:
lastConfigAckTime:
state:
lastConfigSendTime:
blocked: false
lastStateTime:
logLevel: LOG_LEVEL_UNSPECIFIED
gatewayConfig:
- credentials: []
metadata: {}
id: device002
name: ''
numId: '2991873732633082'
config:
lastConfigAckTime:
state:
lastConfigSendTime:
blocked: false
lastStateTime:
logLevel: LOG_LEVEL_UNSPECIFIED
gatewayConfig:
If I run a getDevice I do get the expected metadata but that requires a request for each device which becomes too slow and hammers resources. Bug or design?
const [response] = await iotClient.getDevice({name: devicePath});
Which actually shows the metadata
Found device: device002 {
credentials: [
{
expirationTime: [Object],
publicKey: [Object],
credential: 'publicKey'
}
],
metadata: {
hasGPS: 'true',
model: 'Pyton_v1',
hasSolar: 'true',
netType: 'WIFI'
},
id: 'device002'
}
Upvotes: 1
Views: 502
Reputation: 2299
It is defined in the fieldMask
parameter in listDevices api. Check the example code here:
https://cloud.google.com/iot/docs/how-tos/devices?authuser=1#getting_device_details
Upvotes: 0
Reputation: 336
I've made some tries with the device list functions and I think it is a design.
If you run the "gcloud iot devices list" command you get only the fields id
and num_id
, the ones that are filled in your output array too.
I tried using other client libraries and I got the same results, so it looks like it is designed like this but the NodeJS library retrieves additional fields for each device.
Upvotes: 2