Constructor

DeviceManagerClient

new DeviceManagerClient(options)

Construct an instance of DeviceManagerClient.

Parameter

options

Optional

object

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

Values in options have the following properties:

Parameter

credentials

Optional

object

Credentials object.

credentials.client_email

Optional

string

credentials.private_key

Optional

string

email

Optional

string

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

keyFilename

Optional

string

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

Optional

number

The port on which to connect to the remote host.

projectId

Optional

string

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.

promise

Optional

function()

Custom promise module to use instead of native Promises.

servicePath

Optional

string

The domain name of the API remote host.

Properties

port

static

The port for this API service.

scopes

static

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

servicePath

static

The DNS address for this API service.

Methods

createDevice

createDevice(request, options, callback) returns Promise

Creates a device in a device registry.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

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

device

Object

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

This object should have the same structure as Device

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing Device.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing Device. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const iot = require('@google-cloud/iot');

var client = new iot.v1.DeviceManagerClient({
  // optional auth parameters.
});

var formattedParent = client.registryPath('[PROJECT]', '[LOCATION]', '[REGISTRY]');
var device = {};
var request = {
  parent: formattedParent,
  device: device,
};
client.createDevice(request)
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

createDeviceRegistry

createDeviceRegistry(request, options, callback) returns Promise

Creates a device registry that contains devices.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

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

deviceRegistry

Object

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.

This object should have the same structure as DeviceRegistry

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing DeviceRegistry.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing DeviceRegistry. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const iot = require('@google-cloud/iot');

var client = new iot.v1.DeviceManagerClient({
  // optional auth parameters.
});

var formattedParent = client.locationPath('[PROJECT]', '[LOCATION]');
var deviceRegistry = {};
var request = {
  parent: formattedParent,
  deviceRegistry: deviceRegistry,
};
client.createDeviceRegistry(request)
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

deleteDevice

deleteDevice(request, options, callback) returns Promise

Deletes a device.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

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

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error)

The function which will be called with the result of the API call.

Returns

Promise 

  • The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const iot = require('@google-cloud/iot');

var client = new iot.v1.DeviceManagerClient({
  // optional auth parameters.
});

var formattedName = client.devicePath('[PROJECT]', '[LOCATION]', '[REGISTRY]', '[DEVICE]');
client.deleteDevice({name: formattedName}).catch(err => {
  console.error(err);
});

deleteDeviceRegistry

deleteDeviceRegistry(request, options, callback) returns Promise

Deletes a device registry configuration.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

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

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error)

The function which will be called with the result of the API call.

Returns

Promise 

  • The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const iot = require('@google-cloud/iot');

var client = new iot.v1.DeviceManagerClient({
  // optional auth parameters.
});

var formattedName = client.registryPath('[PROJECT]', '[LOCATION]', '[REGISTRY]');
client.deleteDeviceRegistry({name: formattedName}).catch(err => {
  console.error(err);
});

devicePath

devicePath(project, location, registry, device) returns String

Return a fully-qualified device resource name string.

Parameter

project

String

location

String

registry

String

device

String

Returns

String 

getDevice

getDevice(request, options, callback) returns Promise

Gets details about a device.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

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

Optional

Object

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

This object should have the same structure as FieldMask

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing Device.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing Device. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const iot = require('@google-cloud/iot');

var client = new iot.v1.DeviceManagerClient({
  // optional auth parameters.
});

var formattedName = client.devicePath('[PROJECT]', '[LOCATION]', '[REGISTRY]', '[DEVICE]');
client.getDevice({name: formattedName})
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

getDeviceRegistry

getDeviceRegistry(request, options, callback) returns Promise

Gets a device registry configuration.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

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

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing DeviceRegistry.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing DeviceRegistry. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const iot = require('@google-cloud/iot');

var client = new iot.v1.DeviceManagerClient({
  // optional auth parameters.
});

var formattedName = client.registryPath('[PROJECT]', '[LOCATION]', '[REGISTRY]');
client.getDeviceRegistry({name: formattedName})
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

getIamPolicy

getIamPolicy(request, options, callback) returns Promise

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

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

resource

string

REQUIRED: The resource for which the policy is being requested. resource is usually specified as a path. For example, a Project resource is specified as projects/{project}.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing Policy.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing Policy. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const iot = require('@google-cloud/iot');

var client = new iot.v1.DeviceManagerClient({
  // optional auth parameters.
});

var formattedResource = client.registryPath('[PROJECT]', '[LOCATION]', '[REGISTRY]');
client.getIamPolicy({resource: formattedResource})
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

getProjectId

getProjectId(callback)

Return the project ID used by this class.

Parameter

callback

function(Error, string)

the callback to be called with the current project Id.

listDeviceConfigVersions

listDeviceConfigVersions(request, options, callback) returns Promise

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

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

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

Optional

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

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing ListDeviceConfigVersionsResponse.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing ListDeviceConfigVersionsResponse. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const iot = require('@google-cloud/iot');

var client = new iot.v1.DeviceManagerClient({
  // optional auth parameters.
});

var formattedName = client.devicePath('[PROJECT]', '[LOCATION]', '[REGISTRY]', '[DEVICE]');
client.listDeviceConfigVersions({name: formattedName})
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

listDeviceRegistries

listDeviceRegistries(request, options, callback) returns Promise

Lists device registries.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

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

pageSize

Optional

number

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Array, nullable Object, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is Array of DeviceRegistry.

When autoPaginate: false is specified through options, it contains the result in a single response. If the response indicates the next page exists, the third parameter is set to be used for the next request object. The fourth parameter keeps the raw response object of an object representing ListDeviceRegistriesResponse.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is Array of DeviceRegistry.

    When autoPaginate: false is specified through options, the array has three elements. The first element is Array of DeviceRegistry in a single response. The second element is the next request object if the response indicates the next page exists, or null. The third element is an object representing ListDeviceRegistriesResponse.

    The promise has a method named "cancel" which cancels the ongoing API call.

Example

const iot = require('@google-cloud/iot');

var client = new iot.v1.DeviceManagerClient({
  // optional auth parameters.
});

// Iterate over all elements.
var formattedParent = client.locationPath('[PROJECT]', '[LOCATION]');

client.listDeviceRegistries({parent: formattedParent})
  .then(responses => {
    var resources = responses[0];
    for (let i = 0; i < resources.length; i += 1) {
      // doThingsWith(resources[i])
    }
  })
  .catch(err => {
    console.error(err);
  });

// Or obtain the paged response.
var formattedParent = client.locationPath('[PROJECT]', '[LOCATION]');


var options = {autoPaginate: false};
var callback = responses => {
  // The actual resources in a response.
  var resources = responses[0];
  // The next request if the response shows that there are more responses.
  var nextRequest = responses[1];
  // The actual response object, if necessary.
  // var rawResponse = responses[2];
  for (let i = 0; i < resources.length; i += 1) {
    // doThingsWith(resources[i]);
  }
  if (nextRequest) {
    // Fetch the next page.
    return client.listDeviceRegistries(nextRequest, options).then(callback);
  }
}
client.listDeviceRegistries({parent: formattedParent}, options)
  .then(callback)
  .catch(err => {
    console.error(err);
  });

listDeviceRegistriesStream

listDeviceRegistriesStream(request, options) returns 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.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

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

pageSize

Optional

number

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

See also
https://nodejs.org/api/stream.html
Returns

Stream 

An object stream which emits an object representing DeviceRegistry on 'data' event.

Example

const iot = require('@google-cloud/iot');

var client = new iot.v1.DeviceManagerClient({
  // optional auth parameters.
});

var formattedParent = client.locationPath('[PROJECT]', '[LOCATION]');
client.listDeviceRegistriesStream({parent: formattedParent})
  .on('data', element => {
    // doThingsWith(element)
  }).on('error', err => {
    console.log(err);
  });

listDevices

listDevices(request, options, callback) returns Promise

List devices in a device registry.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

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

deviceNumIds

Optional

Array of number

A list of device numerical ids. If empty, it will ignore this field. This field cannot hold more than 10,000 entries.

deviceIds

Optional

Array of string

A list of device string identifiers. If empty, it will ignore this field. For example, ['device0', 'device12']. This field cannot hold more than 10,000 entries.

fieldMask

Optional

Object

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

This object should have the same structure as FieldMask

pageSize

Optional

number

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Array, nullable Object, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is Array of Device.

When autoPaginate: false is specified through options, it contains the result in a single response. If the response indicates the next page exists, the third parameter is set to be used for the next request object. The fourth parameter keeps the raw response object of an object representing ListDevicesResponse.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is Array of Device.

    When autoPaginate: false is specified through options, the array has three elements. The first element is Array of Device in a single response. The second element is the next request object if the response indicates the next page exists, or null. The third element is an object representing ListDevicesResponse.

    The promise has a method named "cancel" which cancels the ongoing API call.

Example

const iot = require('@google-cloud/iot');

var client = new iot.v1.DeviceManagerClient({
  // optional auth parameters.
});

// Iterate over all elements.
var formattedParent = client.registryPath('[PROJECT]', '[LOCATION]', '[REGISTRY]');

client.listDevices({parent: formattedParent})
  .then(responses => {
    var resources = responses[0];
    for (let i = 0; i < resources.length; i += 1) {
      // doThingsWith(resources[i])
    }
  })
  .catch(err => {
    console.error(err);
  });

// Or obtain the paged response.
var formattedParent = client.registryPath('[PROJECT]', '[LOCATION]', '[REGISTRY]');


var options = {autoPaginate: false};
var callback = responses => {
  // The actual resources in a response.
  var resources = responses[0];
  // The next request if the response shows that there are more responses.
  var nextRequest = responses[1];
  // The actual response object, if necessary.
  // var rawResponse = responses[2];
  for (let i = 0; i < resources.length; i += 1) {
    // doThingsWith(resources[i]);
  }
  if (nextRequest) {
    // Fetch the next page.
    return client.listDevices(nextRequest, options).then(callback);
  }
}
client.listDevices({parent: formattedParent}, options)
  .then(callback)
  .catch(err => {
    console.error(err);
  });

listDevicesStream

listDevicesStream(request, options) returns 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.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

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

deviceNumIds

Optional

Array of number

A list of device numerical ids. If empty, it will ignore this field. This field cannot hold more than 10,000 entries.

deviceIds

Optional

Array of string

A list of device string identifiers. If empty, it will ignore this field. For example, ['device0', 'device12']. This field cannot hold more than 10,000 entries.

fieldMask

Optional

Object

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

This object should have the same structure as FieldMask

pageSize

Optional

number

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

See also
https://nodejs.org/api/stream.html
Returns

Stream 

An object stream which emits an object representing Device on 'data' event.

Example

const iot = require('@google-cloud/iot');

var client = new iot.v1.DeviceManagerClient({
  // optional auth parameters.
});

var formattedParent = client.registryPath('[PROJECT]', '[LOCATION]', '[REGISTRY]');
client.listDevicesStream({parent: formattedParent})
  .on('data', element => {
    // doThingsWith(element)
  }).on('error', err => {
    console.log(err);
  });

listDeviceStates

listDeviceStates(request, options, callback) returns Promise

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

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

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

Optional

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

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing ListDeviceStatesResponse.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing ListDeviceStatesResponse. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const iot = require('@google-cloud/iot');

var client = new iot.v1.DeviceManagerClient({
  // optional auth parameters.
});

var formattedName = client.devicePath('[PROJECT]', '[LOCATION]', '[REGISTRY]', '[DEVICE]');
client.listDeviceStates({name: formattedName})
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

locationPath

locationPath(project, location) returns String

Return a fully-qualified location resource name string.

Parameter

project

String

location

String

Returns

String 

matchDeviceFromDeviceName

matchDeviceFromDeviceName(deviceName) returns String

Parse the deviceName from a device resource.

Parameter

deviceName

String

A fully-qualified path representing a device resources.

Returns

String 

  • A string representing the device.

matchLocationFromDeviceName

matchLocationFromDeviceName(deviceName) returns String

Parse the deviceName from a device resource.

Parameter

deviceName

String

A fully-qualified path representing a device resources.

Returns

String 

  • A string representing the location.

matchLocationFromLocationName

matchLocationFromLocationName(locationName) returns String

Parse the locationName from a location resource.

Parameter

locationName

String

A fully-qualified path representing a location resources.

Returns

String 

  • A string representing the location.

matchLocationFromRegistryName

matchLocationFromRegistryName(registryName) returns String

Parse the registryName from a registry resource.

Parameter

registryName

String

A fully-qualified path representing a registry resources.

Returns

String 

  • A string representing the location.

matchProjectFromDeviceName

matchProjectFromDeviceName(deviceName) returns String

Parse the deviceName from a device resource.

Parameter

deviceName

String

