losant_rest 1.9.2 → 1.10.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/docs/_schemas.md +38445 -24043
  3. data/docs/application.md +124 -2
  4. data/docs/applicationTemplates.md +50 -0
  5. data/docs/auth.md +72 -0
  6. data/docs/device.md +1 -0
  7. data/docs/devices.md +92 -3
  8. data/docs/experienceEndpoints.md +1 -0
  9. data/docs/file.md +4 -4
  10. data/docs/flow.md +94 -1
  11. data/docs/flowVersion.md +96 -1
  12. data/lib/losant_rest.rb +1 -0
  13. data/lib/losant_rest/application.rb +93 -2
  14. data/lib/losant_rest/application_templates.rb +88 -0
  15. data/lib/losant_rest/auth.rb +84 -0
  16. data/lib/losant_rest/client.rb +6 -2
  17. data/lib/losant_rest/device.rb +2 -0
  18. data/lib/losant_rest/devices.rb +105 -2
  19. data/lib/losant_rest/experience_endpoints.rb +2 -0
  20. data/lib/losant_rest/file.rb +3 -3
  21. data/lib/losant_rest/flow.rb +115 -1
  22. data/lib/losant_rest/flow_version.rb +115 -1
  23. data/lib/losant_rest/version.rb +2 -2
  24. data/schemas/advancedDeviceQuery.json +1018 -0
  25. data/schemas/advancedEventQuery.json +382 -13
  26. data/schemas/advancedQuery.json +37 -3
  27. data/schemas/application.json +7 -2
  28. data/schemas/applicationApiTokenPost.json +8 -1
  29. data/schemas/applicationCreationByTemplateResult.json +7 -2
  30. data/schemas/applicationPatch.json +7 -2
  31. data/schemas/applicationPost.json +11 -2
  32. data/schemas/applicationReadme.json +29 -0
  33. data/schemas/applicationReadmePatch.json +11 -0
  34. data/schemas/applicationTemplate.json +99 -0
  35. data/schemas/applicationTemplates.json +140 -0
  36. data/schemas/applications.json +7 -2
  37. data/schemas/dashboard.json +1168 -144
  38. data/schemas/dashboardPatch.json +1168 -144
  39. data/schemas/dashboardPost.json +1168 -144
  40. data/schemas/dashboards.json +1168 -144
  41. data/schemas/dataExport.json +11 -0
  42. data/schemas/dataTableRows.json +3 -0
  43. data/schemas/dataTableRowsExport.json +37 -3
  44. data/schemas/device.json +16 -3
  45. data/schemas/devicePatch.json +16 -3
  46. data/schemas/devicePost.json +16 -3
  47. data/schemas/deviceRecipe.json +16 -3
  48. data/schemas/deviceRecipePatch.json +16 -3
  49. data/schemas/deviceRecipePost.json +16 -3
  50. data/schemas/deviceRecipes.json +16 -3
  51. data/schemas/devices.json +19 -3
  52. data/schemas/devicesDataRemoved.json +12 -0
  53. data/schemas/devicesDeletePost.json +1034 -0
  54. data/schemas/devicesDeleted.json +12 -0
  55. data/schemas/devicesExportPost.json +1035 -0
  56. data/schemas/devicesPatch.json +1773 -7
  57. data/schemas/devicesRemoveDataPost.json +1056 -0
  58. data/schemas/devicesUpdated.json +18 -0
  59. data/schemas/eventPost.json +22 -0
  60. data/schemas/events.json +1 -816
  61. data/schemas/eventsExport.json +382 -13
  62. data/schemas/experienceDomain.json +1 -1
  63. data/schemas/experienceDomainPatch.json +1 -1
  64. data/schemas/experienceDomainPost.json +1 -1
  65. data/schemas/experienceDomains.json +1 -1
  66. data/schemas/experienceGroup.json +7 -0
  67. data/schemas/experienceGroupPatch.json +7 -0
  68. data/schemas/experienceGroupPost.json +7 -0
  69. data/schemas/experienceGroups.json +7 -0
  70. data/schemas/experienceLinkedResources.json +309 -3
  71. data/schemas/experienceVersion.json +1 -1
  72. data/schemas/experienceVersions.json +1 -1
  73. data/schemas/flow.json +103 -1
  74. data/schemas/flowErrors.json +87 -0
  75. data/schemas/flowPatch.json +103 -1
  76. data/schemas/flowPost.json +103 -1
  77. data/schemas/flowStats.json +54 -0
  78. data/schemas/flowVersion.json +206 -2
  79. data/schemas/flowVersionPost.json +103 -1
  80. data/schemas/flowVersions.json +206 -2
  81. data/schemas/flows.json +103 -1
  82. data/schemas/flowsImportPost.json +206 -2
  83. data/schemas/flowsImportResult.json +309 -3
  84. data/schemas/githubLogin.json +10 -1
  85. data/schemas/me.json +3 -0
  86. data/schemas/multiDeviceCommand.json +1019 -0
  87. data/schemas/notebook.json +99 -2
  88. data/schemas/notebookPatch.json +99 -2
  89. data/schemas/notebookPost.json +99 -2
  90. data/schemas/notebooks.json +99 -2
  91. data/schemas/org.json +8 -0
  92. data/schemas/orgPatch.json +9 -0
  93. data/schemas/orgs.json +8 -0
  94. data/schemas/samlResponse.json +21 -0
  95. data/schemas/ssoRequest.json +20 -0
  96. data/schemas/timeSeriesData.json +91 -12
  97. data/schemas/timeSeriesQuery.json +21 -12
  98. data/schemas/userCredentials.json +10 -1
  99. data/schemas/userPost.json +10 -1
  100. metadata +20 -4
@@ -157,5 +157,89 @@ module LosantRest
157
157
  body: body)
158
158
  end
159
159
 
160
+ # Authenticates a user via a SAML response.
161
+ #
162
+ # Authentication:
163
+ # No api access token is required to call this action.
164
+ #
165
+ # Parameters:
166
+ # * {hash} saml - Encoded SAML response from an IDP for a user. (https://api.losant.com/#/definitions/samlResponse)
167
+ # * {string} losantdomain - Domain scope of request (rarely needed)
168
+ # * {boolean} _actions - Return resource actions in response
169
+ # * {boolean} _links - Return resource link in response
170
+ # * {boolean} _embedded - Return embedded resources in response
171
+ #
172
+ # Responses:
173
+ # * 200 - Successful authentication. The included api access token has the scope 'all.User'. (https://api.losant.com/#/definitions/authedUser)
174
+ #
175
+ # Errors:
176
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
177
+ # * 401 - Unauthorized error if authentication fails (https://api.losant.com/#/definitions/error)
178
+ def authenticate_user_saml(params = {})
179
+ params = Utils.symbolize_hash_keys(params)
180
+ query_params = { _actions: false, _links: true, _embedded: true }
181
+ headers = {}
182
+ body = nil
183
+
184
+ raise ArgumentError.new("saml is required") unless params.has_key?(:saml)
185
+
186
+ body = params[:saml] if params.has_key?(:saml)
187
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
188
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
189
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
190
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
191
+
192
+ path = "/auth/user/saml"
193
+
194
+ @client.request(
195
+ method: :post,
196
+ path: path,
197
+ query: query_params,
198
+ headers: headers,
199
+ body: body)
200
+ end
201
+
202
+ # Checks email domain for SSO configuration.
203
+ #
204
+ # Authentication:
205
+ # No api access token is required to call this action.
206
+ #
207
+ # Parameters:
208
+ # * {string} email - The email address associated with the user login
209
+ # * {string} losantdomain - Domain scope of request (rarely needed)
210
+ # * {boolean} _actions - Return resource actions in response
211
+ # * {boolean} _links - Return resource link in response
212
+ # * {boolean} _embedded - Return embedded resources in response
213
+ #
214
+ # Responses:
215
+ # * 200 - Successful finding SSO for domain. Returns SSO request URL and type. (https://api.losant.com/#/definitions/ssoRequest)
216
+ # * 204 - No domain associated with an SSO configuration
217
+ #
218
+ # Errors:
219
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
220
+ def sso_domain(params = {})
221
+ params = Utils.symbolize_hash_keys(params)
222
+ query_params = { _actions: false, _links: true, _embedded: true }
223
+ headers = {}
224
+ body = nil
225
+
226
+ raise ArgumentError.new("email is required") unless params.has_key?(:email)
227
+
228
+ query_params[:email] = params[:email] if params.has_key?(:email)
229
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
230
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
231
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
232
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
233
+
234
+ path = "/auth/ssoDomain"
235
+
236
+ @client.request(
237
+ method: :get,
238
+ path: path,
239
+ query: query_params,
240
+ headers: headers,
241
+ body: body)
242
+ end
243
+
160
244
  end
