Class: PlatformRest::Device
- Inherits:
-
Object
- Object
- PlatformRest::Device
- Defined in:
- lib/platform_rest/device.rb
Overview
Class containing all the actions for the Device Resource
Instance Method Summary collapse
-
#delete(params = {}) ⇒ Object
Deletes a device.
-
#export(params = {}) ⇒ Object
Creates a device data export.
-
#get(params = {}) ⇒ Object
Retrieves information on a device.
-
#get_command(params = {}) ⇒ Object
Retrieve the last known commands(s) sent to the device.
-
#get_composite_state(params = {}) ⇒ Object
Retrieve the composite last complete state of the device.
-
#get_log_entries(params = {}) ⇒ Object
Retrieve the recent log entries about the device.
-
#get_state(params = {}) ⇒ Object
Retrieve the last known state(s) of the device.
-
#initialize(client) ⇒ Device
constructor
A new instance of Device.
-
#patch(params = {}) ⇒ Object
Updates information about a device.
-
#payload_counts(params = {}) ⇒ Object
Returns payload counts for the time range specified for this device.
-
#payload_counts_breakdown(params = {}) ⇒ Object
Returns payload counts per resolution in the time range specified for this device.
-
#remove_data(params = {}) ⇒ Object
Removes all device data for the specified time range.
-
#send_command(params = {}) ⇒ Object
Send a command to a device.
-
#send_state(params = {}) ⇒ Object
Send the current state of the device.
-
#set_connection_status(params = {}) ⇒ Object
Set the current connection status of the device.
Constructor Details
#initialize(client) ⇒ Device
Returns a new instance of Device.
30 31 32 |
# File 'lib/platform_rest/device.rb', line 30 def initialize(client) @client = client end |
Instance Method Details
#delete(params = {}) ⇒ Object
Deletes a device
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.
Parameters:
-
string applicationId - ID associated with the application
-
string deviceId - ID associated with the device
-
string losantdomain - Domain scope of request (rarely needed)
-
boolean _actions - Return resource actions in response
-
boolean _links - Return resource link in response
-
boolean _embedded - Return embedded resources in response
Responses:
-
200 - If device was successfully deleted (api.losant.com/#/definitions/success)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if device was not found (api.losant.com/#/definitions/error)
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/platform_rest/device.rb', line 56 def delete(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId) raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId) headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain) query_params[:_actions] = params[:_actions] if params.has_key?(:_actions) query_params[:_links] = params[:_links] if params.has_key?(:_links) query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded) path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}" @client.request( method: :delete, path: path, query: query_params, headers: headers, body: body) end |
#export(params = {}) ⇒ Object
Creates a device data export. Defaults to all data.
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.
Parameters:
-
string applicationId - ID associated with the application
-
string deviceId - ID associated with the device
-
string start - Start time of export (ms since epoch - 0 means now, negative is relative to now)
-
string end - End time of export (ms since epoch - 0 means now, negative is relative to now)
-
string email - Email address to send export to. Defaults to current user’s email.
-
string callbackUrl - Callback URL to call with export result
-
string includeBlobData - If set will export any blob attributes in base64 form, otherwise they will be downloadable links which will expire.
-
string losantdomain - Domain scope of request (rarely needed)
-
boolean _actions - Return resource actions in response
-
boolean _links - Return resource link in response
-
boolean _embedded - Return embedded resources in response
Responses:
-
202 - If generation of export was successfully started (api.losant.com/#/definitions/jobEnqueuedResult)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if device was not found (api.losant.com/#/definitions/error)
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/platform_rest/device.rb', line 107 def export(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId) raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId) query_params[:start] = params[:start] if params.has_key?(:start) query_params[:end] = params[:end] if params.has_key?(:end) query_params[:email] = params[:email] if params.has_key?(:email) query_params[:callbackUrl] = params[:callbackUrl] if params.has_key?(:callbackUrl) query_params[:includeBlobData] = params[:includeBlobData] if params.has_key?(:includeBlobData) headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain) query_params[:_actions] = params[:_actions] if params.has_key?(:_actions) query_params[:_links] = params[:_links] if params.has_key?(:_links) query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded) path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/export" @client.request( method: :post, path: path, query: query_params, headers: headers, body: body) end |
#get(params = {}) ⇒ Object
Retrieves information on a device
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.
Parameters:
-
string applicationId - ID associated with the application
-
string deviceId - ID associated with the device
-
string excludeConnectionInfo - If set, do not return connection info
-
string tagsAsObject - Return tags as an object map instead of an array
-
string attributesAsObject - Return attributes as an object map instead of an array
-
string losantdomain - Domain scope of request (rarely needed)
-
boolean _actions - Return resource actions in response
-
boolean _links - Return resource link in response
-
boolean _embedded - Return embedded resources in response
Responses:
-
200 - Device information (api.losant.com/#/definitions/device)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if device was not found (api.losant.com/#/definitions/error)
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/platform_rest/device.rb', line 161 def get(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId) raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId) query_params[:excludeConnectionInfo] = params[:excludeConnectionInfo] if params.has_key?(:excludeConnectionInfo) query_params[:tagsAsObject] = params[:tagsAsObject] if params.has_key?(:tagsAsObject) query_params[:attributesAsObject] = params[:attributesAsObject] if params.has_key?(:attributesAsObject) headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain) query_params[:_actions] = params[:_actions] if params.has_key?(:_actions) query_params[:_links] = params[:_links] if params.has_key?(:_links) query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded) path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}" @client.request( method: :get, path: path, query: query_params, headers: headers, body: body) end |
#get_command(params = {}) ⇒ Object
Retrieve the last known commands(s) sent to the device
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.
Parameters:
-
string applicationId - ID associated with the application
-
string deviceId - ID associated with the device
-
string limit - Maximum number of command entries to return
-
string since - (deprecated) Look for command entries since this time (ms since epoch)
-
string sortDirection - Direction to sort the command entries (by time). Accepted values are: asc, desc
-
string duration - Duration of time range to query in milliseconds
-
string start - Start of time range to query in milliseconds since epoch
-
string end - End of time range to query in milliseconds since epoch
-
string losantdomain - Domain scope of request (rarely needed)
-
boolean _actions - Return resource actions in response
-
boolean _links - Return resource link in response
-
boolean _embedded - Return embedded resources in response
Responses:
-
200 - Recent device commands (api.losant.com/#/definitions/deviceCommands)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if device was not found (api.losant.com/#/definitions/error)
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/platform_rest/device.rb', line 216 def get_command(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId) raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId) query_params[:limit] = params[:limit] if params.has_key?(:limit) query_params[:since] = params[:since] if params.has_key?(:since) query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection) query_params[:duration] = params[:duration] if params.has_key?(:duration) query_params[:start] = params[:start] if params.has_key?(:start) query_params[:end] = params[:end] if params.has_key?(:end) headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain) query_params[:_actions] = params[:_actions] if params.has_key?(:_actions) query_params[:_links] = params[:_links] if params.has_key?(:_links) query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded) path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/command" @client.request( method: :get, path: path, query: query_params, headers: headers, body: body) end |
#get_composite_state(params = {}) ⇒ Object
Retrieve the composite last complete state of the device
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.
Parameters:
-
string applicationId - ID associated with the application
-
string deviceId - ID associated with the device
-
string start - Start of time range to look at to build composite state
-
string end - End of time range to look at to build composite state
-
string attributes - Comma-separated list of attributes to include. When not provided, returns all attributes.
-
string losantdomain - Domain scope of request (rarely needed)
-
boolean _actions - Return resource actions in response
-
boolean _links - Return resource link in response
-
boolean _embedded - Return embedded resources in response
Responses:
-
200 - Composite last state of the device (api.losant.com/#/definitions/compositeDeviceState)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if device was not found (api.losant.com/#/definitions/error)
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
# File 'lib/platform_rest/device.rb', line 271 def get_composite_state(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId) raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId) query_params[:start] = params[:start] if params.has_key?(:start) query_params[:end] = params[:end] if params.has_key?(:end) query_params[:attributes] = params[:attributes] if params.has_key?(:attributes) headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain) query_params[:_actions] = params[:_actions] if params.has_key?(:_actions) query_params[:_links] = params[:_links] if params.has_key?(:_links) query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded) path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/compositeState" @client.request( method: :get, path: path, query: query_params, headers: headers, body: body) end |
#get_log_entries(params = {}) ⇒ Object
Retrieve the recent log entries about the device
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.
Parameters:
-
string applicationId - ID associated with the application
-
string deviceId - ID associated with the device
-
string limit - Maximum number of log entries to return
-
string since - (deprecated) Look for log entries since this time (ms since epoch)
-
string sortDirection - Direction to sort the log entries (by time). Accepted values are: asc, desc
-
string duration - Duration of time range to query in milliseconds
-
string start - Start of time range to query in milliseconds since epoch
-
string end - End of time range to query in milliseconds since epoch
-
string losantdomain - Domain scope of request (rarely needed)
-
boolean _actions - Return resource actions in response
-
boolean _links - Return resource link in response
-
boolean _embedded - Return embedded resources in response
Responses:
-
200 - Recent log entries (api.losant.com/#/definitions/deviceLog)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if device was not found (api.losant.com/#/definitions/error)
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
# File 'lib/platform_rest/device.rb', line 326 def get_log_entries(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId) raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId) query_params[:limit] = params[:limit] if params.has_key?(:limit) query_params[:since] = params[:since] if params.has_key?(:since) query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection) query_params[:duration] = params[:duration] if params.has_key?(:duration) query_params[:start] = params[:start] if params.has_key?(:start) query_params[:end] = params[:end] if params.has_key?(:end) headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain) query_params[:_actions] = params[:_actions] if params.has_key?(:_actions) query_params[:_links] = params[:_links] if params.has_key?(:_links) query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded) path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/logs" @client.request( method: :get, path: path, query: query_params, headers: headers, body: body) end |
#get_state(params = {}) ⇒ Object
Retrieve the last known state(s) of the device
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.
Parameters:
-
string applicationId - ID associated with the application
-
string deviceId - ID associated with the device
-
string limit - Maximum number of state entries to return
-
string since - (deprecated) Look for state entries since this time (ms since epoch)
-
string sortDirection - Direction to sort the state entries (by time). Accepted values are: asc, desc
-
string duration - Duration of time range to query in milliseconds
-
string start - Start of time range to query in milliseconds since epoch
-
string end - End of time range to query in milliseconds since epoch
-
string losantdomain - Domain scope of request (rarely needed)
-
boolean _actions - Return resource actions in response
-
boolean _links - Return resource link in response
-
boolean _embedded - Return embedded resources in response
Responses:
-
200 - Recent device states (api.losant.com/#/definitions/deviceStates)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if device was not found (api.losant.com/#/definitions/error)
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 |
# File 'lib/platform_rest/device.rb', line 384 def get_state(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId) raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId) query_params[:limit] = params[:limit] if params.has_key?(:limit) query_params[:since] = params[:since] if params.has_key?(:since) query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection) query_params[:duration] = params[:duration] if params.has_key?(:duration) query_params[:start] = params[:start] if params.has_key?(:start) query_params[:end] = params[:end] if params.has_key?(:end) headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain) query_params[:_actions] = params[:_actions] if params.has_key?(:_actions) query_params[:_links] = params[:_links] if params.has_key?(:_links) query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded) path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/state" @client.request( method: :get, path: path, query: query_params, headers: headers, body: body) end |
#patch(params = {}) ⇒ Object
Updates information about a device
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.
Parameters:
-
string applicationId - ID associated with the application
-
string deviceId - ID associated with the device
-
hash device - Object containing new properties of the device (api.losant.com/#/definitions/devicePatch)
-
string tagsAsObject - Return tags as an object map instead of an array
-
string attributesAsObject - Return attributes as an object map instead of an array
-
string losantdomain - Domain scope of request (rarely needed)
-
boolean _actions - Return resource actions in response
-
boolean _links - Return resource link in response
-
boolean _embedded - Return embedded resources in response
Responses:
-
200 - Updated device information (api.losant.com/#/definitions/device)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if device was not found (api.losant.com/#/definitions/error)
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 |
# File 'lib/platform_rest/device.rb', line 439 def patch(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId) raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId) raise ArgumentError.new("device is required") unless params.has_key?(:device) body = params[:device] if params.has_key?(:device) query_params[:tagsAsObject] = params[:tagsAsObject] if params.has_key?(:tagsAsObject) query_params[:attributesAsObject] = params[:attributesAsObject] if params.has_key?(:attributesAsObject) headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain) query_params[:_actions] = params[:_actions] if params.has_key?(:_actions) query_params[:_links] = params[:_links] if params.has_key?(:_links) query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded) path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}" @client.request( method: :patch, path: path, query: query_params, headers: headers, body: body) end |
#payload_counts(params = {}) ⇒ Object
Returns payload counts for the time range specified for this device
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.
Parameters:
-
string applicationId - ID associated with the application
-
string deviceId - ID associated with the device
-
string start - Start of range for payload count query (ms since epoch)
-
string end - End of range for payload count query (ms since epoch)
-
string losantdomain - Domain scope of request (rarely needed)
-
boolean _actions - Return resource actions in response
-
boolean _links - Return resource link in response
-
boolean _embedded - Return embedded resources in response
Responses:
-
200 - Payload counts, by type (api.losant.com/#/definitions/devicePayloadCounts)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if device was not found (api.losant.com/#/definitions/error)
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 |
# File 'lib/platform_rest/device.rb', line 491 def payload_counts(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId) raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId) query_params[:start] = params[:start] if params.has_key?(:start) query_params[:end] = params[:end] if params.has_key?(:end) headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain) query_params[:_actions] = params[:_actions] if params.has_key?(:_actions) query_params[:_links] = params[:_links] if params.has_key?(:_links) query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded) path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/payloadCounts" @client.request( method: :get, path: path, query: query_params, headers: headers, body: body) end |
#payload_counts_breakdown(params = {}) ⇒ Object
Returns payload counts per resolution in the time range specified for this device
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.
Parameters:
-
string applicationId - ID associated with the application
-
string deviceId - ID associated with the device
-
string start - Start of range for payload count query (ms since epoch)
-
string end - End of range for payload count query (ms since epoch)
-
string resolution - Resolution in milliseconds. Accepted values are: 86400000, 3600000
-
string losantdomain - Domain scope of request (rarely needed)
-
boolean _actions - Return resource actions in response
-
boolean _links - Return resource link in response
-
boolean _embedded - Return embedded resources in response
Responses:
-
200 - Sum of payload counts by date (api.losant.com/#/definitions/payloadCountsBreakdown)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if device was not found (api.losant.com/#/definitions/error)
542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 |
# File 'lib/platform_rest/device.rb', line 542 def payload_counts_breakdown(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId) raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId) query_params[:start] = params[:start] if params.has_key?(:start) query_params[:end] = params[:end] if params.has_key?(:end) query_params[:resolution] = params[:resolution] if params.has_key?(:resolution) headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain) query_params[:_actions] = params[:_actions] if params.has_key?(:_actions) query_params[:_links] = params[:_links] if params.has_key?(:_links) query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded) path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/payloadCountsBreakdown" @client.request( method: :get, path: path, query: query_params, headers: headers, body: body) end |
#remove_data(params = {}) ⇒ Object
Removes all device data for the specified time range. Defaults to all data.
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.
Parameters:
-
string applicationId - ID associated with the application
-
string deviceId - ID associated with the device
-
string start - Start time of export (ms since epoch - 0 means now, negative is relative to now)
-
string end - End time of export (ms since epoch - 0 means now, negative is relative to now)
-
string losantdomain - Domain scope of request (rarely needed)
-
boolean _actions - Return resource actions in response
-
boolean _links - Return resource link in response
-
boolean _embedded - Return embedded resources in response
Responses:
-
202 - If data removal was successfully started (api.losant.com/#/definitions/jobEnqueuedResult)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if device was not found (api.losant.com/#/definitions/error)
593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 |
# File 'lib/platform_rest/device.rb', line 593 def remove_data(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId) raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId) query_params[:start] = params[:start] if params.has_key?(:start) query_params[:end] = params[:end] if params.has_key?(:end) headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain) query_params[:_actions] = params[:_actions] if params.has_key?(:_actions) query_params[:_links] = params[:_links] if params.has_key?(:_links) query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded) path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/data" @client.request( method: :delete, path: path, query: query_params, headers: headers, body: body) end |
#send_command(params = {}) ⇒ Object
Send a command to a device
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.
Parameters:
-
string applicationId - ID associated with the application
-
string deviceId - ID associated with the device
-
hash deviceCommand - Command to send to the device (api.losant.com/#/definitions/deviceCommand)
-
string losantdomain - Domain scope of request (rarely needed)
-
boolean _actions - Return resource actions in response
-
boolean _links - Return resource link in response
-
boolean _embedded - Return embedded resources in response
Responses:
-
200 - If command was successfully sent (api.losant.com/#/definitions/success)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if device was not found (api.losant.com/#/definitions/error)
642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 |
# File 'lib/platform_rest/device.rb', line 642 def send_command(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId) raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId) raise ArgumentError.new("deviceCommand is required") unless params.has_key?(:deviceCommand) body = params[:deviceCommand] if params.has_key?(:deviceCommand) headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain) query_params[:_actions] = params[:_actions] if params.has_key?(:_actions) query_params[:_links] = params[:_links] if params.has_key?(:_links) query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded) path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/command" @client.request( method: :post, path: path, query: query_params, headers: headers, body: body) end |
#send_state(params = {}) ⇒ Object
Send the current state of the device
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.
Parameters:
-
string applicationId - ID associated with the application
-
string deviceId - ID associated with the device
-
hash deviceState - A single device state object, or an array of device state objects (api.losant.com/#/definitions/deviceStateOrStates)
-
string losantdomain - Domain scope of request (rarely needed)
-
boolean _actions - Return resource actions in response
-
boolean _links - Return resource link in response
-
boolean _embedded - Return embedded resources in response
Responses:
-
200 - If state was successfully received (api.losant.com/#/definitions/success)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if device was not found (api.losant.com/#/definitions/error)
691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 |
# File 'lib/platform_rest/device.rb', line 691 def send_state(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId) raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId) raise ArgumentError.new("deviceState is required") unless params.has_key?(:deviceState) body = params[:deviceState] if params.has_key?(:deviceState) headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain) query_params[:_actions] = params[:_actions] if params.has_key?(:_actions) query_params[:_links] = params[:_links] if params.has_key?(:_links) query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded) path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/state" @client.request( method: :post, path: path, query: query_params, headers: headers, body: body) end |
#set_connection_status(params = {}) ⇒ Object
Set the current connection status of the device
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.
Parameters:
-
string applicationId - ID associated with the application
-
string deviceId - ID associated with the device
-
hash connectionStatus - The current connection status of the device (api.losant.com/#/definitions/deviceConnectionStatus)
-
string losantdomain - Domain scope of request (rarely needed)
-
boolean _actions - Return resource actions in response
-
boolean _links - Return resource link in response
-
boolean _embedded - Return embedded resources in response
Responses:
-
200 - If connection status was successfully applied (api.losant.com/#/definitions/success)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if device was not found (api.losant.com/#/definitions/error)
740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 |
# File 'lib/platform_rest/device.rb', line 740 def set_connection_status(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId) raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId) raise ArgumentError.new("connectionStatus is required") unless params.has_key?(:connectionStatus) body = params[:connectionStatus] if params.has_key?(:connectionStatus) headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain) query_params[:_actions] = params[:_actions] if params.has_key?(:_actions) query_params[:_links] = params[:_links] if params.has_key?(:_links) query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded) path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/setConnectionStatus" @client.request( method: :post, path: path, query: query_params, headers: headers, body: body) end |