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.
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
of1. To update this field after creation, use theDeviceManager.ModifyCloudToDeviceConfigmethod.
public RepeatedField<DeviceCredential> Credentials { get; }
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 theDeviceRegistry.credentialsfield.
[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.
[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.
[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'.
[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.
[Output only] The last time an MQTTPINGREQwas received. This field
applies only to devices connecting through MQTT. MQTT clients usually only
sendPINGREQmessages 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.
[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.
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.
The resource path name. For example,projects/p1/locations/us-central1/registries/registry0/devices/dev0orprojects/p1/locations/us-central1/registries/registry0/devices/{num_id}.
Whennameis populated as a response from the service, it always ends
in the device numeric ID.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eThe latest version of the \u003ccode\u003eDevice\u003c/code\u003e class in the Cloud IoT v1 API is 2.2.0, with previous versions also documented.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eDevice\u003c/code\u003e class represents a device resource, implementing several interfaces including \u003ccode\u003eIMessage\u003c/code\u003e, \u003ccode\u003eIEquatable\u003c/code\u003e, and \u003ccode\u003eIDeepCloneable\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eKey properties of a \u003ccode\u003eDevice\u003c/code\u003e include \u003ccode\u003eBlocked\u003c/code\u003e (status), \u003ccode\u003eConfig\u003c/code\u003e (most recent configuration), \u003ccode\u003eCredentials\u003c/code\u003e (authentication), and several timestamps related to device activity.\u003c/p\u003e\n"],["\u003cp\u003eEach device has a unique identifier (\u003ccode\u003eId\u003c/code\u003e), a resource name (\u003ccode\u003eName\u003c/code\u003e), and a server-defined numeric ID (\u003ccode\u003eNumId\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eA device can also store metadata key-value pairs, and record logging information as specified by a \u003ccode\u003eLogLevel\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Cloud IoT v1 API - Class Device (2.2.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.2.0 (latest)](/dotnet/docs/reference/Google.Cloud.Iot.V1/latest/Google.Cloud.Iot.V1.Device)\n- [2.1.0](/dotnet/docs/reference/Google.Cloud.Iot.V1/2.1.0/Google.Cloud.Iot.V1.Device)\n- [2.0.0](/dotnet/docs/reference/Google.Cloud.Iot.V1/2.0.0/Google.Cloud.Iot.V1.Device)\n- [1.2.0](/dotnet/docs/reference/Google.Cloud.Iot.V1/1.2.0/Google.Cloud.Iot.V1.Device)\n- [1.1.0](/dotnet/docs/reference/Google.Cloud.Iot.V1/1.1.0/Google.Cloud.Iot.V1.Device)\n- [1.0.0](/dotnet/docs/reference/Google.Cloud.Iot.V1/1.0.0/Google.Cloud.Iot.V1.Device) \n\n public sealed class Device : IMessage\u003cDevice\u003e, IEquatable\u003cDevice\u003e, IDeepCloneable\u003cDevice\u003e, IBufferMessage, IMessage\n\nReference documentation and code samples for the Cloud IoT v1 API class Device.\n\nThe device resource. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e Device \n\nImplements\n----------\n\n[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[Device](/dotnet/docs/reference/Google.Cloud.Iot.V1/latest/Google.Cloud.Iot.V1.Device), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[Device](/dotnet/docs/reference/Google.Cloud.Iot.V1/latest/Google.Cloud.Iot.V1.Device), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[Device](/dotnet/docs/reference/Google.Cloud.Iot.V1/latest/Google.Cloud.Iot.V1.Device), [IBufferMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage.html), [IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage.html) \n\nInherited Members\n-----------------\n\n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Google.Cloud.Iot.V1](/dotnet/docs/reference/Google.Cloud.Iot.V1/latest/Google.Cloud.Iot.V1)\n\nAssembly\n--------\n\nGoogle.Cloud.Iot.V1.dll\n\nConstructors\n------------\n\n### Device()\n\n public Device()\n\n### Device(Device)\n\n public Device(Device other)\n\nProperties\n----------\n\n### Blocked\n\n public bool Blocked { get; set; }\n\nIf a device is blocked, connections or requests from this device will fail.\nCan be used to temporarily prevent the device from connecting if, for\nexample, the sensor is generating bad data and needs maintenance.\n\n### Config\n\n public DeviceConfig Config { get; set; }\n\nThe most recent device configuration, which is eventually sent from\nCloud IoT Core to the device. If not present on creation, the\nconfiguration will be initialized with an empty payload and version value\nof `1`. To update this field after creation, use the\n`DeviceManager.ModifyCloudToDeviceConfig` method.\n\n### Credentials\n\n public RepeatedField\u003cDeviceCredential\u003e Credentials { get; }\n\nThe credentials used to authenticate this device. To allow credential\nrotation without interruption, multiple device credentials can be bound to\nthis device. No more than 3 credentials can be bound to a single device at\na time. When new credentials are added to a device, they are verified\nagainst the registry credentials. For details, see the description of the\n`DeviceRegistry.credentials` field.\n\n### DeviceName\n\n public DeviceName DeviceName { get; set; }\n\n[DeviceName](/dotnet/docs/reference/Google.Cloud.Iot.V1/latest/Google.Cloud.Iot.V1.DeviceName)-typed view over the [Name](/dotnet/docs/reference/Google.Cloud.Iot.V1/latest/Google.Cloud.Iot.V1.Device#Google_Cloud_Iot_V1_Device_Name) resource name property.\n\n### GatewayConfig\n\n public GatewayConfig GatewayConfig { get; set; }\n\nGateway-related configuration and state.\n\n### Id\n\n public string Id { get; set; }\n\nThe user-defined device identifier. The device ID must be unique\nwithin a device registry.\n\n### LastConfigAckTime\n\n public Timestamp LastConfigAckTime { get; set; }\n\n\\[Output only\\] The last time a cloud-to-device config version acknowledgment\nwas received from the device. This field is only for configurations\nsent through MQTT.\n\n### LastConfigSendTime\n\n public Timestamp LastConfigSendTime { get; set; }\n\n\\[Output only\\] The last time a cloud-to-device config version was sent to\nthe device.\n\n### LastErrorStatus\n\n public Status LastErrorStatus { get; set; }\n\n\\[Output only\\] The error message of the most recent error, such as a failure\nto publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this\nfield. If no errors have occurred, this field has an empty message\nand the status code 0 == OK. Otherwise, this field is expected to have a\nstatus code other than OK.\n\n### LastErrorTime\n\n public Timestamp LastErrorTime { get; set; }\n\n\\[Output only\\] The time the most recent error occurred, such as a failure to\npublish to Cloud Pub/Sub. This field is the timestamp of\n'last_error_status'.\n\n### LastEventTime\n\n public Timestamp LastEventTime { get; set; }\n\n\\[Output only\\] The last time a telemetry event was received. Timestamps are\nperiodically collected and written to storage; they may be stale by a few\nminutes.\n\n### LastHeartbeatTime\n\n public Timestamp LastHeartbeatTime { get; set; }\n\n\\[Output only\\] The last time an MQTT `PINGREQ` was received. This field\napplies only to devices connecting through MQTT. MQTT clients usually only\nsend `PINGREQ` messages if the connection is idle, and no other messages\nhave been sent. Timestamps are periodically collected and written to\nstorage; they may be stale by a few minutes.\n\n### LastStateTime\n\n public Timestamp LastStateTime { get; set; }\n\n\\[Output only\\] The last time a state event was received. Timestamps are\nperiodically collected and written to storage; they may be stale by a few\nminutes.\n\n### LogLevel\n\n public LogLevel LogLevel { get; set; }\n\n**Beta Feature**\n\nThe logging verbosity for device activity. If unspecified,\nDeviceRegistry.log_level will be used.\n\n### Metadata\n\n public MapField\u003cstring, string\u003e Metadata { get; }\n\nThe metadata key-value pairs assigned to the device. This metadata is not\ninterpreted or indexed by Cloud IoT Core. It can be used to add contextual\ninformation for the device.\n\nKeys must conform to the regular expression \\[a-zA-Z\\]\\[a-zA-Z0-9-_.+\\~%\\]+ and\nbe less than 128 bytes in length.\n\nValues are free-form strings. Each value must be less than or equal to 32\nKB in size.\n\nThe total size of all keys and values must be less than 256 KB, and the\nmaximum number of key-value pairs is 500.\n\n### Name\n\n public string Name { get; set; }\n\nThe resource path name. For example,\n`projects/p1/locations/us-central1/registries/registry0/devices/dev0` or\n`projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`.\nWhen `name` is populated as a response from the service, it always ends\nin the device numeric ID.\n\n### NumId\n\n public ulong NumId { get; set; }\n\n\\[Output only\\] A server-defined unique numeric ID for the device. This is a\nmore compact way to identify devices, and it is globally unique.\n\n### State\n\n public DeviceState State { get; set; }\n\n\\[Output only\\] The state most recently received from the device. If no state\nhas been reported, this field is not present."]]