161
245
  end
@@ -27,7 +27,7 @@ module LosantRest
27
27
  #
28
28
  # User API for accessing Losant data
29
29
  #
30
- # Built For Version 1.16.2
30
+ # Built For Version 1.17.3
31
31
  class Client
32
32
  attr_accessor :auth_token, :url
33
33
 
@@ -72,6 +72,10 @@ module LosantRest
72
72
  @application_keys ||= ApplicationKeys.new(self)
73
73
  end
74
74
 
75
+ def application_templates
76
+ @application_templates ||= ApplicationTemplates.new(self)
77
+ end
78
+
75
79
  def applications
76
80
  @applications ||= Applications.new(self)
77
81
  end
@@ -274,7 +278,7 @@ module LosantRest
274
278
 
275
279
  headers["Accept"] = "application/json"
276
280
  headers["Content-Type"] = "application/json"
277
- headers["Accept-Version"] = "^1.16.2"
281
+ headers["Accept-Version"] = "^1.17.3"
278
282
  headers["Authorization"] = "Bearer #{self.auth_token}" if self.auth_token
279
283
  path = self.url + options.fetch(:path, "")
280
284
 
@@ -92,6 +92,7 @@ module LosantRest
92
92
  # * {string} end - End time of export (ms since epoch - 0 means now, negative is relative to now)
93
93
  # * {string} email - Email address to send export to. Defaults to current user's email.
94
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.
95
96
  # * {string} losantdomain - Domain scope of request (rarely needed)
96
97
  # * {boolean} _actions - Return resource actions in response
97
98
  # * {boolean} _links - Return resource link in response
@@ -116,6 +117,7 @@ module LosantRest
116
117
  query_params[:end] = params[:end] if params.has_key?(:end)
117
118
  query_params[:email] = params[:email] if params.has_key?(:email)
118
119
  query_params[:callbackUrl] = params[:callbackUrl] if params.has_key?(:callbackUrl)
120
+ query_params[:includeBlobData] = params[:includeBlobData] if params.has_key?(:includeBlobData)
119
121
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
120
122
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
121
123
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
@@ -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,6 +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
152
+ # * {hash} query - Device filter JSON object which overrides the filterField, filter, deviceClass, tagFilter, and parentId parameters. (https://api.losant.com/#/definitions/advancedDeviceQuery)
102
153
  # * {string} losantdomain - Domain scope of request (rarely needed)
103
154
  # * {boolean} _actions - Return resource actions in response
104
155
  # * {boolean} _links - Return resource link in response
@@ -128,6 +179,8 @@ module LosantRest
128
179
  query_params[:tagFilter] = params[:tagFilter] if params.has_key?(:tagFilter)
129
180
  query_params[:excludeConnectionInfo] = params[:excludeConnectionInfo] if params.has_key?(:excludeConnectionInfo)
