DeviceManagerClient

DeviceManagerClient

Internet of Things (IoT) service. Securely connect and manage IoT devices.

Constructor

new DeviceManagerClient(optionsopt)

Construct an instance of DeviceManagerClient.

Parameters:
Name Type Attributes Description
options object <optional>

The configuration object. See the subsequent parameters for more details.

Properties
Name Type Attributes Description
credentials object <optional>

Credentials object.

Properties
Name Type Attributes Description
client_email string <optional>
private_key string <optional>
email string <optional>

Account email address. Required when using a .pem or .p12 keyFilename.

keyFilename string <optional>

Full path to the a .json, .pem, or .p12 key downloaded from the Google Developers Console. If you provide a path to a JSON file, the projectId option below is not necessary. NOTE: .pem and .p12 require you to specify options.email as well.

port number <optional>

The port on which to connect to the remote host.

projectId string <optional>

The project ID from the Google Developer's Console, e.g. 'grape-spaceship-123'. We will also check the environment variable GCLOUD_PROJECT for your project ID. If your app is running in an environment which supports Application Default Credentials, your project ID will be detected automatically.

apiEndpoint string <optional>

The domain name of the API remote host.

Members

(static) apiEndpoint

The DNS address for this API service - same as servicePath(), exists for compatibility reasons.

(static) port

The port for this API service.

(static) scopes

The scopes needed to make gRPC calls for every method defined in this service.

(static) servicePath

The DNS address for this API service.

Methods

bindDeviceToGateway(request, optionsopt) → {Promise}

Associates the device with the gateway.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. The name of the registry. For example, projects/example-project/locations/us-central1/registries/my-registry.

gatewayId string

Required. The value of gateway_id can be either the device numeric ID or the user-defined device identifier.

deviceId string

Required. The device to associate with the specified gateway. The value of device_id can be either the device numeric ID or the user-defined device identifier.

options object <optional>

Call options. See CallOptions for more details.

close()

Terminate the GRPC channel and close the client.

The client will no longer be usable and all future behavior is undefined.

createDevice(request, optionsopt) → {Promise}

Creates a device in a device registry.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. The name of the device registry where this device should be created. For example, projects/example-project/locations/us-central1/registries/my-registry.

device google.cloud.iot.v1.Device

Required. The device registration details. The field name must be empty. The server generates name from the device registry id and the parent field.

options object <optional>

Call options. See CallOptions for more details.

createDeviceRegistry(request, optionsopt) → {Promise}

Creates a device registry that contains devices.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. The project and cloud region where this device registry must be created. For example, projects/example-project/locations/us-central1.

deviceRegistry google.cloud.iot.v1.DeviceRegistry

Required. The device registry. The field name must be empty. The server will generate that field from the device registry id provided and the parent field.

options object <optional>

Call options. See CallOptions for more details.

deleteDevice(request, optionsopt) → {Promise}

Deletes a device.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

Required. The name of the device. For example, projects/p0/locations/us-central1/registries/registry0/devices/device0 or projects/p0/locations/us-central1/registries/registry0/devices/{num_id}.

options object <optional>

Call options. See CallOptions for more details.

deleteDeviceRegistry(request, optionsopt) → {Promise}

Deletes a device registry configuration.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

Required. The name of the device registry. For example, projects/example-project/locations/us-central1/registries/my-registry.

options object <optional>

Call options. See CallOptions for more details.

devicePath(project, location, registry, device) → {string}

Return a fully-qualified device resource name string.

Parameters:
Name Type Description
project string
location string
registry string
device string

getDevice(request, optionsopt) → {Promise}

Gets details about a device.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

Required. The name of the device. For example, projects/p0/locations/us-central1/registries/registry0/devices/device0 or projects/p0/locations/us-central1/registries/registry0/devices/{num_id}.

fieldMask google.protobuf.FieldMask

The fields of the Device resource to be returned in the response. If the field mask is unset or empty, all fields are returned.

options object <optional>

Call options. See CallOptions for more details.

getDeviceRegistry(request, optionsopt) → {Promise}

Gets a device registry configuration.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

Required. The name of the device registry. For example, projects/example-project/locations/us-central1/registries/my-registry.

options object <optional>

Call options. See CallOptions for more details.

getIamPolicy(request, optionsopt) → {Promise}

Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
resource string

REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.

options google.iam.v1.GetPolicyOptions

OPTIONAL: A GetPolicyOptions object for specifying options to GetIamPolicy. This field is only used by Cloud IAM.

