losant_rest 1.19.0 → 1.19.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/docs/_schemas.md +872 -38
  3. data/docs/applications.md +49 -0
  4. data/docs/device.md +12 -3
  5. data/docs/me.md +116 -0
  6. data/lib/losant_rest/version.rb +1 -1
  7. data/lib/platform_rest/application.rb +932 -0
  8. data/lib/platform_rest/application_api_token.rb +176 -0
  9. data/lib/platform_rest/application_api_tokens.rb +136 -0
  10. data/lib/platform_rest/application_certificate.rb +176 -0
  11. data/lib/platform_rest/application_certificate_authorities.rb +138 -0
  12. data/lib/platform_rest/application_certificate_authority.rb +176 -0
  13. data/lib/platform_rest/application_certificates.rb +138 -0
  14. data/lib/platform_rest/application_dashboard.rb +225 -0
  15. data/lib/platform_rest/application_dashboards.rb +138 -0
  16. data/lib/platform_rest/application_key.rb +176 -0
  17. data/lib/platform_rest/application_keys.rb +141 -0
  18. data/lib/platform_rest/application_template.rb +79 -0
  19. data/lib/platform_rest/application_templates.rb +176 -0
  20. data/lib/platform_rest/applications.rb +209 -0
  21. data/lib/platform_rest/audit_log.rb +81 -0
  22. data/lib/platform_rest/audit_logs.rb +93 -0
  23. data/lib/platform_rest/auth.rb +245 -0
  24. data/lib/platform_rest/client.rb +410 -0
  25. data/lib/platform_rest/credential.rb +224 -0
  26. data/lib/platform_rest/credentials.rb +138 -0
  27. data/lib/platform_rest/dashboard.rb +268 -0
  28. data/lib/platform_rest/dashboards.rb +136 -0
  29. data/lib/platform_rest/data.rb +176 -0
  30. data/lib/platform_rest/data_table.rb +274 -0
  31. data/lib/platform_rest/data_table_row.rb +182 -0
  32. data/lib/platform_rest/data_table_rows.rb +343 -0
  33. data/lib/platform_rest/data_tables.rb +138 -0
  34. data/lib/platform_rest/device.rb +767 -0
  35. data/lib/platform_rest/device_recipe.rb +234 -0
  36. data/lib/platform_rest/device_recipes.rb +146 -0
  37. data/lib/platform_rest/devices.rb +707 -0
  38. data/lib/platform_rest/edge_deployment.rb +81 -0
  39. data/lib/platform_rest/edge_deployments.rb +236 -0
  40. data/lib/platform_rest/embedded_deployment.rb +81 -0
  41. data/lib/platform_rest/embedded_deployments.rb +280 -0
  42. data/lib/platform_rest/error.rb +34 -0
  43. data/lib/platform_rest/event.rb +176 -0
  44. data/lib/platform_rest/events.rb +341 -0
  45. data/lib/platform_rest/experience.rb +142 -0
  46. data/lib/platform_rest/experience_domain.rb +176 -0
  47. data/lib/platform_rest/experience_domains.rb +126 -0
  48. data/lib/platform_rest/experience_endpoint.rb +230 -0
  49. data/lib/platform_rest/experience_endpoints.rb +200 -0
  50. data/lib/platform_rest/experience_group.rb +180 -0
  51. data/lib/platform_rest/experience_groups.rb +141 -0
  52. data/lib/platform_rest/experience_slug.rb +176 -0
  53. data/lib/platform_rest/experience_slugs.rb +126 -0
  54. data/lib/platform_rest/experience_user.rb +176 -0
  55. data/lib/platform_rest/experience_users.rb +142 -0
  56. data/lib/platform_rest/experience_version.rb +176 -0
  57. data/lib/platform_rest/experience_versions.rb +138 -0
  58. data/lib/platform_rest/experience_view.rb +228 -0
  59. data/lib/platform_rest/experience_views.rb +142 -0
  60. data/lib/platform_rest/file.rb +226 -0
  61. data/lib/platform_rest/files.rb +144 -0
  62. data/lib/platform_rest/flow.rb +580 -0
  63. data/lib/platform_rest/flow_version.rb +352 -0
  64. data/lib/platform_rest/flow_versions.rb +201 -0
  65. data/lib/platform_rest/flows.rb +310 -0
  66. data/lib/platform_rest/instance.rb +377 -0
  67. data/lib/platform_rest/instance_api_token.rb +176 -0
  68. data/lib/platform_rest/instance_api_tokens.rb +136 -0
  69. data/lib/platform_rest/instance_custom_node.rb +282 -0
  70. data/lib/platform_rest/instance_custom_nodes.rb +136 -0
  71. data/lib/platform_rest/instance_member.rb +176 -0
  72. data/lib/platform_rest/instance_members.rb +134 -0
  73. data/lib/platform_rest/instance_org.rb +336 -0
  74. data/lib/platform_rest/instance_org_invite.rb +182 -0
  75. data/lib/platform_rest/instance_org_invites.rb +138 -0
  76. data/lib/platform_rest/instance_org_member.rb +182 -0
  77. data/lib/platform_rest/instance_org_members.rb +138 -0
  78. data/lib/platform_rest/instance_orgs.rb +139 -0
  79. data/lib/platform_rest/instance_sandbox.rb +181 -0
  80. data/lib/platform_rest/instance_sandboxes.rb +98 -0
  81. data/lib/platform_rest/instances.rb +88 -0
  82. data/lib/platform_rest/integration.rb +178 -0
  83. data/lib/platform_rest/integrations.rb +138 -0
  84. data/lib/platform_rest/me.rb +923 -0
  85. data/lib/platform_rest/notebook.rb +423 -0
  86. data/lib/platform_rest/notebooks.rb +138 -0
  87. data/lib/platform_rest/org.rb +663 -0
  88. data/lib/platform_rest/org_invites.rb +124 -0
  89. data/lib/platform_rest/orgs.rb +140 -0
  90. data/lib/platform_rest/resource_job.rb +326 -0
  91. data/lib/platform_rest/resource_jobs.rb +138 -0
  92. data/lib/platform_rest/user_api_token.rb +170 -0
  93. data/lib/platform_rest/user_api_tokens.rb +132 -0
  94. data/lib/platform_rest/utils.rb +44 -0
  95. data/lib/platform_rest/webhook.rb +178 -0
  96. data/lib/platform_rest/webhooks.rb +138 -0
  97. data/lib/platform_rest.rb +129 -0
  98. data/schemas/apiTokenPost.json +4 -0
  99. data/schemas/applicationDashboardPost.json +66 -0
  100. data/schemas/dashboard.json +66 -0
  101. data/schemas/dashboardPatch.json +66 -0
  102. data/schemas/dashboardPost.json +66 -0
  103. data/schemas/dashboards.json +66 -0
  104. data/schemas/deviceConnectionStatus.json +10 -0
  105. data/schemas/deviceLog.json +3 -0
  106. data/schemas/event.json +8 -0
  107. data/schemas/eventPlusNewCount.json +8 -0
  108. data/schemas/events.json +8 -0
  109. data/schemas/githubLogin.json +4 -0
  110. data/schemas/integrationPatch.json +0 -10
  111. data/schemas/orgInviteActionUser.json +18 -0
  112. data/schemas/orgInviteResultUser.json +18 -0
  113. data/schemas/orgInviteUser.json +51 -0
  114. data/schemas/orgInvitesUser.json +59 -0
  115. data/schemas/payloadCountsBreakdown.json +1 -25
  116. data/schemas/periodSummaries.json +172 -0
  117. data/schemas/samlResponse.json +4 -0
  118. data/schemas/userCredentials.json +4 -0
  119. data/schemas/userPost.json +4 -0
  120. metadata +98 -2
@@ -0,0 +1,707 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (c) 2023 Losant IoT, Inc.
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ require "json"
24
+
25
+ module PlatformRest
26
+
27
+ # Class containing all the actions for the Devices Resource
28
+ class Devices
29
+
30
+ def initialize(client)
31
+ @client = client
32
+ end
33
+
34
+ # Gets the attribute names that match the given query. Maximum 1K returned.
35
+ #
36
+ # Authentication:
37
+ # The client must be configured with a valid api
38
+ # access token to call this action. The token
39
+ # must include at least one of the following scopes:
40
+ # all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, devices.*, or devices.attributeNames.
41
+ #
42
+ # Parameters:
43
+ # * {string} applicationId - ID associated with the application
44
+ # * {hash} query - Device filter JSON object (https://api.losant.com/#/definitions/advancedDeviceQuery)
45
+ # * {hash} dataType - Filter the devices by the given attribute data type or types (https://api.losant.com/#/definitions/deviceAttributeDataTypeFilter)
46
+ # * {string} startsWith - Filter attributes down to those that have names starting with the given string. Case insensitive.
47
+ # * {string} losantdomain - Domain scope of request (rarely needed)
48
+ # * {boolean} _actions - Return resource actions in response
49
+ # * {boolean} _links - Return resource link in response
50
+ # * {boolean} _embedded - Return embedded resources in response
51
+ #
52
+ # Responses:
53
+ # * 200 - The matching attribute names (https://api.losant.com/#/definitions/attributeNamesResponse)
54
+ #
55
+ # Errors:
56
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
57
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
58
+ def attribute_names(params = {})
59
+ params = Utils.symbolize_hash_keys(params)
60
+ query_params = { _actions: false, _links: true, _embedded: true }
61
+ headers = {}
62
+ body = nil
63
+
64
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
65
+
66
+ query_params[:query] = params[:query] if params.has_key?(:query)
67
+ query_params[:query] = JSON.dump(query_params[:query]) if query_params.has_key?(:query)
68
+ query_params[:dataType] = params[:dataType] if params.has_key?(:dataType)
69
+ query_params[:startsWith] = params[:startsWith] if params.has_key?(:startsWith)
70
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
71
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
72
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
73
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
74
+
75
+ path = "/applications/#{params[:applicationId]}/devices/attributeNames"
76
+
77
+ @client.request(
78
+ method: :get,
79
+ path: path,
80
+ query: query_params,
81
+ headers: headers,
82
+ body: body)
83
+ end
84
+
85
+ # Delete devices
86
+ #
87
+ # Authentication:
88
+ # The client must be configured with a valid api
89
+ # access token to call this action. The token
90
+ # must include at least one of the following scopes:
91
+ # all.Application, all.Organization, all.User, devices.*, or devices.delete.
92
+ #
93
+ # Parameters:
94
+ # * {string} applicationId - ID associated with the application
95
+ # * {hash} options - Object containing device query and email (https://api.losant.com/#/definitions/devicesDeletePost)
96
+ # * {string} losantdomain - Domain scope of request (rarely needed)
97
+ # * {boolean} _actions - Return resource actions in response
98
+ # * {boolean} _links - Return resource link in response
99
+ # * {boolean} _embedded - Return embedded resources in response
100
+ #
101
+ # Responses:
102
+ # * 200 - Object indicating number of devices deleted or failed (https://api.losant.com/#/definitions/bulkDeleteResponse)
103
+ # * 202 - If a job was enqueued for the devices to be deleted (https://api.losant.com/#/definitions/jobEnqueuedResult)
104
+ #
105
+ # Errors:
106
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
107
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
108
+ def delete(params = {})
109
+ params = Utils.symbolize_hash_keys(params)
110
+ query_params = { _actions: false, _links: true, _embedded: true }
111
+ headers = {}
112
+ body = nil
113
+
114
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
115
+ raise ArgumentError.new("options is required") unless params.has_key?(:options)
116
+
117
+ body = params[:options] if params.has_key?(:options)
118
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
119
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
120
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
121
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
122
+
123
+ path = "/applications/#{params[:applicationId]}/devices/delete"
124
+
125
+ @client.request(
126
+ method: :post,
127
+ path: path,
128
+ query: query_params,
129
+ headers: headers,
130
+ body: body)
131
+ end
132
+
133
+ # Gets the device names that match the given query. Maximum 1K returned.
134
+ #
135
+ # Authentication:
136
+ # The client must be configured with a valid api
137
+ # access token to call this action. The token
138
+ # must include at least one of the following scopes:
139
+ # all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, devices.*, or devices.deviceNames.
140
+ #
141
+ # Parameters:
142
+ # * {string} applicationId - ID associated with the application
143
+ # * {hash} query - Device filter JSON object (https://api.losant.com/#/definitions/advancedDeviceQuery)
144
+ # * {string} startsWith - Filter devices down to those that have names starting with the given string. Case insensitive.
145
+ # * {string} losantdomain - Domain scope of request (rarely needed)
146
+ # * {boolean} _actions - Return resource actions in response
147
+ # * {boolean} _links - Return resource link in response
148
+ # * {boolean} _embedded - Return embedded resources in response
149
+ #
150
+ # Responses:
151
+ # * 200 - The matching device names (https://api.losant.com/#/definitions/deviceNamesResponse)
152
+ #
153
+ # Errors:
154
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
155
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
156
+ def device_names(params = {})
157
+ params = Utils.symbolize_hash_keys(params)
158
+ query_params = { _actions: false, _links: true, _embedded: true }
159
+ headers = {}
160
+ body = nil
161
+
162
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
163
+
164
+ query_params[:query] = params[:query] if params.has_key?(:query)
165
+ query_params[:query] = JSON.dump(query_params[:query]) if query_params.has_key?(:query)
166
+ query_params[:startsWith] = params[:startsWith] if params.has_key?(:startsWith)
167
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
168
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
169
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
170
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
171
+
172
+ path = "/applications/#{params[:applicationId]}/devices/deviceNames"
173
+
174
+ @client.request(
175
+ method: :get,
176
+ path: path,
177
+ query: query_params,
178
+ headers: headers,
179
+ body: body)
180
+ end
181
+
182
+ # Creates an export of all device metadata
183
+ #
184
+ # Authentication:
185
+ # The client must be configured with a valid api
186
+ # access token to call this action. The token
187
+ # must include at least one of the following scopes:
188
+ # all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, devices.*, or devices.export.
189
+ #
190
+ # Parameters:
191
+ # * {string} applicationId - ID associated with the application
192
+ # * {string} email - Email address to send export to. Defaults to current user's email.
193
+ # * {string} callbackUrl - Callback URL to call with export result
194
+ # * {hash} options - Object containing device query and optionally email or callback (https://api.losant.com/#/definitions/devicesExportPost)
195
+ # * {string} losantdomain - Domain scope of request (rarely needed)
196
+ # * {boolean} _actions - Return resource actions in response
197
+ # * {boolean} _links - Return resource link in response
198
+ # * {boolean} _embedded - Return embedded resources in response
199
+ #
200
+ # Responses:
201
+ # * 202 - If generation of export was successfully started (https://api.losant.com/#/definitions/jobEnqueuedResult)
202
+ #
203
+ # Errors:
204
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
205
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
206
+ def export(params = {})
207
+ params = Utils.symbolize_hash_keys(params)
208
+ query_params = { _actions: false, _links: true, _embedded: true }
209
+ headers = {}
210
+ body = nil
211
+
212
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
213
+
214
+ query_params[:email] = params[:email] if params.has_key?(:email)
215
+ query_params[:callbackUrl] = params[:callbackUrl] if params.has_key?(:callbackUrl)
216
+ body = params[:options] if params.has_key?(:options)
217
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
218
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
219
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
220
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
221
+
222
+ path = "/applications/#{params[:applicationId]}/devices/export"
223
+
224
+ @client.request(
225
+ method: :post,
226
+ path: path,
227
+ query: query_params,
228
+ headers: headers,
229
+ body: body)
230
+ end
231
+
232
+ # Returns the devices for an application
233
+ #
234
+ # Authentication:
235
+ # The client must be configured with a valid api
236
+ # access token to call this action. The token
237
+ # must include at least one of the following scopes:
238
+ # all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, devices.*, or devices.get.
239
+ #
240
+ # Parameters:
241
+ # * {string} applicationId - ID associated with the application
242
+ # * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate, lastUpdated, connectionStatus
243
+ # * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc
244
+ # * {string} page - Which page of results to return
245
+ # * {string} perPage - How many items to return per page
246
+ # * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name
247
+ # * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering.
248
+ # * {hash} deviceClass - Filter the devices by the given device class or classes (https://api.losant.com/#/definitions/deviceClassFilter)
249
+ # * {hash} tagFilter - Array of tag pairs to filter by (https://api.losant.com/#/definitions/deviceTagFilter)
250
+ # * {string} excludeConnectionInfo - If set, do not return connection info
251
+ # * {string} parentId - Filter devices as children of a given system id
252
+ # * {hash} query - Device filter JSON object which overrides the filterField, filter, deviceClass, tagFilter, and parentId parameters. (https://api.losant.com/#/definitions/advancedDeviceQuery)
253
+ # * {string} tagsAsObject - Return tags as an object map instead of an array
254
+ # * {string} attributesAsObject - Return attributes as an object map instead of an array
255
+ # * {string} losantdomain - Domain scope of request (rarely needed)
256
+ # * {boolean} _actions - Return resource actions in response
257
+ # * {boolean} _links - Return resource link in response
258
+ # * {boolean} _embedded - Return embedded resources in response
259
+ #
260
+ # Responses:
261
+ # * 200 - Collection of devices (https://api.losant.com/#/definitions/devices)
262
+ #
263
+ # Errors:
264
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
265
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
266
+ def get(params = {})
267
+ params = Utils.symbolize_hash_keys(params)
268
+ query_params = { _actions: false, _links: true, _embedded: true }
269
+ headers = {}
270
+ body = nil
271
+
272
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
273
+
274
+ query_params[:sortField] = params[:sortField] if params.has_key?(:sortField)
275
+ query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection)
276
+ query_params[:page] = params[:page] if params.has_key?(:page)
277
+ query_params[:perPage] = params[:perPage] if params.has_key?(:perPage)
278
+ query_params[:filterField] = params[:filterField] if params.has_key?(:filterField)
279
+ query_params[:filter] = params[:filter] if params.has_key?(:filter)
280
+ query_params[:deviceClass] = params[:deviceClass] if params.has_key?(:deviceClass)
281
+ query_params[:tagFilter] = params[:tagFilter] if params.has_key?(:tagFilter)
282
+ query_params[:excludeConnectionInfo] = params[:excludeConnectionInfo] if params.has_key?(:excludeConnectionInfo)
283
+ query_params[:parentId] = params[:parentId] if params.has_key?(:parentId)
284
+ query_params[:query] = params[:query] if params.has_key?(:query)
285
+ query_params[:query] = JSON.dump(query_params[:query]) if query_params.has_key?(:query)
286
+ query_params[:tagsAsObject] = params[:tagsAsObject] if params.has_key?(:tagsAsObject)
287
+ query_params[:attributesAsObject] = params[:attributesAsObject] if params.has_key?(:attributesAsObject)
288
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
289
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
290
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
291
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
292
+
293
+ path = "/applications/#{params[:applicationId]}/devices"
294
+
295
+ @client.request(
296
+ method: :get,
297
+ path: path,
298
+ query: query_params,
299
+ headers: headers,
300
+ body: body)
301
+ end
302
+
303
+ # Retrieve the composite last complete state of the matching devices
304
+ #
305
+ # Authentication:
306
+ # The client must be configured with a valid api
307
+ # access token to call this action. The token
308
+ # must include at least one of the following scopes:
309
+ # all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, devices.*, or devices.getCompositeState.
310
+ #
311
+ # Parameters:
312
+ # * {string} applicationId - ID associated with the application
313
+ # * {string} start - Start of time range to look at to build composite state
314
+ # * {string} end - End of time range to look at to build composite state
315
+ # * {string} attributes - Comma-separated list of attributes to include. When not provided, returns all attributes.
316
+ # * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate, lastUpdated, connectionStatus
317
+ # * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc
318
+ # * {string} page - Which page of results to return
319
+ # * {string} perPage - How many items to return per page
320
+ # * {hash} query - Device advanced query JSON object (https://api.losant.com/#/definitions/advancedDeviceQuery)
321
+ # * {string} losantdomain - Domain scope of request (rarely needed)
322
+ # * {boolean} _actions - Return resource actions in response
323
+ # * {boolean} _links - Return resource link in response
324
+ # * {boolean} _embedded - Return embedded resources in response
325
+ #
326
+ # Responses:
327
+ # * 200 - Collection of composite last state of the devices (https://api.losant.com/#/definitions/compositeDevicesState)
328
+ #
329
+ # Errors:
330
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
331
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
332
+ def get_composite_state(params = {})
333
+ params = Utils.symbolize_hash_keys(params)
334
+ query_params = { _actions: false, _links: true, _embedded: true }
335
+ headers = {}
336
+ body = nil
337
+
338
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
339
+
340
+ query_params[:start] = params[:start] if params.has_key?(:start)
341
+ query_params[:end] = params[:end] if params.has_key?(:end)
342
+ query_params[:attributes] = params[:attributes] if params.has_key?(:attributes)
343
+ query_params[:sortField] = params[:sortField] if params.has_key?(:sortField)
344
+ query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection)
345
+ query_params[:page] = params[:page] if params.has_key?(:page)
346
+ query_params[:perPage] = params[:perPage] if params.has_key?(:perPage)
347
+ query_params[:query] = params[:query] if params.has_key?(:query)
348
+ query_params[:query] = JSON.dump(query_params[:query]) if query_params.has_key?(:query)
349
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
350
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
351
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
352
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
353
+
354
+ path = "/applications/#{params[:applicationId]}/devices/compositeState"
355
+
356
+ @client.request(
357
+ method: :get,
358
+ path: path,
359
+ query: query_params,
360
+ headers: headers,
361
+ body: body)
362
+ end
363
+
364
+ # Update the fields of one or more devices
365
+ #
366
+ # Authentication:
367
+ # The client must be configured with a valid api
368
+ # access token to call this action. The token
369
+ # must include at least one of the following scopes:
370
+ # all.Application, all.Organization, all.User, devices.*, or devices.patch.
371
+ #
372
+ # Parameters:
373
+ # * {string} applicationId - ID associated with the application
374
+ # * {hash} patchInfo - Object containing device query or IDs and update operations (https://api.losant.com/#/definitions/devicesPatch)
375
+ # * {string} losantdomain - Domain scope of request (rarely needed)
376
+ # * {boolean} _actions - Return resource actions in response
377
+ # * {boolean} _links - Return resource link in response
378
+ # * {boolean} _embedded - Return embedded resources in response
379
+ #
380
+ # Responses:
381
+ # * 200 - Object including an update log link and the number of devices updated, failed, and skipped (https://api.losant.com/#/definitions/devicesUpdated)
382
+ # * 202 - Successfully queued bulk update job (https://api.losant.com/#/definitions/jobEnqueuedResult)
383
+ #
384
+ # Errors:
385
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
386
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
387
+ def patch(params = {})
388
+ params = Utils.symbolize_hash_keys(params)
389
+ query_params = { _actions: false, _links: true, _embedded: true }
390
+ headers = {}
391
+ body = nil
392
+
393
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
394
+ raise ArgumentError.new("patchInfo is required") unless params.has_key?(:patchInfo)
395
+
396
+ body = params[:patchInfo] if params.has_key?(:patchInfo)
397
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
398
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
399
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
400
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
401
+
402
+ path = "/applications/#{params[:applicationId]}/devices"
403
+
404
+ @client.request(
405
+ method: :patch,
406
+ path: path,
407
+ query: query_params,
408
+ headers: headers,
409
+ body: body)
410
+ end
411
+
412
+ # Creates an export of payload count information for the matching devices
413
+ #
414
+ # Authentication:
415
+ # The client must be configured with a valid api
416
+ # access token to call this action. The token
417
+ # must include at least one of the following scopes:
418
+ # all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, devices.*, or devices.payloadCounts.
419
+ #
420
+ # Parameters:
421
+ # * {string} applicationId - ID associated with the application
422
+ # * {hash} options - Object containing export configuration (https://api.losant.com/#/definitions/devicesExportPayloadCountPost)
423
+ # * {string} losantdomain - Domain scope of request (rarely needed)
424
+ # * {boolean} _actions - Return resource actions in response
425
+ # * {boolean} _links - Return resource link in response
426
+ # * {boolean} _embedded - Return embedded resources in response
427
+ #
428
+ # Responses:
429
+ # * 202 - If generation of export was successfully started (https://api.losant.com/#/definitions/jobEnqueuedResult)
430
+ #
431
+ # Errors:
432
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
433
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
434
+ def payload_counts(params = {})
435
+ params = Utils.symbolize_hash_keys(params)
436
+ query_params = { _actions: false, _links: true, _embedded: true }
437
+ headers = {}
438
+ body = nil
439
+
440
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
441
+
442
+ body = params[:options] if params.has_key?(:options)
443
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
444
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
445
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
446
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
447
+
448
+ path = "/applications/#{params[:applicationId]}/devices/payloadCounts"
449
+
450
+ @client.request(
451
+ method: :post,
452
+ path: path,
453
+ query: query_params,
454
+ headers: headers,
455
+ body: body)
456
+ end
457
+
458
+ # Create a new device for an application
459
+ #
460
+ # Authentication:
461
+ # The client must be configured with a valid api
462
+ # access token to call this action. The token
463
+ # must include at least one of the following scopes:
464
+ # all.Application, all.Organization, all.User, devices.*, or devices.post.
465
+ #
466
+ # Parameters:
467
+ # * {string} applicationId - ID associated with the application
468
+ # * {hash} device - New device information (https://api.losant.com/#/definitions/devicePost)
469
+ # * {string} tagsAsObject - Return tags as an object map instead of an array
470
+ # * {string} attributesAsObject - Return attributes as an object map instead of an array
471
+ # * {string} losantdomain - Domain scope of request (rarely needed)
472
+ # * {boolean} _actions - Return resource actions in response
473
+ # * {boolean} _links - Return resource link in response
474
+ # * {boolean} _embedded - Return embedded resources in response
475
+ #
476
+ # Responses:
477
+ # * 201 - Successfully created device (https://api.losant.com/#/definitions/device)
478
+ #
479
+ # Errors:
480
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
481
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
482
+ def post(params = {})
483
+ params = Utils.symbolize_hash_keys(params)
484
+ query_params = { _actions: false, _links: true, _embedded: true }
485
+ headers = {}
486
+ body = nil
487
+
488
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
489
+ raise ArgumentError.new("device is required") unless params.has_key?(:device)
490
+
491
+ body = params[:device] if params.has_key?(:device)
492
+ query_params[:tagsAsObject] = params[:tagsAsObject] if params.has_key?(:tagsAsObject)
493
+ query_params[:attributesAsObject] = params[:attributesAsObject] if params.has_key?(:attributesAsObject)
494
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
495
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
496
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
497
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
498
+
499
+ path = "/applications/#{params[:applicationId]}/devices"
500
+
501
+ @client.request(
502
+ method: :post,
503
+ path: path,
504
+ query: query_params,
505
+ headers: headers,
506
+ body: body)
507
+ end
508
+
509
+ # Removes all device data for the specified time range. Defaults to all data.
510
+ #
511
+ # Authentication:
512
+ # The client must be configured with a valid api
513
+ # access token to call this action. The token
514
+ # must include at least one of the following scopes:
515
+ # all.Application, all.Organization, all.User, devices.*, or devices.removeData.
516
+ #
517
+ # Parameters:
518
+ # * {string} applicationId - ID associated with the application
519
+ # * {hash} options - Object defining the device data to delete and devices to delete from (https://api.losant.com/#/definitions/devicesRemoveDataPost)
520
+ # * {string} losantdomain - Domain scope of request (rarely needed)
521
+ # * {boolean} _actions - Return resource actions in response
522
+ # * {boolean} _links - Return resource link in response
523
+ # * {boolean} _embedded - Return embedded resources in response
524
+ #
525
+ # Responses:
526
+ # * 200 - Object indicating number of devices completed or skipped (https://api.losant.com/#/definitions/devicesDataRemoved)
527
+ # * 202 - If a job was enqueued for device data to be removed (https://api.losant.com/#/definitions/jobEnqueuedResult)
528
+ #
529
+ # Errors:
530
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
531
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
532
+ def remove_data(params = {})
533
+ params = Utils.symbolize_hash_keys(params)
534
+ query_params = { _actions: false, _links: true, _embedded: true }
535
+ headers = {}
536
+ body = nil
537
+
538
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
539
+ raise ArgumentError.new("options is required") unless params.has_key?(:options)
540
+
541
+ body = params[:options] if params.has_key?(:options)
542
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
543
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
544
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
545
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
546
+
547
+ path = "/applications/#{params[:applicationId]}/devices/removeData"
548
+
549
+ @client.request(
550
+ method: :post,
551
+ path: path,
552
+ query: query_params,
553
+ headers: headers,
554
+ body: body)
555
+ end
556
+
557
+ # Send a command to multiple devices
558
+ #
559
+ # Authentication:
560
+ # The client must be configured with a valid api
561
+ # access token to call this action. The token
562
+ # must include at least one of the following scopes:
563
+ # all.Application, all.Device, all.Organization, all.User, devices.*, or devices.sendCommand.
564
+ #
565
+ # Parameters:
566
+ # * {string} applicationId - ID associated with the application
567
+ # * {hash} multiDeviceCommand - Command to send to the device (https://api.losant.com/#/definitions/multiDeviceCommand)
568
+ # * {string} losantdomain - Domain scope of request (rarely needed)
569
+ # * {boolean} _actions - Return resource actions in response
570
+ # * {boolean} _links - Return resource link in response
571
+ # * {boolean} _embedded - Return embedded resources in response
572
+ #
573
+ # Responses:
574
+ # * 200 - If command was successfully sent (https://api.losant.com/#/definitions/success)
575
+ # * 202 - If command was queued to be sent (https://api.losant.com/#/definitions/jobEnqueuedResult)
576
+ #
577
+ # Errors:
578
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
579
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
580
+ def send_command(params = {})
581
+ params = Utils.symbolize_hash_keys(params)
582
+ query_params = { _actions: false, _links: true, _embedded: true }
583
+ headers = {}
584
+ body = nil
585
+
586
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
587
+ raise ArgumentError.new("multiDeviceCommand is required") unless params.has_key?(:multiDeviceCommand)
588
+
589
+ body = params[:multiDeviceCommand] if params.has_key?(:multiDeviceCommand)
590
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
591
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
592
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
593
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
594
+
595
+ path = "/applications/#{params[:applicationId]}/devices/command"
596
+
597
+ @client.request(
598
+ method: :post,
599
+ path: path,
600
+ query: query_params,
601
+ headers: headers,
602
+ body: body)
603
+ end
604
+
605
+ # Gets the unique tag keys for devices that match the given query. Maximum 1K returned.
606
+ #
607
+ # Authentication:
608
+ # The client must be configured with a valid api
609
+ # access token to call this action. The token
610
+ # must include at least one of the following scopes:
611
+ # all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, devices.*, or devices.tagKeys.
612
+ #
613
+ # Parameters:
614
+ # * {string} applicationId - ID associated with the application
615
+ # * {hash} query - Device filter JSON object (https://api.losant.com/#/definitions/advancedDeviceQuery)
616
+ # * {string} startsWith - Filter keys down to those that start with the given string. Case insensitive.
617
+ # * {string} losantdomain - Domain scope of request (rarely needed)
618
+ # * {boolean} _actions - Return resource actions in response
619
+ # * {boolean} _links - Return resource link in response
620
+ # * {boolean} _embedded - Return embedded resources in response
621
+ #
622
+ # Responses:
623
+ # * 200 - The matching tag keys (https://api.losant.com/#/definitions/tagKeysResponse)
624
+ #
625
+ # Errors:
626
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
627
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
628
+ def tag_keys(params = {})
629
+ params = Utils.symbolize_hash_keys(params)
630
+ query_params = { _actions: false, _links: true, _embedded: true }
631
+ headers = {}
632
+ body = nil
633
+
634
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
635
+
636
+ query_params[:query] = params[:query] if params.has_key?(:query)
637
+ query_params[:query] = JSON.dump(query_params[:query]) if query_params.has_key?(:query)
638
+ query_params[:startsWith] = params[:startsWith] if params.has_key?(:startsWith)
639
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
640
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
641
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
642
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
643
+
644
+ path = "/applications/#{params[:applicationId]}/devices/tagKeys"
645
+
646
+ @client.request(
647
+ method: :get,
648
+ path: path,
649
+ query: query_params,
650
+ headers: headers,
651
+ body: body)
652
+ end
653
+
654
+ # Gets the unique tag values for the given key for devices that match the given query. Maximum 1K returned.
655
+ #
656
+ # Authentication:
657
+ # The client must be configured with a valid api
658
+ # access token to call this action. The token
659
+ # must include at least one of the following scopes:
660
+ # all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, devices.*, or devices.tagValues.
661
+ #
662
+ # Parameters:
663
+ # * {string} applicationId - ID associated with the application
664
+ # * {hash} query - Device filter JSON object (https://api.losant.com/#/definitions/advancedDeviceQuery)
665
+ # * {string} key - The tag key to get the values for
666
+ # * {string} startsWith - Filter values down to those that start with the given string. Case insensitive.
667
+ # * {string} losantdomain - Domain scope of request (rarely needed)
668
+ # * {boolean} _actions - Return resource actions in response
669
+ # * {boolean} _links - Return resource link in response
670
+ # * {boolean} _embedded - Return embedded resources in response
671
+ #
672
+ # Responses:
673
+ # * 200 - The matching tag values (https://api.losant.com/#/definitions/tagValuesResponse)
674
+ #
675
+ # Errors:
676
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
677
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
678
+ def tag_values(params = {})
679
+ params = Utils.symbolize_hash_keys(params)
680
+ query_params = { _actions: false, _links: true, _embedded: true }
681
+ headers = {}
682
+ body = nil
683
+
684
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
685
+ raise ArgumentError.new("key is required") unless params.has_key?(:key)
686
+
687
+ query_params[:query] = params[:query] if params.has_key?(:query)
688
+ query_params[:query] = JSON.dump(query_params[:query]) if query_params.has_key?(:query)
689
+ query_params[:key] = params[:key] if params.has_key?(:key)
690
+ query_params[:startsWith] = params[:startsWith] if params.has_key?(:startsWith)
691
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
692
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
693
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
694
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
695
+
696
+ path = "/applications/#{params[:applicationId]}/devices/tagValues"
697
+
698
+ @client.request(
699
+ method: :get,
700
+ path: path,
701
+ query: query_params,
702
+ headers: headers,
703
+ body: body)
704
+ end
705
+
706
+ end
707
+ end