losant_rest 1.10.0 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/docs/_schemas.md +18838 -4104
  3. data/docs/application.md +85 -0
  4. data/docs/applicationApiTokens.md +2 -2
  5. data/docs/applicationCertificateAuthorities.md +1 -1
  6. data/docs/applicationCertificates.md +1 -1
  7. data/docs/applicationKeys.md +1 -1
  8. data/docs/applicationTemplate.md +46 -0
  9. data/docs/applicationTemplates.md +77 -2
  10. data/docs/applications.md +1 -1
  11. data/docs/auditLogs.md +1 -1
  12. data/docs/dashboards.md +1 -1
  13. data/docs/dataTables.md +1 -1
  14. data/docs/device.md +7 -3
  15. data/docs/deviceRecipes.md +1 -1
  16. data/docs/devices.md +93 -5
  17. data/docs/edgeDeployments.md +1 -1
  18. data/docs/events.md +1 -1
  19. data/docs/experienceEndpoints.md +1 -0
  20. data/docs/experienceGroups.md +1 -1
  21. data/docs/experienceUsers.md +1 -1
  22. data/docs/experienceVersions.md +1 -1
  23. data/docs/experienceViews.md +1 -1
  24. data/docs/file.md +4 -4
  25. data/docs/files.md +1 -1
  26. data/docs/flow.md +94 -1
  27. data/docs/flowVersion.md +96 -1
  28. data/docs/flowVersions.md +1 -1
  29. data/docs/flows.md +2 -2
  30. data/docs/integrations.md +1 -1
  31. data/docs/me.md +0 -36
  32. data/docs/notebooks.md +1 -1
  33. data/docs/orgs.md +1 -1
  34. data/docs/webhooks.md +1 -1
  35. data/lib/losant_rest.rb +1 -0
  36. data/lib/losant_rest/application.rb +48 -0
  37. data/lib/losant_rest/application_api_tokens.rb +1 -1
  38. data/lib/losant_rest/application_template.rb +79 -0
  39. data/lib/losant_rest/application_templates.rb +89 -1
  40. data/lib/losant_rest/client.rb +6 -2
  41. data/lib/losant_rest/device.rb +11 -3
  42. data/lib/losant_rest/devices.rb +103 -3
  43. data/lib/losant_rest/experience_endpoints.rb +2 -0
  44. data/lib/losant_rest/file.rb +3 -3
  45. data/lib/losant_rest/flow.rb +115 -1
  46. data/lib/losant_rest/flow_version.rb +115 -1
  47. data/lib/losant_rest/me.rb +0 -41
  48. data/lib/losant_rest/version.rb +1 -1
  49. data/schemas/advancedDeviceQuery.json +110 -0
  50. data/schemas/advancedEventQuery.json +198 -0
  51. data/schemas/advancedQuery.json +22 -0
  52. data/schemas/application.json +13 -0
  53. data/schemas/applicationApiTokenPost.json +10 -1
  54. data/schemas/applicationApplyTemplatePatch.json +19 -0
  55. data/schemas/applicationCreationByTemplateResult.json +13 -0
  56. data/schemas/applicationPatch.json +5 -0
  57. data/schemas/applicationPost.json +13 -0
  58. data/schemas/applicationTemplate.json +20 -0
  59. data/schemas/applicationTemplateCategories.json +43 -0
  60. data/schemas/applicationTemplateCategory.json +23 -0
  61. data/schemas/applicationTemplates.json +32 -0
  62. data/schemas/applications.json +13 -0
  63. data/schemas/authedUser.json +3 -0
  64. data/schemas/changePassword.json +2 -2
  65. data/schemas/dashboard.json +1288 -145
  66. data/schemas/dashboardPatch.json +1288 -145
  67. data/schemas/dashboardPost.json +1288 -145
  68. data/schemas/dashboards.json +1288 -145
  69. data/schemas/dataExport.json +142 -0
  70. data/schemas/dataTableRowsExport.json +22 -0
  71. data/schemas/device.json +16 -3
  72. data/schemas/deviceAttributeDataTypeFilter.json +29 -0
  73. data/schemas/deviceClassFilter.json +1 -2
  74. data/schemas/devicePatch.json +16 -3
  75. data/schemas/devicePost.json +16 -3
  76. data/schemas/deviceRecipe.json +16 -3
  77. data/schemas/deviceRecipePatch.json +16 -3
  78. data/schemas/deviceRecipePost.json +16 -3
  79. data/schemas/deviceRecipes.json +16 -3
  80. data/schemas/devices.json +16 -3
  81. data/schemas/devicesDataRemoved.json +12 -0
  82. data/schemas/devicesDeletePost.json +1034 -0
  83. data/schemas/devicesDeleted.json +12 -0
  84. data/schemas/devicesExportPost.json +1035 -0
  85. data/schemas/devicesPatch.json +1773 -7
  86. data/schemas/devicesRemoveDataPost.json +1056 -0
  87. data/schemas/devicesUpdated.json +18 -0
  88. data/schemas/eventPost.json +22 -0
  89. data/schemas/eventsExport.json +198 -0
  90. data/schemas/experienceDomain.json +1 -1
  91. data/schemas/experienceDomainPatch.json +1 -1
  92. data/schemas/experienceDomainPost.json +1 -1
  93. data/schemas/experienceDomains.json +1 -1
  94. data/schemas/experienceLinkedResources.json +372 -3
  95. data/schemas/experienceVersion.json +1 -1
  96. data/schemas/experienceVersions.json +1 -1
  97. data/schemas/flow.json +124 -1
  98. data/schemas/flowErrors.json +87 -0
  99. data/schemas/flowPatch.json +124 -1
  100. data/schemas/flowPost.json +124 -1
  101. data/schemas/flowStats.json +54 -0
  102. data/schemas/flowVersion.json +248 -2
  103. data/schemas/flowVersionPost.json +124 -1
  104. data/schemas/flowVersions.json +248 -2
  105. data/schemas/flows.json +124 -1
  106. data/schemas/flowsImportPost.json +248 -2
  107. data/schemas/flowsImportResult.json +372 -3
  108. data/schemas/githubLogin.json +16 -4
  109. data/schemas/me.json +3 -3
  110. data/schemas/mePatch.json +2 -2
  111. data/schemas/multiDeviceCommand.json +1019 -0
  112. data/schemas/notebook.json +89 -0
  113. data/schemas/notebookPatch.json +89 -0
  114. data/schemas/notebookPost.json +89 -0
  115. data/schemas/notebooks.json +89 -0
  116. data/schemas/org.json +1 -1
  117. data/schemas/orgInviteInfo.json +3 -0
  118. data/schemas/orgInvitePost.json +3 -0
  119. data/schemas/orgInvites.json +3 -0
  120. data/schemas/orgPatch.json +1 -1
  121. data/schemas/orgs.json +1 -1
  122. data/schemas/passwordResetFinish.json +2 -2
  123. data/schemas/samlResponse.json +1 -1
  124. data/schemas/templateKeywords.json +14 -0
  125. data/schemas/timeSeriesData.json +101 -12
  126. data/schemas/timeSeriesQuery.json +101 -12
  127. data/schemas/userCredentials.json +14 -3
  128. data/schemas/userPost.json +22 -7
  129. metadata +20 -5
@@ -33,7 +33,7 @@ all.User, all.User.read, orgs.*, or orgs.get.
33
33
  | sortField | string | N | Field to sort the results by. Accepted values are: name, id, creationDate, lastUpdated | name | name |
34
34
  | sortDirection | string | N | Direction to sort the results by. Accepted values are: asc, desc | asc | asc |
35
35
  | page | string | N | Which page of results to return | 0 | 0 |
36
- | perPage | string | N | How many items to return per page | 1000 | 10 |
36
+ | perPage | string | N | How many items to return per page | 100 | 10 |
37
37
  | filterField | string | N | Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name | | name |
38
38
  | filter | string | N | Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. | | my*org |
39
39
  | summaryExclude | string | N | Comma-separated list of summary fields to exclude from org summaries | | payloadCount |
@@ -34,7 +34,7 @@ all.Application, all.Application.read, all.Organization, all.Organization.read,
34
34
  | sortField | string | N | Field to sort the results by. Accepted values are: name, id, creationDate, lastUpdated | name | name |
35
35
  | sortDirection | string | N | Direction to sort the results by. Accepted values are: asc, desc | asc | asc |
36
36
  | page | string | N | Which page of results to return | 0 | 0 |
37
- | perPage | string | N | How many items to return per page | 1000 | 10 |
37
+ | perPage | string | N | How many items to return per page | 100 | 10 |
38
38
  | filterField | string | N | Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name | | name |
39
39
  | filter | string | N | Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering. | | my*webhook |
40
40
  | losantdomain | string | N | Domain scope of request (rarely needed) | | example.com |
@@ -32,6 +32,7 @@ require_relative "losant_rest/application_certificate_authority"
32
32
  require_relative "losant_rest/application_certificates"
33
33
  require_relative "losant_rest/application_key"
34
34
  require_relative "losant_rest/application_keys"
35
+ require_relative "losant_rest/application_template"
35
36
  require_relative "losant_rest/application_templates"
36
37
  require_relative "losant_rest/applications"
37
38
  require_relative "losant_rest/audit_log"
@@ -31,6 +31,54 @@ module LosantRest
31
31
  @client = client
32
32
  end
33
33
 
34
+ # Add resources to an application via an application template
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, application.*, or application.applyTemplate.
41
+ #
42
+ # Parameters:
43
+ # * {string} applicationId - ID of the associated application
44
+ # * {hash} options - Object containing template import options (https://api.losant.com/#/definitions/applicationApplyTemplatePatch)
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 - Updated application information (https://api.losant.com/#/definitions/application)
52
+ # * 202 - If a job was enqueued for the resources to be imported into the application (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 is not found (https://api.losant.com/#/definitions/error)
57
+ def apply_template(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]}/applyTemplate"
73
+
74
+ @client.request(
75
+ method: :patch,
76
+ path: path,
77
+ query: query_params,
78
+ headers: headers,
79
+ body: body)
80
+ end
81
+
34
82
  # Returns success when a job has been enqueued to archive this application's device data for a given day
35
83
  #
36
84
  # Authentication:
@@ -41,7 +41,7 @@ module LosantRest
41
41
  #
42
42
  # Parameters:
43
43
  # * {string} applicationId - ID associated with the application
44
- # * {string} sortField - Field to sort the results by. Accepted values are: name, status, id, creationDate, lastUpdated
44
+ # * {string} sortField - Field to sort the results by. Accepted values are: name, status, id, creationDate, lastUpdated, expirationDate
45
45
  # * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc
46
46
  # * {string} page - Which page of results to return
47
47
  # * {string} perPage - How many items to return per page
@@ -0,0 +1,79 @@
1
+ # The MIT License (MIT)
2
+ #
3
+ # Copyright (c) 2020 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 Application Template Resource
28
+ class ApplicationTemplate
29
+
30
+ def initialize(client)
31
+ @client = client
32
+ end
33
+
34
+ # Retrieves information on an application template
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.User, all.User.read, applicationTemplate.*, or applicationTemplate.get.
41
+ #
42
+ # Parameters:
43
+ # * {string} templateId - ID associated with the template
44
+ # * {string} losantdomain - Domain scope of request (rarely needed)
45
+ # * {boolean} _actions - Return resource actions in response
46
+ # * {boolean} _links - Return resource link in response
47
+ # * {boolean} _embedded - Return embedded resources in response
48
+ #
49
+ # Responses:
50
+ # * 200 - Application template information (https://api.losant.com/#/definitions/applicationTemplate)
51
+ #
52
+ # Errors:
53
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
54
+ # * 404 - Error if template was not found (https://api.losant.com/#/definitions/error)
55
+ def get(params = {})
56
+ params = Utils.symbolize_hash_keys(params)
57
+ query_params = { _actions: false, _links: true, _embedded: true }
58
+ headers = {}
59
+ body = nil
60
+
61
+ raise ArgumentError.new("templateId is required") unless params.has_key?(:templateId)
62
+
63
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
64
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
65
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
66
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
67
+
68
+ path = "/applicationTemplates/#{params[:templateId]}"
69
+
70
+ @client.request(
71
+ method: :get,
72
+ path: path,
73
+ query: query_params,
74
+ headers: headers,
75
+ body: body)
76
+ end
77
+
78
+ end
79
+ end
@@ -44,8 +44,10 @@ module LosantRest
44
44
  # * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc
45
45
  # * {string} page - Which page of results to return
46
46
  # * {string} perPage - How many items to return per page
47
- # * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name
47
+ # * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name, authorName
48
48
  # * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering.
49
+ # * {array} keywords - List of keywords to filter by. Matches all provided keywords.
50
+ # * {string} categoryId - ID of a category to filter by.
49
51
  # * {string} losantdomain - Domain scope of request (rarely needed)
50
52
  # * {boolean} _actions - Return resource actions in response
51
53
  # * {boolean} _links - Return resource link in response
@@ -69,6 +71,8 @@ module LosantRest
69
71
  query_params[:perPage] = params[:perPage] if params.has_key?(:perPage)
70
72
  query_params[:filterField] = params[:filterField] if params.has_key?(:filterField)
71
73
  query_params[:filter] = params[:filter] if params.has_key?(:filter)
74
+ query_params[:keywords] = params[:keywords] if params.has_key?(:keywords)
75
+ query_params[:categoryId] = params[:categoryId] if params.has_key?(:categoryId)
72
76
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
73
77
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
74
78
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
@@ -84,5 +88,89 @@ module LosantRest
84
88
  body: body)
85
89
  end
86
90
 
91
+ # Returns a category list, beginning at the specified category
92
+ #
93
+ # Authentication:
94
+ # The client must be configured with a valid api
95
+ # access token to call this action. The token
96
+ # must include at least one of the following scopes:
97
+ # all.User, all.User.read, applicationTemplates.*, or applicationTemplates.getCategories.
98
+ #
99
+ # Parameters:
100
+ # * {string} baseId - ID of the category to begin from
101
+ # * {string} losantdomain - Domain scope of request (rarely needed)
102
+ # * {boolean} _actions - Return resource actions in response
103
+ # * {boolean} _links - Return resource link in response
104
+ # * {boolean} _embedded - Return embedded resources in response
105
+ #
106
+ # Responses:
107
+ # * 200 - Collection of application categories (https://api.losant.com/#/definitions/applicationTemplateCategories)
108
+ #
109
+ # Errors:
110
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
111
+ def get_categories(params = {})
112
+ params = Utils.symbolize_hash_keys(params)
113
+ query_params = { _actions: false, _links: true, _embedded: true }
114
+ headers = {}
115
+ body = nil
116
+
117
+
118
+ query_params[:baseId] = params[:baseId] if params.has_key?(:baseId)
119
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
120
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
121
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
122
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
123
+
124
+ path = "/applicationTemplates/categories"
125
+
126
+ @client.request(
127
+ method: :get,
128
+ path: path,
129
+ query: query_params,
130
+ headers: headers,
131
+ body: body)
132
+ end
133
+
134
+ # Returns an array of all unique keywords currently in use by templates
135
+ #
136
+ # Authentication:
137
+ # The client must be configured with a valid api
138
+ # access token to call this action. The token
139
+ # must include at least one of the following scopes:
140
+ # all.User, all.User.read, applicationTemplates.*, or applicationTemplates.getUniqueKeywords.
141
+ #
142
+ # Parameters:
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 - Array of all unique template keywords (https://api.losant.com/#/definitions/templateKeywords)
150
+ #
151
+ # Errors:
152
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
153
+ def get_unique_keywords(params = {})
154
+ params = Utils.symbolize_hash_keys(params)
155
+ query_params = { _actions: false, _links: true, _embedded: true }
156
+ headers = {}
157
+ body = nil
158
+
159
+
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 = "/applicationTemplates/keywords"
166
+
167
+ @client.request(
168
+ method: :get,
169
+ path: path,
170
+ query: query_params,
171
+ headers: headers,
172
+ body: body)
173
+ end
174
+
87
175
  end
88
176
  end
@@ -27,7 +27,7 @@ module LosantRest
27
27
  #
28
28
  # User API for accessing Losant data
29
29
  #
30
- # Built For Version 1.17.0
30
+ # Built For Version 1.18.0
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_template
76
+ @application_template ||= ApplicationTemplate.new(self)
77
+ end
78
+
75
79
  def application_templates
76
80
  @application_templates ||= ApplicationTemplates.new(self)
77
81
  end
@@ -278,7 +282,7 @@ module LosantRest
278
282
 
279
283
  headers["Accept"] = "application/json"
280
284
  headers["Content-Type"] = "application/json"
281
- headers["Accept-Version"] = "^1.17.0"
285
+ headers["Accept-Version"] = "^1.18.0"
282
286
  headers["Authorization"] = "Bearer #{self.auth_token}" if self.auth_token
283
287
  path = self.url + options.fetch(:path, "")
284
288
 
@@ -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)
@@ -190,8 +192,9 @@ module LosantRest
190
192
  # Parameters:
191
193
  # * {string} applicationId - ID associated with the application
192
194
  # * {string} deviceId - ID associated with the device
193
- # * {string} limit - Max command entries to return (ordered by time descending)
195
+ # * {string} limit - Maximum number of command entries to return
194
196
  # * {string} since - Look for command entries since this time (ms since epoch)
197
+ # * {string} sortDirection - Direction to sort the command entries (by time). Accepted values are: asc, desc
195
198
  # * {string} losantdomain - Domain scope of request (rarely needed)
196
199
  # * {boolean} _actions - Return resource actions in response
197
200
  # * {boolean} _links - Return resource link in response
@@ -214,6 +217,7 @@ module LosantRest
214
217
 
215
218
  query_params[:limit] = params[:limit] if params.has_key?(:limit)
216
219
  query_params[:since] = params[:since] if params.has_key?(:since)
220
+ query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection)
217
221
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
218
222
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
219
223
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
@@ -292,8 +296,9 @@ module LosantRest
292
296
  # Parameters:
293
297
  # * {string} applicationId - ID associated with the application
294
298
  # * {string} deviceId - ID associated with the device
295
- # * {string} limit - Max log entries to return (ordered by time descending)
299
+ # * {string} limit - Maximum number of log entries to return
296
300
  # * {string} since - Look for log entries since this time (ms since epoch)
301
+ # * {string} sortDirection - Direction to sort the log entries (by time). Accepted values are: asc, desc
297
302
  # * {string} losantdomain - Domain scope of request (rarely needed)
298
303
  # * {boolean} _actions - Return resource actions in response
299
304
  # * {boolean} _links - Return resource link in response
@@ -316,6 +321,7 @@ module LosantRest
316
321
 
317
322
  query_params[:limit] = params[:limit] if params.has_key?(:limit)
318
323
  query_params[:since] = params[:since] if params.has_key?(:since)
324
+ query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection)
319
325
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
320
326
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
321
327
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
@@ -342,8 +348,9 @@ module LosantRest
342
348
  # Parameters:
343
349
  # * {string} applicationId - ID associated with the application
344
350
  # * {string} deviceId - ID associated with the device
345
- # * {string} limit - Max state entries to return (ordered by time descending)
351
+ # * {string} limit - Maximum number of state entries to return
346
352
  # * {string} since - Look for state entries since this time (ms since epoch)
353
+ # * {string} sortDirection - Direction to sort the state entries (by time). Accepted values are: asc, desc
347
354
  # * {string} losantdomain - Domain scope of request (rarely needed)
348
355
  # * {boolean} _actions - Return resource actions in response
349
356
  # * {boolean} _links - Return resource link in response
@@ -366,6 +373,7 @@ module LosantRest
366
373
 
367
374
  query_params[:limit] = params[:limit] if params.has_key?(:limit)
368
375
  query_params[:since] = params[:since] if params.has_key?(:since)
376
+ query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection)
369
377
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
370
378
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
371
379
  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,7 +149,7 @@ module LosantRest
99
149
  # * {hash} tagFilter - Array of tag pairs to filter by (https://api.losant.com/#/definitions/deviceTagFilter)
100
150
  # * {string} excludeConnectionInfo - If set, do not return connection info
101
151
  # * {string} parentId - Filter devices as children of a given system id
102
- # * {hash} query - Device filter JSON object which overides the filterField, filter, deviceClass, tagFilter, and parentId parameters. (https://api.losant.com/#/definitions/advancedDeviceQuery)
152
+ # * {hash} query - Device filter JSON object which overrides the filterField, filter, deviceClass, tagFilter, and parentId parameters. (https://api.losant.com/#/definitions/advancedDeviceQuery)
103
153
  # * {string} losantdomain - Domain scope of request (rarely needed)
104
154
  # * {boolean} _actions - Return resource actions in response
105
155
  # * {boolean} _links - Return resource link in response
@@ -156,14 +206,15 @@ module LosantRest
156
206
  #
157
207
  # Parameters:
158
208
  # * {string} applicationId - ID associated with the application
159
- # * {hash} patchInfo - Object containing device filter fields and updated properties (https://api.losant.com/#/definitions/devicesPatch)
209
+ # * {hash} patchInfo - Object containing device query or IDs and update operations (https://api.losant.com/#/definitions/devicesPatch)
160
210
  # * {string} losantdomain - Domain scope of request (rarely needed)
161
211
  # * {boolean} _actions - Return resource actions in response
162
212
  # * {boolean} _links - Return resource link in response
163
213
  # * {boolean} _embedded - Return embedded resources in response
164
214
  #
165
215
  # Responses:
166
- # * 201 - Successfully queued bulk update job (https://api.losant.com/#/definitions/success)
216
+ # * 200 - Object including an update log link and the number of devices updated, failed, and skipped (https://api.losant.com/#/definitions/devicesUpdated)
217
+ # * 202 - Successfully queued bulk update job (https://api.losant.com/#/definitions/jobEnqueuedResult)
167
218
  #
168
219
  # Errors:
169
220
  # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
@@ -175,6 +226,7 @@ module LosantRest
175
226
  body = nil
176
227
 
177
228
  raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
229
+ raise ArgumentError.new("patchInfo is required") unless params.has_key?(:patchInfo)
178
230
 
179
231
  body = params[:patchInfo] if params.has_key?(:patchInfo)
180
232
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
@@ -239,6 +291,54 @@ module LosantRest
239
291
  body: body)
240
292
  end
241
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
+
242
342
  # Send a command to multiple devices
243
343
  #
244
344
  # Authentication: