losant_rest 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/docs/device.md CHANGED
@@ -10,6 +10,7 @@ parameters and the potential responses.
10
10
  * [Export](#export)
11
11
  * [Get](#get)
12
12
  * [Get Command](#get-command)
13
+ * [Get Composite State](#get-composite-state)
13
14
  * [Get Log Entries](#get-log-entries)
14
15
  * [Get State](#get-state)
15
16
  * [Patch](#patch)
@@ -55,7 +56,7 @@ puts result
55
56
 
56
57
  ## Export
57
58
 
58
- Creates a device data export (to be emailed to the requestor). Defaults to all data.
59
+ Creates a device data export. Defaults to all data.
59
60
 
60
61
  ```ruby
61
62
  result = client.device.export(
@@ -73,6 +74,8 @@ puts result
73
74
  | deviceId | string | Y | ID associated with the device | | 575ecf887ae143cd83dc4aa2 |
74
75
  | start | string | N | Start time of export (ms since epoch - 0 means now, negative is relative to now) | 1 | 1465790400000 |
75
76
  | end | string | N | End time of export (ms since epoch - 0 means now, negative is relative to now) | 0 | 1465790400000 |
77
+ | email | string | N | Email address to send export to. Defaults to current user's email. | | email@example.com |
78
+ | callbackUrl | string | N | Callback URL to call with export result. | | https://example.com/cburl |
76
79
 
77
80
  #### Successful Responses
78
81
 
@@ -159,6 +162,42 @@ puts result
159
162
 
160
163
  <br/>
161
164
 
165
+ ## Get Composite State
166
+
167
+ Retrieve the composite last complete state of the device
168
+
169
+ ```ruby
170
+ result = client.device.get_composite_state(
171
+ applicationId: my_application_id,
172
+ deviceId: my_device_id)
173
+
174
+ puts result
175
+ ```
176
+
177
+ #### Available Parameters
178
+
179
+ | Name | Type | Required | Description | Default | Example |
180
+ | ---- | ---- | -------- | ----------- | ------- | ------- |
181
+ | applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
182
+ | deviceId | string | Y | ID associated with the device | | 575ecf887ae143cd83dc4aa2 |
183
+ | start | string | N | Start of time range to look at to build composite state | 1 | 1465790400000 |
184
+ | end | string | N | End of time range to look at to build composite state | 0 | 1465790400000 |
185
+
186
+ #### Successful Responses
187
+
188
+ | Code | Type | Description |
189
+ | ---- | ---- | ----------- |
190
+ | 200 | [Composite Device State](_schemas.md#composite-device-state) | Composite last state of the device |
191
+
192
+ #### Error Responses
193
+
194
+ | Code | Type | Description |
195
+ | ---- | ---- | ----------- |
196
+ | 400 | [Error](_schemas.md#error) | Error if malformed request |
197
+ | 404 | [Error](_schemas.md#error) | Error if device was not found |
198
+
199
+ <br/>
200
+
162
201
  ## Get Log Entries
163
202
 
164
203
  Retrieve the recent log entries about the device
data/docs/me.md CHANGED
@@ -16,6 +16,7 @@ parameters and the potential responses.
16
16
  * [Get](#get)
17
17
  * [Patch](#patch)
18
18
  * [Payload Counts](#payload-counts)
19
+ * [Transfer Resources](#transfer-resources)
19
20
  * [Verify Email](#verify-email)
20
21
 
21
22
  <br/>
@@ -211,7 +212,7 @@ puts result
211
212
  | Name | Type | Required | Description | Default | Example |
212
213
  | ---- | ---- | -------- | ----------- | ------- | ------- |
213
214
  | parentId | string | N | Parent id of the recent list | | 575ec8687ae143cd83dc4a97 |
214
- | itemType | undefined | Y | Item type to get the recent list of. Accepted values are: application, device, flow, dashboard | | application |
215
+ | itemType | undefined | Y | Item type to get the recent list of. Accepted values are: application, device, flow, dashboard, organization | | application |
215
216
 
216
217
  #### Successful Responses
217
218
 
@@ -300,8 +301,8 @@ puts result
300
301
 
301
302
  | Name | Type | Required | Description | Default | Example |
302
303
  | ---- | ---- | -------- | ----------- | ------- | ------- |
303
- | start | string | N | Start of range for payload count query (ms since epoch) | -2592000000 | 0 |
304
- | end | string | N | End of range for payload count query (ms since epoch) | 0 | 1465790400000 |
304
+ | start | string | N | Start of range for payload count query (ms since epoch) | | 0 |
305
+ | end | string | N | End of range for payload count query (ms since epoch) | | 1465790400000 |
305
306
 
306
307
  #### Successful Responses
307
308
 
@@ -314,7 +315,36 @@ puts result
314
315
  | Code | Type | Description |
315
316
  | ---- | ---- | ----------- |
316
317
  | 400 | [Error](_schemas.md#error) | Error if malformed request |
317
- | 404 | [Error](_schemas.md#error) | Error if application was not found |
318
+
319
+ <br/>
320
+
321
+ ## Transfer Resources
322
+
323
+ Moves resources to a new owner
324
+
325
+ ```ruby
326
+ result = client.me.transfer_resources(transfer: my_transfer)
327
+
328
+ puts result
329
+ ```
330
+
331
+ #### Available Parameters
332
+
333
+ | Name | Type | Required | Description | Default | Example |
334
+ | ---- | ---- | -------- | ----------- | ------- | ------- |
335
+ | transfer | [Resource Transfer](_schemas.md#resource-transfer) | Y | Object containing properties of the transfer | | [Resource Transfer Example](_schemas.md#resource-transfer-example) |
336
+
337
+ #### Successful Responses
338
+
339
+ | Code | Type | Description |
340
+ | ---- | ---- | ----------- |
341
+ | 200 | [Success](_schemas.md#success) | If resource transfer was successful |
342
+
343
+ #### Error Responses
344
+
345
+ | Code | Type | Description |
346
+ | ---- | ---- | ----------- |
347
+ | 400 | [Error](_schemas.md#error) | Error if malformed request |
318
348
 
319
349
  <br/>
320
350
 
data/docs/org.md CHANGED
@@ -15,6 +15,7 @@ parameters and the potential responses.
15
15
  * [Pending Invites](#pending-invites)
16
16
  * [Remove Member](#remove-member)
17
17
  * [Revoke Invite](#revoke-invite)
18
+ * [Transfer Resources](#transfer-resources)
18
19
 
19
20
  <br/>
20
21
 
@@ -197,8 +198,8 @@ puts result
197
198
  | Name | Type | Required | Description | Default | Example |
198
199
  | ---- | ---- | -------- | ----------- | ------- | ------- |
199
200
  | orgId | string | Y | ID associated with the organization | | 575ed6e87ae143cd83dc4aa8 |
200
- | start | string | N | Start of range for payload count query (ms since epoch) | -2592000000 | 0 |
201
- | end | string | N | End of range for payload count query (ms since epoch) | 0 | 1465790400000 |
201
+ | start | string | N | Start of range for payload count query (ms since epoch) | | 0 |
202
+ | end | string | N | End of range for payload count query (ms since epoch) | | 1465790400000 |
202
203
 
203
204
  #### Successful Responses
204
205
 
@@ -211,7 +212,7 @@ puts result
211
212
  | Code | Type | Description |
212
213
  | ---- | ---- | ----------- |
213
214
  | 400 | [Error](_schemas.md#error) | Error if malformed request |
214
- | 404 | [Error](_schemas.md#error) | Error if application was not found |
215
+ | 404 | [Error](_schemas.md#error) | Error if organization was not found |
215
216
 
216
217
  <br/>
217
218
 
@@ -311,3 +312,37 @@ puts result
311
312
  | ---- | ---- | ----------- |
312
313
  | 400 | [Error](_schemas.md#error) | Error if malformed request |
313
314
  | 404 | [Error](_schemas.md#error) | Error if organization not found |
315
+
316
+ <br/>
317
+
318
+ ## Transfer Resources
319
+
320
+ Moves resources to a new owner
321
+
322
+ ```ruby
323
+ result = client.org.transfer_resources(
324
+ orgId: my_org_id,
325
+ transfer: my_transfer)
326
+
327
+ puts result
328
+ ```
329
+
330
+ #### Available Parameters
331
+
332
+ | Name | Type | Required | Description | Default | Example |
333
+ | ---- | ---- | -------- | ----------- | ------- | ------- |
334
+ | orgId | string | Y | ID associated with the organization | | 575ed6e87ae143cd83dc4aa8 |
335
+ | transfer | [Resource Transfer](_schemas.md#resource-transfer) | Y | Object containing properties of the transfer | | [Resource Transfer Example](_schemas.md#resource-transfer-example) |
336
+
337
+ #### Successful Responses
338
+
339
+ | Code | Type | Description |
340
+ | ---- | ---- | ----------- |
341
+ | 200 | [Success](_schemas.md#success) | If resource transfer was successful |
342
+
343
+ #### Error Responses
344
+
345
+ | Code | Type | Description |
346
+ | ---- | ---- | ----------- |
347
+ | 400 | [Error](_schemas.md#error) | Error if malformed request |
348
+ | 404 | [Error](_schemas.md#error) | Error if organization was not found |
@@ -5,7 +5,7 @@ module LosantRest
5
5
  #
6
6
  # User API for accessing Losant data
7
7
  #
8
- # Built For Version 1.4.10
8
+ # Built For Version 1.5.0
9
9
  class Client
10
10
  attr_accessor :auth_token, :url
11
11
 
@@ -128,7 +128,7 @@ module LosantRest
128
128
 
129
129
  headers["Accept"] = "application/json"
130
130
  headers["Content-Type"] = "application/json"
131
- headers["Accept-Version"] = "^1.4.10"
131
+ headers["Accept-Version"] = "^1.5.0"
132
132
  headers["Authorization"] = "Bearer #{self.auth_token}" if self.auth_token
133
133
  path = self.url + options.fetch(:path, "")
134
134
 
@@ -47,13 +47,15 @@ module LosantRest
47
47
  body: body)
48
48
  end
49
49
 
50
- # Creates a device data export (to be emailed to the requestor). Defaults to all data.
50
+ # Creates a device data export. Defaults to all data.
51
51
  #
52
52
  # Parameters:
53
53
  # * {string} applicationId - ID associated with the application
54
54
  # * {string} deviceId - ID associated with the device
55
55
  # * {string} start - Start time of export (ms since epoch - 0 means now, negative is relative to now)
56
56
  # * {string} end - End time of export (ms since epoch - 0 means now, negative is relative to now)
57
+ # * {string} email - Email address to send export to. Defaults to current user&#x27;s email.
58
+ # * {string} callbackUrl - Callback URL to call with export result.
57
59
  # * {string} losantdomain - Domain scope of request (rarely needed)
58
60
  # * {boolean} _actions - Return resource actions in response
59
61
  # * {boolean} _links - Return resource link in response
@@ -76,6 +78,8 @@ module LosantRest
76
78
 
77
79
  query_params[:start] = params[:start] if params.has_key?(:start)
78
80
  query_params[:end] = params[:end] if params.has_key?(:end)
81
+ query_params[:email] = params[:email] if params.has_key?(:email)
82
+ query_params[:callbackUrl] = params[:callbackUrl] if params.has_key?(:callbackUrl)
79
83
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
80
84
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
81
85
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
@@ -175,6 +179,50 @@ module LosantRest
175
179
  body: body)
176
180
  end
177
181
 
182
+ # Retrieve the composite last complete state of the device
183
+ #
184
+ # Parameters:
185
+ # * {string} applicationId - ID associated with the application
186
+ # * {string} deviceId - ID associated with the device
187
+ # * {string} start - Start of time range to look at to build composite state
188
+ # * {string} end - End of time range to look at to build composite state
189
+ # * {string} losantdomain - Domain scope of request (rarely needed)
190
+ # * {boolean} _actions - Return resource actions in response
191
+ # * {boolean} _links - Return resource link in response
192
+ # * {boolean} _embedded - Return embedded resources in response
193
+ #
194
+ # Responses:
195
+ # * 200 - Composite last state of the device (https://api.losant.com/#/definitions/compositeDeviceState)
196
+ #
197
+ # Errors:
198
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
199
+ # * 404 - Error if device was not found (https://api.losant.com/#/definitions/error)
200
+ def get_composite_state(params = {})
201
+ params = Utils.symbolize_hash_keys(params)
202
+ query_params = { _actions: false, _links: true, _embedded: true }
203
+ headers = {}
204
+ body = nil
205
+
206
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
207
+ raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId)
208
+
209
+ query_params[:start] = params[:start] if params.has_key?(:start)
210
+ query_params[:end] = params[:end] if params.has_key?(:end)
211
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
212
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
213
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
214
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
215
+
216
+ path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/compositeState"
217
+
218
+ @client.request(
219
+ method: :get,
220
+ path: path,
221
+ query: query_params,
222
+ headers: headers,
223
+ body: body)
224
+ end
225
+
178
226
  # Retrieve the recent log entries about the device
179
227
  #
180
228
  # Parameters:
@@ -233,7 +233,7 @@ module LosantRest
233
233
  #
234
234
  # Parameters:
235
235
  # * {string} parentId - Parent id of the recent list
236
- # * {undefined} itemType - Item type to get the recent list of. Accepted values are: application, device, flow, dashboard
236
+ # * {undefined} itemType - Item type to get the recent list of. Accepted values are: application, device, flow, dashboard, organization
237
237
  # * {string} losantdomain - Domain scope of request (rarely needed)
238
238
  # * {boolean} _actions - Return resource actions in response
239
239
  # * {boolean} _links - Return resource link in response
@@ -358,7 +358,6 @@ module LosantRest
358
358
  #
359
359
  # Errors:
360
360
  # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
361
- # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
362
361
  def payload_counts(params = {})
363
362
  params = Utils.symbolize_hash_keys(params)
364
363
  query_params = { _actions: false, _links: true, _embedded: true }
@@ -383,6 +382,44 @@ module LosantRest
383
382
  body: body)
384
383
  end
385
384
 
385
+ # Moves resources to a new owner
386
+ #
387
+ # Parameters:
388
+ # * {hash} transfer - Object containing properties of the transfer (https://api.losant.com/#/definitions/resourceTransfer)
389
+ # * {string} losantdomain - Domain scope of request (rarely needed)
390
+ # * {boolean} _actions - Return resource actions in response
391
+ # * {boolean} _links - Return resource link in response
392
+ # * {boolean} _embedded - Return embedded resources in response
393
+ #
394
+ # Responses:
395
+ # * 200 - If resource transfer was successful (https://api.losant.com/#/definitions/success)
396
+ #
397
+ # Errors:
398
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
399
+ def transfer_resources(params = {})
400
+ params = Utils.symbolize_hash_keys(params)
401
+ query_params = { _actions: false, _links: true, _embedded: true }
402
+ headers = {}
403
+ body = nil
404
+
405
+ raise ArgumentError.new("transfer is required") unless params.has_key?(:transfer)
406
+
407
+ body = params[:transfer] if params.has_key?(:transfer)
408
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
409
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
410
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
411
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
412
+
413
+ path = "/me/transferResources"
414
+
415
+ @client.request(
416
+ method: :patch,
417
+ path: path,
418
+ query: query_params,
419
+ headers: headers,
420
+ body: body)
421
+ end
422
+
386
423
  # Sends an email verification to the user
387
424
  #
388
425
  # Parameters:
@@ -222,7 +222,7 @@ module LosantRest
222
222
  #
223
223
  # Errors:
224
224
  # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
225
- # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
225
+ # * 404 - Error if organization was not found (https://api.losant.com/#/definitions/error)
226
226
  def payload_counts(params = {})
227
227
  params = Utils.symbolize_hash_keys(params)
228
228
  query_params = { _actions: false, _links: true, _embedded: true }
@@ -368,5 +368,46 @@ module LosantRest
368
368
  body: body)
369
369
  end
370
370
 
371
+ # Moves resources to a new owner
372
+ #
373
+ # Parameters:
374
+ # * {string} orgId - ID associated with the organization
375
+ # * {hash} transfer - Object containing properties of the transfer (https://api.losant.com/#/definitions/resourceTransfer)
376
+ # * {string} losantdomain - Domain scope of request (rarely needed)
377
+ # * {boolean} _actions - Return resource actions in response
378
+ # * {boolean} _links - Return resource link in response
379
+ # * {boolean} _embedded - Return embedded resources in response
380
+ #
381
+ # Responses:
382
+ # * 200 - If resource transfer was successful (https://api.losant.com/#/definitions/success)
383
+ #
384
+ # Errors:
385
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
386
+ # * 404 - Error if organization was not found (https://api.losant.com/#/definitions/error)
387
+ def transfer_resources(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("orgId is required") unless params.has_key?(:orgId)
394
+ raise ArgumentError.new("transfer is required") unless params.has_key?(:transfer)
395
+
396
+ body = params[:transfer] if params.has_key?(:transfer)
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 = "/orgs/#{params[:orgId]}/transferResources"
403
+
404
+ @client.request(
405
+ method: :patch,
406
+ path: path,
407
+ query: query_params,
408
+ headers: headers,
409
+ body: body)
410
+ end
411
+
371
412
  end
372
413
  end
@@ -1,3 +1,3 @@
1
1
  module LosantRest
2
- VERSION = "1.0.5"
2
+ VERSION = "1.0.6"
3
3
  end
@@ -0,0 +1,44 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema#",
3
+ "type": "object",
4
+ "patternProperties": {
5
+ "^[0-9a-zA-Z_-]{1,255}$": {
6
+ "type": "object",
7
+ "properties": {
8
+ "value": {
9
+ "type": [
10
+ "number",
11
+ "string",
12
+ "boolean"
13
+ ]
14
+ },
15
+ "time": {
16
+ "oneOf": [
17
+ {
18
+ "type": "string"
19
+ },
20
+ {
21
+ "type": "number"
22
+ },
23
+ {
24
+ "type": "object",
25
+ "properties": {
26
+ "$date": {
27
+ "type": "string"
28
+ }
29
+ },
30
+ "additionalProperties": false,
31
+ "required": [
32
+ "$date"
33
+ ]
34
+ }
35
+ ]
36
+ },
37
+ "relayId": {
38
+ "type": "string"
39
+ }
40
+ }
41
+ }
42
+ },
43
+ "additionalProperties": false
44
+ }