options object <optional>

Call options. See CallOptions for more details.

getProjectId(callback)

Return the project ID used by this class.

Parameters:
Name Type Description
callback function

the callback to be called with the current project Id.

initialize() → {Promise}

Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.

You can await on this method if you want to make sure the client is initialized.

listDeviceConfigVersions(request, optionsopt) → {Promise}

Lists the last few versions of the device configuration in descending order (i.e.: newest first).

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

Required. The name of the device. For example, projects/p0/locations/us-central1/registries/registry0/devices/device0 or projects/p0/locations/us-central1/registries/registry0/devices/{num_id}.

numVersions number

The number of versions to list. Versions are listed in decreasing order of the version number. The maximum number of versions retained is 10. If this value is zero, it will return all the versions available.

options object <optional>

Call options. See CallOptions for more details.

listDeviceRegistries(request, optionsopt) → {Promise}

Lists device registries.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. The project and cloud region path. For example, projects/example-project/locations/us-central1.

pageSize number

The maximum number of registries to return in the response. If this value is zero, the service will select a default size. A call may return fewer objects than requested. A non-empty next_page_token in the response indicates that more data is available.

pageToken string

The value returned by the last ListDeviceRegistriesResponse; indicates that this is a continuation of a prior ListDeviceRegistries call and the system should return the next page of data.

options object <optional>

Call options. See CallOptions for more details.

listDeviceRegistriesAsync(request, optionsopt) → {Object}

Equivalent to listDeviceRegistries, but returns an iterable object.

for-await-of syntax is used with the iterable to recursively get response element on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. The project and cloud region path. For example, projects/example-project/locations/us-central1.

pageSize number

The maximum number of registries to return in the response. If this value is zero, the service will select a default size. A call may return fewer objects than requested. A non-empty next_page_token in the response indicates that more data is available.

pageToken string

The value returned by the last ListDeviceRegistriesResponse; indicates that this is a continuation of a prior ListDeviceRegistries call and the system should return the next page of data.

options object <optional>

Call options. See CallOptions for more details.

listDeviceRegistriesStream(request, optionsopt) → {Stream}

Equivalent to listDeviceRegistries, but returns a NodeJS Stream object.

This fetches the paged responses for listDeviceRegistries continuously and invokes the callback registered for 'data' event for each element in the responses.

The returned object has 'end' method when no more elements are required.

autoPaginate option will be ignored.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. The project and cloud region path. For example, projects/example-project/locations/us-central1.

pageSize number

The maximum number of registries to return in the response. If this value is zero, the service will select a default size. A call may return fewer objects than requested. A non-empty next_page_token in the response indicates that more data is available.

pageToken string

The value returned by the last ListDeviceRegistriesResponse; indicates that this is a continuation of a prior ListDeviceRegistries call and the system should return the next page of data.

options object <optional>

Call options. See CallOptions for more details.

See:

listDevices(request, optionsopt) → {Promise}

List devices in a device registry.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. The device registry path. Required. For example, projects/my-project/locations/us-central1/registries/my-registry.

deviceNumIds Array.<number>

A list of device numeric IDs. If empty, this field is ignored. Maximum IDs: 10,000.

deviceIds Array.<string>

A list of device string IDs. For example, ['device0', 'device12']. If empty, this field is ignored. Maximum IDs: 10,000

fieldMask google.protobuf.FieldMask

The fields of the Device resource to be returned in the response. The fields id and num_id are always returned, along with any other fields specified.

gatewayListOptions google.cloud.iot.v1.GatewayListOptions

Options related to gateways.

pageSize number

The maximum number of devices to return in the response. If this value is zero, the service will select a default size. A call may return fewer objects than requested. A non-empty next_page_token in the response indicates that more data is available.

pageToken string

The value returned by the last ListDevicesResponse; indicates that this is a continuation of a prior ListDevices call and the system should return the next page of data.

options object <optional>

Call options. See CallOptions for more details.

listDevicesAsync(request, optionsopt) → {Object}

Equivalent to listDevices, but returns an iterable object.

for-await-of syntax is used with the iterable to recursively get response element on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. The device registry path. Required. For example, projects/my-project/locations/us-central1/registries/my-registry.

deviceNumIds Array.<number>

A list of device numeric IDs. If empty, this field is ignored. Maximum IDs: 10,000.

deviceIds Array.<string>

A list of device string IDs. For example, ['device0', 'device12']. If empty, this field is ignored. Maximum IDs: 10,000

fieldMask google.protobuf.FieldMask

The fields of the Device resource to be returned in the response. The fields id and num_id are always returned, along with any other fields specified.

gatewayListOptions google.cloud.iot.v1.GatewayListOptions

Options related to gateways.

pageSize number

The maximum number of devices to return in the response. If this value is zero, the service will select a default size. A call may return fewer objects than requested. A non-empty next_page_token in the response indicates that more data is available.

pageToken string

The value returned by the last ListDevicesResponse; indicates that this is a continuation of a prior ListDevices call and the system should return the next page of data.

options object <optional>

Call options. See CallOptions for more details.

listDevicesStream(request, optionsopt) → {Stream}

Equivalent to listDevices, but returns a NodeJS Stream object.

This fetches the paged responses for listDevices continuously and invokes the callback registered for 'data' event for each element in the responses.

The returned object has 'end' method when no more elements are required.

autoPaginate option will be ignored.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. The device registry path. Required. For example, projects/my-project/locations/us-central1/registries/my-registry.

deviceNumIds Array.<number>

A list of device numeric IDs. If empty, this field is ignored. Maximum IDs: 10,000.

deviceIds Array.<string>

A list of device string IDs. For example, ['device0', 'device12']. If empty, this field is ignored. Maximum IDs: 10,000

fieldMask google.protobuf.FieldMask

The fields of the Device resource to be returned in the response. The fields id and num_id are always returned, along with any other fields specified.

gatewayListOptions google.cloud.iot.v1.GatewayListOptions

Options related to gateways.

pageSize number

The maximum number of devices to return in the response. If this value is zero, the service will select a default size. A call may return fewer objects than requested. A non-empty next_page_token in the response indicates that more data is available.

pageToken string

The value returned by the last ListDevicesResponse; indicates that this is a continuation of a prior ListDevices call and the system should return the next page of data.

options object <optional>

Call options. See CallOptions for more details.

See:

listDeviceStates(request, optionsopt) → {Promise}

Lists the last few versions of the device state in descending order (i.e.: newest first).

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

Required. The name of the device. For example, projects/p0/locations/us-central1/registries/registry0/devices/device0 or projects/p0/locations/us-central1/registries/registry0/devices/{num_id}.

numStates number

The number of states to list. States are listed in descending order of update time. The maximum number of states retained is 10. If this value is zero, it will return all the states available.

options object <optional>

Call options. See CallOptions for more details.

locationPath(project, location) → {string}

Return a fully-qualified location resource name string.

Parameters:
Name Type Description
project string
location string

matchDeviceFromDeviceName(deviceName) → {string}

Parse the device from Device resource.

Parameters:
Name Type Description
deviceName string

A fully-qualified path representing Device resource.

matchLocationFromDeviceName(deviceName) → {string}

Parse the location from Device resource.

Parameters:
Name Type Description
deviceName string

A fully-qualified path representing Device resource.

matchLocationFromLocationName(locationName) → {string}

Parse the location from Location resource.

Parameters:
Name Type Description
locationName string

A fully-qualified path representing Location resource.

matchLocationFromRegistryName(registryName) → {string}

Parse the location from Registry resource.

Parameters:
Name Type Description
registryName string

A fully-qualified path representing Registry resource.

matchProjectFromDeviceName(deviceName) → {string}

Parse the project from Device resource.

Parameters:
Name Type Description
deviceName string

A fully-qualified path representing Device resource.

matchProjectFromLocationName(locationName) → {string}

Parse the project from Location resource.

Parameters:
Name Type Description
locationName string

A fully-qualified path representing Location resource.

matchProjectFromRegistryName(registryName) → {string}

Parse the project from Registry resource.

Parameters:
Name Type Description
registryName string

A fully-qualified path representing Registry resource.

matchRegistryFromDeviceName(deviceName) → {string}

Parse the registry from Device resource.

Parameters:
Name Type Description
deviceName string

A fully-qualified path representing Device resource.

matchRegistryFromRegistryName(registryName) → {string}

Parse the registry from Registry resource.

Parameters:
Name Type Description
registryName string

A fully-qualified path representing Registry resource.

modifyCloudToDeviceConfig(request, optionsopt) → {Promise}

Modifies the configuration for the device, which is eventually sent from the Cloud IoT Core servers. Returns the modified configuration version and its metadata.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

Required. The name of the device. For example, projects/p0/locations/us-central1/registries/registry0/devices/device0 or projects/p0/locations/us-central1/registries/registry0/devices/{num_id}.

versionToUpdate number

The version number to update. If this value is zero, it will not check the version number of the server and will always update the current version; otherwise, this update will fail if the version number found on the server does not match this version number. This is used to support multiple simultaneous updates without losing data.

binaryData Buffer

Required. The configuration data for the device.

options object <optional>

Call options. See CallOptions for more details.

registryPath(project, location, registry) → {string}

Return a fully-qualified registry resource name string.

Parameters:
Name Type Description
project string
location string
registry string

sendCommandToDevice(request, optionsopt) → {Promise}

Sends a command to the specified device. In order for a device to be able to receive commands, it must:

  1. be connected to Cloud IoT Core using the MQTT protocol, and
  2. be subscribed to the group of MQTT topics specified by /devices/{device-id}/commands/#. This subscription will receive commands at the top-level topic /devices/{device-id}/commands as well as commands for subfolders, like /devices/{device-id}/commands/subfolder. Note that subscribing to specific subfolders is not supported. If the command could not be delivered to the device, this method will return an error; in particular, if the device is not subscribed, this method will return FAILED_PRECONDITION. Otherwise, this method will return OK. If the subscription is QoS 1, at least once delivery will be guaranteed; for QoS 0, no acknowledgment will be expected from the device.
Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

Required. The name of the device. For example, projects/p0/locations/us-central1/registries/registry0/devices/device0 or projects/p0/locations/us-central1/registries/registry0/devices/{num_id}.

binaryData Buffer

Required. The command data to send to the device.

subfolder string

Optional subfolder for the command. If empty, the command will be delivered to the /devices/{device-id}/commands topic, otherwise it will be delivered to the /devices/{device-id}/commands/{subfolder} topic. Multi-level subfolders are allowed. This field must not have more than 256 characters, and must not contain any MQTT wildcards ("+" or "#") or null characters.

options object <optional>

Call options. See CallOptions for more details.

setIamPolicy(request, optionsopt) → {Promise}

Sets the access control policy on the specified resource. Replaces any existing policy.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
resource string

REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.

policy google.iam.v1.Policy

REQUIRED: The complete policy to be applied to the resource. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud Platform services (such as Projects) might reject them.

options object <optional>

Call options. See CallOptions for more details.

testIamPermissions(request, optionsopt) → {Promise}

Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
resource string

REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.

permissions Array.<string>

The set of permissions to check for the resource. Permissions with wildcards (such as '' or 'storage.') are not allowed. For more information see IAM Overview.

options object <optional>

Call options. See CallOptions for more details.

unbindDeviceFromGateway(request, optionsopt) → {Promise}

Deletes the association between the device and the gateway.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

Required. The name of the registry. For example, projects/example-project/locations/us-central1/registries/my-registry.

gatewayId string

Required. The value of gateway_id can be either the device numeric ID or the user-defined device identifier.

deviceId string

Required. The device to disassociate from the specified gateway. The value of device_id can be either the device numeric ID or the user-defined device identifier.

options object <optional>

Call options. See CallOptions for more details.

updateDevice(request, optionsopt) → {Promise}

Updates a device.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
device google.cloud.iot.v1.Device

Required. The new values for the device. The id and num_id fields must be empty, and the field name must specify the name path. For example, projects/p0/locations/us-central1/registries/registry0/devices/device0or projects/p0/locations/us-central1/registries/registry0/devices/{num_id}.

updateMask google.protobuf.FieldMask

Required. Only updates the device fields indicated by this mask. The field mask must not be empty, and it must not contain fields that are immutable or only set by the server. Mutable top-level fields: credentials, blocked, and metadata

options object <optional>

Call options. See CallOptions for more details.

updateDeviceRegistry(request, optionsopt) → {Promise}

Updates a device registry configuration.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
deviceRegistry google.cloud.iot.v1.DeviceRegistry

Required. The new values for the device registry. The id field must be empty, and the name field must indicate the path of the resource. For example, projects/example-project/locations/us-central1/registries/my-registry.

updateMask google.protobuf.FieldMask

Required. Only updates the device_registry fields indicated by this mask. The field mask must not be empty, and it must not contain fields that are immutable or only set by the server. Mutable top-level fields: event_notification_config, http_config, mqtt_config, and state_notification_config.

options object <optional>

Call options. See CallOptions for more details.