losant_rest 1.10.1 → 1.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,14 +6,57 @@ parameters and the potential responses.
6
6
 
7
7
  ##### Contents
8
8
 
9
+ * [Delete](#delete)
9
10
  * [Export](#export)
10
11
  * [Get](#get)
11
12
  * [Patch](#patch)
12
13
  * [Post](#post)
14
+ * [Remove Data](#remove-data)
13
15
  * [Send Command](#send-command)
14
16
 
15
17
  <br/>
16
18
 
19
+ ## Delete
20
+
21
+ Delete devices
22
+
23
+ ```ruby
24
+ result = client.devices.delete(
25
+ applicationId: my_application_id,
26
+ options: my_options)
27
+
28
+ puts result
29
+ ```
30
+
31
+ #### Authentication
32
+ The client must be configured with a valid api access token to call this
33
+ action. The token must include at least one of the following scopes:
34
+ all.Application, all.Organization, all.User, devices.*, or devices.delete.
35
+
36
+ #### Available Parameters
37
+
38
+ | Name | Type | Required | Description | Default | Example |
39
+ | ---- | ---- | -------- | ----------- | ------- | ------- |
40
+ | applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
41
+ | options | [Devices Delete Post](_schemas.md#devices-delete-post) | Y | Object containing device query and email | | [Devices Delete Post Example](_schemas.md#devices-delete-post-example) |
42
+ | losantdomain | string | N | Domain scope of request (rarely needed) | | example.com |
43
+
44
+ #### Successful Responses
45
+
46
+ | Code | Type | Description |
47
+ | ---- | ---- | ----------- |
48
+ | 200 | [Devices Deleted](_schemas.md#devices-deleted) | Object indicating number of devices deleted or failed |
49
+ | 202 | [Job Enqueued API Result](_schemas.md#job-enqueued-api-result) | If a job was enqueued for the devices to be deleted |
50
+
51
+ #### Error Responses
52
+
53
+ | Code | Type | Description |
54
+ | ---- | ---- | ----------- |
55
+ | 400 | [Error](_schemas.md#error) | Error if malformed request |
56
+ | 404 | [Error](_schemas.md#error) | Error if application was not found |
57
+
58
+ <br/>
59
+
17
60
  ## Export
18
61
 
19
62
  Creates an export of all device metadata
@@ -36,6 +79,7 @@ all.Application, all.Application.read, all.Organization, all.Organization.read,
36
79
  | applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
37
80
  | email | string | N | Email address to send export to. Defaults to current user&#x27;s email. | | email@example.com |
38
81
  | callbackUrl | string | N | Callback URL to call with export result | | https://example.com/cburl |
82
+ | options | [Devices Metadata Export Post](_schemas.md#devices-metadata-export-post) | N | Object containing device query and optionally email or callback | | [Devices Metadata Export Post Example](_schemas.md#devices-metadata-export-post-example) |
39
83
  | losantdomain | string | N | Domain scope of request (rarely needed) | | example.com |
40
84
 
41
85
  #### Successful Responses
@@ -83,7 +127,7 @@ all.Application, all.Application.read, all.Device, all.Device.read, all.Organiza
83
127
  | tagFilter | [Device Tag Filter](_schemas.md#device-tag-filter) | N | Array of tag pairs to filter by | | [Device Tag Filter Example](_schemas.md#device-tag-filter-example) |
84
128
  | excludeConnectionInfo | string | N | If set, do not return connection info | | true |
85
129
  | parentId | string | N | Filter devices as children of a given system id | | 575ecf887ae143cd83dc4aa2 |
86
- | query | [Advanced Device Query](_schemas.md#advanced-device-query) | N | Device filter JSON object which overides the filterField, filter, deviceClass, tagFilter, and parentId parameters. | | [Advanced Device Query Example](_schemas.md#advanced-device-query-example) |
130
+ | query | [Advanced Device Query](_schemas.md#advanced-device-query) | N | Device filter JSON object which overrides the filterField, filter, deviceClass, tagFilter, and parentId parameters. | | [Advanced Device Query Example](_schemas.md#advanced-device-query-example) |
87
131
  | losantdomain | string | N | Domain scope of request (rarely needed) | | example.com |
88
132
 
89
133
  #### Successful Responses
@@ -121,14 +165,15 @@ all.Application, all.Organization, all.User, devices.*, or devices.patch.
121
165
  | Name | Type | Required | Description | Default | Example |
122
166
  | ---- | ---- | -------- | ----------- | ------- | ------- |
123
167
  | applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
124
- | patchInfo | [Devices Patch](_schemas.md#devices-patch) | N | Object containing device filter fields and updated properties | | [Devices Patch Example](_schemas.md#devices-patch-example) |
168
+ | patchInfo | [Devices Patch](_schemas.md#devices-patch) | N | Object containing device query or IDs and update operations | | [Devices Patch Example](_schemas.md#devices-patch-example) |
125
169
  | losantdomain | string | N | Domain scope of request (rarely needed) | | example.com |
126
170
 
127
171
  #### Successful Responses
128
172
 
129
173
  | Code | Type | Description |
130
174
  | ---- | ---- | ----------- |
131
- | 201 | [Success](_schemas.md#success) | Successfully queued bulk update job |
175
+ | 200 | [Devices Updated](_schemas.md#devices-updated) | Object including an update log link and the number of devices updated, failed, and skipped |
176
+ | 202 | [Job Enqueued API Result](_schemas.md#job-enqueued-api-result) | Successfully queued bulk update job |
132
177
 
133
178
  #### Error Responses
134
179
 
@@ -179,6 +224,47 @@ all.Application, all.Organization, all.User, devices.*, or devices.post.
179
224
 
180
225
  <br/>
181
226
 
227
+ ## Remove Data
228
+
229
+ Removes all device data for the specified time range. Defaults to all data.
230
+
231
+ ```ruby
232
+ result = client.devices.remove_data(
233
+ applicationId: my_application_id,
234
+ options: my_options)
235
+
236
+ puts result
237
+ ```
238
+
239
+ #### Authentication
240
+ The client must be configured with a valid api access token to call this
241
+ action. The token must include at least one of the following scopes:
242
+ all.Application, all.Organization, all.User, devices.*, or devices.removeData.
243
+
244
+ #### Available Parameters
245
+
246
+ | Name | Type | Required | Description | Default | Example |
247
+ | ---- | ---- | -------- | ----------- | ------- | ------- |
248
+ | applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
249
+ | options | [Devices Remove Data Post](_schemas.md#devices-remove-data-post) | Y | Object defining the device data to delete and devices to delete from | | [Devices Remove Data Post Example](_schemas.md#devices-remove-data-post-example) |
250
+ | losantdomain | string | N | Domain scope of request (rarely needed) | | example.com |
251
+
252
+ #### Successful Responses
253
+
254
+ | Code | Type | Description |
255
+ | ---- | ---- | ----------- |
256
+ | 200 | [Devices Data Removed](_schemas.md#devices-data-removed) | Object indicating number of devices completed or skipped |
257
+ | 202 | [Job Enqueued API Result](_schemas.md#job-enqueued-api-result) | If a job was enqueued for device data to be removed |
258
+
259
+ #### Error Responses
260
+
261
+ | Code | Type | Description |
262
+ | ---- | ---- | ----------- |
263
+ | 400 | [Error](_schemas.md#error) | Error if malformed request |
264
+ | 404 | [Error](_schemas.md#error) | Error if device was not found |
265
+
266
+ <br/>
267
+
182
268
  ## Send Command
183
269
 
184
270
  Send a command to multiple devices
@@ -27,7 +27,7 @@ module LosantRest
27
27
  #
28
28
  # User API for accessing Losant data
29
29
  #
30
- # Built For Version 1.17.1
30
+ # Built For Version 1.17.2
31
31
  class Client
32
32
  attr_accessor :auth_token, :url
33
33
 
@@ -278,7 +278,7 @@ module LosantRest
278
278
 
279
279
  headers["Accept"] = "application/json"
280
280
  headers["Content-Type"] = "application/json"
281
- headers["Accept-Version"] = "^1.17.1"
281
+ headers["Accept-Version"] = "^1.17.2"
282
282
  headers["Authorization"] = "Bearer #{self.auth_token}" if self.auth_token
283
283
  path = self.url + options.fetch(:path, "")
284
284
 
@@ -31,6 +31,54 @@ module LosantRest
31
31
  @client = client
32
32
  end
33
33
 
34
+ # Delete devices
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, devices.*, or devices.delete.
41
+ #
42
+ # Parameters:
43
+ # * {string} applicationId - ID associated with the application
44
+ # * {hash} options - Object containing device query and email (https://api.losant.com/#/definitions/devicesDeletePost)
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 - Object indicating number of devices deleted or failed (https://api.losant.com/#/definitions/devicesDeleted)
52
+ # * 202 - If a job was enqueued for the devices to be deleted (https://api.losant.com/#/definitions/jobEnqueuedResult)
53
+ #
54
+ # Errors:
55
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
56
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
57
+ def delete(params = {})
58
+ params = Utils.symbolize_hash_keys(params)
59
+ query_params = { _actions: false, _links: true, _embedded: true }
60
+ headers = {}
61
+ body = nil
62
+
63
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
64
+ raise ArgumentError.new("options is required") unless params.has_key?(:options)
65
+
66
+ body = params[:options] if params.has_key?(:options)
67
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
68
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
69
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
70
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
71
+
72
+ path = "/applications/#{params[:applicationId]}/devices/delete"
73
+
74
+ @client.request(
75
+ method: :post,
76
+ path: path,
77
+ query: query_params,
78
+ headers: headers,
79
+ body: body)
80
+ end
81
+
34
82
  # Creates an export of all device metadata
35
83
  #
36
84
  # Authentication:
@@ -43,6 +91,7 @@ module LosantRest
43
91
  # * {string} applicationId - ID associated with the application
44
92
  # * {string} email - Email address to send export to. Defaults to current user's email.
45
93
  # * {string} callbackUrl - Callback URL to call with export result
94
+ # * {hash} options - Object containing device query and optionally email or callback (https://api.losant.com/#/definitions/devicesExportPost)
46
95
  # * {string} losantdomain - Domain scope of request (rarely needed)
47
96
  # * {boolean} _actions - Return resource actions in response
48
97
  # * {boolean} _links - Return resource link in response
@@ -64,6 +113,7 @@ module LosantRest
64
113
 
65
114
  query_params[:email] = params[:email] if params.has_key?(:email)
66
115
  query_params[:callbackUrl] = params[:callbackUrl] if params.has_key?(:callbackUrl)
116
+ body = params[:options] if params.has_key?(:options)
67
117
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
68
118
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
69
119
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
@@ -99,7 +149,7 @@ module LosantRest
99
149
  # * {hash} tagFilter - Array of tag pairs to filter by (https://api.losant.com/#/definitions/deviceTagFilter)
100
150
  # * {string} excludeConnectionInfo - If set, do not return connection info
101
151
  # * {string} parentId - Filter devices as children of a given system id
102
- # * {hash} query - Device filter JSON object which overides the filterField, filter, deviceClass, tagFilter, and parentId parameters. (https://api.losant.com/#/definitions/advancedDeviceQuery)
152
+ # * {hash} query - Device filter JSON object which overrides the filterField, filter, deviceClass, tagFilter, and parentId parameters. (https://api.losant.com/#/definitions/advancedDeviceQuery)
103
153
  # * {string} losantdomain - Domain scope of request (rarely needed)
104
154
  # * {boolean} _actions - Return resource actions in response
105
155
  # * {boolean} _links - Return resource link in response
@@ -156,14 +206,15 @@ module LosantRest
156
206
  #
157
207
  # Parameters:
158
208
  # * {string} applicationId - ID associated with the application
159
- # * {hash} patchInfo - Object containing device filter fields and updated properties (https://api.losant.com/#/definitions/devicesPatch)
209
+ # * {hash} patchInfo - Object containing device query or IDs and update operations (https://api.losant.com/#/definitions/devicesPatch)
160
210
  # * {string} losantdomain - Domain scope of request (rarely needed)
161
211
  # * {boolean} _actions - Return resource actions in response
162
212
  # * {boolean} _links - Return resource link in response
163
213
  # * {boolean} _embedded - Return embedded resources in response
164
214
  #
165
215
  # Responses:
166
- # * 201 - Successfully queued bulk update job (https://api.losant.com/#/definitions/success)
216
+ # * 200 - Object including an update log link and the number of devices updated, failed, and skipped (https://api.losant.com/#/definitions/devicesUpdated)
217
+ # * 202 - Successfully queued bulk update job (https://api.losant.com/#/definitions/jobEnqueuedResult)
167
218
  #
168
219
  # Errors:
169
220
  # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
@@ -239,6 +290,54 @@ module LosantRest
239
290
  body: body)
240
291
  end
241
292
 
293
+ # Removes all device data for the specified time range. Defaults to all data.
294
+ #
295
+ # Authentication:
296
+ # The client must be configured with a valid api
297
+ # access token to call this action. The token
298
+ # must include at least one of the following scopes:
299
+ # all.Application, all.Organization, all.User, devices.*, or devices.removeData.
300
+ #
301
+ # Parameters:
302
+ # * {string} applicationId - ID associated with the application
303
+ # * {hash} options - Object defining the device data to delete and devices to delete from (https://api.losant.com/#/definitions/devicesRemoveDataPost)
304
+ # * {string} losantdomain - Domain scope of request (rarely needed)
305
+ # * {boolean} _actions - Return resource actions in response
306
+ # * {boolean} _links - Return resource link in response
307
+ # * {boolean} _embedded - Return embedded resources in response
308
+ #
309
+ # Responses:
310
+ # * 200 - Object indicating number of devices completed or skipped (https://api.losant.com/#/definitions/devicesDataRemoved)
311
+ # * 202 - If a job was enqueued for device data to be removed (https://api.losant.com/#/definitions/jobEnqueuedResult)
312
+ #
313
+ # Errors:
314
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
315
+ # * 404 - Error if device was not found (https://api.losant.com/#/definitions/error)
316
+ def remove_data(params = {})
317
+ params = Utils.symbolize_hash_keys(params)
318
+ query_params = { _actions: false, _links: true, _embedded: true }
319
+ headers = {}
320
+ body = nil
321
+
322
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
323
+ raise ArgumentError.new("options is required") unless params.has_key?(:options)
324
+
325
+ body = params[:options] if params.has_key?(:options)
326
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
327
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
328
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
329
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
330
+
331
+ path = "/applications/#{params[:applicationId]}/devices/removeData"
332
+
333
+ @client.request(
334
+ method: :post,
335
+ path: path,
336
+ query: query_params,
337
+ headers: headers,
338
+ body: body)
339
+ end
340
+
242
341
  # Send a command to multiple devices
243
342
  #
244
343
  # Authentication:
@@ -21,5 +21,5 @@
21
21
  # SOFTWARE.
22
22
 
23
23
  module LosantRest
24
- VERSION = "1.10.1"
24
+ VERSION = "1.10.2"
25
25
  end
@@ -159,6 +159,28 @@
159
159
  },
160
160
  "$ci": {
161
161
  "type": "boolean"
162
+ },
163
+ "$in": {
164
+ "type": "array",
165
+ "maxItems": 100,
166
+ "items": {
167
+ "type": [
168
+ "string",
169
+ "number",
170
+ "boolean"
171
+ ]
172
+ }
173
+ },
174
+ "$nin": {
175
+ "type": "array",
176
+ "maxItems": 100,
177
+ "items": {
178
+ "type": [
179
+ "string",
180
+ "number",
181
+ "boolean"
182
+ ]
183
+ }
162
184
  }
163
185
  },
164
186
  "additionalProperties": false
@@ -240,6 +262,28 @@
240
262
  },
241
263
  "$ci": {
242
264
  "type": "boolean"
265
+ },
266
+ "$in": {
267
+ "type": "array",
268
+ "maxItems": 100,
269
+ "items": {
270
+ "type": [
271
+ "string",
272
+ "number",
273
+ "boolean"
274
+ ]
275
+ }
276
+ },
277
+ "$nin": {
278
+ "type": "array",
279
+ "maxItems": 100,
280
+ "items": {
281
+ "type": [
282
+ "string",
283
+ "number",
284
+ "boolean"
285
+ ]
286
+ }
243
287
  }
244
288
  },
245
289
  "additionalProperties": false
@@ -321,6 +365,28 @@
321
365
  },
322
366
  "$ci": {
323
367
  "type": "boolean"
368
+ },
369
+ "$in": {
370
+ "type": "array",
371
+ "maxItems": 100,
372
+ "items": {
373
+ "type": [
374
+ "string",
375
+ "number",
376
+ "boolean"
377
+ ]
378
+ }
379
+ },
380
+ "$nin": {
381
+ "type": "array",
382
+ "maxItems": 100,
383
+ "items": {
384
+ "type": [
385
+ "string",
386
+ "number",
387
+ "boolean"
388
+ ]
389
+ }
324
390
  }
325
391
  },
326
392
  "additionalProperties": false
@@ -402,6 +468,28 @@
402
468
  },
403
469
  "$ci": {
404
470
  "type": "boolean"
471
+ },
472
+ "$in": {
473
+ "type": "array",
474
+ "maxItems": 100,
475
+ "items": {
476
+ "type": [
477
+ "string",
478
+ "number",
479
+ "boolean"
480
+ ]
481
+ }
482
+ },
483
+ "$nin": {
484
+ "type": "array",
485
+ "maxItems": 100,
486
+ "items": {
487
+ "type": [
488
+ "string",
489
+ "number",
490
+ "boolean"
491
+ ]
492
+ }
405
493
  }
406
494
  },
407
495
  "additionalProperties": false
@@ -666,6 +754,28 @@
666
754
  },
667
755
  "$ci": {
668
756
  "type": "boolean"
757
+ },
758
+ "$in": {
759
+ "type": "array",
760
+ "maxItems": 100,
761
+ "items": {
762
+ "type": [
763
+ "string",
764
+ "number",
765
+ "boolean"
766
+ ]
767
+ }
768
+ },
769
+ "$nin": {
770
+ "type": "array",
771
+ "maxItems": 100,
772
+ "items": {
773
+ "type": [
774
+ "string",
775
+ "number",
776
+ "boolean"
777
+ ]
778
+ }
669
779
  }
670
780
  },
671
781
  "additionalProperties": false