Google Cloud IoT Core V1 Client - Class Device (1.5.12)

Reference documentation and code samples for the Google Cloud IoT Core V1 Client class Device.

The device resource.

Generated from protobuf message google.cloud.iot.v1.Device

Methods

__construct

Constructor.

Parameters
NameDescription
data array

Optional. Data for populating the Message object.

↳ id string

The user-defined device identifier. The device ID must be unique within a device registry.

↳ name string

The resource path name. For example, projects/p1/locations/us-central1/registries/registry0/devices/dev0 or projects/p1/locations/us-central1/registries/registry0/devices/{num_id}. When name is populated as a response from the service, it always ends in the device numeric ID.

↳ num_id int|string

[Output only] A server-defined unique numeric ID for the device. This is a more compact way to identify devices, and it is globally unique.

↳ credentials array<Google\Cloud\Iot\V1\DeviceCredential>

The credentials used to authenticate this device. To allow credential rotation without interruption, multiple device credentials can be bound to this device. No more than 3 credentials can be bound to a single device at a time. When new credentials are added to a device, they are verified against the registry credentials. For details, see the description of the DeviceRegistry.credentials field.

↳ last_heartbeat_time Google\Protobuf\Timestamp

[Output only] The last time an MQTT PINGREQ was received. This field applies only to devices connecting through MQTT. MQTT clients usually only send PINGREQ messages if the connection is idle, and no other messages have been sent. Timestamps are periodically collected and written to storage; they may be stale by a few minutes.

↳ last_event_time Google\Protobuf\Timestamp

[Output only] The last time a telemetry event was received. Timestamps are periodically collected and written to storage; they may be stale by a few minutes.

↳ last_state_time Google\Protobuf\Timestamp

[Output only] The last time a state event was received. Timestamps are periodically collected and written to storage; they may be stale by a few minutes.

↳ last_config_ack_time Google\Protobuf\Timestamp

[Output only] The last time a cloud-to-device config version acknowledgment was received from the device. This field is only for configurations sent through MQTT.

↳ last_config_send_time Google\Protobuf\Timestamp

[Output only] The last time a cloud-to-device config version was sent to the device.

↳ blocked bool

If a device is blocked, connections or requests from this device will fail. Can be used to temporarily prevent the device from connecting if, for example, the sensor is generating bad data and needs maintenance.

↳ last_error_time Google\Protobuf\Timestamp

[Output only] The time the most recent error occurred, such as a failure to publish to Cloud Pub/Sub. This field is the timestamp of 'last_error_status'.

↳ last_error_status Google\Rpc\Status

[Output only] The error message of the most recent error, such as a failure to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this field. If no errors have occurred, this field has an empty message and the status code 0 == OK. Otherwise, this field is expected to have a status code other than OK.

↳ config Google\Cloud\Iot\V1\DeviceConfig

The most recent device configuration, which is eventually sent from Cloud IoT Core to the device. If not present on creation, the configuration will be initialized with an empty payload and version value of 1. To update this field after creation, use the DeviceManager.ModifyCloudToDeviceConfig method.

↳ state Google\Cloud\Iot\V1\DeviceState

[Output only] The state most recently received from the device. If no state has been reported, this field is not present.

↳ log_level int

Beta Feature The logging verbosity for device activity. If unspecified, DeviceRegistry.log_level will be used.

↳ metadata array|Google\Protobuf\Internal\MapField

The metadata key-value pairs assigned to the device. This metadata is not interpreted or indexed by Cloud IoT Core. It can be used to add contextual information for the device. Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and be less than 128 bytes in length. Values are free-form strings. Each value must be less than or equal to 32 KB in size. The total size of all keys and values must be less than 256 KB, and the maximum number of key-value pairs is 500.

↳ gateway_config Google\Cloud\Iot\V1\GatewayConfig

Gateway-related configuration and state.

getId

The user-defined device identifier. The device ID must be unique within a device registry.

Returns
TypeDescription
string

setId

The user-defined device identifier. The device ID must be unique within a device registry.

Parameter
NameDescription
var string
Returns
TypeDescription
$this

getName

The resource path name. For example, projects/p1/locations/us-central1/registries/registry0/devices/dev0 or projects/p1/locations/us-central1/registries/registry0/devices/{num_id}.

When name is populated as a response from the service, it always ends in the device numeric ID.

