diff --git a/samples/manager/manager.js b/samples/manager/manager.js index 06ee202a..2b956390 100644 --- a/samples/manager/manager.js +++ b/samples/manager/manager.js @@ -449,7 +449,34 @@ const listDevices = async (registryId, projectId, cloudRegion) => { registryId ); - const [response] = await iotClient.listDevices({parent: parentName}); + // See full list of device fields: https://cloud.google.com/iot/docs/reference/cloudiot/rest/v1/projects.locations.registries.devices + // Warning! Use snake_case field names. + const fieldMask = { + paths: [ + 'id', + 'name', + 'num_id', + 'credentials', + 'last_heartbeat_time', + 'last_event_time', + 'last_state_time', + 'last_config_ack_time', + 'last_config_send_time', + 'blocked', + 'last_error_time', + 'last_error_status', + 'config', + 'state', + 'log_level', + 'metadata', + 'gateway_config', + ], + }; + + const [response] = await iotClient.listDevices({ + parent: parentName, + fieldMask, + }); const devices = response; if (devices.length > 0) { @@ -620,7 +647,34 @@ const getDevice = async (deviceId, registryId, projectId, cloudRegion) => { deviceId ); - const [response] = await iotClient.getDevice({name: devicePath}); + // See full list of device fields: https://cloud.google.com/iot/docs/reference/cloudiot/rest/v1/projects.locations.registries.devices + // Warning! Use snake_case field names. + const fieldMask = { + paths: [ + 'id', + 'name', + 'num_id', + 'credentials', + 'last_heartbeat_time', + 'last_event_time', + 'last_state_time', + 'last_config_ack_time', + 'last_config_send_time', + 'blocked', + 'last_error_time', + 'last_error_status', + 'config', + 'state', + 'log_level', + 'metadata', + 'gateway_config', + ], + }; + + const [response] = await iotClient.getDevice({ + name: devicePath, + fieldMask, + }); const data = response; console.log('Found device:', deviceId, data);