Skip to content

Latest commit

 

History

History
628 lines (457 loc) · 23.3 KB

device.md

File metadata and controls

628 lines (457 loc) · 23.3 KB

Device Actions

Details on the various actions that can be performed on the Device resource, including the expected parameters and the potential responses.

Contents

Delete

Deletes a device

result = client.device.delete(
  applicationId: my_application_id,
  deviceId: my_device_id)

puts result

Authentication

The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, device.*, or device.delete.

Available Parameters

Name Type Required Description Default Example
applicationId string Y ID associated with the application 575ec8687ae143cd83dc4a97
deviceId string Y ID associated with the device 575ecf887ae143cd83dc4aa2
losantdomain string N Domain scope of request (rarely needed) example.com

Successful Responses

Code Type Description
200 Success If device was successfully deleted

Error Responses

Code Type Description
400 Error Error if malformed request
404 Error Error if device was not found

Export

Creates a device data export. Defaults to all data.

result = client.device.export(
  applicationId: my_application_id,
  deviceId: my_device_id)

puts result

Authentication

The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.export.

Available Parameters

Name Type Required Description Default Example
applicationId string Y ID associated with the application 575ec8687ae143cd83dc4a97
deviceId string Y ID associated with the device 575ecf887ae143cd83dc4aa2
start string N Start time of export (ms since epoch - 0 means now, negative is relative to now) 1 1465790400000
end string N End time of export (ms since epoch - 0 means now, negative is relative to now) 0 1465790400000
email string N Email address to send export to. Defaults to current user's email. [email protected]
callbackUrl string N Callback URL to call with export result https://example.com/cburl
includeBlobData string N If set will export any blob attributes in base64 form, otherwise they will be downloadable links which will expire. true
losantdomain string N Domain scope of request (rarely needed) example.com

Successful Responses

Code Type Description
202 Job Enqueued API Result If generation of export was successfully started

Error Responses

Code Type Description
400 Error Error if malformed request
404 Error Error if device was not found

Get

Retrieves information on a device

result = client.device.get(
  applicationId: my_application_id,
  deviceId: my_device_id)

puts result

Authentication

The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.get.

Available Parameters

Name Type Required Description Default Example
applicationId string Y ID associated with the application 575ec8687ae143cd83dc4a97
deviceId string Y ID associated with the device 575ecf887ae143cd83dc4aa2
excludeConnectionInfo string N If set, do not return connection info true
tagsAsObject string N Return tags as an object map instead of an array true
attributesAsObject string N Return attributes as an object map instead of an array false
losantdomain string N Domain scope of request (rarely needed) example.com

Successful Responses

Code Type Description
200 Device Device information

Error Responses

Code Type Description
400 Error Error if malformed request
404 Error Error if device was not found

Get Command

Retrieve the last known commands(s) sent to the device

result = client.device.get_command(
  applicationId: my_application_id,
  deviceId: my_device_id)

puts result

Authentication

The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.getCommand.

Available Parameters

Name Type Required Description Default Example
applicationId string Y ID associated with the application 575ec8687ae143cd83dc4a97
deviceId string Y ID associated with the device 575ecf887ae143cd83dc4aa2
limit string N Maximum number of command entries to return 1 10
since string N (deprecated) Look for command entries since this time (ms since epoch) 1465790400000
sortDirection string N Direction to sort the command entries (by time). Accepted values are: asc, desc desc desc
duration string N Duration of time range to query in milliseconds 86400000
start string N Start of time range to query in milliseconds since epoch 1465790400000
end string N End of time range to query in milliseconds since epoch 0
losantdomain string N Domain scope of request (rarely needed) example.com

Successful Responses

Code Type Description
200 Device Commands Recent device commands

Error Responses

Code Type Description
400 Error Error if malformed request
404 Error Error if device was not found

Get Composite State

Retrieve the composite last complete state of the device

result = client.device.get_composite_state(
  applicationId: my_application_id,
  deviceId: my_device_id)

puts result

Authentication

The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.getCompositeState.

Available Parameters

Name Type Required Description Default Example
applicationId string Y ID associated with the application 575ec8687ae143cd83dc4a97
deviceId string Y ID associated with the device 575ecf887ae143cd83dc4aa2
start string N Start of time range to look at to build composite state 1 1465790400000
end string N End of time range to look at to build composite state 0 1465790400000
attributes string N Comma-separated list of attributes to include. When not provided, returns all attributes. myAttr1,myAttr2
losantdomain string N Domain scope of request (rarely needed) example.com

Successful Responses

Code Type Description
200 Composite Device State Composite last state of the device

Error Responses

Code Type Description
400 Error Error if malformed request
404 Error Error if device was not found

Get Log Entries

Retrieve the recent log entries about the device

result = client.device.get_log_entries(
  applicationId: my_application_id,
  deviceId: my_device_id)

puts result

Authentication

The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.getLogEntries.

Available Parameters

Name Type Required Description Default Example
applicationId string Y ID associated with the application 575ec8687ae143cd83dc4a97
deviceId string Y ID associated with the device 575ecf887ae143cd83dc4aa2
limit string N Maximum number of log entries to return 1 10
since string N (deprecated) Look for log entries since this time (ms since epoch) 1465790400000
sortDirection string N Direction to sort the log entries (by time). Accepted values are: asc, desc desc desc
duration string N Duration of time range to query in milliseconds 86400000
start string N Start of time range to query in milliseconds since epoch 1465790400000
end string N End of time range to query in milliseconds since epoch 0
losantdomain string N Domain scope of request (rarely needed) example.com

Successful Responses

Code Type Description
200 Device Log Recent log entries

Error Responses

Code Type Description
400 Error Error if malformed request
404 Error Error if device was not found

Get State

Retrieve the last known state(s) of the device

result = client.device.get_state(
  applicationId: my_application_id,
  deviceId: my_device_id)

puts result

Authentication

The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.getState.

Available Parameters

Name Type Required Description Default Example
applicationId string Y ID associated with the application 575ec8687ae143cd83dc4a97
deviceId string Y ID associated with the device 575ecf887ae143cd83dc4aa2
limit string N Maximum number of state entries to return 1 10
since string N (deprecated) Look for state entries since this time (ms since epoch) 1465790400000
sortDirection string N Direction to sort the state entries (by time). Accepted values are: asc, desc desc desc
duration string N Duration of time range to query in milliseconds 86400000
start string N Start of time range to query in milliseconds since epoch 1465790400000
end string N End of time range to query in milliseconds since epoch 0
losantdomain string N Domain scope of request (rarely needed) example.com

Successful Responses

Code Type Description
200 Device States Recent device states

Error Responses

Code Type Description
400 Error Error if malformed request
404 Error Error if device was not found

Patch

Updates information about a device

result = client.device.patch(
  applicationId: my_application_id,
  deviceId: my_device_id,
  device: my_device)

puts result

Authentication

The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, device.*, or device.patch.

Available Parameters

Name Type Required Description Default Example
applicationId string Y ID associated with the application 575ec8687ae143cd83dc4a97
deviceId string Y ID associated with the device 575ecf887ae143cd83dc4aa2
device Device Patch Y Object containing new properties of the device Device Patch Example
tagsAsObject string N Return tags as an object map instead of an array true
attributesAsObject string N Return attributes as an object map instead of an array false
losantdomain string N Domain scope of request (rarely needed) example.com

Successful Responses

Code Type Description
200 Device Updated device information

Error Responses

Code Type Description
400 Error Error if malformed request
404 Error Error if device was not found

Payload Counts

Returns payload counts for the time range specified for this device

result = client.device.payload_counts(
  applicationId: my_application_id,
  deviceId: my_device_id)

puts result

Authentication

The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.payloadCounts.

Available Parameters

Name Type Required Description Default Example
applicationId string Y ID associated with the application 575ec8687ae143cd83dc4a97
deviceId string Y ID associated with the device 575ecf887ae143cd83dc4aa2
start string N Start of range for payload count query (ms since epoch) -2592000000 0
end string N End of range for payload count query (ms since epoch) 0 1465790400000
losantdomain string N Domain scope of request (rarely needed) example.com

Successful Responses

Code Type Description
200 Device Payload Counts Payload counts, by type

Error Responses

Code Type Description
400 Error Error if malformed request
404 Error Error if device was not found

Payload Counts Breakdown

Returns payload counts per resolution in the time range specified for this device

result = client.device.payload_counts_breakdown(
  applicationId: my_application_id,
  deviceId: my_device_id)

puts result

Authentication

The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.payloadCountsBreakdown.

Available Parameters

Name Type Required Description Default Example
applicationId string Y ID associated with the application 575ec8687ae143cd83dc4a97
deviceId string Y ID associated with the device 575ecf887ae143cd83dc4aa2
start string N Start of range for payload count query (ms since epoch) -2592000000 0
end string N End of range for payload count query (ms since epoch) 0 1465790400000
resolution string N Resolution in milliseconds. Accepted values are: 86400000, 3600000 86400000 86400000
losantdomain string N Domain scope of request (rarely needed) example.com

Successful Responses

Code Type Description
200 Payload Counts Breakdown Sum of payload counts by date

Error Responses

Code Type Description
400 Error Error if malformed request
404 Error Error if device was not found

Remove Data

Removes all device data for the specified time range. Defaults to all data.

result = client.device.remove_data(
  applicationId: my_application_id,
  deviceId: my_device_id)

puts result

Authentication

The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Organization, all.User, device.*, or device.removeData.

Available Parameters

Name Type Required Description Default Example
applicationId string Y ID associated with the application 575ec8687ae143cd83dc4a97
deviceId string Y ID associated with the device 575ecf887ae143cd83dc4aa2
start string N Start time of export (ms since epoch - 0 means now, negative is relative to now) 1 1465790400000
end string N End time of export (ms since epoch - 0 means now, negative is relative to now) 0 1465790400000
losantdomain string N Domain scope of request (rarely needed) example.com

Successful Responses

Code Type Description
202 Job Enqueued API Result If data removal was successfully started

Error Responses

Code Type Description
400 Error Error if malformed request
404 Error Error if device was not found

Send Command

Send a command to a device

result = client.device.send_command(
  applicationId: my_application_id,
  deviceId: my_device_id,
  deviceCommand: my_device_command)

puts result

Authentication

The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Device, all.Organization, all.User, device.*, or device.sendCommand.

Available Parameters

Name Type Required Description Default Example
applicationId string Y ID associated with the application 575ec8687ae143cd83dc4a97
deviceId string Y ID associated with the device 575ecf887ae143cd83dc4aa2
deviceCommand Device Command Y Command to send to the device Device Command Example
losantdomain string N Domain scope of request (rarely needed) example.com

Successful Responses

Code Type Description
200 Success If command was successfully sent

Error Responses

Code Type Description
400 Error Error if malformed request
404 Error Error if device was not found

Send State

Send the current state of the device

result = client.device.send_state(
  applicationId: my_application_id,
  deviceId: my_device_id,
  deviceState: my_device_state)

puts result

Authentication

The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Device, all.Organization, all.User, device.*, or device.sendState.

Available Parameters

Name Type Required Description Default Example
applicationId string Y ID associated with the application 575ec8687ae143cd83dc4a97
deviceId string Y ID associated with the device 575ecf887ae143cd83dc4aa2
deviceState Device State or States Y A single device state object, or an array of device state objects Device State or States Example
losantdomain string N Domain scope of request (rarely needed) example.com

Successful Responses

Code Type Description
200 Success If state was successfully received

Error Responses

Code Type Description
400 Error Error if malformed request
404 Error Error if device was not found

Set Connection Status

Set the current connection status of the device

result = client.device.set_connection_status(
  applicationId: my_application_id,
  deviceId: my_device_id,
  connectionStatus: my_connection_status)

puts result

Authentication

The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Application, all.Device, all.Organization, all.User, device.*, or device.setConnectionStatus.

Available Parameters

Name Type Required Description Default Example
applicationId string Y ID associated with the application 575ec8687ae143cd83dc4a97
deviceId string Y ID associated with the device 575ecf887ae143cd83dc4aa2
connectionStatus Device Connection Status Y The current connection status of the device Device Connection Status Example
losantdomain string N Domain scope of request (rarely needed) example.com

Successful Responses

Code Type Description
200 Success If connection status was successfully applied

Error Responses

Code Type Description
400 Error Error if malformed request
404 Error Error if device was not found