Class: LosantRest::Devices
- Inherits:
-
Object
- Object
- LosantRest::Devices
- Defined in:
- lib/losant_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.
-
#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/losant_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/losant_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/losant_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/losant_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:
-
200 - If generation of export was successfully started (api.losant.com/#/definitions/success)
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/losant_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 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)
264 265 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 |
# File 'lib/losant_rest/devices.rb', line 264 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) 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 |
#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)
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
# File 'lib/losant_rest/devices.rb', line 322 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:
-
200 - If generation of export was successfully started (api.losant.com/#/definitions/success)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if application was not found (api.losant.com/#/definitions/error)
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 |
# File 'lib/losant_rest/devices.rb', line 369 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 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)
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 |
# File 'lib/losant_rest/devices.rb', line 415 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) 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:
-
200 - Object indicating number of devices completed or skipped (api.losant.com/#/definitions/devicesDataRemoved)
-
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)
463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 |
# File 'lib/losant_rest/devices.rb', line 463 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)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if application was not found (api.losant.com/#/definitions/error)
510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 |
# File 'lib/losant_rest/devices.rb', line 510 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)
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 |
# File 'lib/losant_rest/devices.rb', line 558 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)
608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 |
# File 'lib/losant_rest/devices.rb', line 608 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 |