Returns
TypeDescription
string

setName

The resource path name. For example, projects/p1/locations/us-central1/registries/registry0/devices/dev0 or projects/p1/locations/us-central1/registries/registry0/devices/{num_id}.

When name is populated as a response from the service, it always ends in the device numeric ID.

Parameter
NameDescription
var string
Returns
TypeDescription
$this

getNumId

[Output only] A server-defined unique numeric ID for the device. This is a more compact way to identify devices, and it is globally unique.

Returns
TypeDescription
int|string

setNumId

[Output only] A server-defined unique numeric ID for the device. This is a more compact way to identify devices, and it is globally unique.

Parameter
NameDescription
var int|string
Returns
TypeDescription
$this

getCredentials

The credentials used to authenticate this device. To allow credential rotation without interruption, multiple device credentials can be bound to this device. No more than 3 credentials can be bound to a single device at a time. When new credentials are added to a device, they are verified against the registry credentials. For details, see the description of the DeviceRegistry.credentials field.

Returns
TypeDescription
Google\Protobuf\Internal\RepeatedField

setCredentials

The credentials used to authenticate this device. To allow credential rotation without interruption, multiple device credentials can be bound to this device. No more than 3 credentials can be bound to a single device at a time. When new credentials are added to a device, they are verified against the registry credentials. For details, see the description of the DeviceRegistry.credentials field.

Parameter
NameDescription
var array<Google\Cloud\Iot\V1\DeviceCredential>
Returns
TypeDescription
$this

getLastHeartbeatTime

[Output only] The last time an MQTT PINGREQ was received. This field applies only to devices connecting through MQTT. MQTT clients usually only send PINGREQ messages if the connection is idle, and no other messages have been sent. Timestamps are periodically collected and written to storage; they may be stale by a few minutes.

Returns
TypeDescription
Google\Protobuf\Timestamp|null

hasLastHeartbeatTime

clearLastHeartbeatTime

setLastHeartbeatTime

[Output only] The last time an MQTT PINGREQ was received. This field applies only to devices connecting through MQTT. MQTT clients usually only send PINGREQ messages if the connection is idle, and no other messages have been sent. Timestamps are periodically collected and written to storage; they may be stale by a few minutes.

Parameter
NameDescription
var Google\Protobuf\Timestamp
Returns
TypeDescription
$this

getLastEventTime

[Output only] The last time a telemetry event was received. Timestamps are periodically collected and written to storage; they may be stale by a few minutes.

Returns
TypeDescription
Google\Protobuf\Timestamp|null

hasLastEventTime

clearLastEventTime

setLastEventTime

[Output only] The last time a telemetry event was received. Timestamps are periodically collected and written to storage; they may be stale by a few minutes.

Parameter
NameDescription
var Google\Protobuf\Timestamp
Returns
TypeDescription
$this

getLastStateTime

[Output only] The last time a state event was received. Timestamps are periodically collected and written to storage; they may be stale by a few minutes.

Returns
TypeDescription
Google\Protobuf\Timestamp|null

hasLastStateTime

clearLastStateTime

setLastStateTime

[Output only] The last time a state event was received. Timestamps are periodically collected and written to storage; they may be stale by a few minutes.

Parameter
NameDescription
var Google\Protobuf\Timestamp
Returns
TypeDescription
$this

getLastConfigAckTime

[Output only] The last time a cloud-to-device config version acknowledgment was received from the device. This field is only for configurations sent through MQTT.

Returns
TypeDescription
Google\Protobuf\Timestamp|null

hasLastConfigAckTime

clearLastConfigAckTime

setLastConfigAckTime

[Output only] The last time a cloud-to-device config version acknowledgment was received from the device. This field is only for configurations sent through MQTT.

Parameter
NameDescription
var Google\Protobuf\Timestamp
Returns
TypeDescription
$this

getLastConfigSendTime

[Output only] The last time a cloud-to-device config version was sent to the device.

Returns
TypeDescription
Google\Protobuf\Timestamp|null

hasLastConfigSendTime

clearLastConfigSendTime

setLastConfigSendTime

[Output only] The last time a cloud-to-device config version was sent to the device.

Parameter
NameDescription
var Google\Protobuf\Timestamp
Returns
TypeDescription
$this

getBlocked

If a device is blocked, connections or requests from this device will fail.

