# Cloud IoT V1 API - Class Google::Cloud::Iot::V1::Device (v0.9.2)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [0.9.2 (latest)](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/Google-Cloud-Iot-V1-Device)
- [0.9.1](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/0.9.1/Google-Cloud-Iot-V1-Device)
- [0.8.0](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/0.8.0/Google-Cloud-Iot-V1-Device)
- [0.7.1](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/0.7.1/Google-Cloud-Iot-V1-Device)
- [0.6.0](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/0.6.0/Google-Cloud-Iot-V1-Device)
- [0.5.0](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/0.5.0/Google-Cloud-Iot-V1-Device)
- [0.4.0](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/0.4.0/Google-Cloud-Iot-V1-Device)
- [0.3.5](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/0.3.5/Google-Cloud-Iot-V1-Device)
Reference documentation and code samples for the Cloud IoT V1 API class Google::Cloud::Iot::V1::Device.

The device resource.

## Inherits

- Object

## Extended By

- Google::Protobuf::MessageExts::ClassMethods

## Includes

- Google::Protobuf::MessageExts

## Methods

### #blocked

    def blocked() -> ::Boolean

**Returns**

- (::Boolean) --- 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.

### #blocked=

    def blocked=(value) -> ::Boolean

**Parameter**

- **value** (::Boolean) --- 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**

- (::Boolean) --- 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.

### #config

    def config() -> ::Google::Cloud::Iot::V1::DeviceConfig

**Returns**

- ([::Google::Cloud::Iot::V1::DeviceConfig](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/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.

### #config=

    def config=(value) -> ::Google::Cloud::Iot::V1::DeviceConfig

**Parameter**

- **value** ([::Google::Cloud::Iot::V1::DeviceConfig](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/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.
**Returns**

- ([::Google::Cloud::Iot::V1::DeviceConfig](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/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.

### #credentials

    def credentials() -> ::Array<::Google::Cloud::Iot::V1::DeviceCredential>

**Returns**

- (::Array\<[::Google::Cloud::Iot::V1::DeviceCredential](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/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.

### #credentials=

    def credentials=(value) -> ::Array<::Google::Cloud::Iot::V1::DeviceCredential>

**Parameter**

- **value** (::Array\<[::Google::Cloud::Iot::V1::DeviceCredential](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/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.
**Returns**

- (::Array\<[::Google::Cloud::Iot::V1::DeviceCredential](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/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.

### #gateway_config

    def gateway_config() -> ::Google::Cloud::Iot::V1::GatewayConfig

**Returns**

- ([::Google::Cloud::Iot::V1::GatewayConfig](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/Google-Cloud-Iot-V1-GatewayConfig)) --- Gateway-related configuration and state.

### #gateway_config=

    def gateway_config=(value) -> ::Google::Cloud::Iot::V1::GatewayConfig

**Parameter**

- **value** ([::Google::Cloud::Iot::V1::GatewayConfig](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/Google-Cloud-Iot-V1-GatewayConfig)) --- Gateway-related configuration and state.
**Returns**

- ([::Google::Cloud::Iot::V1::GatewayConfig](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/Google-Cloud-Iot-V1-GatewayConfig)) --- Gateway-related configuration and state.

### #id

    def id() -> ::String

**Returns**

- (::String) --- The user-defined device identifier. The device ID must be unique within a device registry.

### #id=

    def id=(value) -> ::String

**Parameter**

- **value** (::String) --- The user-defined device identifier. The device ID must be unique within a device registry.
**Returns**

- (::String) --- The user-defined device identifier. The device ID must be unique within a device registry.

### #last_config_ack_time

    def last_config_ack_time() -> ::Google::Protobuf::Timestamp

**Returns**

- ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/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_ack_time=

    def last_config_ack_time=(value) -> ::Google::Protobuf::Timestamp

**Parameter**

- **value** ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/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.
**Returns**

- ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/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

    def last_config_send_time() -> ::Google::Protobuf::Timestamp

**Returns**

- ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/Google-Protobuf-Timestamp)) --- \[Output only\] The last time a cloud-to-device config version was sent to the device.

### #last_config_send_time=

    def last_config_send_time=(value) -> ::Google::Protobuf::Timestamp

**Parameter**

- **value** ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/Google-Protobuf-Timestamp)) --- \[Output only\] The last time a cloud-to-device config version was sent to the device.
**Returns**

- ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/Google-Protobuf-Timestamp)) --- \[Output only\] The last time a cloud-to-device config version was sent to the device.

### #last_error_status

    def last_error_status() -> ::Google::Rpc::Status

**Returns**

- ([::Google::Rpc::Status](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/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.

### #last_error_status=

    def last_error_status=(value) -> ::Google::Rpc::Status

**Parameter**

- **value** ([::Google::Rpc::Status](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/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.
**Returns**

- ([::Google::Rpc::Status](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/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.

### #last_error_time

    def last_error_time() -> ::Google::Protobuf::Timestamp

**Returns**

- ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/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_time=

    def last_error_time=(value) -> ::Google::Protobuf::Timestamp

**Parameter**

- **value** ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/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'.
**Returns**

- ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/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_event_time

    def last_event_time() -> ::Google::Protobuf::Timestamp

**Returns**

- ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/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_event_time=

    def last_event_time=(value) -> ::Google::Protobuf::Timestamp

**Parameter**

- **value** ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/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.
**Returns**

- ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/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_heartbeat_time

    def last_heartbeat_time() -> ::Google::Protobuf::Timestamp

**Returns**

- ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/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_heartbeat_time=

    def last_heartbeat_time=(value) -> ::Google::Protobuf::Timestamp

**Parameter**

- **value** ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/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.
**Returns**

- ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/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_state_time

    def last_state_time() -> ::Google::Protobuf::Timestamp

**Returns**

- ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/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_state_time=

    def last_state_time=(value) -> ::Google::Protobuf::Timestamp

**Parameter**

- **value** ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/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.
**Returns**

- ([::Google::Protobuf::Timestamp](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/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.

### #log_level

    def log_level() -> ::Google::Cloud::Iot::V1::LogLevel

**Returns**

- ([::Google::Cloud::Iot::V1::LogLevel](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/Google-Cloud-Iot-V1-LogLevel)) --- **Beta Feature**


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

### #log_level=

    def log_level=(value) -> ::Google::Cloud::Iot::V1::LogLevel

**Parameter**

- **value** ([::Google::Cloud::Iot::V1::LogLevel](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/Google-Cloud-Iot-V1-LogLevel)) --- **Beta Feature**


  The logging verbosity for device activity. If unspecified,
  DeviceRegistry.log_level will be used.
**Returns**

- ([::Google::Cloud::Iot::V1::LogLevel](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/Google-Cloud-Iot-V1-LogLevel)) --- **Beta Feature**


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

### #metadata

    def metadata() -> ::Google::Protobuf::Map{::String => ::String}

**Returns**

- (::Google::Protobuf::Map{::String =\> ::String}) --- 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.

### #metadata=

    def metadata=(value) -> ::Google::Protobuf::Map{::String => ::String}

**Parameter**

- **value** (::Google::Protobuf::Map{::String =\> ::String}) --- 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**

- (::Google::Protobuf::Map{::String =\> ::String}) --- 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.

### #name

    def name() -> ::String

**Returns**

- (::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.

### #name=

    def name=(value) -> ::String

**Parameter**

- **value** (::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.
**Returns**

- (::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

    def num_id() -> ::Integer

**Returns**

- (::Integer) --- \[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.

### #num_id=

    def num_id=(value) -> ::Integer

**Parameter**

- **value** (::Integer) --- \[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**

- (::Integer) --- \[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.

### #state

    def state() -> ::Google::Cloud::Iot::V1::DeviceState

**Returns**

- ([::Google::Cloud::Iot::V1::DeviceState](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/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.

### #state=

    def state=(value) -> ::Google::Cloud::Iot::V1::DeviceState

**Parameter**

- **value** ([::Google::Cloud::Iot::V1::DeviceState](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/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.
**Returns**

- ([::Google::Cloud::Iot::V1::DeviceState](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-iot-v1/latest/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.