Class: PlatformRest::Devices
- Inherits:
-
Object
- Object
- PlatformRest::Devices
- Defined in:
- lib/platform_rest/devices.rb
Overview
Class containing all the actions for the Devices Resource
Instance Method Summary collapse
-
#attribute_names(params = {}) ⇒ Object
Gets the attribute names that match the given query.
-
#delete(params = {}) ⇒ Object
Delete devices.
-
#device_names(params = {}) ⇒ Object
Gets the device names that match the given query.
-
#export(params = {}) ⇒ Object
Creates an export of all device metadata.
-
#get(params = {}) ⇒ Object
Returns the devices for an application.
-
#get_composite_state(params = {}) ⇒ Object
Retrieve the composite last complete state of the matching devices.
-
#initialize(client) ⇒ Devices
constructor
A new instance of Devices.
-
#patch(params = {}) ⇒ Object
Update the fields of one or more devices.
-
#payload_counts(params = {}) ⇒ Object
Creates an export of payload count information for the matching devices.
-
#post(params = {}) ⇒ Object
Create a new device for an application.
-
#remove_data(params = {}) ⇒ Object
Removes all device data for the specified time range.
-
#send_command(params = {}) ⇒ Object
Send a command to multiple devices.
-
#tag_keys(params = {}) ⇒ Object
Gets the unique tag keys for devices that match the given query.
-
#tag_values(params = {}) ⇒ Object
Gets the unique tag values for the given key for devices that match the given query.
Constructor Details
#initialize(client) ⇒ Devices
Returns a new instance of Devices.
30 31 32 |
# File 'lib/platform_rest/devices.rb', line 30 def initialize(client) @client = client end |
Instance Method Details
#attribute_names(params = {}) ⇒ Object
Gets the attribute names that match the given query. Maximum 1K returned.
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, devices.*, or devices.attributeNames.
Parameters:
-
string applicationId - ID associated with the application
-
hash query - Device filter JSON object (api.losant.com/#/definitions/advancedDeviceQuery)
-
hash dataType - Filter the devices by the given attribute data type or types (api.losant.com/#/definitions/deviceAttributeDataTypeFilter)
-
string startsWith - Filter attributes down to those that have names starting with the given string. Case insensitive.
-
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 - The matching attribute names (api.losant.com/#/definitions/attributeNamesResponse)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if application was not found (api.losant.com/#/definitions/error)
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/platform_rest/devices.rb', line 58 def attribute_names(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) query_params[:query] = params[:query] if params.has_key?(:query) query_params[:query] = JSON.dump(query_params[:query]) if query_params.has_key?(:query) query_params[:dataType] = params[:dataType] if params.has_key?(:dataType) query_params[:startsWith] = params[:startsWith] if params.has_key?(:startsWith) 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/attributeNames" @client.request( method: :get, path: path, query: query_params, headers: headers, body: body) end |
#delete(params = {}) ⇒ Object
Delete devices
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, devices.*, or devices.delete.
Parameters:
-
string applicationId - ID associated with the application
-
hash options - Object containing device query and email (api.losant.com/#/definitions/devicesDeletePost)
-
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 - Object indicating number of devices deleted or failed (api.losant.com/#/definitions/bulkDeleteResponse)
-
202 - If a job was enqueued for the devices to be deleted (api.losant.com/#/definitions/jobEnqueuedResult)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if application was not found (api.losant.com/#/definitions/error)
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/platform_rest/devices.rb', line 108 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("options is required") unless params.has_key?(:options) body = params[:options] if params.has_key?(:options) 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/delete" @client.request( method: :post, path: path, query: query_params, headers: headers, body: body) end |
#device_names(params = {}) ⇒ Object
Gets the device names that match the given query. Maximum 1K returned.
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, devices.*, or devices.deviceNames.
Parameters:
-
string applicationId - ID associated with the application
-
hash query - Device filter JSON object (api.losant.com/#/definitions/advancedDeviceQuery)
-
string startsWith - Filter devices down to those that have names starting with the given string. Case insensitive.
-
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 - The matching device names (api.losant.com/#/definitions/deviceNamesResponse)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if application was not found (api.losant.com/#/definitions/error)
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/platform_rest/devices.rb', line 156 def device_names(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) query_params[:query] = params[:query] if params.has_key?(:query) query_params[:query] = JSON.dump(query_params[:query]) if query_params.has_key?(:query) query_params[:startsWith] = params[:startsWith] if params.has_key?(:startsWith) 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/deviceNames" @client.request( method: :get, path: path, query: query_params, headers: headers, body: body) end |
#export(params = {}) ⇒ Object
Creates an export of all device metadata
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, devices.*, or devices.export.
Parameters:
-
string applicationId - ID associated with the application
-
string email - Email address to send export to. Defaults to current user’s email.
-
string callbackUrl - Callback URL to call with export result
-
hash options - Object containing device query and optionally email or callback (api.losant.com/#/definitions/devicesExportPost)
-
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 application was not found (api.losant.com/#/definitions/error)
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'lib/platform_rest/devices.rb', line 206 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) query_params[:email] = params[:email] if params.has_key?(:email) query_params[:callbackUrl] = params[:callbackUrl] if params.has_key?(:callbackUrl) body = params[:options] if params.has_key?(:options) 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/export" @client.request( method: :post, path: path, query: query_params, headers: headers, body: body) end |
#get(params = {}) ⇒ Object
Returns the devices for an application
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, devices.*, or devices.get.
Parameters:
-
string applicationId - ID associated with the application
-
string sortField - Field to sort the results by. Accepted values are: name, id, creationDate, lastUpdated, connectionStatus
-
string sortDirection - Direction to sort the results by. Accepted values are: asc, desc
-
string page - Which page of results to return
-
string perPage - How many items to return per page
-
string filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name
-
string filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering.
-
hash deviceClass - Filter the devices by the given device class or classes (api.losant.com/#/definitions/deviceClassFilter)
-
hash tagFilter - Array of tag pairs to filter by (api.losant.com/#/definitions/deviceTagFilter)
-
string excludeConnectionInfo - If set, do not return connection info
-
string parentId - Filter devices as children of a given system id
-
hash query - Device filter JSON object which overrides the filterField, filter, deviceClass, tagFilter, and parentId parameters. (api.losant.com/#/definitions/advancedDeviceQuery)
-
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 - Collection of devices (api.losant.com/#/definitions/devices)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if application was not found (api.losant.com/#/definitions/error)
266 267 268 269 270 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 297 298 299 300 301 |
# File 'lib/platform_rest/devices.rb', line 266 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) query_params[:sortField] = params[:sortField] if params.has_key?(:sortField) query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection) query_params[:page] = params[:page] if params.has_key?(:page) query_params[:perPage] = params[:perPage] if params.has_key?(:perPage) query_params[:filterField] = params[:filterField] if params.has_key?(:filterField) query_params[:filter] = params[:filter] if params.has_key?(:filter) query_params[:deviceClass] = params[:deviceClass] if params.has_key?(:deviceClass) query_params[:tagFilter] = params[:tagFilter] if params.has_key?(:tagFilter) query_params[:excludeConnectionInfo] = params[:excludeConnectionInfo] if params.has_key?(:excludeConnectionInfo) query_params[:parentId] = params[:parentId] if params.has_key?(:parentId) query_params[:query] = params[:query] if params.has_key?(:query) query_params[:query] = JSON.dump(query_params[:query]) if query_params.has_key?(:query) 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" @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 matching devices
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, devices.*, or devices.getCompositeState.
Parameters:
-
string applicationId - ID associated with the application
-
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 sortField - Field to sort the results by. Accepted values are: name, id, creationDate, lastUpdated, connectionStatus
-
string sortDirection - Direction to sort the results by. Accepted values are: asc, desc
-
string page - Which page of results to return
-
string perPage - How many items to return per page
-
hash query - Device advanced query JSON object (api.losant.com/#/definitions/advancedDeviceQuery)
-
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 - Collection of composite last state of the devices (api.losant.com/#/definitions/compositeDevicesState)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if application was not found (api.losant.com/#/definitions/error)
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
# File 'lib/platform_rest/devices.rb', line 332 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) 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) query_params[:sortField] = params[:sortField] if params.has_key?(:sortField) query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection) query_params[:page] = params[:page] if params.has_key?(:page) query_params[:perPage] = params[:perPage] if params.has_key?(:perPage) query_params[:query] = params[:query] if params.has_key?(:query) query_params[:query] = JSON.dump(query_params[:query]) if query_params.has_key?(:query) 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/compositeState" @client.request( method: :get, path: path, query: query_params, headers: headers, body: body) end |
#patch(params = {}) ⇒ Object
Update the fields of one or more devices
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, devices.*, or devices.patch.
Parameters:
-
string applicationId - ID associated with the application
-
hash patchInfo - Object containing device query or IDs and update operations (api.losant.com/#/definitions/devicesPatch)
-
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 - Object including an update log link and the number of devices updated, failed, and skipped (api.losant.com/#/definitions/devicesUpdated)
-
202 - Successfully queued bulk update job (api.losant.com/#/definitions/jobEnqueuedResult)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if application was not found (api.losant.com/#/definitions/error)
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 |
# File 'lib/platform_rest/devices.rb', line 387 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("patchInfo is required") unless params.has_key?(:patchInfo) body = params[:patchInfo] if params.has_key?(:patchInfo) 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" @client.request( method: :patch, path: path, query: query_params, headers: headers, body: body) end |
#payload_counts(params = {}) ⇒ Object
Creates an export of payload count information for the matching devices
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, devices.*, or devices.payloadCounts.
Parameters:
-
string applicationId - ID associated with the application
-
hash options - Object containing export configuration (api.losant.com/#/definitions/devicesExportPayloadCountPost)
-
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 application was not found (api.losant.com/#/definitions/error)
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 |
# File 'lib/platform_rest/devices.rb', line 434 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) body = params[:options] if params.has_key?(:options) 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/payloadCounts" @client.request( method: :post, path: path, query: query_params, headers: headers, body: body) end |
#post(params = {}) ⇒ Object
Create a new device for an application
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, devices.*, or devices.post.
Parameters:
-
string applicationId - ID associated with the application
-
hash device - New device information (api.losant.com/#/definitions/devicePost)
-
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:
-
201 - Successfully created device (api.losant.com/#/definitions/device)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if application was not found (api.losant.com/#/definitions/error)
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 |
# File 'lib/platform_rest/devices.rb', line 482 def post(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("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" @client.request( method: :post, 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, devices.*, or devices.removeData.
Parameters:
-
string applicationId - ID associated with the application
-
hash options - Object defining the device data to delete and devices to delete from (api.losant.com/#/definitions/devicesRemoveDataPost)
-
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 a job was enqueued for device data to be removed (api.losant.com/#/definitions/jobEnqueuedResult)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if application was not found (api.losant.com/#/definitions/error)
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 |
# File 'lib/platform_rest/devices.rb', line 531 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("options is required") unless params.has_key?(:options) body = params[:options] if params.has_key?(:options) 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/removeData" @client.request( method: :post, path: path, query: query_params, headers: headers, body: body) end |
#send_command(params = {}) ⇒ Object
Send a command to multiple devices
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, devices.*, or devices.sendCommand.
Parameters:
-
string applicationId - ID associated with the application
-
hash multiDeviceCommand - Command to send to the device (api.losant.com/#/definitions/multiDeviceCommand)
-
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)
-
202 - If command was queued to be sent (api.losant.com/#/definitions/jobEnqueuedResult)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if application was not found (api.losant.com/#/definitions/error)
579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 |
# File 'lib/platform_rest/devices.rb', line 579 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("multiDeviceCommand is required") unless params.has_key?(:multiDeviceCommand) body = params[:multiDeviceCommand] if params.has_key?(:multiDeviceCommand) 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/command" @client.request( method: :post, path: path, query: query_params, headers: headers, body: body) end |
#tag_keys(params = {}) ⇒ Object
Gets the unique tag keys for devices that match the given query. Maximum 1K returned.
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, devices.*, or devices.tagKeys.
Parameters:
-
string applicationId - ID associated with the application
-
hash query - Device filter JSON object (api.losant.com/#/definitions/advancedDeviceQuery)
-
string startsWith - Filter keys down to those that start with the given string. Case insensitive.
-
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 - The matching tag keys (api.losant.com/#/definitions/tagKeysResponse)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if application was not found (api.losant.com/#/definitions/error)
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 |
# File 'lib/platform_rest/devices.rb', line 627 def tag_keys(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) query_params[:query] = params[:query] if params.has_key?(:query) query_params[:query] = JSON.dump(query_params[:query]) if query_params.has_key?(:query) query_params[:startsWith] = params[:startsWith] if params.has_key?(:startsWith) 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/tagKeys" @client.request( method: :get, path: path, query: query_params, headers: headers, body: body) end |
#tag_values(params = {}) ⇒ Object
Gets the unique tag values for the given key for devices that match the given query. Maximum 1K returned.
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, devices.*, or devices.tagValues.
Parameters:
-
string applicationId - ID associated with the application
-
hash query - Device filter JSON object (api.losant.com/#/definitions/advancedDeviceQuery)
-
string key - The tag key to get the values for
-
string startsWith - Filter values down to those that start with the given string. Case insensitive.
-
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 - The matching tag values (api.losant.com/#/definitions/tagValuesResponse)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if application was not found (api.losant.com/#/definitions/error)
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 |
# File 'lib/platform_rest/devices.rb', line 677 def tag_values(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("key is required") unless params.has_key?(:key) query_params[:query] = params[:query] if params.has_key?(:query) query_params[:query] = JSON.dump(query_params[:query]) if query_params.has_key?(:query) query_params[:key] = params[:key] if params.has_key?(:key) query_params[:startsWith] = params[:startsWith] if params.has_key?(:startsWith) 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/tagValues" @client.request( method: :get, path: path, query: query_params, headers: headers, body: body) end |