A fully-qualified path representing a device resources.

Returns

String 

  • A string representing the project.

matchProjectFromLocationName

matchProjectFromLocationName(locationName) returns String

Parse the locationName from a location resource.

Parameter

locationName

String

A fully-qualified path representing a location resources.

Returns

String 

  • A string representing the project.

matchProjectFromRegistryName

matchProjectFromRegistryName(registryName) returns String

Parse the registryName from a registry resource.

Parameter

registryName

String

A fully-qualified path representing a registry resources.

Returns

String 

  • A string representing the project.

matchRegistryFromDeviceName

matchRegistryFromDeviceName(deviceName) returns String

Parse the deviceName from a device resource.

Parameter

deviceName

String

A fully-qualified path representing a device resources.

Returns

String 

  • A string representing the registry.

matchRegistryFromRegistryName

matchRegistryFromRegistryName(registryName) returns String

Parse the registryName from a registry resource.

Parameter

registryName

String

A fully-qualified path representing a registry resources.

Returns

String 

  • A string representing the registry.

modifyCloudToDeviceConfig

modifyCloudToDeviceConfig(request, options, callback) returns 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.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

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

string

The configuration data for the device.

versionToUpdate

Optional

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.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing DeviceConfig.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing DeviceConfig. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const iot = require('@google-cloud/iot');

var client = new iot.v1.DeviceManagerClient({
  // optional auth parameters.
});

var formattedName = client.devicePath('[PROJECT]', '[LOCATION]', '[REGISTRY]', '[DEVICE]');
var binaryData = '';
var request = {
  name: formattedName,
  binaryData: binaryData,
};
client.modifyCloudToDeviceConfig(request)
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

registryPath

registryPath(project, location, registry) returns String

Return a fully-qualified registry resource name string.

Parameter

project

String

location

String

registry

String

Returns

String 

setIamPolicy

setIamPolicy(request, options, callback) returns Promise

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

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

resource

string

REQUIRED: The resource for which the policy is being specified. resource is usually specified as a path. For example, a Project resource is specified as projects/{project}.

policy

Object

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.

This object should have the same structure as Policy

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing Policy.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing Policy. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const iot = require('@google-cloud/iot');

var client = new iot.v1.DeviceManagerClient({
  // optional auth parameters.
});

var formattedResource = client.registryPath('[PROJECT]', '[LOCATION]', '[REGISTRY]');
var policy = {};
var request = {
  resource: formattedResource,
  policy: policy,
};
client.setIamPolicy(request)
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

testIamPermissions

testIamPermissions(request, options, callback) returns 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.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

resource

string

REQUIRED: The resource for which the policy detail is being requested. resource is usually specified as a path. For example, a Project resource is specified as projects/{project}.

permissions

Array of 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

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing TestIamPermissionsResponse.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing TestIamPermissionsResponse. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const iot = require('@google-cloud/iot');

var client = new iot.v1.DeviceManagerClient({
  // optional auth parameters.
});

var formattedResource = client.registryPath('[PROJECT]', '[LOCATION]', '[REGISTRY]');
var permissions = [];
var request = {
  resource: formattedResource,
  permissions: permissions,
};
client.testIamPermissions(request)
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

updateDevice

updateDevice(request, options, callback) returns Promise

Updates a device.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

device

Object

The new values for the device registry. 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}.

This object should have the same structure as Device

updateMask

Object

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

This object should have the same structure as FieldMask

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing Device.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing Device. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const iot = require('@google-cloud/iot');

var client = new iot.v1.DeviceManagerClient({
  // optional auth parameters.
});

var device = {};
var updateMask = {};
var request = {
  device: device,
  updateMask: updateMask,
};
client.updateDevice(request)
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

updateDeviceRegistry

updateDeviceRegistry(request, options, callback) returns Promise

Updates a device registry configuration.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

deviceRegistry

Object

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.

This object should have the same structure as DeviceRegistry

updateMask

Object

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.

This object should have the same structure as FieldMask

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing DeviceRegistry.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing DeviceRegistry. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const iot = require('@google-cloud/iot');

var client = new iot.v1.DeviceManagerClient({
  // optional auth parameters.
});

var deviceRegistry = {};
var updateMask = {};
var request = {
  deviceRegistry: deviceRegistry,
  updateMask: updateMask,
};
client.updateDeviceRegistry(request)
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });