0.1.25 • Published 5 years ago

iotery-server-sdk v0.1.25

Weekly downloads
2
License
MIT
Repository
-
Last release
5 years ago

iotery.io Server SDK

The node.js iotery.io server SDK is intended to be used on your server in order to interact with the itoery.io IoT Platform. The SDK is a fully featured wrapper for the REST API.

Getting Started

Setup your free account on iotery.io and go to your dashboard to get your server API Key.

After you get your key, install the SDK:

npm install iotery-server-sdk

And finally, some simple example usage:

const iotery = require("iotery-server-sdk")("YOUR_IOTERY_API_KEY_HERE");

async function main() {
  let thermalSensorDeviceType = await iotery.createDeviceType(null, {
    enum: "THERMAL_SENSOR",
    name: "Thermal Sensor Type"
  });

  let device = await iotery.createDevice(null, {
    name: "My Device",
    deviceTypeUuid: thermalSensorDeviceType.uuid
  });

  let devices = await iotery.getDevices(null, {
    limit: 10
  });
}

The above code connects you to the iotary.io platform, creates a device type, and a device, then retrieves all your devices.

Next, you might want to create a data type for the the device type you created...here's an example snippet:

let temperatureDataType = await iotery.createDataType(
  { deviceTypeUuid: thermalSensorDeviceType.uuid },
  {
    name: "Temperature",
    enum: "TEMPERATURE",
    units: "C",
    isNumber: true
  }
);

For a tutorial on setting up a full stack system in 15 minutes using iotery.io, check this link out.

API

This SDK simply wraps the REST API, so more information and specifics can be found there. Since the API is a wrapper around the REST API, the syntax is standard for each of the Create, Read, Update, and Delete operations on iotery.io resources. All methods return a Promise.

Creating Resources

The generalized syntax for creating resources in iotery.io looks like:

methodName({ input: "parameters" }, { data: "variables" });

For example, to create a device, the javascript would look like

createDevice(
  { deviceTypeUuid: "a-valid-device-type-uuid" },
  { name: "My Device", other: "parameter" }
);

where createDevice maps to methodName, deviceTypeUuid maps to input, and name and other map to data : "variables" in the generalized form given above.

The available resource creation methods are

methodNameinputlinkdescription
createAccountManagerlinkCreate an account manager.
createConsumerlinkCreate a consumer.
linkConsumerToDeviceconsumerUuidlinkLink a consumer to a device.
linkConsumerToNetworkconsumerUuidlinkLink a consumer to a network.
createConsumerSecretconsumerUuidlinkCreate a consumer secret for authentication.
createDeviceTypelinkCreate a device type.
createSettingTypelinkCreate a setting type.
createDefaultSettinglinkCreate a default setting.
createDataTypelinkCreate a data type.
createDevicelinkCreate a device.
createBatchedCommandInstanceslinkCreate a set of batched command instances.
clearUnexecutedDeviceCommandInstancesdeviceUuidlinkClear all unexecuted command instance for a device.
createDeviceCommandInstancedeviceUuidlinkCreate a command instance for a device.
createDeviceNotificationInstancedeviceUuidlinkCreate a notification instance for a device.
createSettingdeviceUuidlinkCreate a setting for a device.
createFirmwareRecordlinkCreate a firmware record.
createSeverityTypelinkCreate a severity type.
createNotificationTypelinkCreate a notification type.
createNotificationFieldlinkCreate a notification field.
createPriorityTypelinkCreate a priority type.
createCommandTypelinkCreate a command type.
createCommandFieldlinkCreate a command field.
createEventTypelinkCreate an event type.
createEventlinkCreate an event.
createGroupingTypelinkCreate a grouping type.
createTeamlinkCreate a team.
resetTeamteamUuidlinkReset a team by uuid.
linkAccountManagerToTeamteamUuidlinkLink an account manager to a team.
createGroupingBatchedCommandsgroupingUuidlinkCreate a set of batched commands for a grouping and all child grouping devices.
moveDeviceToGroupinggroupingUuidlinkMove a device to a grouping.
createNetworklinkCreate a network.
createNetworkBatchedCommandsnetworkUuidlinkCreate a set of batched commands for a network's devices.
createGroupingnetworkUuidlinkCreate a network grouping.
addChildGroupingnetworkUuid,groupingUuidlinkAdd a child grouping.
createNetworkLocationnetworkUuidlinkCreate a network location.
createSchedulenetworkUuidlinkCreate a schedule.
executeNetworkSchedulenetworkUuid,scheduleUuidlinkExecute a schedule.
deprovisionNetworknetworkUuidlinkDeprovision a network.
provisionNetworklinkProvision a network.
provisionDevicenetworkUuid,deviceUuidlinkProvision a device.
deprovisionDevicenetworkUuid,deviceUuidlinkDeprovision a device.
executeSchedulescheduleUuidlinkExecute a schedule.
createGroupingDevicelinkCreate a GroupingDevice link.
createGroupingLinklinkCreate a GroupingLink.
createWebhookActionlinkCreate a webhook action.
createQrCodelinkCreate a QR code.
createIoteryTemplatelinkCreate an iotery template.
applyIoteryTemplateioteryTemplateUuidlinkApply an iotery template by uuid.

Reading Resources

The generalized syntax for reading resources looks like:

methodName({ input: "parameters" }, { query: "variables" });

For example, to get a device, the javascript would look like

getDeviceByUuid({ deviceUuid: "a-valid-device-uuid" }, { limit: 1 });

where getDeviceByUuid maps to methodName, deviceUuid maps to input, and limit maps to query in the generalized form given above.

The available resource reading methods are

methodNameinputlinkdescription
getHealthCheckResultlinkGet the result of a server health check.
getAccountManageruserUuidlinkGet an account manager by uuid.
getConsumerListlinkGet a list of available consumers.
getConsumerconsumerUuidlinkGet a consumer by uuid.
getConsumerDeviceListconsumerUuidlinkGet a list of devices linked to a consumer.
getConsumerNetworkListconsumerUuidlinkGet a list of networks linked to a consumer.
getDeviceTypeListlinkGet a list of available device types.
getDeviceTypedeviceTypeUuidlinkGet a device type by uuid.
getSettingTypeListlinkGet a list of available setting types.
getSettingTypesettingTypeUuidlinkGet a setting type by uuid.
getDefaultSettingListlinkGet a list of default settings.
getDefaultSettingdefaultSettingUuidlinkGet a default setting by uuid.
getDataTypeListlinkGet a list of available data types.
getDataTypedataTypeUuidlinkGet a data type by uuid.
getCommandInstanceListlinkGet a list of command instances.
getCommandInstancecommandInstanceUuidlinkGet a command instance by uuid.
getDeviceListlinkGet a list of devices.
getDevicedeviceUuidlinkGet a device by uuid.
getDeviceDataListdeviceUuidlinkGet a list of data for a device.
getDeviceEventListdeviceUuidlinkGet a list of events for a device.
getDeviceIsppConfigurationdeviceUuidlinkGet an ISPP configuration for a device.
getDeviceNotificationInstanceListdeviceUuidlinkGet a list of notification instances for a device.
getDeviceSettingListdeviceUuidlinkGet a list of settings for a device.
getDeviceSystemEventListdeviceUuidlinkGet a list of system events for a device.
getNotificationInstancenotificationInstanceUuidlinkGet a notification instance by uuid.
getSettingsettingUuidlinkGet a setting by uuid.
getFirmwareRecordListlinkGet a list of firmware records.
getFirmwareRecordfirmwareUuidlinkGet a firmware record by uuid.
getSeverityTypeListlinkGet a list of available severity types.
getSeverityTypeseverityTypeUuidlinkDelete a severity type by uuid.
getNotificationTypeListlinkGet a list of available notification types.
getNotificationTypenotificationTypeUuidlinkGet a notification type by uuid.
getNotificationFieldListlinkGet a list of available notification fields.
getNotificationFieldnotificationFieldUuidlinkGet a notification field by uuid.
getPriorityTypeListlinkGet a list of available priority types.
getPriorityTypepriorityTypeUuidlinkGet a priority type by uuid.
getCommandTypeListlinkGet a list of available command types.
getCommandTypecommandTypeUuidlinkGet a command type by uuid.
getCommandFieldListlinkGet a list of available command fields.
getCommandFieldcommandFieldUuidlinkGet a command field by uuid.
getEventTypeListlinkGet a list of available event types.
getEventTypeeventTypeUuidlinkGet an event type by uuid.
getEventListlinkGet a list of events.
getEventeventUuidlinkGet an event by uuid.
getGroupingTypeListlinkGet a list of available grouping types.
getGroupingTypegroupingTypeUuidlinkGet a grouping type by uuid.
getTeamListlinkGet a list of available teams.
getTeamteamUuidlinkGet a team by uuid.
getUserListForTeamteamUuidlinkGet a list of users for a team.
getGroupinggroupingUuidlinkGet a grouping by uuid.
getChildGroupingListgroupingUuidlinkGet a list of child groupings for a grouping.
getDeviceListForGroupinggroupingUuidlinkGet a list of devices for a grouping.
getNetworkListlinkGet a list of networks.
getNetworknetworkUuidlinkGet a network by uuid.
getNetworkDeviceListnetworkUuidlinkGet a network's devices.
getNetworkGroupingListnetworkUuidlinkGet a network's groupings.
getNetworkGroupingnetworkUuid,groupingUuidlinkGet a network's grouping by uuid.
getNetworkLocationListnetworkUuidlinkGet a network's locations.
getNetworkLocationnetworkUuid,networkLocationUuidlinkGet a network location by uuid.
getNetworkScheduleListnetworkUuidlinkGet a list of a network's schedules.
getNetworkSchedulenetworkUuid,scheduleUuidlinkGet a schedule by uuid.
getSchedulescheduleUuidlinkGet a schedule by uuid.
getGroupingDeviceListlinkGet a list of GroupingDevice links.
getGroupingDevicegroupingDeviceUuidlinkGet a GroupingDevice link by uuid.
getGroupingLinkListlinkGet a list of GroupingLinks.
getGroupingLinkgroupingLinkUuidlinkGet a GroupingLink by uuid.
getWebhookActionListlinkGet a list of webhook actions.
getWebhookActionwebhookActionUuidlinkGet a webhook action by uuid.
getWebhookActionTypeListlinkGet a list of webhook action types.
getWebhookActionTypewebhookActionTypeUuidlinkGet a webhook action type by uuid.
getQrCodeListlinkGet a list of QR codes.
getQrCodeqrCodeUuidlinkGet a QR code by uuid.
getIoteryTemplateListlinkGet a list of iotery templates.
getIoteryTemplateioteryTemplateUuidlinkGet an iotery template by uuid.

Updating Resources

The generalized syntax for updating resources in iotery.io looks like:

methodName({ input: "parameters" }, { data: "variables to update" });

For example, to create a device, the javascript would look like

updateDevice(
  { deviceUuid: "a-valid-device-uuid" },
  { name: "My New Device Name", other: "new value" }
);

where updateDevice maps to methodName, deviceUuid maps to input, and name and other map to data : "variables to update" in the generalized form given above.

The available update methods are

methodNameinputlinkdescription
updateAccountManageruserUuidlinkUpdate an account manager by uuid.
updateConsumerconsumerUuidlinkUpdate a consumer by uuid.
updateDeviceTypedeviceTypeUuidlinkUpdate a device type by uuid.
updateSettingTypesettingTypeUuidlinkUpdate a setting type by uuid.
updateDefaultSettingdefaultSettingUuidlinkUpdate a default setting by uuid.
updateDataTypedataTypeUuidlinkUpdate a data type by uuid.
updateCommandInstancecommandInstanceUuidlinkUpdate a command instance by uuid.
updateDevicedeviceUuidlinkUpdate a device by uuid.
updateNotificationInstancenotificationInstanceUuidlinkUpdate a notification instance.
updateSettingsettingUuidlinkUpdate a setting.
updateFirmwareRecordfirmwareUuidlinkUpdate a firmware record by uuid.
updateSeverityTypeseverityTypeUuidlinkUpdate a severity type by uuid.
updateNotificationTypenotificationTypeUuidlinkUpdate a notification type by uuid.
updateNotificationFieldnotificationFieldUuidlinkUpdate a notification field by uuid.
updatePriorityTypepriorityTypeUuidlinkUpdate a priority type by uuid.
updateCommandTypecommandTypeUuidlinkUpdate a command type by uuid.
updateCommandFieldcommandFieldUuidlinkUpdate a command field by uuid.
updateEventTypeeventTypeUuidlinkUpdate an event type by uuid.
updateEventeventUuidlinkUpdate an event by uuid.
updateGroupingTypegroupingTypeUuidlinkUpdate a grouping type by uuid.
updateTeamteamUuidlinkUpdate a team by uuid.
updateGroupinggroupingUuidlinkUpdate a grouping.
updateNetworkLocationnetworkLocationUuidlinkUpdate a network location by uuid.
updateNetworknetworkUuidlinkUpdate a network by uuid.
updateNetworkGroupingnetworkUuid,groupingUuidlinkUpdate a network grouping.
updateNetworkNetworkLocationnetworkUuid,networkLocationUuidlinkUpdate a network location.
updateNetworkSchedulenetworkUuid,scheduleUuidlinkUpdate a schedule.
updateSchedulescheduleUuidlinkUpdate a schedule.
updateGroupingDevicegroupingDeviceUuidlinkUpdate a GroupingDevice link by uuid.
updateGroupingLinkgroupingLinkUuidlinkUpdate a GroupingLink by uuid.
updateWebhookActionwebhookActionUuidlinkUpdate a webhook action by uuid.
updateQrCodeqrCodeUuidlinkUpdate a QR code by uuid.

Deleting Resources

The generalized syntax for deleting resources looks like:

methodName({ input: "parameters" });

For example, to delete a device, the javascript would look like

deleteDevice({ deviceUuid: "a-valid-device-uuid" });

where deleteDevice maps to methodName and deviceUuid maps to input in the generalized form given above.

The available resource deleting methods are

methodNameinputlinkdescription
deleteAccountManageruserUuidlinkDelete an account manager by uuid.
deleteConsumerconsumerUuidlinkDelete a consumer by uuid.
unlinkConsumerFromDeviceconsumerUuid,deviceUuidlinkUnlink a consumer from a device.
unlinkConsumerFromNetworkconsumerUuid,networkUuidlinkUnlink a consumer from a network.
deleteConsumerSecretListconsumerUuidlinkDelete all stored consumer secrets.
deleteDeviceTypedeviceTypeUuidlinkDelete a device type by uuid.
deleteSettingTypesettingTypeUuidlinkDelete a setting type by uuid.
deleteDefaultSettingdefaultSettingUuidlinkDelete a default setting by uuid.
deleteDataTypedataTypeUuidlinkDelete a data type by uuid.
deleteDevicedeviceUuidlinkDelete a device by uuid.
deleteNotificationInstancenotificationInstanceUuidlinkDelete a notification instance by uuid.
deleteSettingsettingUuidlinkDelete a setting by uuid.
deleteFirmwareRecordfirmwareUuidlinkDelete a firmware record by uuid.
deleteSeverityTypeseverityTypeUuidlinkDelete a severity type by uuid.
deleteNotificationTypenotificationTypeUuidlinkDelete a notification type by uuid.
deleteNotificationFieldnotificationFieldUuidlinkDelete a notification field by uuid.
deletePriorityTypepriorityTypeUuidlinkDelete a priority type by uuid.
deleteCommandTypecommandTypeUuidlinkDelete a command type by uuid.
deleteCommandFieldcommandFieldUuidlinkDelete a command field by uuid.
deleteEventTypeeventTypeUuidlinkDelete an event type by uuid.
deleteEventeventUuidlinkDelete an event by uuid.
deleteGroupingTypegroupingTypeUuidlinkDelete a grouping type by uuid.
deleteTeamteamUuidlinkDelete a team by uuid.
unlinkAccountManagerFromTeamteamUuid,userUuidlinkUnlink account manager from a team.
deleteGroupinggroupingUuidlinkDelete a grouping by uuid.
deleteNetworknetworkUuidlinkDelete a network by uuid.
deleteNetworkGroupingnetworkUuid,groupingUuidlinkDelete a network's grouping by uuid.
removeDeviceFromGroupingnetworkUuid,groupingUuid,deviceUuidlinkremove a device from a grouping
deleteNetworkLocationnetworkUuid,networkLocationUuidlinkDelete a network location by uuid.
deleteNetworkSchedulenetworkUuid,scheduleUuidlinkDelete a schedule by uuid.
deleteSchedulescheduleUuidlinkDelete a schedule by uuid.
deleteGroupingDevicegroupingDeviceUuidlinkDelete a GroupingDevice link by uuid.
deleteGroupingLinkgroupingLinkUuidlinkDelete a GroupingLink by uuid.
deleteWebhookActionwebhookActionUuidlinkDelete a webhook action type by uuid.
deleteQrCodeqrCodeUuidlinkDelete a QR code by uuid.
deleteIoteryTemplateioteryTemplateUuidlinkDelete an iotery template by uuid.

Contributing

We welcome contributors and PRs! Let us know if you are interested.

Testing

To test, start the mock-server.js in /test and use mocha to run test/index.js.

0.1.25

5 years ago

0.1.24

5 years ago

0.1.23

5 years ago

0.1.22

5 years ago

0.1.21

5 years ago

0.1.20

5 years ago

0.1.19

5 years ago

0.1.18

5 years ago

0.1.17

5 years ago

0.1.16

5 years ago

0.1.15

5 years ago

0.1.14

5 years ago

0.1.13

5 years ago

0.1.12

5 years ago

0.1.10

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago