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,310 @@
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 Flows Resource
28
+ class Flows
29
+
30
+ def initialize(client)
31
+ @client = client
32
+ end
33
+
34
+ # Returns the flows for an application
35
+ #
36
+ # Authentication:
37
+ # The client must be configured with a valid api
38
+ # access token to call this action. The token
39
+ # must include at least one of the following scopes:
40
+ # all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, flows.*, or flows.get.
41
+ #
42
+ # Parameters:
43
+ # * {string} applicationId - ID associated with the application
44
+ # * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate, lastUpdated
45
+ # * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc
46
+ # * {string} page - Which page of results to return
47
+ # * {string} perPage - How many items to return per page
48
+ # * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name
49
+ # * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering.
50
+ # * {string} flowClass - Filter the workflows by the given flow class. Accepted values are: edge, embedded, cloud, customNode, experience
51
+ # * {hash} triggerFilter - Array of triggers to filter by - always filters against default flow version. (https://api.losant.com/#/definitions/flowTriggerFilter)
52
+ # * {string} includeCustomNodes - If the result of the request should also include the details of any custom nodes referenced by the returned workflows
53
+ # * {hash} query - Workflow filter JSON object which overrides the filterField, filter, triggerFilter, and flowClass parameters. (https://api.losant.com/#/definitions/advancedFlowQuery)
54
+ # * {string} allVersions - If the request should also return flows with matching versions. Only applicable for requests with an advanced query.
55
+ # * {string} losantdomain - Domain scope of request (rarely needed)
56
+ # * {boolean} _actions - Return resource actions in response
57
+ # * {boolean} _links - Return resource link in response
58
+ # * {boolean} _embedded - Return embedded resources in response
59
+ #
60
+ # Responses:
61
+ # * 200 - Collection of flows (https://api.losant.com/#/definitions/flows)
62
+ #
63
+ # Errors:
64
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
65
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
66
+ def get(params = {})
67
+ params = Utils.symbolize_hash_keys(params)
68
+ query_params = { _actions: false, _links: true, _embedded: true }
69
+ headers = {}
70
+ body = nil
71
+
72
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
73
+
74
+ query_params[:sortField] = params[:sortField] if params.has_key?(:sortField)
75
+ query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection)
76
+ query_params[:page] = params[:page] if params.has_key?(:page)
77
+ query_params[:perPage] = params[:perPage] if params.has_key?(:perPage)
78
+ query_params[:filterField] = params[:filterField] if params.has_key?(:filterField)
79
+ query_params[:filter] = params[:filter] if params.has_key?(:filter)
80
+ query_params[:flowClass] = params[:flowClass] if params.has_key?(:flowClass)
81
+ query_params[:triggerFilter] = params[:triggerFilter] if params.has_key?(:triggerFilter)
82
+ query_params[:includeCustomNodes] = params[:includeCustomNodes] if params.has_key?(:includeCustomNodes)
83
+ query_params[:query] = params[:query] if params.has_key?(:query)
84
+ query_params[:query] = JSON.dump(query_params[:query]) if query_params.has_key?(:query)
85
+ query_params[:allVersions] = params[:allVersions] if params.has_key?(:allVersions)
86
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
87
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
88
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
89
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
90
+
91
+ path = "/applications/#{params[:applicationId]}/flows"
92
+
93
+ @client.request(
94
+ method: :get,
95
+ path: path,
96
+ query: query_params,
97
+ headers: headers,
98
+ body: body)
99
+ end
100
+
101
+ # Returns the flows by version for an application
102
+ #
103
+ # Authentication:
104
+ # The client must be configured with a valid api
105
+ # access token to call this action. The token
106
+ # must include at least one of the following scopes:
107
+ # all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, flows.*, or flows.getByVersion.
108
+ #
109
+ # Parameters:
110
+ # * {string} applicationId - ID associated with the application
111
+ # * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate, lastUpdated
112
+ # * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc
113
+ # * {string} page - Which page of results to return
114
+ # * {string} perPage - How many items to return per page
115
+ # * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name
116
+ # * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering.
117
+ # * {string} flowClass - Filter the workflows by the given flow class. Accepted values are: edge, embedded, cloud, customNode, experience
118
+ # * {string} version - Return the workflow versions for the given version.
119
+ # * {hash} triggerFilter - Array of triggers to filter by - always filters against default flow version. (https://api.losant.com/#/definitions/flowTriggerFilter)
120
+ # * {string} includeCustomNodes - If the result of the request should also include the details of any custom nodes referenced by the returned workflows
121
+ # * {hash} query - Workflow filter JSON object which overrides the filterField, filter, triggerFilter, and flowClass parameters. (https://api.losant.com/#/definitions/advancedFlowByVersionQuery)
122
+ # * {string} losantdomain - Domain scope of request (rarely needed)
123
+ # * {boolean} _actions - Return resource actions in response
124
+ # * {boolean} _links - Return resource link in response
125
+ # * {boolean} _embedded - Return embedded resources in response
126
+ #
127
+ # Responses:
128
+ # * 200 - Collection of flow versions (https://api.losant.com/#/definitions/flowVersions)
129
+ #
130
+ # Errors:
131
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
132
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
133
+ def get_by_version(params = {})
134
+ params = Utils.symbolize_hash_keys(params)
135
+ query_params = { _actions: false, _links: true, _embedded: true }
136
+ headers = {}
137
+ body = nil
138
+
139
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
140
+ raise ArgumentError.new("version is required") unless params.has_key?(:version)
141
+
142
+ query_params[:sortField] = params[:sortField] if params.has_key?(:sortField)
143
+ query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection)
144
+ query_params[:page] = params[:page] if params.has_key?(:page)
145
+ query_params[:perPage] = params[:perPage] if params.has_key?(:perPage)
146
+ query_params[:filterField] = params[:filterField] if params.has_key?(:filterField)
147
+ query_params[:filter] = params[:filter] if params.has_key?(:filter)
148
+ query_params[:flowClass] = params[:flowClass] if params.has_key?(:flowClass)
149
+ query_params[:version] = params[:version] if params.has_key?(:version)
150
+ query_params[:triggerFilter] = params[:triggerFilter] if params.has_key?(:triggerFilter)
151
+ query_params[:includeCustomNodes] = params[:includeCustomNodes] if params.has_key?(:includeCustomNodes)
152
+ query_params[:query] = params[:query] if params.has_key?(:query)
153
+ query_params[:query] = JSON.dump(query_params[:query]) if query_params.has_key?(:query)
154
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
155
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
156
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
157
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
158
+
159
+ path = "/applications/#{params[:applicationId]}/flows/version"
160
+
161
+ @client.request(
162
+ method: :get,
163
+ path: path,
164
+ query: query_params,
165
+ headers: headers,
166
+ body: body)
167
+ end
168
+
169
+ # Import a set of flows and flow versions
170
+ #
171
+ # Authentication:
172
+ # The client must be configured with a valid api
173
+ # access token to call this action. The token
174
+ # must include at least one of the following scopes:
175
+ # all.Application, all.Organization, all.User, flows.*, or flows.import.
176
+ #
177
+ # Parameters:
178
+ # * {string} applicationId - ID associated with the application
179
+ # * {hash} importData - New flow and flow version information (https://api.losant.com/#/definitions/flowsImportPost)
180
+ # * {string} losantdomain - Domain scope of request (rarely needed)
181
+ # * {boolean} _actions - Return resource actions in response
182
+ # * {boolean} _links - Return resource link in response
183
+ # * {boolean} _embedded - Return embedded resources in response
184
+ #
185
+ # Responses:
186
+ # * 201 - Successfully imported workflows (https://api.losant.com/#/definitions/flowsImportResult)
187
+ #
188
+ # Errors:
189
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
190
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
191
+ def import(params = {})
192
+ params = Utils.symbolize_hash_keys(params)
193
+ query_params = { _actions: false, _links: true, _embedded: true }
194
+ headers = {}
195
+ body = nil
196
+
197
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
198
+ raise ArgumentError.new("importData is required") unless params.has_key?(:importData)
199
+
200
+ body = params[:importData] if params.has_key?(:importData)
201
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
202
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
203
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
204
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
205
+
206
+ path = "/applications/#{params[:applicationId]}/flows/import"
207
+
208
+ @client.request(
209
+ method: :post,
210
+ path: path,
211
+ query: query_params,
212
+ headers: headers,
213
+ body: body)
214
+ end
215
+
216
+ # Gets additional nodes that should be available in the palette
217
+ #
218
+ # Authentication:
219
+ # The client must be configured with a valid api
220
+ # access token to call this action. The token
221
+ # must include at least one of the following scopes:
222
+ # all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, flows.*, or flows.palette.
223
+ #
224
+ # Parameters:
225
+ # * {string} applicationId - ID associated with the application
226
+ # * {string} losantdomain - Domain scope of request (rarely needed)
227
+ # * {boolean} _actions - Return resource actions in response
228
+ # * {boolean} _links - Return resource link in response
229
+ # * {boolean} _embedded - Return embedded resources in response
230
+ #
231
+ # Responses:
232
+ # * 200 - The additional nodes available in the palette (https://api.losant.com/#/definitions/paletteResponse)
233
+ #
234
+ # Errors:
235
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
236
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
237
+ def palette(params = {})
238
+ params = Utils.symbolize_hash_keys(params)
239
+ query_params = { _actions: false, _links: true, _embedded: true }
240
+ headers = {}
241
+ body = nil
242
+
243
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
244
+
245
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
246
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
247
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
248
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
249
+
250
+ path = "/applications/#{params[:applicationId]}/flows/palette"
251
+
252
+ @client.request(
253
+ method: :get,
254
+ path: path,
255
+ query: query_params,
256
+ headers: headers,
257
+ body: body)
258
+ end
259
+
260
+ # Create a new flow for an application
261
+ #
262
+ # Authentication:
263
+ # The client must be configured with a valid api
264
+ # access token to call this action. The token
265
+ # must include at least one of the following scopes:
266
+ # all.Application, all.Organization, all.User, flows.*, or flows.post.
267
+ #
268
+ # Parameters:
269
+ # * {string} applicationId - ID associated with the application
270
+ # * {hash} flow - New flow information (https://api.losant.com/#/definitions/flowPost)
271
+ # * {string} includeCustomNodes - If the result of the request should also include the details of any custom nodes referenced by the returned workflows
272
+ # * {string} losantdomain - Domain scope of request (rarely needed)
273
+ # * {boolean} _actions - Return resource actions in response
274
+ # * {boolean} _links - Return resource link in response
275
+ # * {boolean} _embedded - Return embedded resources in response
276
+ #
277
+ # Responses:
278
+ # * 201 - Successfully created flow (https://api.losant.com/#/definitions/flow)
279
+ #
280
+ # Errors:
281
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
282
+ # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
283
+ def post(params = {})
284
+ params = Utils.symbolize_hash_keys(params)
285
+ query_params = { _actions: false, _links: true, _embedded: true }
286
+ headers = {}
287
+ body = nil
288
+
289
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
290
+ raise ArgumentError.new("flow is required") unless params.has_key?(:flow)
291
+
292
+ body = params[:flow] if params.has_key?(:flow)
293
+ query_params[:includeCustomNodes] = params[:includeCustomNodes] if params.has_key?(:includeCustomNodes)
294
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
295
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
296
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
297
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
298
+
299
+ path = "/applications/#{params[:applicationId]}/flows"
300
+
301
+ @client.request(
302
+ method: :post,
303
+ path: path,
304
+ query: query_params,
305
+ headers: headers,
306
+ body: body)
307
+ end
308
+
309
+ end
310
+ end
@@ -0,0 +1,377 @@
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 Instance Resource
28
+ class Instance
29
+
30
+ def initialize(client)
31
+ @client = client
32
+ end
33
+
34
+ # Returns device counts by day for the time range specified for this instance
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.Instance, all.Instance.read, all.User, all.User.read, instance.*, or instance.deviceCounts.
41
+ #
42
+ # Parameters:
43
+ # * {string} instanceId - ID associated with the instance
44
+ # * {string} start - Start of range for device count query (ms since epoch)
45
+ # * {string} end - End of range for device count query (ms since epoch)
46
+ # * {string} losantdomain - Domain scope of request (rarely needed)
47
+ # * {boolean} _actions - Return resource actions in response
48
+ # * {boolean} _links - Return resource link in response
49
+ # * {boolean} _embedded - Return embedded resources in response
50
+ #
51
+ # Responses:
52
+ # * 200 - Device counts by day (https://api.losant.com/#/definitions/deviceCounts)
53
+ #
54
+ # Errors:
55
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
56
+ # * 404 - Error if instance was not found (https://api.losant.com/#/definitions/error)
57
+ def device_counts(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("instanceId is required") unless params.has_key?(:instanceId)
64
+
65
+ query_params[:start] = params[:start] if params.has_key?(:start)
66
+ query_params[:end] = params[:end] if params.has_key?(:end)
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 = "/instances/#{params[:instanceId]}/deviceCounts"
73
+
74
+ @client.request(
75
+ method: :get,
76
+ path: path,
77
+ query: query_params,
78
+ headers: headers,
79
+ body: body)
80
+ end
81
+
82
+ # Generates a CSV report on instance stats
83
+ #
84
+ # Authentication:
85
+ # The client must be configured with a valid api
86
+ # access token to call this action. The token
87
+ # must include at least one of the following scopes:
88
+ # all.Instance, all.Instance.read, all.User, all.User.read, instance.*, or instance.generateReport.
89
+ #
90
+ # Parameters:
91
+ # * {string} instanceId - ID associated with the instance
92
+ # * {hash} options - Object containing report configuration (https://api.losant.com/#/definitions/instanceReportOptionsPost)
93
+ # * {string} losantdomain - Domain scope of request (rarely needed)
94
+ # * {boolean} _actions - Return resource actions in response
95
+ # * {boolean} _links - Return resource link in response
96
+ # * {boolean} _embedded - Return embedded resources in response
97
+ #
98
+ # Responses:
99
+ # * 202 - If generation of report was successfully started (https://api.losant.com/#/definitions/jobEnqueuedResult)
100
+ #
101
+ # Errors:
102
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
103
+ def generate_report(params = {})
104
+ params = Utils.symbolize_hash_keys(params)
105
+ query_params = { _actions: false, _links: true, _embedded: true }
106
+ headers = {}
107
+ body = nil
108
+
109
+ raise ArgumentError.new("instanceId is required") unless params.has_key?(:instanceId)
110
+
111
+ body = params[:options] if params.has_key?(:options)
112
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
113
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
114
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
115
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
116
+
117
+ path = "/instances/#{params[:instanceId]}/generateReport"
118
+
119
+ @client.request(
120
+ method: :post,
121
+ path: path,
122
+ query: query_params,
123
+ headers: headers,
124
+ body: body)
125
+ end
126
+
127
+ # Returns an instance
128
+ #
129
+ # Authentication:
130
+ # The client must be configured with a valid api
131
+ # access token to call this action. The token
132
+ # must include at least one of the following scopes:
133
+ # all.Instance, all.Instance.read, all.User, all.User.read, instance.*, or instance.get.
134
+ #
135
+ # Parameters:
136
+ # * {string} instanceId - ID associated with the instance
137
+ # * {string} losantdomain - Domain scope of request (rarely needed)
138
+ # * {boolean} _actions - Return resource actions in response
139
+ # * {boolean} _links - Return resource link in response
140
+ # * {boolean} _embedded - Return embedded resources in response
141
+ #
142
+ # Responses:
143
+ # * 200 - A single instance (https://api.losant.com/#/definitions/instance)
144
+ #
145
+ # Errors:
146
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
147
+ # * 404 - Error if instance was not found (https://api.losant.com/#/definitions/error)
148
+ def get(params = {})
149
+ params = Utils.symbolize_hash_keys(params)
150
+ query_params = { _actions: false, _links: true, _embedded: true }
151
+ headers = {}
152
+ body = nil
153
+
154
+ raise ArgumentError.new("instanceId is required") unless params.has_key?(:instanceId)
155
+
156
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
157
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
158
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
159
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
160
+
161
+ path = "/instances/#{params[:instanceId]}"
162
+
163
+ @client.request(
164
+ method: :get,
165
+ path: path,
166
+ query: query_params,
167
+ headers: headers,
168
+ body: body)
169
+ end
170
+
171
+ # Return historical summary entries for an instance
172
+ #
173
+ # Authentication:
174
+ # The client must be configured with a valid api
175
+ # access token to call this action. The token
176
+ # must include at least one of the following scopes:
177
+ # all.Instance, all.Instance.read, all.User, all.User.read, instance.*, or instance.historicalSummaries.
178
+ #
179
+ # Parameters:
180
+ # * {string} instanceId - ID associated with the instance
181
+ # * {string} month - Timestamp within the month to report a summary for.
182
+ # * {string} sortField - Field to sort the results by. Accepted values are: resourceId, currentPeriodStart
183
+ # * {string} sortDirection - Direction to sort the results in. Accepted values are: asc, desc
184
+ # * {string} page - Which page of results to return
185
+ # * {string} perPage - How many items to return per page
186
+ # * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: resourceType, resourceId, ownerId, ownerType
187
+ # * {string} filter - Filter to apply against the filtered field. Blank or not provided means no filtering.
188
+ # * {string} losantdomain - Domain scope of request (rarely needed)
189
+ # * {boolean} _actions - Return resource actions in response
190
+ # * {boolean} _links - Return resource link in response
191
+ # * {boolean} _embedded - Return embedded resources in response
192
+ #
193
+ # Responses:
194
+ # * 200 - Collection of historical summaries (https://api.losant.com/#/definitions/historicalSummaries)
195
+ #
196
+ # Errors:
197
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
198
+ def historical_summaries(params = {})
199
+ params = Utils.symbolize_hash_keys(params)
200
+ query_params = { _actions: false, _links: true, _embedded: true }
201
+ headers = {}
202
+ body = nil
203
+
204
+ raise ArgumentError.new("instanceId is required") unless params.has_key?(:instanceId)
205
+
206
+ query_params[:month] = params[:month] if params.has_key?(:month)
207
+ query_params[:sortField] = params[:sortField] if params.has_key?(:sortField)
208
+ query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection)
209
+ query_params[:page] = params[:page] if params.has_key?(:page)
210
+ query_params[:perPage] = params[:perPage] if params.has_key?(:perPage)
211
+ query_params[:filterField] = params[:filterField] if params.has_key?(:filterField)
212
+ query_params[:filter] = params[:filter] if params.has_key?(:filter)
213
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
214
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
215
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
216
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
217
+
218
+ path = "/instances/#{params[:instanceId]}/historicalSummaries"
219
+
220
+ @client.request(
221
+ method: :get,
222
+ path: path,
223
+ query: query_params,
224
+ headers: headers,
225
+ body: body)
226
+ end
227
+
228
+ # Returns notebook execution usage by day for the time range specified for this instance
229
+ #
230
+ # Authentication:
231
+ # The client must be configured with a valid api
232
+ # access token to call this action. The token
233
+ # must include at least one of the following scopes:
234
+ # all.Instance, all.Instance.read, all.User, all.User.read, instance.*, or instance.notebookMinuteCounts.
235
+ #
236
+ # Parameters:
237
+ # * {string} instanceId - ID associated with the instance
238
+ # * {string} start - Start of range for notebook execution query (ms since epoch)
239
+ # * {string} end - End of range for notebook execution query (ms since epoch)
240
+ # * {string} losantdomain - Domain scope of request (rarely needed)
241
+ # * {boolean} _actions - Return resource actions in response
242
+ # * {boolean} _links - Return resource link in response
243
+ # * {boolean} _embedded - Return embedded resources in response
244
+ #
245
+ # Responses:
246
+ # * 200 - Notebook usage information (https://api.losant.com/#/definitions/notebookMinuteCounts)
247
+ #
248
+ # Errors:
249
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
250
+ # * 404 - Error if instance was not found (https://api.losant.com/#/definitions/error)
251
+ def notebook_minute_counts(params = {})
252
+ params = Utils.symbolize_hash_keys(params)
253
+ query_params = { _actions: false, _links: true, _embedded: true }
254
+ headers = {}
255
+ body = nil
256
+
257
+ raise ArgumentError.new("instanceId is required") unless params.has_key?(:instanceId)
258
+
259
+ query_params[:start] = params[:start] if params.has_key?(:start)
260
+ query_params[:end] = params[:end] if params.has_key?(:end)
261
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
262
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
263
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
264
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
265
+
266
+ path = "/instances/#{params[:instanceId]}/notebookMinuteCounts"
267
+
268
+ @client.request(
269
+ method: :get,
270
+ path: path,
271
+ query: query_params,
272
+ headers: headers,
273
+ body: body)
274
+ end
275
+
276
+ # Updates information about an instance
277
+ #
278
+ # Authentication:
279
+ # The client must be configured with a valid api
280
+ # access token to call this action. The token
281
+ # must include at least one of the following scopes:
282
+ # all.Instance, all.User, instance.*, or instance.patch.
283
+ #
284
+ # Parameters:
285
+ # * {string} instanceId - ID associated with the instance
286
+ # * {hash} instance - Updated instance information (https://api.losant.com/#/definitions/instancePatch)
287
+ # * {string} losantdomain - Domain scope of request (rarely needed)
288
+ # * {boolean} _actions - Return resource actions in response
289
+ # * {boolean} _links - Return resource link in response
290
+ # * {boolean} _embedded - Return embedded resources in response
291
+ #
292
+ # Responses:
293
+ # * 200 - The updated instance object (https://api.losant.com/#/definitions/instance)
294
+ #
295
+ # Errors:
296
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
297
+ def patch(params = {})
298
+ params = Utils.symbolize_hash_keys(params)
299
+ query_params = { _actions: false, _links: true, _embedded: true }
300
+ headers = {}
301
+ body = nil
302
+
303
+ raise ArgumentError.new("instanceId is required") unless params.has_key?(:instanceId)
304
+ raise ArgumentError.new("instance is required") unless params.has_key?(:instance)
305
+
306
+ body = params[:instance] if params.has_key?(:instance)
307
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
308
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
309
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
310
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
311
+
312
+ path = "/instances/#{params[:instanceId]}"
313
+
314
+ @client.request(
315
+ method: :patch,
316
+ path: path,
317
+ query: query_params,
318
+ headers: headers,
319
+ body: body)
320
+ end
321
+
322
+ # Returns payload counts per resolution in the time range specified for this instance
323
+ #
324
+ # Authentication:
325
+ # The client must be configured with a valid api
326
+ # access token to call this action. The token
327
+ # must include at least one of the following scopes:
328
+ # all.Instance, all.Instance.read, all.User, all.User.read, instance.*, or instance.payloadCountsBreakdown.
329
+ #
330
+ # Parameters:
331
+ # * {string} instanceId - ID associated with the instance
332
+ # * {string} start - Start of range for payload count query (ms since epoch)
333
+ # * {string} end - End of range for payload count query (ms since epoch)
334
+ # * {string} resolution - Resolution in milliseconds. Accepted values are: 86400000, 3600000
335
+ # * {string} asBytes - If the resulting stats should be returned as bytes
336
+ # * {string} includeNonBillable - If non-billable payloads should be included in the result
337
+ # * {string} losantdomain - Domain scope of request (rarely needed)
338
+ # * {boolean} _actions - Return resource actions in response
339
+ # * {boolean} _links - Return resource link in response
340
+ # * {boolean} _embedded - Return embedded resources in response
341
+ #
342
+ # Responses:
343
+ # * 200 - Sum of payload counts by date (https://api.losant.com/#/definitions/payloadCountsBreakdown)
344
+ #
345
+ # Errors:
346
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
347
+ # * 404 - Error if instance was not found (https://api.losant.com/#/definitions/error)
348
+ def payload_counts_breakdown(params = {})
349
+ params = Utils.symbolize_hash_keys(params)
350
+ query_params = { _actions: false, _links: true, _embedded: true }
351
+ headers = {}
352
+ body = nil
353
+
354
+ raise ArgumentError.new("instanceId is required") unless params.has_key?(:instanceId)
355
+
356
+ query_params[:start] = params[:start] if params.has_key?(:start)
357
+ query_params[:end] = params[:end] if params.has_key?(:end)
358
+ query_params[:resolution] = params[:resolution] if params.has_key?(:resolution)
359
+ query_params[:asBytes] = params[:asBytes] if params.has_key?(:asBytes)
360
+ query_params[:includeNonBillable] = params[:includeNonBillable] if params.has_key?(:includeNonBillable)
361
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
362
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
363
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
364
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
365
+
366
+ path = "/instances/#{params[:instanceId]}/payloadCountsBreakdown"
367
+
368
+ @client.request(
369
+ method: :get,
370
+ path: path,
371
+ query: query_params,
372
+ headers: headers,
373
+ body: body)
374
+ end
375
+
376
+ end
377
+ end