Can be used to temporarily prevent the device from connecting if, for example, the sensor is generating bad data and needs maintenance.

Returns
TypeDescription
bool

setBlocked

If a device is blocked, connections or requests from this device will fail.

Can be used to temporarily prevent the device from connecting if, for example, the sensor is generating bad data and needs maintenance.

Parameter
NameDescription
var bool
Returns
TypeDescription
$this

getLastErrorTime

[Output only] The time the most recent error occurred, such as a failure to publish to Cloud Pub/Sub. This field is the timestamp of 'last_error_status'.

Returns
TypeDescription
Google\Protobuf\Timestamp|null

hasLastErrorTime

clearLastErrorTime

setLastErrorTime

[Output only] The time the most recent error occurred, such as a failure to publish to Cloud Pub/Sub. This field is the timestamp of 'last_error_status'.

Parameter
NameDescription
var Google\Protobuf\Timestamp
Returns
TypeDescription
$this

getLastErrorStatus

[Output only] The error message of the most recent error, such as a failure to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this field. If no errors have occurred, this field has an empty message and the status code 0 == OK. Otherwise, this field is expected to have a status code other than OK.

Returns
TypeDescription
Google\Rpc\Status|null

hasLastErrorStatus

clearLastErrorStatus

setLastErrorStatus

[Output only] The error message of the most recent error, such as a failure to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this field. If no errors have occurred, this field has an empty message and the status code 0 == OK. Otherwise, this field is expected to have a status code other than OK.

Parameter
NameDescription
var Google\Rpc\Status
Returns
TypeDescription
$this

getConfig

The most recent device configuration, which is eventually sent from Cloud IoT Core to the device. If not present on creation, the configuration will be initialized with an empty payload and version value of 1. To update this field after creation, use the DeviceManager.ModifyCloudToDeviceConfig method.

Returns
TypeDescription
Google\Cloud\Iot\V1\DeviceConfig|null

hasConfig

clearConfig

setConfig

The most recent device configuration, which is eventually sent from Cloud IoT Core to the device. If not present on creation, the configuration will be initialized with an empty payload and version value of 1. To update this field after creation, use the DeviceManager.ModifyCloudToDeviceConfig method.

Parameter
NameDescription
var Google\Cloud\Iot\V1\DeviceConfig
Returns
TypeDescription
$this

getState

[Output only] The state most recently received from the device. If no state has been reported, this field is not present.

Returns
TypeDescription
Google\Cloud\Iot\V1\DeviceState|null

hasState

clearState

setState

[Output only] The state most recently received from the device. If no state has been reported, this field is not present.

Parameter
NameDescription
var Google\Cloud\Iot\V1\DeviceState
Returns
TypeDescription
$this

getLogLevel

Beta Feature The logging verbosity for device activity. If unspecified, DeviceRegistry.log_level will be used.

Returns
TypeDescription
int

setLogLevel

Beta Feature The logging verbosity for device activity. If unspecified, DeviceRegistry.log_level will be used.

Parameter
NameDescription
var int
Returns
TypeDescription
$this

getMetadata

The metadata key-value pairs assigned to the device. This metadata is not interpreted or indexed by Cloud IoT Core. It can be used to add contextual information for the device.

Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and be less than 128 bytes in length. Values are free-form strings. Each value must be less than or equal to 32 KB in size. The total size of all keys and values must be less than 256 KB, and the maximum number of key-value pairs is 500.

Returns
TypeDescription
Google\Protobuf\Internal\MapField

setMetadata

The metadata key-value pairs assigned to the device. This metadata is not interpreted or indexed by Cloud IoT Core. It can be used to add contextual information for the device.

Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and be less than 128 bytes in length. Values are free-form strings. Each value must be less than or equal to 32 KB in size. The total size of all keys and values must be less than 256 KB, and the maximum number of key-value pairs is 500.

Parameter
NameDescription
var array|Google\Protobuf\Internal\MapField
Returns
TypeDescription
$this

getGatewayConfig

Gateway-related configuration and state.

Returns
TypeDescription
Google\Cloud\Iot\V1\GatewayConfig|null

hasGatewayConfig

clearGatewayConfig

setGatewayConfig

Gateway-related configuration and state.

Parameter
NameDescription
var Google\Cloud\Iot\V1\GatewayConfig
Returns
TypeDescription
$this