130
181
  query_params[:parentId] = params[:parentId] if params.has_key?(:parentId)
182
+ query_params[:query] = params[:query] if params.has_key?(:query)
183
+ query_params[:query] = JSON.dump(query_params[:query]) if query_params.has_key?(:query)
131
184
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
132
185
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
133
186
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
@@ -153,14 +206,15 @@ module LosantRest
153
206
  #
154
207
  # Parameters:
155
208
  # * {string} applicationId - ID associated with the application
156
- # * {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)
157
210
  # * {string} losantdomain - Domain scope of request (rarely needed)
158
211
  # * {boolean} _actions - Return resource actions in response
159
212
  # * {boolean} _links - Return resource link in response
160
213
  # * {boolean} _embedded - Return embedded resources in response
161
214
  #
162
215
  # Responses:
163
- # * 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)
164
218
  #
165
219
  # Errors:
166
220
  # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
@@ -172,6 +226,7 @@ module LosantRest
172
226
  body = nil
173
227
 
174
228
  raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
229
+ raise ArgumentError.new("patchInfo is required") unless params.has_key?(:patchInfo)
175
230
 
176
231
  body = params[:patchInfo] if params.has_key?(:patchInfo)
177
232
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
@@ -236,6 +291,54 @@ module LosantRest
236
291
  body: body)
237
292
  end
238
293
 
294
+ # Removes all device data for the specified time range. Defaults to all data.
295
+ #
296
+ # Authentication:
297
+ # The client must be configured with a valid api
298
+ # access token to call this action. The token
299
+ # must include at least one of the following scopes:
300
+ # all.Application, all.Organization, all.User, devices.*, or devices.removeData.
301
+ #
302
+ # Parameters:
303
+ # * {string} applicationId - ID associated with the application
304
+ # * {hash} options - Object defining the device data to delete and devices to delete from (https://api.losant.com/#/definitions/devicesRemoveDataPost)
305
+ # * {string} losantdomain - Domain scope of request (rarely needed)
306
+ # * {boolean} _actions - Return resource actions in response
307
+ # * {boolean} _links - Return resource link in response
308
+ # * {boolean} _embedded - Return embedded resources in response
309
+ #
310
+ # Responses:
311
+ # * 200 - Object indicating number of devices completed or skipped (https://api.losant.com/#/definitions/devicesDataRemoved)
312
+ # * 202 - If a job was enqueued for device data to be removed (https://api.losant.com/#/definitions/jobEnqueuedResult)
313
+ #
314
+ # Errors:
315
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
316
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
317
+ def remove_data(params = {})
318
+ params = Utils.symbolize_hash_keys(params)
319
+ query_params = { _actions: false, _links: true, _embedded: true }
320
+ headers = {}
321
+ body = nil
322
+
323
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
324
+ raise ArgumentError.new("options is required") unless params.has_key?(:options)
325
+
326
+ body = params[:options] if params.has_key?(:options)
327
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
328
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
329
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
330
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
331
+
332
+ path = "/applications/#{params[:applicationId]}/devices/removeData"
333
+
334
+ @client.request(
335
+ method: :post,
336
+ path: path,
337
+ query: query_params,
338
+ headers: headers,
339
+ body: body)
340
+ end
341
+
239
342
  # Send a command to multiple devices
240
343
  #
241
344
  # Authentication:
@@ -148,6 +148,7 @@ module LosantRest
148
148
  # * {string} applicationId - ID associated with the application
149
149
  # * {string} statGrouping - Field to group the statistics by. Accepted values are: statusCode, endpointId, version, domain
150
150
  # * {string} duration - Duration in milliseconds
151
+ # * {string} end - End of time range in milliseconds since epoch
151
152
  # * {string} resolution - Resolution in milliseconds
152
153
  # * {string} versionFilter - Filters the stats to a particular experience version
153
154
  # * {string} domainFilter - Filters the stats to a particular experience domain or slug
@@ -174,6 +175,7 @@ module LosantRest
174
175
 
175
176
  query_params[:statGrouping] = params[:statGrouping] if params.has_key?(:statGrouping)
176
177
  query_params[:duration] = params[:duration] if params.has_key?(:duration)
178
+ query_params[:end] = params[:end] if params.has_key?(:end)
177
179
  query_params[:resolution] = params[:resolution] if params.has_key?(:resolution)
178
180
  query_params[:versionFilter] = params[:versionFilter] if params.has_key?(:versionFilter)
179
181
  query_params[:domainFilter] = params[:domainFilter] if params.has_key?(:domainFilter)
@@ -52,7 +52,7 @@ module LosantRest
52
52
  #
53
53
  # Errors:
54
54
  # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
55
- # * 404 - Error if event was not found (https://api.losant.com/#/definitions/error)
55
+ # * 404 - Error if file was not found (https://api.losant.com/#/definitions/error)
56
56
  def delete(params = {})
57
57
  params = Utils.symbolize_hash_keys(params)
58
58
  query_params = { _actions: false, _links: true, _embedded: true }
@@ -146,7 +146,7 @@ module LosantRest
146
146
  #
147
147
  # Errors:
148
148
  # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
149
- # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
149
+ # * 404 - Error if file was not found (https://api.losant.com/#/definitions/error)
150
150
  def move(params = {})
151
151
  params = Utils.symbolize_hash_keys(params)
152
152
  query_params = { _actions: false, _links: true, _embedded: true }
@@ -195,7 +195,7 @@ module LosantRest
195
195
  #
196
196
  # Errors:
197
197
  # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
198
- # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
198
+ # * 404 - Error if file was not found (https://api.losant.com/#/definitions/error)
199
199
  def patch(params = {})
200
200
  params = Utils.symbolize_hash_keys(params)
201
201
  query_params = { _actions: false, _links: true, _embedded: true }
@@ -123,6 +123,64 @@ module LosantRest
123
123
  body: body)
124
124
  end
125
125
 
126
+ # Get information about errors that occurred during runs of this workflow
127
+ #
128
+ # Authentication:
129
+ # The client must be configured with a valid api
130
+ # access token to call this action. The token
131
+ # must include at least one of the following scopes:
132
+ # all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, flow.*, or flow.errors.
133
+ #
134
+ # Parameters:
135
+ # * {string} applicationId - ID associated with the application
136
+ # * {string} flowId - ID associated with the flow
137
+ # * {string} duration - Duration of time range in milliseconds
138
+ # * {string} end - End of time range in milliseconds since epoch
139
+ # * {string} limit - Maximum number of errors to return
140
+ # * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc
141
+ # * {string} flowVersion - Flow version name or ID. When not included, will be errors for all versions. Pass develop for just the develop version.
142
+ # * {string} deviceId - For edge workflows, the Device ID to return workflow errors for. When not included, will be errors for all device IDs.
143
+ # * {string} losantdomain - Domain scope of request (rarely needed)
144
+ # * {boolean} _actions - Return resource actions in response
145
+ # * {boolean} _links - Return resource link in response
146
+ # * {boolean} _embedded - Return embedded resources in response
147
+ #
148
+ # Responses:
149
+ # * 200 - Workflow error information (https://api.losant.com/#/definitions/flowErrors)
150
+ #
151
+ # Errors:
152
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
153
+ # * 404 - Error if flow was not found (https://api.losant.com/#/definitions/error)
154
+ def errors(params = {})
155
+ params = Utils.symbolize_hash_keys(params)
156
+ query_params = { _actions: false, _links: true, _embedded: true }
157
+ headers = {}
158
+ body = nil
159
+
160
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
161
+ raise ArgumentError.new("flowId is required") unless params.has_key?(:flowId)
162
+
163
+ query_params[:duration] = params[:duration] if params.has_key?(:duration)
164
+ query_params[:end] = params[:end] if params.has_key?(:end)
165
+ query_params[:limit] = params[:limit] if params.has_key?(:limit)
166
+ query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection)
167
+ query_params[:flowVersion] = params[:flowVersion] if params.has_key?(:flowVersion)
168
+ query_params[:deviceId] = params[:deviceId] if params.has_key?(:deviceId)
169
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
170
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
171
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
172
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
173
+
174
+ path = "/applications/#{params[:applicationId]}/flows/#{params[:flowId]}/errors"
175
+
176
+ @client.request(
177
+ method: :get,
178
+ path: path,
179
+ query: query_params,
180
+ headers: headers,
181
+ body: body)
182
+ end
183
+
126
184
  # Retrieves information on a flow
127
185
  #
128
186
  # Authentication:
@@ -194,7 +252,7 @@ module LosantRest
194
252
  #
195
253
  # Errors:
196
254
  # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
197
- # * 404 - Error if device was not found (https://api.losant.com/#/definitions/error)
255
+ # * 404 - Error if flow was not found (https://api.losant.com/#/definitions/error)
198
256
  def get_log_entries(params = {})
199
257
  params = Utils.symbolize_hash_keys(params)
200
258
  query_params = { _actions: false, _links: true, _embedded: true }
@@ -416,5 +474,61 @@ module LosantRest
416
474
  body: body)
417
475
  end
418
476
 
477
+ # Get statistics about workflow runs for this workflow
478
+ #
479
+ # Authentication:
480
+ # The client must be configured with a valid api
481
+ # access token to call this action. The token
482
+ # must include at least one of the following scopes:
483
+ # all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, flow.*, or flow.stats.
484
+ #
485
+ # Parameters:
486
+ # * {string} applicationId - ID associated with the application
487
+ # * {string} flowId - ID associated with the flow
488
+ # * {string} duration - Duration of time range in milliseconds
489
+ # * {string} end - End of time range in milliseconds since epoch
490
+ # * {string} resolution - Resolution in milliseconds
491
+ # * {string} flowVersion - Flow version name or ID. When not included, will be aggregate for all versions. Pass develop for just the develop version.
492
+ # * {string} deviceId - For edge workflows, the device ID to return workflow stats for. When not included, will be aggregate for all device IDs.
493
+ # * {string} losantdomain - Domain scope of request (rarely needed)
494
+ # * {boolean} _actions - Return resource actions in response
495
+ # * {boolean} _links - Return resource link in response
496
+ # * {boolean} _embedded - Return embedded resources in response
497
+ #
498
+ # Responses:
499
+ # * 200 - Statistics for workflow runs (https://api.losant.com/#/definitions/flowStats)
500
+ #
501
+ # Errors:
502
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
503
+ # * 404 - Error if flow was not found (https://api.losant.com/#/definitions/error)
504
+ def stats(params = {})
505
+ params = Utils.symbolize_hash_keys(params)
506
+ query_params = { _actions: false, _links: true, _embedded: true }
507
+ headers = {}
508
+ body = nil
509
+
510
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
511
+ raise ArgumentError.new("flowId is required") unless params.has_key?(:flowId)
512
+
513
+ query_params[:duration] = params[:duration] if params.has_key?(:duration)
514
+ query_params[:end] = params[:end] if params.has_key?(:end)
515
+ query_params[:resolution] = params[:resolution] if params.has_key?(:resolution)
516
+ query_params[:flowVersion] = params[:flowVersion] if params.has_key?(:flowVersion)
517
+ query_params[:deviceId] = params[:deviceId] if params.has_key?(:deviceId)
518
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
519
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
520
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
521
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
522
+
523
+ path = "/applications/#{params[:applicationId]}/flows/#{params[:flowId]}/stats"
524
+
525
+ @client.request(
526
+ method: :get,
527
+ path: path,
528
+ query: query_params,
529
+ headers: headers,
530
+ body: body)
531
+ end
532
+
419
533
  end
420
534
  end