losant_rest 1.19.4 → 1.19.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (237) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +9 -9
  4. data/docs/_schemas.md +1142 -63
  5. data/docs/instanceAuditLog.md +49 -0
  6. data/docs/instanceAuditLogs.md +53 -0
  7. data/examples/auth.rb +1 -1
  8. data/examples/list_devices.rb +1 -1
  9. data/lib/platform_rest/application.rb +1 -1
  10. data/lib/platform_rest/application_api_token.rb +1 -1
  11. data/lib/platform_rest/application_api_tokens.rb +1 -1
  12. data/lib/platform_rest/application_certificate.rb +1 -1
  13. data/lib/platform_rest/application_certificate_authorities.rb +1 -1
  14. data/lib/platform_rest/application_certificate_authority.rb +1 -1
  15. data/lib/platform_rest/application_certificates.rb +1 -1
  16. data/lib/platform_rest/application_dashboard.rb +1 -1
  17. data/lib/platform_rest/application_dashboards.rb +1 -1
  18. data/lib/platform_rest/application_key.rb +1 -1
  19. data/lib/platform_rest/application_keys.rb +1 -1
  20. data/lib/platform_rest/application_template.rb +1 -1
  21. data/lib/platform_rest/application_templates.rb +1 -1
  22. data/lib/platform_rest/applications.rb +1 -1
  23. data/lib/platform_rest/audit_log.rb +1 -1
  24. data/lib/platform_rest/audit_logs.rb +1 -1
  25. data/lib/platform_rest/auth.rb +1 -1
  26. data/lib/platform_rest/client.rb +11 -3
  27. data/lib/platform_rest/credential.rb +1 -1
  28. data/lib/platform_rest/credentials.rb +1 -1
  29. data/lib/platform_rest/dashboard.rb +1 -1
  30. data/lib/platform_rest/dashboards.rb +1 -1
  31. data/lib/platform_rest/data.rb +1 -1
  32. data/lib/platform_rest/data_table.rb +1 -1
  33. data/lib/platform_rest/data_table_row.rb +1 -1
  34. data/lib/platform_rest/data_table_rows.rb +1 -1
  35. data/lib/platform_rest/data_tables.rb +1 -1
  36. data/lib/platform_rest/device.rb +1 -1
  37. data/lib/platform_rest/device_recipe.rb +1 -1
  38. data/lib/platform_rest/device_recipes.rb +1 -1
  39. data/lib/platform_rest/devices.rb +1 -1
  40. data/lib/platform_rest/edge_deployment.rb +1 -1
  41. data/lib/platform_rest/edge_deployments.rb +1 -1
  42. data/lib/platform_rest/embedded_deployment.rb +1 -1
  43. data/lib/platform_rest/embedded_deployments.rb +1 -1
  44. data/lib/platform_rest/error.rb +1 -1
  45. data/lib/platform_rest/event.rb +1 -1
  46. data/lib/platform_rest/events.rb +1 -1
  47. data/lib/platform_rest/experience.rb +1 -1
  48. data/lib/platform_rest/experience_domain.rb +1 -1
  49. data/lib/platform_rest/experience_domains.rb +1 -1
  50. data/lib/platform_rest/experience_endpoint.rb +1 -1
  51. data/lib/platform_rest/experience_endpoints.rb +1 -1
  52. data/lib/platform_rest/experience_group.rb +1 -1
  53. data/lib/platform_rest/experience_groups.rb +1 -1
  54. data/lib/platform_rest/experience_slug.rb +1 -1
  55. data/lib/platform_rest/experience_slugs.rb +1 -1
  56. data/lib/platform_rest/experience_user.rb +1 -1
  57. data/lib/platform_rest/experience_users.rb +1 -1
  58. data/lib/platform_rest/experience_version.rb +1 -1
  59. data/lib/platform_rest/experience_versions.rb +1 -1
  60. data/lib/platform_rest/experience_view.rb +1 -1
  61. data/lib/platform_rest/experience_views.rb +1 -1
  62. data/lib/platform_rest/file.rb +1 -1
  63. data/lib/platform_rest/files.rb +1 -1
  64. data/lib/platform_rest/flow.rb +1 -1
  65. data/lib/platform_rest/flow_version.rb +1 -1
  66. data/lib/platform_rest/flow_versions.rb +1 -1
  67. data/lib/platform_rest/flows.rb +1 -1
  68. data/lib/platform_rest/instance.rb +1 -1
  69. data/lib/platform_rest/instance_api_token.rb +1 -1
  70. data/lib/platform_rest/instance_api_tokens.rb +1 -1
  71. data/lib/{losant_rest/application_template.rb → platform_rest/instance_audit_log.rb} +13 -11
  72. data/lib/{losant_rest/audit_logs.rb → platform_rest/instance_audit_logs.rb} +12 -12
  73. data/lib/platform_rest/instance_custom_node.rb +1 -1
  74. data/lib/platform_rest/instance_custom_nodes.rb +1 -1
  75. data/lib/platform_rest/instance_member.rb +1 -1
  76. data/lib/platform_rest/instance_members.rb +1 -1
  77. data/lib/platform_rest/instance_org.rb +1 -1
  78. data/lib/platform_rest/instance_org_invite.rb +1 -1
  79. data/lib/platform_rest/instance_org_invites.rb +1 -1
  80. data/lib/platform_rest/instance_org_member.rb +1 -1
  81. data/lib/platform_rest/instance_org_members.rb +1 -1
  82. data/lib/platform_rest/instance_orgs.rb +1 -1
  83. data/lib/platform_rest/instance_sandbox.rb +1 -1
  84. data/lib/platform_rest/instance_sandboxes.rb +1 -1
  85. data/lib/platform_rest/instances.rb +1 -1
  86. data/lib/platform_rest/integration.rb +1 -1
  87. data/lib/platform_rest/integrations.rb +1 -1
  88. data/lib/platform_rest/me.rb +1 -1
  89. data/lib/platform_rest/notebook.rb +1 -1
  90. data/lib/platform_rest/notebooks.rb +1 -1
  91. data/lib/platform_rest/org.rb +1 -1
  92. data/lib/platform_rest/org_invites.rb +1 -1
  93. data/lib/platform_rest/orgs.rb +1 -1
  94. data/lib/platform_rest/resource_job.rb +1 -1
  95. data/lib/platform_rest/resource_jobs.rb +1 -1
  96. data/lib/platform_rest/user_api_token.rb +1 -1
  97. data/lib/platform_rest/user_api_tokens.rb +1 -1
  98. data/lib/platform_rest/utils.rb +1 -1
  99. data/lib/{losant_rest → platform_rest}/version.rb +3 -3
  100. data/lib/platform_rest/webhook.rb +1 -1
  101. data/lib/platform_rest/webhooks.rb +1 -1
  102. data/lib/platform_rest.rb +3 -1
  103. data/losant_rest.gemspec +2 -2
  104. data/schemas/apiTokenPost.json +9 -1
  105. data/schemas/auditLog.json +3 -2
  106. data/schemas/auditLogFilter.json +3 -2
  107. data/schemas/auditLogs.json +3 -2
  108. data/schemas/credential.json +50 -1
  109. data/schemas/credentialLinkedResources.json +81 -4
  110. data/schemas/credentialPatch.json +56 -0
  111. data/schemas/credentialPost.json +71 -1
  112. data/schemas/credentials.json +50 -1
  113. data/schemas/deviceConnectionStatus.json +6 -2
  114. data/schemas/devicesHistoricalImportPost.json +25 -0
  115. data/schemas/experienceLinkedResources.json +7 -5
  116. data/schemas/experienceView.json +1 -2
  117. data/schemas/experienceViewPatch.json +1 -2
  118. data/schemas/experienceViewPost.json +2 -4
  119. data/schemas/experienceViews.json +1 -2
  120. data/schemas/flow.json +2 -1
  121. data/schemas/flowPatch.json +2 -1
  122. data/schemas/flowPost.json +2 -1
  123. data/schemas/flowVersion.json +4 -2
  124. data/schemas/flowVersionPost.json +2 -1
  125. data/schemas/flowVersions.json +4 -2
  126. data/schemas/flows.json +2 -1
  127. data/schemas/flowsImportPost.json +4 -2
  128. data/schemas/flowsImportResult.json +6 -3
  129. data/schemas/githubLogin.json +9 -1
  130. data/schemas/instance.json +1 -4
  131. data/schemas/instanceAuditLog.json +94 -0
  132. data/schemas/instanceAuditLogFilter.json +106 -0
  133. data/schemas/instanceAuditLogs.json +41 -0
  134. data/schemas/instanceCustomNodePatch.json +2 -1
  135. data/schemas/instanceCustomNodePost.json +2 -1
  136. data/schemas/instanceOrgMember.json +4 -1
  137. data/schemas/instances.json +1 -4
  138. data/schemas/integration.json +75 -1
  139. data/schemas/integrationPatch.json +73 -0
  140. data/schemas/integrationPost.json +75 -1
  141. data/schemas/integrations.json +75 -1
  142. data/schemas/mePatch.json +18 -0
  143. data/schemas/samlResponse.json +9 -1
  144. data/schemas/userCredentials.json +9 -1
  145. data/schemas/userPost.json +9 -1
  146. data/test/basic_test.rb +6 -6
  147. data/test/test_helper.rb +1 -1
  148. metadata +11 -94
  149. data/lib/losant_rest/application.rb +0 -932
  150. data/lib/losant_rest/application_api_token.rb +0 -176
  151. data/lib/losant_rest/application_api_tokens.rb +0 -136
  152. data/lib/losant_rest/application_certificate.rb +0 -176
  153. data/lib/losant_rest/application_certificate_authorities.rb +0 -138
  154. data/lib/losant_rest/application_certificate_authority.rb +0 -176
  155. data/lib/losant_rest/application_certificates.rb +0 -138
  156. data/lib/losant_rest/application_dashboard.rb +0 -225
  157. data/lib/losant_rest/application_dashboards.rb +0 -138
  158. data/lib/losant_rest/application_key.rb +0 -176
  159. data/lib/losant_rest/application_keys.rb +0 -141
  160. data/lib/losant_rest/application_templates.rb +0 -176
  161. data/lib/losant_rest/applications.rb +0 -142
  162. data/lib/losant_rest/audit_log.rb +0 -81
  163. data/lib/losant_rest/auth.rb +0 -245
  164. data/lib/losant_rest/client.rb +0 -410
  165. data/lib/losant_rest/credential.rb +0 -224
  166. data/lib/losant_rest/credentials.rb +0 -138
  167. data/lib/losant_rest/dashboard.rb +0 -268
  168. data/lib/losant_rest/dashboards.rb +0 -136
  169. data/lib/losant_rest/data.rb +0 -176
  170. data/lib/losant_rest/data_table.rb +0 -274
  171. data/lib/losant_rest/data_table_row.rb +0 -182
  172. data/lib/losant_rest/data_table_rows.rb +0 -343
  173. data/lib/losant_rest/data_tables.rb +0 -138
  174. data/lib/losant_rest/device.rb +0 -749
  175. data/lib/losant_rest/device_recipe.rb +0 -234
  176. data/lib/losant_rest/device_recipes.rb +0 -146
  177. data/lib/losant_rest/devices.rb +0 -707
  178. data/lib/losant_rest/edge_deployment.rb +0 -81
  179. data/lib/losant_rest/edge_deployments.rb +0 -236
  180. data/lib/losant_rest/embedded_deployment.rb +0 -81
  181. data/lib/losant_rest/embedded_deployments.rb +0 -280
  182. data/lib/losant_rest/error.rb +0 -34
  183. data/lib/losant_rest/event.rb +0 -176
  184. data/lib/losant_rest/events.rb +0 -341
  185. data/lib/losant_rest/experience.rb +0 -142
  186. data/lib/losant_rest/experience_domain.rb +0 -176
  187. data/lib/losant_rest/experience_domains.rb +0 -126
  188. data/lib/losant_rest/experience_endpoint.rb +0 -230
  189. data/lib/losant_rest/experience_endpoints.rb +0 -200
  190. data/lib/losant_rest/experience_group.rb +0 -180
  191. data/lib/losant_rest/experience_groups.rb +0 -141
  192. data/lib/losant_rest/experience_slug.rb +0 -176
  193. data/lib/losant_rest/experience_slugs.rb +0 -126
  194. data/lib/losant_rest/experience_user.rb +0 -176
  195. data/lib/losant_rest/experience_users.rb +0 -142
  196. data/lib/losant_rest/experience_version.rb +0 -176
  197. data/lib/losant_rest/experience_versions.rb +0 -138
  198. data/lib/losant_rest/experience_view.rb +0 -228
  199. data/lib/losant_rest/experience_views.rb +0 -142
  200. data/lib/losant_rest/file.rb +0 -226
  201. data/lib/losant_rest/files.rb +0 -144
  202. data/lib/losant_rest/flow.rb +0 -580
  203. data/lib/losant_rest/flow_version.rb +0 -352
  204. data/lib/losant_rest/flow_versions.rb +0 -201
  205. data/lib/losant_rest/flows.rb +0 -310
  206. data/lib/losant_rest/instance.rb +0 -377
  207. data/lib/losant_rest/instance_api_token.rb +0 -176
  208. data/lib/losant_rest/instance_api_tokens.rb +0 -136
  209. data/lib/losant_rest/instance_custom_node.rb +0 -282
  210. data/lib/losant_rest/instance_custom_nodes.rb +0 -136
  211. data/lib/losant_rest/instance_member.rb +0 -176
  212. data/lib/losant_rest/instance_members.rb +0 -134
  213. data/lib/losant_rest/instance_org.rb +0 -336
  214. data/lib/losant_rest/instance_org_invite.rb +0 -182
  215. data/lib/losant_rest/instance_org_invites.rb +0 -138
  216. data/lib/losant_rest/instance_org_member.rb +0 -182
  217. data/lib/losant_rest/instance_org_members.rb +0 -138
  218. data/lib/losant_rest/instance_orgs.rb +0 -139
  219. data/lib/losant_rest/instance_sandbox.rb +0 -181
  220. data/lib/losant_rest/instance_sandboxes.rb +0 -98
  221. data/lib/losant_rest/instances.rb +0 -88
  222. data/lib/losant_rest/integration.rb +0 -178
  223. data/lib/losant_rest/integrations.rb +0 -138
  224. data/lib/losant_rest/me.rb +0 -790
  225. data/lib/losant_rest/notebook.rb +0 -423
  226. data/lib/losant_rest/notebooks.rb +0 -138
  227. data/lib/losant_rest/org.rb +0 -663
  228. data/lib/losant_rest/org_invites.rb +0 -124
  229. data/lib/losant_rest/orgs.rb +0 -140
  230. data/lib/losant_rest/resource_job.rb +0 -326
  231. data/lib/losant_rest/resource_jobs.rb +0 -138
  232. data/lib/losant_rest/user_api_token.rb +0 -170
  233. data/lib/losant_rest/user_api_tokens.rb +0 -132
  234. data/lib/losant_rest/utils.rb +0 -44
  235. data/lib/losant_rest/webhook.rb +0 -178
  236. data/lib/losant_rest/webhooks.rb +0 -138
  237. data/lib/losant_rest.rb +0 -129
@@ -1,34 +0,0 @@
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
- module LosantRest
24
- class ResponseError < StandardError
25
- attr_reader :code
26
- attr_reader :type
27
-
28
- def initialize(code, result)
29
- @code = code
30
- @type = result["type"]
31
- super(result["message"])
32
- end
33
- end
34
- end
@@ -1,176 +0,0 @@
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 LosantRest
26
-
27
- # Class containing all the actions for the Event Resource
28
- class Event
29
-
30
- def initialize(client)
31
- @client = client
32
- end
33
-
34
- # Deletes an event
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, event.*, or event.delete.
41
- #
42
- # Parameters:
43
- # * {string} applicationId - ID associated with the application
44
- # * {string} eventId - ID associated with the event
45
- # * {string} losantdomain - Domain scope of request (rarely needed)
46
- # * {boolean} _actions - Return resource actions in response
47
- # * {boolean} _links - Return resource link in response
48
- # * {boolean} _embedded - Return embedded resources in response
49
- #
50
- # Responses:
51
- # * 200 - If event was successfully deleted (https://api.losant.com/#/definitions/success)
52
- #
53
- # Errors:
54
- # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
55
- # * 404 - Error if event was not found (https://api.losant.com/#/definitions/error)
56
- def delete(params = {})
57
- params = Utils.symbolize_hash_keys(params)
58
- query_params = { _actions: false, _links: true, _embedded: true }
59
- headers = {}
60
- body = nil
61
-
62
- raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
63
- raise ArgumentError.new("eventId is required") unless params.has_key?(:eventId)
64
-
65
- headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
66
- query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
67
- query_params[:_links] = params[:_links] if params.has_key?(:_links)
68
- query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
69
-
70
- path = "/applications/#{params[:applicationId]}/events/#{params[:eventId]}"
71
-
72
- @client.request(
73
- method: :delete,
74
- path: path,
75
- query: query_params,
76
- headers: headers,
77
- body: body)
78
- end
79
-
80
- # Retrieves information on an event
81
- #
82
- # Authentication:
83
- # The client must be configured with a valid api
84
- # access token to call this action. The token
85
- # must include at least one of the following scopes:
86
- # all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, event.*, or event.get.
87
- #
88
- # Parameters:
89
- # * {string} applicationId - ID associated with the application
90
- # * {string} eventId - ID associated with the event
91
- # * {string} losantdomain - Domain scope of request (rarely needed)
92
- # * {boolean} _actions - Return resource actions in response
93
- # * {boolean} _links - Return resource link in response
94
- # * {boolean} _embedded - Return embedded resources in response
95
- #
96
- # Responses:
97
- # * 200 - Event information (https://api.losant.com/#/definitions/event)
98
- #
99
- # Errors:
100
- # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
101
- # * 404 - Error if event was not found (https://api.losant.com/#/definitions/error)
102
- def get(params = {})
103
- params = Utils.symbolize_hash_keys(params)
104
- query_params = { _actions: false, _links: true, _embedded: true }
105
- headers = {}
106
- body = nil
107
-
108
- raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
109
- raise ArgumentError.new("eventId is required") unless params.has_key?(:eventId)
110
-
111
- headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
112
- query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
113
- query_params[:_links] = params[:_links] if params.has_key?(:_links)
114
- query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
115
-
116
- path = "/applications/#{params[:applicationId]}/events/#{params[:eventId]}"
117
-
118
- @client.request(
119
- method: :get,
120
- path: path,
121
- query: query_params,
122
- headers: headers,
123
- body: body)
124
- end
125
-
126
- # Updates information about an event
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.Organization, all.User, event.*, or event.patch.
133
- #
134
- # Parameters:
135
- # * {string} applicationId - ID associated with the application
136
- # * {string} eventId - ID associated with the event
137
- # * {hash} event - Object containing new properties of the event (https://api.losant.com/#/definitions/eventPatch)
138
- # * {string} losantdomain - Domain scope of request (rarely needed)
139
- # * {boolean} _actions - Return resource actions in response
140
- # * {boolean} _links - Return resource link in response
141
- # * {boolean} _embedded - Return embedded resources in response
142
- #
143
- # Responses:
144
- # * 200 - Updated event information (https://api.losant.com/#/definitions/event)
145
- #
146
- # Errors:
147
- # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
148
- # * 404 - Error if event is not found (https://api.losant.com/#/definitions/error)
149
- def patch(params = {})
150
- params = Utils.symbolize_hash_keys(params)
151
- query_params = { _actions: false, _links: true, _embedded: true }
152
- headers = {}
153
- body = nil
154
-
155
- raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
156
- raise ArgumentError.new("eventId is required") unless params.has_key?(:eventId)
157
- raise ArgumentError.new("event is required") unless params.has_key?(:event)
158
-
159
- body = params[:event] if params.has_key?(:event)
160
- headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
161
- query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
162
- query_params[:_links] = params[:_links] if params.has_key?(:_links)
163
- query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
164
-
165
- path = "/applications/#{params[:applicationId]}/events/#{params[:eventId]}"
166
-
167
- @client.request(
168
- method: :patch,
169
- path: path,
170
- query: query_params,
171
- headers: headers,
172
- body: body)
173
- end
174
-
175
- end
176
- end
@@ -1,341 +0,0 @@
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 LosantRest
26
-
27
- # Class containing all the actions for the Events Resource
28
- class Events
29
-
30
- def initialize(client)
31
- @client = client
32
- end
33
-
34
- # Delete events
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, events.*, or events.delete.
41
- #
42
- # Parameters:
43
- # * {string} applicationId - ID associated with the application
44
- # * {hash} query - Query to apply to filter the events (https://api.losant.com/#/definitions/advancedEventQuery)
45
- # * {string} losantdomain - Domain scope of request (rarely needed)
46
- # * {boolean} _actions - Return resource actions in response
47
- # * {boolean} _links - Return resource link in response
48
- # * {boolean} _embedded - Return embedded resources in response
49
- #
50
- # Responses:
51
- # * 200 - If request successfully deletes a set of Events (https://api.losant.com/#/definitions/eventsDeleted)
52
- #
53
- # Errors:
54
- # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
55
- # * 404 - Error if events were not found (https://api.losant.com/#/definitions/error)
56
- def delete(params = {})
57
- params = Utils.symbolize_hash_keys(params)
58
- query_params = { _actions: false, _links: true, _embedded: true }
59
- headers = {}
60
- body = nil
61
-
62
- raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
63
-
64
- body = params[:query] if params.has_key?(:query)
65
- headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
66
- query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
67
- query_params[:_links] = params[:_links] if params.has_key?(:_links)
68
- query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
69
-
70
- path = "/applications/#{params[:applicationId]}/events/delete"
71
-
72
- @client.request(
73
- method: :post,
74
- path: path,
75
- query: query_params,
76
- headers: headers,
77
- body: body)
78
- end
79
-
80
- # Request an export of an application's event data
81
- #
82
- # Authentication:
83
- # The client must be configured with a valid api
84
- # access token to call this action. The token
85
- # must include at least one of the following scopes:
86
- # all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, events.*, or events.export.
87
- #
88
- # Parameters:
89
- # * {string} applicationId - ID associated with the application
90
- # * {hash} exportData - Export options for events (https://api.losant.com/#/definitions/eventsExport)
91
- # * {string} losantdomain - Domain scope of request (rarely needed)
92
- # * {boolean} _actions - Return resource actions in response
93
- # * {boolean} _links - Return resource link in response
94
- # * {boolean} _embedded - Return embedded resources in response
95
- #
96
- # Responses:
97
- # * 202 - If generation of export was successfully started (https://api.losant.com/#/definitions/jobEnqueuedResult)
98
- #
99
- # Errors:
100
- # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
101
- # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
102
- def export(params = {})
103
- params = Utils.symbolize_hash_keys(params)
104
- query_params = { _actions: false, _links: true, _embedded: true }
105
- headers = {}
106
- body = nil
107
-
108
- raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
109
-
110
- body = params[:exportData] if params.has_key?(:exportData)
111
- headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
112
- query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
113
- query_params[:_links] = params[:_links] if params.has_key?(:_links)
114
- query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
115
-
116
- path = "/applications/#{params[:applicationId]}/events/export"
117
-
118
- @client.request(
119
- method: :post,
120
- path: path,
121
- query: query_params,
122
- headers: headers,
123
- body: body)
124
- end
125
-
126
- # Returns the events for an application
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, events.*, or events.get.
133
- #
134
- # Parameters:
135
- # * {string} applicationId - ID associated with the application
136
- # * {string} sortField - Field to sort the results by. Accepted values are: subject, id, creationDate, lastUpdated, level, state, deviceId
137
- # * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc
138
- # * {string} page - Which page of results to return
139
- # * {string} perPage - How many items to return per page
140
- # * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: subject
141
- # * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering.
142
- # * {string} state - If provided, return events only in the given state. Accepted values are: new, acknowledged, resolved
143
- # * {hash} query - Event filter JSON object which overrides the filterField, filter, and state parameters. (https://api.losant.com/#/definitions/advancedEventQuery)
144
- # * {string} losantdomain - Domain scope of request (rarely needed)
145
- # * {boolean} _actions - Return resource actions in response
146
- # * {boolean} _links - Return resource link in response
147
- # * {boolean} _embedded - Return embedded resources in response
148
- #
149
- # Responses:
150
- # * 200 - Collection of events (https://api.losant.com/#/definitions/events)
151
- #
152
- # Errors:
153
- # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
154
- # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
155
- def get(params = {})
156
- params = Utils.symbolize_hash_keys(params)
157
- query_params = { _actions: false, _links: true, _embedded: true }
158
- headers = {}
159
- body = nil
160
-
161
- raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
162
-
163
- query_params[:sortField] = params[:sortField] if params.has_key?(:sortField)
164
- query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection)
165
- query_params[:page] = params[:page] if params.has_key?(:page)
166
- query_params[:perPage] = params[:perPage] if params.has_key?(:perPage)
167
- query_params[:filterField] = params[:filterField] if params.has_key?(:filterField)
168
- query_params[:filter] = params[:filter] if params.has_key?(:filter)
169
- query_params[:state] = params[:state] if params.has_key?(:state)
170
- query_params[:query] = params[:query] if params.has_key?(:query)
171
- query_params[:query] = JSON.dump(query_params[:query]) if query_params.has_key?(:query)
172
- headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
173
- query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
174
- query_params[:_links] = params[:_links] if params.has_key?(:_links)
175
- query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
176
-
177
- path = "/applications/#{params[:applicationId]}/events"
178
-
179
- @client.request(
180
- method: :get,
181
- path: path,
182
- query: query_params,
183
- headers: headers,
184
- body: body)
185
- end
186
-
187
- # Returns the first new event ordered by severity and then creation
188
- #
189
- # Authentication:
190
- # The client must be configured with a valid api
191
- # access token to call this action. The token
192
- # must include at least one of the following scopes:
193
- # all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, events.*, or events.mostRecentBySeverity.
194
- #
195
- # Parameters:
196
- # * {string} applicationId - ID associated with the application
197
- # * {string} filter - Filter to apply against event subjects. Supports globbing. Blank or not provided means no filtering.
198
- # * {hash} query - Event filter JSON object which overrides the filter parameter. (https://api.losant.com/#/definitions/advancedEventQuery)
199
- # * {string} losantdomain - Domain scope of request (rarely needed)
200
- # * {boolean} _actions - Return resource actions in response
201
- # * {boolean} _links - Return resource link in response
202
- # * {boolean} _embedded - Return embedded resources in response
203
- #
204
- # Responses:
205
- # * 200 - The event, plus count of currently new events (https://api.losant.com/#/definitions/eventPlusNewCount)
206
- #
207
- # Errors:
208
- # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
209
- def most_recent_by_severity(params = {})
210
- params = Utils.symbolize_hash_keys(params)
211
- query_params = { _actions: false, _links: true, _embedded: true }
212
- headers = {}
213
- body = nil
214
-
215
- raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
216
-
217
- query_params[:filter] = params[:filter] if params.has_key?(:filter)
218
- query_params[:query] = params[:query] if params.has_key?(:query)
219
- query_params[:query] = JSON.dump(query_params[:query]) if query_params.has_key?(:query)
220
- headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
221
- query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
222
- query_params[:_links] = params[:_links] if params.has_key?(:_links)
223
- query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
224
-
225
- path = "/applications/#{params[:applicationId]}/events/mostRecentBySeverity"
226
-
227
- @client.request(
228
- method: :get,
229
- path: path,
230
- query: query_params,
231
- headers: headers,
232
- body: body)
233
- end
234
-
235
- # Asynchronously updates information for matching events by subject and/or current state
236
- #
237
- # Authentication:
238
- # The client must be configured with a valid api
239
- # access token to call this action. The token
240
- # must include at least one of the following scopes:
241
- # all.Application, all.Organization, all.User, events.*, or events.patch.
242
- #
243
- # Parameters:
244
- # * {string} applicationId - ID associated with the application
245
- # * {string} filterField - Field to filter the events to act on by. Blank or not provided means no filtering. Accepted values are: subject
246
- # * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering.
247
- # * {string} state - If provided, act on events only in the given state. Accepted values are: new, acknowledged, resolved
248
- # * {hash} query - Event filter JSON object which overrides the filterField, filter, and state parameters. (https://api.losant.com/#/definitions/advancedEventQuery)
249
- # * {hash} updates - Object containing updated information for the events (https://api.losant.com/#/definitions/eventPatch)
250
- # * {string} losantdomain - Domain scope of request (rarely needed)
251
- # * {boolean} _actions - Return resource actions in response
252
- # * {boolean} _links - Return resource link in response
253
- # * {boolean} _embedded - Return embedded resources in response
254
- #
255
- # Responses:
256
- # * 200 - If the bulk update has been completed (https://api.losant.com/#/definitions/success)
257
- # * 202 - If a bulk update job has been enqueued (https://api.losant.com/#/definitions/jobEnqueuedResult)
258
- #
259
- # Errors:
260
- # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
261
- # * 404 - Error if application is not found (https://api.losant.com/#/definitions/error)
262
- def patch(params = {})
263
- params = Utils.symbolize_hash_keys(params)
264
- query_params = { _actions: false, _links: true, _embedded: true }
265
- headers = {}
266
- body = nil
267
-
268
- raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
269
- raise ArgumentError.new("updates is required") unless params.has_key?(:updates)
270
-
271
- query_params[:filterField] = params[:filterField] if params.has_key?(:filterField)
272
- query_params[:filter] = params[:filter] if params.has_key?(:filter)
273
- query_params[:state] = params[:state] if params.has_key?(:state)
274
- query_params[:query] = params[:query] if params.has_key?(:query)
275
- query_params[:query] = JSON.dump(query_params[:query]) if query_params.has_key?(:query)
276
- body = params[:updates] if params.has_key?(:updates)
277
- headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
278
- query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
279
- query_params[:_links] = params[:_links] if params.has_key?(:_links)
280
- query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
281
-
282
- path = "/applications/#{params[:applicationId]}/events"
283
-
284
- @client.request(
285
- method: :patch,
286
- path: path,
287
- query: query_params,
288
- headers: headers,
289
- body: body)
290
- end
291
-
292
- # Create a new event for an application
293
- #
294
- # Authentication:
295
- # The client must be configured with a valid api
296
- # access token to call this action. The token
297
- # must include at least one of the following scopes:
298
- # all.Application, all.Organization, all.User, events.*, or events.post.
299
- #
300
- # Parameters:
301
- # * {string} applicationId - ID associated with the application
302
- # * {hash} event - New event information (https://api.losant.com/#/definitions/eventPost)
303
- # * {string} losantdomain - Domain scope of request (rarely needed)
304
- # * {boolean} _actions - Return resource actions in response
305
- # * {boolean} _links - Return resource link in response
306
- # * {boolean} _embedded - Return embedded resources in response
307
- #
308
- # Responses:
309
- # * 201 - Successfully created event (https://api.losant.com/#/definitions/event)
310
- #
311
- # Errors:
312
- # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
313
- # * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
314
- # * 429 - Error if event creation rate limit exceeded (https://api.losant.com/#/definitions/error)
315
- def post(params = {})
316
- params = Utils.symbolize_hash_keys(params)
317
- query_params = { _actions: false, _links: true, _embedded: true }
318
- headers = {}
319
- body = nil
320
-
321
- raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
322
- raise ArgumentError.new("event is required") unless params.has_key?(:event)
323
-
324
- body = params[:event] if params.has_key?(:event)
325
- headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
326
- query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
327
- query_params[:_links] = params[:_links] if params.has_key?(:_links)
328
- query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
329
-
330
- path = "/applications/#{params[:applicationId]}/events"
331
-
332
- @client.request(
333
- method: :post,
334
- path: path,
335
- query: query_params,
336
- headers: headers,
337
- body: body)
338
- end
339
-
340
- end
341
- end