Skip to content

HublessGenericIoT/hublessapi

Repository files navigation

hublessapi NPM version Build Status Dependency Status Coverage percentage

Api for the hubless

Installation

$ npm install --save hublessapi

The API Definition

The API that will be implemented by this app is described below.

Models

A device

{
  id: //uuid that identifies the device.
  name: //human readable name of the device.
  room: //room that the device is in.
  user: //user that the device belongs to. (Currently this is >1 for a user device and 0 for a testing device.)
  type: //the class of device. enum{LIGHT, ...} Currently not supported.
  attributes: {
    //an arbitrary set of attributes attached to the device.
    //currently unsupported, but will be stored in dynamo.
  }
  shadow: {
    //data returned from getDeviceShadow. See AWS API for details.
  }
}

/devices

POST

Request body:

{
  //a device object as defined above. (without the id attribute or schema attribute.)
}

Response body:

{
  status: "Success|Error",
  payload: {
    id: //the id of the created device.
    mqttData: {
      url: //the url to connect to the broker
      username: //the username to connect.
      password: //the password to connect.
    }
  }
}

GET

Get all of the devices in the system. Returns a response in the form:

a parameter ?user={userid} can be provided to limit the devices returned. If not provided, it CURRENTLY defaults to 1. (aka user devices).

NOTE: This response will be paged if it is too long. Information about paging will be added later.

{
    "status": "Success|Error",
    "payload": {
        "devices": [], //array of devices
        "nextToken": "" //paging token.
    }
}

/devices/{id}

GET

Used to get information about a specific device.

{
    status: "Success|Error",
    payload: {} //a single device, as defined above.
}

PUT

{
  //a device (with or without the id, but if given, the id must match)
  //the device referred to in the url will be updated to match what is given.
  //ALL DEVICE METADATA WILL BE ERASED IF OMITTED
  //NOTE: The Shadow IS NOT updated via this endpoint.
}

Contributing

All of these functions are deployed using grunt.

All lambda functions here are deployed to AWS using grunt.

License

MIT © David Tschida

About

API for the thing. Replaces the lambda

Resources

License

Stars

Watchers

Forks

Packages

No packages published