projects.locations.registries.devices

Resource: Device

JSON representation

JSON representation

{ "id": string, "name": string, "numId": string, "credentials": [ { object(DeviceCredential) } ], "lastHeartbeatTime": string, "lastEventTime": string, "lastStateTime": string, "lastConfigAckTime": string, "lastConfigSendTime": string, "blocked": boolean, "lastErrorTime": string, "lastErrorStatus": { object(Status) }, "config": { object(DeviceConfig) }, "state": { object(DeviceState) }, "logLevel": enum(LogLevel), "metadata": { string: string, ... }, "gatewayConfig": { object(GatewayConfig) } }

Fields

Fields

id

string

The user-defined permanent device identifier. The device ID must be unique within a device registry. 3-255 characters. Start with a letter. You can also include numbers and these characters: + . % - _ ~

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/{numId}. When name is populated as a response from the service, it always ends in the device’s numeric ID.

numId

string

[Output only] The device’s server-defined unique numeric ID. This is a more compact way to identify devices and is globally unique.

credentials[]

object(DeviceCredential)

The credentials used to authenticate this device. Multiple device credentials can be bound to this device to allow credential rotation without interruption. At most, three 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 DeviceRegistry.credentials field’s description.

lastHeartbeatTime

string (Timestamp format)

[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.

A timestamp in RFC3339 UTC Zulu format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".

lastEventTime

string (Timestamp format)

[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.

A timestamp in RFC3339 UTC Zulu format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".

lastStateTime

string (Timestamp format)

[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.

A timestamp in RFC3339 UTC Zulu format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".

lastConfigAckTime

string (Timestamp format)

[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.

A timestamp in RFC3339 UTC Zulu format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".

lastConfigSendTime

string (Timestamp format)

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

A timestamp in RFC3339 UTC Zulu format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".

blocked

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.

lastErrorTime

string (Timestamp format)

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

A timestamp in RFC3339 UTC Zulu format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".

lastErrorStatus

object(Status)

[Output only] The most recent error’s error message, such as a failure to publish to Cloud Pub/Sub. ‘lastErrorTime' is this field’s timestamp. 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

object(DeviceConfig)

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

state

object(DeviceState)

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

logLevel

enum(LogLevel)

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

metadata

map (key: string, value: string)

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

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.

An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.

gatewayConfig

object(GatewayConfig)

Gateway-related configuration and state.

DeviceCredential

A server-stored device credential used for authentication.

JSON representation

JSON representation

{ "expirationTime": string, "publicKey": { object(PublicKeyCredential) } }

Fields

Fields

expirationTime

string (Timestamp format)

[Optional] The time at which this credential becomes invalid. This credential will be ignored for new client authentication requests after this timestamp; however, it will not be automatically deleted.

A timestamp in RFC3339 UTC Zulu format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".

publicKey

object(PublicKeyCredential)

A public key used to verify the signature of JSON Web Tokens (JWTs). When adding a new device credential via device creation or modifications, this public key credential may be required to be signed by one of the registry-level certificates. More specifically, if the registry contains at least one certificate, one of them must sign any new device credential. As a result, only X.509 certificates are accepted as device credentials when the registry contains certificates. However, self-signed certificates and public keys will be accepted if the registry does not contain a certificate. New device credentials must be different from every registry-level certificate.

PublicKeyCredential

A public key format and data.

JSON representation

JSON representation

{ "format": enum(PublicKeyFormat), "key": string }

Fields

Fields

format

enum(PublicKeyFormat)

The key format.

key

string

The key data.

PublicKeyFormat

The public key’s supported formats.

Enums

Enums

UNSPECIFIED_PUBLIC_KEY_FORMAT

The format has not been specified. This is an invalid default value and must not be used.

RSA_PEM

An RSA public key encoded in base64 and wrapped by -----BEGIN PUBLIC KEY----- and -----END PUBLIC KEY-----. This can verify RS256 signatures in JWT tokens (RFC7518).

RSA_X509_PEM

As RSA_PEM, but wrapped in an X.509v3 certificate (RFC5280), encoded in base64, and wrapped by -----BEGIN CERTIFICATE----- and -----END CERTIFICATE-----.

ES256_PEM

The public key for the ECDSA algorithm using P-256 and SHA-256, encoded in base64, and wrapped by -----BEGIN PUBLIC KEY----- and -----END PUBLIC KEY-----. This can be used to verify JWT tokens with the ES256 algorithm (RFC7518). This curve is defined in OpenSSL as the prime256v1 curve.

ES256_X509_PEM

As ES256_PEM, but wrapped in an X.509v3 certificate (RFC5280), encoded in base64, and wrapped by -----BEGIN CERTIFICATE----- and -----END CERTIFICATE-----.

Status

The Status type defines a logical error model suitable for programming environments, including REST, RPC, and gRPC APIs. The error model is designed to be:

  • Simple to use and understood by most users

  • Flexible enough to meet unexpected needs

Overview

The Status message contains three pieces of data: error code, error message, and error details. The error code should be a google.rpc.Code enum value, but it may accept additional error codes if needed. The error message should be a developer-facing English message that helps developers understand and resolve the error. If a localized user-facing error message is required, put it in the error details or localize it in the client. The optional error details may contain arbitrary information about the error. A predefined set of error detail types in the package google.rpc can be used for common error conditions.

Language mapping

The Status message is the error model’s logical representation, but it is not necessarily the actual wire format. The Status message can be mapped differently when exposed in different client libraries and wire protocols. For example, it will likely be mapped to some Java exceptions but more likely mapped to some C error codes.

Other uses

The error model and the Status message can be used in various environments, with or without APIs, to provide a consistent developer experience across different environments.

This error model’s example uses include:

  • Partial errors. If a service needs to return them to the client, it may embed the Status in the normal response to indicate them.

  • Workflow errors. A typical workflow has multiple steps. Each step may have an error reporting Status message.

  • Batch operations. If a client uses batch request and batch response, the Status message should be used directly inside batch response, one for each error sub-response.

  • Asynchronous operations. If an API calls asynchronous operations results in its response, the status of those operations should be represented directly using the Status message.

  • Logging. If some API errors are stored in logs, the Status message could be used directly after any stripping needed for security/privacy reasons.

JSON representation

JSON representation

Fields

Fields

code

number

The status code, which should be a google.rpc.Code enum value.

message

string

A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.

details[]

object

A list of messages that carry the error details. There is a common set of message types for APIs to use.

An object containing arbitrary type fields. An additional field "@type" contains a URI identifying the type. Example: { "id": 1234, "@type": "types.example.com/standard/id" }.

GatewayConfig

Gateway-related configuration and state.

JSON representation

JSON representation

Fields

Fields

gatewayType

enum(GatewayType)

Indicates whether the device is a gateway.

gatewayAuthMethod

enum(GatewayAuthMethod)

Indicates how to authorize and authenticate devices to access the gateway.

lastAccessedGatewayId

string

[Output only] The gateway ID the device accessed most recently.

lastAccessedGatewayTime

string (Timestamp format)

[Output only] The most recent time the device accessed the gateway specified in last_accessed_gateway.

A timestamp in RFC3339 UTC Zulu format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".

GatewayType

Gateway type.

Enums

Enums

GATEWAY_TYPE_UNSPECIFIED

If unspecified, the device is a non-gateway device.

GATEWAY

The device is a gateway.

NON_GATEWAY

The device is not a gateway.

GatewayAuthMethod

The gateway authorization/authentication method. This setting determines how ClearBlade IoT Core authorizes/authenticates devices to access the gateway.

Enums

Enums

GATEWAY_AUTH_METHOD_UNSPECIFIED

No authentication/authorization method specified. No devices are allowed to access the gateway.

ASSOCIATION_ONLY

The device is authenticated through the gateway association only, and device credentials are ignored even if provided.

DEVICE_AUTH_TOKEN_ONLY

The device is authenticated through its credentials, and the gateway association is not checked.

ASSOCIATION_AND_DEVICE_AUTH_TOKEN

The device is authenticated through device credentials and gateway association. The device must be bound to the gateway and provide its credentials.

Methods

Methods

create

Creates a device in a device registry.

delete

Deletes a device.

get

Gets a device’s details.

list

List devices in a device registry.

modifyCloudToDeviceConfig

Modifies the device configuration, which is eventually sent from the ClearBlade IoT Core servers.

patch

Updates a device.

sendCommandToDevice

Sends a command to the specified device.