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,767 @@
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 Device Resource
28
+ class Device
29
+
30
+ def initialize(client)
31
+ @client = client
32
+ end
33
+
34
+ # Deletes a device
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.Organization, all.User, device.*, or device.delete.
41
+ #
42
+ # Parameters:
43
+ # * {string} applicationId - ID associated with the application
44
+ # * {string} deviceId - ID associated with the device
45
+ # * {string} losantdomain - Domain scope of request (rarely needed)
46
+ # * {boolean} _actions - Return resource actions in response
47
+ # * {boolean} _links - Return resource link in response
48
+ # * {boolean} _embedded - Return embedded resources in response
49
+ #
50
+ # Responses:
51
+ # * 200 - If device was successfully deleted (https://api.losant.com/#/definitions/success)
52
+ #
53
+ # Errors:
54
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
55
+ # * 404 - Error if device was not found (https://api.losant.com/#/definitions/error)
56
+ def delete(params = {})
57
+ params = Utils.symbolize_hash_keys(params)
58
+ query_params = { _actions: false, _links: true, _embedded: true }
59
+ headers = {}
60
+ body = nil
61
+
62
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
63
+ raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId)
64
+
65
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
66
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
67
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
68
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
69
+
70
+ path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}"
71
+
72
+ @client.request(
73
+ method: :delete,
74
+ path: path,
75
+ query: query_params,
76
+ headers: headers,
77
+ body: body)
78
+ end
79
+
80
+ # Creates a device data export. Defaults to all data.
81
+ #
82
+ # Authentication:
83
+ # The client must be configured with a valid api
84
+ # access token to call this action. The token
85
+ # must include at least one of the following scopes:
86
+ # all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.export.
87
+ #
88
+ # Parameters:
89
+ # * {string} applicationId - ID associated with the application
90
+ # * {string} deviceId - ID associated with the device
91
+ # * {string} start - Start time of export (ms since epoch - 0 means now, negative is relative to now)
92
+ # * {string} end - End time of export (ms since epoch - 0 means now, negative is relative to now)
93
+ # * {string} email - Email address to send export to. Defaults to current user's email.
94
+ # * {string} callbackUrl - Callback URL to call with export result
95
+ # * {string} includeBlobData - If set will export any blob attributes in base64 form, otherwise they will be downloadable links which will expire.
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
+ # * 202 - If generation of export was successfully started (https://api.losant.com/#/definitions/jobEnqueuedResult)
103
+ #
104
+ # Errors:
105
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
106
+ # * 404 - Error if device was not found (https://api.losant.com/#/definitions/error)
107
+ def export(params = {})
108
+ params = Utils.symbolize_hash_keys(params)
109
+ query_params = { _actions: false, _links: true, _embedded: true }
110
+ headers = {}
111
+ body = nil
112
+
113
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
114
+ raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId)
115
+
116
+ query_params[:start] = params[:start] if params.has_key?(:start)
117
+ query_params[:end] = params[:end] if params.has_key?(:end)
118
+ query_params[:email] = params[:email] if params.has_key?(:email)
119
+ query_params[:callbackUrl] = params[:callbackUrl] if params.has_key?(:callbackUrl)
120
+ query_params[:includeBlobData] = params[:includeBlobData] if params.has_key?(:includeBlobData)
121
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
122
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
123
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
124
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
125
+
126
+ path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/export"
127
+
128
+ @client.request(
129
+ method: :post,
130
+ path: path,
131
+ query: query_params,
132
+ headers: headers,
133
+ body: body)
134
+ end
135
+
136
+ # Retrieves information on a device
137
+ #
138
+ # Authentication:
139
+ # The client must be configured with a valid api
140
+ # access token to call this action. The token
141
+ # must include at least one of the following scopes:
142
+ # all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.get.
143
+ #
144
+ # Parameters:
145
+ # * {string} applicationId - ID associated with the application
146
+ # * {string} deviceId - ID associated with the device
147
+ # * {string} excludeConnectionInfo - If set, do not return connection info
148
+ # * {string} tagsAsObject - Return tags as an object map instead of an array
149
+ # * {string} attributesAsObject - Return attributes as an object map instead of an array
150
+ # * {string} losantdomain - Domain scope of request (rarely needed)
151
+ # * {boolean} _actions - Return resource actions in response
152
+ # * {boolean} _links - Return resource link in response
153
+ # * {boolean} _embedded - Return embedded resources in response
154
+ #
155
+ # Responses:
156
+ # * 200 - Device information (https://api.losant.com/#/definitions/device)
157
+ #
158
+ # Errors:
159
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
160
+ # * 404 - Error if device was not found (https://api.losant.com/#/definitions/error)
161
+ def get(params = {})
162
+ params = Utils.symbolize_hash_keys(params)
163
+ query_params = { _actions: false, _links: true, _embedded: true }
164
+ headers = {}
165
+ body = nil
166
+
167
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
168
+ raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId)
169
+
170
+ query_params[:excludeConnectionInfo] = params[:excludeConnectionInfo] if params.has_key?(:excludeConnectionInfo)
171
+ query_params[:tagsAsObject] = params[:tagsAsObject] if params.has_key?(:tagsAsObject)
172
+ query_params[:attributesAsObject] = params[:attributesAsObject] if params.has_key?(:attributesAsObject)
173
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
174
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
175
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
176
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
177
+
178
+ path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}"
179
+
180
+ @client.request(
181
+ method: :get,
182
+ path: path,
183
+ query: query_params,
184
+ headers: headers,
185
+ body: body)
186
+ end
187
+
188
+ # Retrieve the last known commands(s) sent to the device
189
+ #
190
+ # Authentication:
191
+ # The client must be configured with a valid api
192
+ # access token to call this action. The token
193
+ # must include at least one of the following scopes:
194
+ # all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.getCommand.
195
+ #
196
+ # Parameters:
197
+ # * {string} applicationId - ID associated with the application
198
+ # * {string} deviceId - ID associated with the device
199
+ # * {string} limit - Maximum number of command entries to return
200
+ # * {string} since - (deprecated) Look for command entries since this time (ms since epoch)
201
+ # * {string} sortDirection - Direction to sort the command entries (by time). Accepted values are: asc, desc
202
+ # * {string} duration - Duration of time range to query in milliseconds
203
+ # * {string} start - Start of time range to query in milliseconds since epoch
204
+ # * {string} end - End of time range to query in milliseconds since epoch
205
+ # * {string} losantdomain - Domain scope of request (rarely needed)
206
+ # * {boolean} _actions - Return resource actions in response
207
+ # * {boolean} _links - Return resource link in response
208
+ # * {boolean} _embedded - Return embedded resources in response
209
+ #
210
+ # Responses:
211
+ # * 200 - Recent device commands (https://api.losant.com/#/definitions/deviceCommands)
212
+ #
213
+ # Errors:
214
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
215
+ # * 404 - Error if device was not found (https://api.losant.com/#/definitions/error)
216
+ def get_command(params = {})
217
+ params = Utils.symbolize_hash_keys(params)
218
+ query_params = { _actions: false, _links: true, _embedded: true }
219
+ headers = {}
220
+ body = nil
221
+
222
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
223
+ raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId)
224
+
225
+ query_params[:limit] = params[:limit] if params.has_key?(:limit)
226
+ query_params[:since] = params[:since] if params.has_key?(:since)
227
+ query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection)
228
+ query_params[:duration] = params[:duration] if params.has_key?(:duration)
229
+ query_params[:start] = params[:start] if params.has_key?(:start)
230
+ query_params[:end] = params[:end] if params.has_key?(:end)
231
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
232
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
233
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
234
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
235
+
236
+ path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/command"
237
+
238
+ @client.request(
239
+ method: :get,
240
+ path: path,
241
+ query: query_params,
242
+ headers: headers,
243
+ body: body)
244
+ end
245
+
246
+ # Retrieve the composite last complete state of the device
247
+ #
248
+ # Authentication:
249
+ # The client must be configured with a valid api
250
+ # access token to call this action. The token
251
+ # must include at least one of the following scopes:
252
+ # all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.getCompositeState.
253
+ #
254
+ # Parameters:
255
+ # * {string} applicationId - ID associated with the application
256
+ # * {string} deviceId - ID associated with the device
257
+ # * {string} start - Start of time range to look at to build composite state
258
+ # * {string} end - End of time range to look at to build composite state
259
+ # * {string} attributes - Comma-separated list of attributes to include. When not provided, returns all attributes.
260
+ # * {string} losantdomain - Domain scope of request (rarely needed)
261
+ # * {boolean} _actions - Return resource actions in response
262
+ # * {boolean} _links - Return resource link in response
263
+ # * {boolean} _embedded - Return embedded resources in response
264
+ #
265
+ # Responses:
266
+ # * 200 - Composite last state of the device (https://api.losant.com/#/definitions/compositeDeviceState)
267
+ #
268
+ # Errors:
269
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
270
+ # * 404 - Error if device was not found (https://api.losant.com/#/definitions/error)
271
+ def get_composite_state(params = {})
272
+ params = Utils.symbolize_hash_keys(params)
273
+ query_params = { _actions: false, _links: true, _embedded: true }
274
+ headers = {}
275
+ body = nil
276
+
277
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
278
+ raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId)
279
+
280
+ query_params[:start] = params[:start] if params.has_key?(:start)
281
+ query_params[:end] = params[:end] if params.has_key?(:end)
282
+ query_params[:attributes] = params[:attributes] if params.has_key?(:attributes)
283
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
284
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
285
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
286
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
287
+
288
+ path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/compositeState"
289
+
290
+ @client.request(
291
+ method: :get,
292
+ path: path,
293
+ query: query_params,
294
+ headers: headers,
295
+ body: body)
296
+ end
297
+
298
+ # Retrieve the recent log entries about the device
299
+ #
300
+ # Authentication:
301
+ # The client must be configured with a valid api
302
+ # access token to call this action. The token
303
+ # must include at least one of the following scopes:
304
+ # all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.getLogEntries.
305
+ #
306
+ # Parameters:
307
+ # * {string} applicationId - ID associated with the application
308
+ # * {string} deviceId - ID associated with the device
309
+ # * {string} limit - Maximum number of log entries to return
310
+ # * {string} since - (deprecated) Look for log entries since this time (ms since epoch)
311
+ # * {string} sortDirection - Direction to sort the log entries (by time). Accepted values are: asc, desc
312
+ # * {string} duration - Duration of time range to query in milliseconds
313
+ # * {string} start - Start of time range to query in milliseconds since epoch
314
+ # * {string} end - End of time range to query in milliseconds since epoch
315
+ # * {string} losantdomain - Domain scope of request (rarely needed)
316
+ # * {boolean} _actions - Return resource actions in response
317
+ # * {boolean} _links - Return resource link in response
318
+ # * {boolean} _embedded - Return embedded resources in response
319
+ #
320
+ # Responses:
321
+ # * 200 - Recent log entries (https://api.losant.com/#/definitions/deviceLog)
322
+ #
323
+ # Errors:
324
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
325
+ # * 404 - Error if device was not found (https://api.losant.com/#/definitions/error)
326
+ def get_log_entries(params = {})
327
+ params = Utils.symbolize_hash_keys(params)
328
+ query_params = { _actions: false, _links: true, _embedded: true }
329
+ headers = {}
330
+ body = nil
331
+
332
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
333
+ raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId)
334
+
335
+ query_params[:limit] = params[:limit] if params.has_key?(:limit)
336
+ query_params[:since] = params[:since] if params.has_key?(:since)
337
+ query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection)
338
+ query_params[:duration] = params[:duration] if params.has_key?(:duration)
339
+ query_params[:start] = params[:start] if params.has_key?(:start)
340
+ query_params[:end] = params[:end] if params.has_key?(:end)
341
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
342
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
343
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
344
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
345
+
346
+ path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/logs"
347
+
348
+ @client.request(
349
+ method: :get,
350
+ path: path,
351
+ query: query_params,
352
+ headers: headers,
353
+ body: body)
354
+ end
355
+
356
+ # Retrieve the last known state(s) of the device
357
+ #
358
+ # Authentication:
359
+ # The client must be configured with a valid api
360
+ # access token to call this action. The token
361
+ # must include at least one of the following scopes:
362
+ # all.Application, all.Application.read, all.Device, all.Device.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.getState.
363
+ #
364
+ # Parameters:
365
+ # * {string} applicationId - ID associated with the application
366
+ # * {string} deviceId - ID associated with the device
367
+ # * {string} limit - Maximum number of state entries to return
368
+ # * {string} since - (deprecated) Look for state entries since this time (ms since epoch)
369
+ # * {string} sortDirection - Direction to sort the state entries (by time). Accepted values are: asc, desc
370
+ # * {string} duration - Duration of time range to query in milliseconds
371
+ # * {string} start - Start of time range to query in milliseconds since epoch
372
+ # * {string} end - End of time range to query in milliseconds since epoch
373
+ # * {string} losantdomain - Domain scope of request (rarely needed)
374
+ # * {boolean} _actions - Return resource actions in response
375
+ # * {boolean} _links - Return resource link in response
376
+ # * {boolean} _embedded - Return embedded resources in response
377
+ #
378
+ # Responses:
379
+ # * 200 - Recent device states (https://api.losant.com/#/definitions/deviceStates)
380
+ #
381
+ # Errors:
382
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
383
+ # * 404 - Error if device was not found (https://api.losant.com/#/definitions/error)
384
+ def get_state(params = {})
385
+ params = Utils.symbolize_hash_keys(params)
386
+ query_params = { _actions: false, _links: true, _embedded: true }
387
+ headers = {}
388
+ body = nil
389
+
390
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
391
+ raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId)
392
+
393
+ query_params[:limit] = params[:limit] if params.has_key?(:limit)
394
+ query_params[:since] = params[:since] if params.has_key?(:since)
395
+ query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection)
396
+ query_params[:duration] = params[:duration] if params.has_key?(:duration)
397
+ query_params[:start] = params[:start] if params.has_key?(:start)
398
+ query_params[:end] = params[:end] if params.has_key?(:end)
399
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
400
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
401
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
402
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
403
+
404
+ path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/state"
405
+
406
+ @client.request(
407
+ method: :get,
408
+ path: path,
409
+ query: query_params,
410
+ headers: headers,
411
+ body: body)
412
+ end
413
+
414
+ # Updates information about a device
415
+ #
416
+ # Authentication:
417
+ # The client must be configured with a valid api
418
+ # access token to call this action. The token
419
+ # must include at least one of the following scopes:
420
+ # all.Application, all.Organization, all.User, device.*, or device.patch.
421
+ #
422
+ # Parameters:
423
+ # * {string} applicationId - ID associated with the application
424
+ # * {string} deviceId - ID associated with the device
425
+ # * {hash} device - Object containing new properties of the device (https://api.losant.com/#/definitions/devicePatch)
426
+ # * {string} tagsAsObject - Return tags as an object map instead of an array
427
+ # * {string} attributesAsObject - Return attributes as an object map instead of an array
428
+ # * {string} losantdomain - Domain scope of request (rarely needed)
429
+ # * {boolean} _actions - Return resource actions in response
430
+ # * {boolean} _links - Return resource link in response
431
+ # * {boolean} _embedded - Return embedded resources in response
432
+ #
433
+ # Responses:
434
+ # * 200 - Updated device information (https://api.losant.com/#/definitions/device)
435
+ #
436
+ # Errors:
437
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
438
+ # * 404 - Error if device was not found (https://api.losant.com/#/definitions/error)
439
+ def patch(params = {})
440
+ params = Utils.symbolize_hash_keys(params)
441
+ query_params = { _actions: false, _links: true, _embedded: true }
442
+ headers = {}
443
+ body = nil
444
+
445
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
446
+ raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId)
447
+ raise ArgumentError.new("device is required") unless params.has_key?(:device)
448
+
449
+ body = params[:device] if params.has_key?(:device)
450
+ query_params[:tagsAsObject] = params[:tagsAsObject] if params.has_key?(:tagsAsObject)
451
+ query_params[:attributesAsObject] = params[:attributesAsObject] if params.has_key?(:attributesAsObject)
452
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
453
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
454
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
455
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
456
+
457
+ path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}"
458
+
459
+ @client.request(
460
+ method: :patch,
461
+ path: path,
462
+ query: query_params,
463
+ headers: headers,
464
+ body: body)
465
+ end
466
+
467
+ # Returns payload counts for the time range specified for this device
468
+ #
469
+ # Authentication:
470
+ # The client must be configured with a valid api
471
+ # access token to call this action. The token
472
+ # must include at least one of the following scopes:
473
+ # all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.payloadCounts.
474
+ #
475
+ # Parameters:
476
+ # * {string} applicationId - ID associated with the application
477
+ # * {string} deviceId - ID associated with the device
478
+ # * {string} start - Start of range for payload count query (ms since epoch)
479
+ # * {string} end - End of range for payload count query (ms since epoch)
480
+ # * {string} losantdomain - Domain scope of request (rarely needed)
481
+ # * {boolean} _actions - Return resource actions in response
482
+ # * {boolean} _links - Return resource link in response
483
+ # * {boolean} _embedded - Return embedded resources in response
484
+ #
485
+ # Responses:
486
+ # * 200 - Payload counts, by type (https://api.losant.com/#/definitions/devicePayloadCounts)
487
+ #
488
+ # Errors:
489
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
490
+ # * 404 - Error if device was not found (https://api.losant.com/#/definitions/error)
491
+ def payload_counts(params = {})
492
+ params = Utils.symbolize_hash_keys(params)
493
+ query_params = { _actions: false, _links: true, _embedded: true }
494
+ headers = {}
495
+ body = nil
496
+
497
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
498
+ raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId)
499
+
500
+ query_params[:start] = params[:start] if params.has_key?(:start)
501
+ query_params[:end] = params[:end] if params.has_key?(:end)
502
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
503
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
504
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
505
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
506
+
507
+ path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/payloadCounts"
508
+
509
+ @client.request(
510
+ method: :get,
511
+ path: path,
512
+ query: query_params,
513
+ headers: headers,
514
+ body: body)
515
+ end
516
+
517
+ # Returns payload counts per resolution in the time range specified for this device
518
+ #
519
+ # Authentication:
520
+ # The client must be configured with a valid api
521
+ # access token to call this action. The token
522
+ # must include at least one of the following scopes:
523
+ # all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, device.*, or device.payloadCountsBreakdown.
524
+ #
525
+ # Parameters:
526
+ # * {string} applicationId - ID associated with the application
527
+ # * {string} deviceId - ID associated with the device
528
+ # * {string} start - Start of range for payload count query (ms since epoch)
529
+ # * {string} end - End of range for payload count query (ms since epoch)
530
+ # * {string} resolution - Resolution in milliseconds. Accepted values are: 86400000, 3600000
531
+ # * {string} losantdomain - Domain scope of request (rarely needed)
532
+ # * {boolean} _actions - Return resource actions in response
533
+ # * {boolean} _links - Return resource link in response
534
+ # * {boolean} _embedded - Return embedded resources in response
535
+ #
536
+ # Responses:
537
+ # * 200 - Sum of payload counts by date (https://api.losant.com/#/definitions/payloadCountsBreakdown)
538
+ #
539
+ # Errors:
540
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
541
+ # * 404 - Error if device was not found (https://api.losant.com/#/definitions/error)
542
+ def payload_counts_breakdown(params = {})
543
+ params = Utils.symbolize_hash_keys(params)
544
+ query_params = { _actions: false, _links: true, _embedded: true }
545
+ headers = {}
546
+ body = nil
547
+
548
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
549
+ raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId)
550
+
551
+ query_params[:start] = params[:start] if params.has_key?(:start)
552
+ query_params[:end] = params[:end] if params.has_key?(:end)
553
+ query_params[:resolution] = params[:resolution] if params.has_key?(:resolution)
554
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
555
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
556
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
557
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
558
+
559
+ path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/payloadCountsBreakdown"
560
+
561
+ @client.request(
562
+ method: :get,
563
+ path: path,
564
+ query: query_params,
565
+ headers: headers,
566
+ body: body)
567
+ end
568
+
569
+ # Removes all device data for the specified time range. Defaults to all data.
570
+ #
571
+ # Authentication:
572
+ # The client must be configured with a valid api
573
+ # access token to call this action. The token
574
+ # must include at least one of the following scopes:
575
+ # all.Application, all.Organization, all.User, device.*, or device.removeData.
576
+ #
577
+ # Parameters:
578
+ # * {string} applicationId - ID associated with the application
579
+ # * {string} deviceId - ID associated with the device
580
+ # * {string} start - Start time of export (ms since epoch - 0 means now, negative is relative to now)
581
+ # * {string} end - End time of export (ms since epoch - 0 means now, negative is relative to now)
582
+ # * {string} losantdomain - Domain scope of request (rarely needed)
583
+ # * {boolean} _actions - Return resource actions in response
584
+ # * {boolean} _links - Return resource link in response
585
+ # * {boolean} _embedded - Return embedded resources in response
586
+ #
587
+ # Responses:
588
+ # * 202 - If data removal was successfully started (https://api.losant.com/#/definitions/jobEnqueuedResult)
589
+ #
590
+ # Errors:
591
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
592
+ # * 404 - Error if device was not found (https://api.losant.com/#/definitions/error)
593
+ def remove_data(params = {})
594
+ params = Utils.symbolize_hash_keys(params)
595
+ query_params = { _actions: false, _links: true, _embedded: true }
596
+ headers = {}
597
+ body = nil
598
+
599
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
600
+ raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId)
601
+
602
+ query_params[:start] = params[:start] if params.has_key?(:start)
603
+ query_params[:end] = params[:end] if params.has_key?(:end)
604
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
605
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
606
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
607
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
608
+
609
+ path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/data"
610
+
611
+ @client.request(
612
+ method: :delete,
613
+ path: path,
614
+ query: query_params,
615
+ headers: headers,
616
+ body: body)
617
+ end
618
+
619
+ # Send a command to a device
620
+ #
621
+ # Authentication:
622
+ # The client must be configured with a valid api
623
+ # access token to call this action. The token
624
+ # must include at least one of the following scopes:
625
+ # all.Application, all.Device, all.Organization, all.User, device.*, or device.sendCommand.
626
+ #
627
+ # Parameters:
628
+ # * {string} applicationId - ID associated with the application
629
+ # * {string} deviceId - ID associated with the device
630
+ # * {hash} deviceCommand - Command to send to the device (https://api.losant.com/#/definitions/deviceCommand)
631
+ # * {string} losantdomain - Domain scope of request (rarely needed)
632
+ # * {boolean} _actions - Return resource actions in response
633
+ # * {boolean} _links - Return resource link in response
634
+ # * {boolean} _embedded - Return embedded resources in response
635
+ #
636
+ # Responses:
637
+ # * 200 - If command was successfully sent (https://api.losant.com/#/definitions/success)
638
+ #
639
+ # Errors:
640
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
641
+ # * 404 - Error if device was not found (https://api.losant.com/#/definitions/error)
642
+ def send_command(params = {})
643
+ params = Utils.symbolize_hash_keys(params)
644
+ query_params = { _actions: false, _links: true, _embedded: true }
645
+ headers = {}
646
+ body = nil
647
+
648
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
649
+ raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId)
650
+ raise ArgumentError.new("deviceCommand is required") unless params.has_key?(:deviceCommand)
651
+
652
+ body = params[:deviceCommand] if params.has_key?(:deviceCommand)
653
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
654
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
655
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
656
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
657
+
658
+ path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/command"
659
+
660
+ @client.request(
661
+ method: :post,
662
+ path: path,
663
+ query: query_params,
664
+ headers: headers,
665
+ body: body)
666
+ end
667
+
668
+ # Send the current state of the device
669
+ #
670
+ # Authentication:
671
+ # The client must be configured with a valid api
672
+ # access token to call this action. The token
673
+ # must include at least one of the following scopes:
674
+ # all.Application, all.Device, all.Organization, all.User, device.*, or device.sendState.
675
+ #
676
+ # Parameters:
677
+ # * {string} applicationId - ID associated with the application
678
+ # * {string} deviceId - ID associated with the device
679
+ # * {hash} deviceState - A single device state object, or an array of device state objects (https://api.losant.com/#/definitions/deviceStateOrStates)
680
+ # * {string} losantdomain - Domain scope of request (rarely needed)
681
+ # * {boolean} _actions - Return resource actions in response
682
+ # * {boolean} _links - Return resource link in response
683
+ # * {boolean} _embedded - Return embedded resources in response
684
+ #
685
+ # Responses:
686
+ # * 200 - If state was successfully received (https://api.losant.com/#/definitions/success)
687
+ #
688
+ # Errors:
689
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
690
+ # * 404 - Error if device was not found (https://api.losant.com/#/definitions/error)
691
+ def send_state(params = {})
692
+ params = Utils.symbolize_hash_keys(params)
693
+ query_params = { _actions: false, _links: true, _embedded: true }
694
+ headers = {}
695
+ body = nil
696
+
697
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
698
+ raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId)
699
+ raise ArgumentError.new("deviceState is required") unless params.has_key?(:deviceState)
700
+
701
+ body = params[:deviceState] if params.has_key?(:deviceState)
702
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
703
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
704
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
705
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
706
+
707
+ path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/state"
708
+
709
+ @client.request(
710
+ method: :post,
711
+ path: path,
712
+ query: query_params,
713
+ headers: headers,
714
+ body: body)
715
+ end
716
+
717
+ # Set the current connection status of the device
718
+ #
719
+ # Authentication:
720
+ # The client must be configured with a valid api
721
+ # access token to call this action. The token
722
+ # must include at least one of the following scopes:
723
+ # all.Application, all.Device, all.Organization, all.User, device.*, or device.setConnectionStatus.
724
+ #
725
+ # Parameters:
726
+ # * {string} applicationId - ID associated with the application
727
+ # * {string} deviceId - ID associated with the device
728
+ # * {hash} connectionStatus - The current connection status of the device (https://api.losant.com/#/definitions/deviceConnectionStatus)
729
+ # * {string} losantdomain - Domain scope of request (rarely needed)
730
+ # * {boolean} _actions - Return resource actions in response
731
+ # * {boolean} _links - Return resource link in response
732
+ # * {boolean} _embedded - Return embedded resources in response
733
+ #
734
+ # Responses:
735
+ # * 200 - If connection status was successfully applied (https://api.losant.com/#/definitions/success)
736
+ #
737
+ # Errors:
738
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
739
+ # * 404 - Error if device was not found (https://api.losant.com/#/definitions/error)
740
+ def set_connection_status(params = {})
741
+ params = Utils.symbolize_hash_keys(params)
742
+ query_params = { _actions: false, _links: true, _embedded: true }
743
+ headers = {}
744
+ body = nil
745
+
746
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
747
+ raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId)
748
+ raise ArgumentError.new("connectionStatus is required") unless params.has_key?(:connectionStatus)
749
+
750
+ body = params[:connectionStatus] if params.has_key?(:connectionStatus)
751
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
752
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
753
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
754
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
755
+
756
+ path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/setConnectionStatus"
757
+
758
+ @client.request(
759
+ method: :post,
760
+ path: path,
761
+ query: query_params,
762
+ headers: headers,
763
+ body: body)
764
+ end
765
+
766
+ end
767
+ end