Class: AWS.IotData

Identifier:
iotdata
API Version:
2017-09-20
Defined in:
iotdata.js

Overview

Constructs a service interface object. Each API operation is exposed as a function on service.

Sending a Request Using IotData

var iotdata = new GG.IotData();
iotdata.getThingShadow(params, function (err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Constructor Summary collapse

Method Summary collapse

Constructor Details

new GG.IotData() ⇒ Object

Constructs a service object. This object has one method for each API operation.

Examples:

Constructing a IotData object

var iotdata = new GG.IotData();

Method Details

getThingShadow(params = {}, callback)

Gets the thing shadow for the specified thing.

Examples:

Calling the getThingShadow operation

var params = {
  thingName: 'STRING_VALUE' /* required */
};
iotdata.getThingShadow(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • thingName — (String)

      The name of the thing.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • payload — (Buffer, Typed Array, Blob, String)

        The state information, in JSON format.

Returns:

  • Nothing

publish(params = {}, callback)

Publishes a message within Greengrass.

Examples:

Calling the publish operation

var params = {
  topic: 'STRING_VALUE', /* required */
  payload: new Buffer('...') || 'STRING_VALUE'
};
iotdata.publish(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • topic — (String)

      The name of the MQTT topic.

    • payload — (Buffer, Typed Array, Blob, String)

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs.

Returns:

  • Nothing

updateThingShadow(params = {}, callback) ⇒ GG.Request

Updates the thing shadow for the specified thing.

Examples:

Calling the updateThingShadow operation

var params = {
  payload: 'Proper JSON data', /* required */
  thingName: 'STRING_VALUE' /* required */
};
iotdata.updateThingShadow(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

Parameters:

  • params (Object) (defaults to: {})
    • thingName — (String)

      The name of the thing.

    • payload — (Proper JSON data)

      The state information, in JSON format.

Callback (callback):

  • function(err, data) { ... }

    Called when a response from the service is returned.

    Parameters:

    • err (Error)

      the error object returned from the request. Set to null if the request is successful.

    • data (Object)

      the de-serialized data returned from the request. Set to null if a request error occurs. The data object has the following properties:

      • payload — (Buffer, Typed Array, Blob, String)

        The state information, in JSON format.

Returns:

  • Nothing