losant_rest 1.2.3 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -0
- data/docs/_schemas.md +997 -157
- data/docs/dataTable.md +214 -0
- data/docs/dataTableRow.md +136 -0
- data/docs/dataTableRows.md +139 -0
- data/docs/dataTables.md +91 -0
- data/docs/flow.md +41 -1
- data/lib/losant_rest/client.rb +18 -2
- data/lib/losant_rest/data_table.rb +272 -0
- data/lib/losant_rest/data_table_row.rb +180 -0
- data/lib/losant_rest/data_table_rows.rb +192 -0
- data/lib/losant_rest/data_tables.rb +136 -0
- data/lib/losant_rest/flow.rb +47 -1
- data/lib/losant_rest/version.rb +1 -1
- data/lib/losant_rest.rb +4 -0
- data/schemas/application.json +3 -0
- data/schemas/applicationApiTokenPost.json +16 -0
- data/schemas/applications.json +3 -0
- data/schemas/auditLog.json +1 -0
- data/schemas/auditLogFilter.json +1 -0
- data/schemas/auditLogs.json +1 -0
- data/schemas/dataTable.json +79 -0
- data/schemas/dataTableColumn.json +39 -0
- data/schemas/dataTablePatch.json +16 -0
- data/schemas/dataTablePost.json +63 -0
- data/schemas/dataTableQuery.json +86 -0
- data/schemas/dataTableRow.json +28 -0
- data/schemas/dataTableRowInsertUpdate.json +15 -0
- data/schemas/dataTableRows.json +68 -0
- data/schemas/dataTables.json +121 -0
- data/schemas/flow.json +1 -0
- data/schemas/flowPatch.json +1 -0
- data/schemas/flowPost.json +1 -0
- data/schemas/flowVersion.json +1 -0
- data/schemas/flowVersionPost.json +1 -0
- data/schemas/flowVersions.json +1 -0
- data/schemas/flows.json +1 -0
- data/schemas/me.json +14 -0
- data/schemas/org.json +14 -0
- data/schemas/orgs.json +14 -0
- data/schemas/payloadCounts.json +8 -0
- metadata +19 -2
@@ -0,0 +1,272 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2017 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
|
+
|
25
|
+
# Class containing all the actions for the Data Table Resource
|
26
|
+
class DataTable
|
27
|
+
|
28
|
+
def initialize(client)
|
29
|
+
@client = client
|
30
|
+
end
|
31
|
+
|
32
|
+
# Adds a new column to this data table
|
33
|
+
#
|
34
|
+
# Authentication:
|
35
|
+
# The client must be configured with a valid api
|
36
|
+
# access token to call this action. The token
|
37
|
+
# must include at least one of the following scopes:
|
38
|
+
# all.Application, all.Organization, all.User, dataTable.*, or dataTable.addColumn.
|
39
|
+
#
|
40
|
+
# Parameters:
|
41
|
+
# * {string} applicationId - ID associated with the application
|
42
|
+
# * {string} dataTableId - ID associated with the data table
|
43
|
+
# * {hash} dataTableColumn - Object containing the new column properties (https://api.losant.com/#/definitions/dataTableColumn)
|
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 - Updated data table information (https://api.losant.com/#/definitions/dataTable)
|
51
|
+
#
|
52
|
+
# Errors:
|
53
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
54
|
+
# * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error)
|
55
|
+
def add_column(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("applicationId is required") unless params.has_key?(:applicationId)
|
62
|
+
raise ArgumentError.new("dataTableId is required") unless params.has_key?(:dataTableId)
|
63
|
+
raise ArgumentError.new("dataTableColumn is required") unless params.has_key?(:dataTableColumn)
|
64
|
+
|
65
|
+
body = params[:dataTableColumn] if params.has_key?(:dataTableColumn)
|
66
|
+
headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
|
67
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
68
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
69
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
70
|
+
|
71
|
+
path = "/applications/#{params[:applicationId]}/data-tables/#{params[:dataTableId]}/column"
|
72
|
+
|
73
|
+
@client.request(
|
74
|
+
method: :post,
|
75
|
+
path: path,
|
76
|
+
query: query_params,
|
77
|
+
headers: headers,
|
78
|
+
body: body)
|
79
|
+
end
|
80
|
+
|
81
|
+
# Deletes a data table
|
82
|
+
#
|
83
|
+
# Authentication:
|
84
|
+
# The client must be configured with a valid api
|
85
|
+
# access token to call this action. The token
|
86
|
+
# must include at least one of the following scopes:
|
87
|
+
# all.Application, all.Organization, all.User, dataTable.*, or dataTable.delete.
|
88
|
+
#
|
89
|
+
# Parameters:
|
90
|
+
# * {string} applicationId - ID associated with the application
|
91
|
+
# * {string} dataTableId - ID associated with the data table
|
92
|
+
# * {string} losantdomain - Domain scope of request (rarely needed)
|
93
|
+
# * {boolean} _actions - Return resource actions in response
|
94
|
+
# * {boolean} _links - Return resource link in response
|
95
|
+
# * {boolean} _embedded - Return embedded resources in response
|
96
|
+
#
|
97
|
+
# Responses:
|
98
|
+
# * 200 - If data table was successfully deleted (https://api.losant.com/#/definitions/success)
|
99
|
+
#
|
100
|
+
# Errors:
|
101
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
102
|
+
# * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error)
|
103
|
+
def delete(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("applicationId is required") unless params.has_key?(:applicationId)
|
110
|
+
raise ArgumentError.new("dataTableId is required") unless params.has_key?(:dataTableId)
|
111
|
+
|
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 = "/applications/#{params[:applicationId]}/data-tables/#{params[:dataTableId]}"
|
118
|
+
|
119
|
+
@client.request(
|
120
|
+
method: :delete,
|
121
|
+
path: path,
|
122
|
+
query: query_params,
|
123
|
+
headers: headers,
|
124
|
+
body: body)
|
125
|
+
end
|
126
|
+
|
127
|
+
# Retrieves information on a data table
|
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.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, dataTable.*, or dataTable.get.
|
134
|
+
#
|
135
|
+
# Parameters:
|
136
|
+
# * {string} applicationId - ID associated with the application
|
137
|
+
# * {string} dataTableId - ID associated with the data table
|
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 - Data table information (https://api.losant.com/#/definitions/dataTable)
|
145
|
+
#
|
146
|
+
# Errors:
|
147
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
148
|
+
# * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error)
|
149
|
+
def get(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("dataTableId is required") unless params.has_key?(:dataTableId)
|
157
|
+
|
158
|
+
headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
|
159
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
160
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
161
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
162
|
+
|
163
|
+
path = "/applications/#{params[:applicationId]}/data-tables/#{params[:dataTableId]}"
|
164
|
+
|
165
|
+
@client.request(
|
166
|
+
method: :get,
|
167
|
+
path: path,
|
168
|
+
query: query_params,
|
169
|
+
headers: headers,
|
170
|
+
body: body)
|
171
|
+
end
|
172
|
+
|
173
|
+
# Updates information about a data table
|
174
|
+
#
|
175
|
+
# Authentication:
|
176
|
+
# The client must be configured with a valid api
|
177
|
+
# access token to call this action. The token
|
178
|
+
# must include at least one of the following scopes:
|
179
|
+
# all.Application, all.Organization, all.User, dataTable.*, or dataTable.patch.
|
180
|
+
#
|
181
|
+
# Parameters:
|
182
|
+
# * {string} applicationId - ID associated with the application
|
183
|
+
# * {string} dataTableId - ID associated with the data table
|
184
|
+
# * {hash} dataTable - Object containing updated properties of the data table (https://api.losant.com/#/definitions/dataTablePatch)
|
185
|
+
# * {string} losantdomain - Domain scope of request (rarely needed)
|
186
|
+
# * {boolean} _actions - Return resource actions in response
|
187
|
+
# * {boolean} _links - Return resource link in response
|
188
|
+
# * {boolean} _embedded - Return embedded resources in response
|
189
|
+
#
|
190
|
+
# Responses:
|
191
|
+
# * 200 - Updated data table information (https://api.losant.com/#/definitions/dataTable)
|
192
|
+
#
|
193
|
+
# Errors:
|
194
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
195
|
+
# * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error)
|
196
|
+
def patch(params = {})
|
197
|
+
params = Utils.symbolize_hash_keys(params)
|
198
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
199
|
+
headers = {}
|
200
|
+
body = nil
|
201
|
+
|
202
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
203
|
+
raise ArgumentError.new("dataTableId is required") unless params.has_key?(:dataTableId)
|
204
|
+
raise ArgumentError.new("dataTable is required") unless params.has_key?(:dataTable)
|
205
|
+
|
206
|
+
body = params[:dataTable] if params.has_key?(:dataTable)
|
207
|
+
headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
|
208
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
209
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
210
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
211
|
+
|
212
|
+
path = "/applications/#{params[:applicationId]}/data-tables/#{params[:dataTableId]}"
|
213
|
+
|
214
|
+
@client.request(
|
215
|
+
method: :patch,
|
216
|
+
path: path,
|
217
|
+
query: query_params,
|
218
|
+
headers: headers,
|
219
|
+
body: body)
|
220
|
+
end
|
221
|
+
|
222
|
+
# Removes a column from this data table
|
223
|
+
#
|
224
|
+
# Authentication:
|
225
|
+
# The client must be configured with a valid api
|
226
|
+
# access token to call this action. The token
|
227
|
+
# must include at least one of the following scopes:
|
228
|
+
# all.Application, all.Organization, all.User, dataTable.*, or dataTable.removeColumn.
|
229
|
+
#
|
230
|
+
# Parameters:
|
231
|
+
# * {string} applicationId - ID associated with the application
|
232
|
+
# * {string} dataTableId - ID associated with the data table
|
233
|
+
# * {string} columnName - Name of the column to remove
|
234
|
+
# * {string} losantdomain - Domain scope of request (rarely needed)
|
235
|
+
# * {boolean} _actions - Return resource actions in response
|
236
|
+
# * {boolean} _links - Return resource link in response
|
237
|
+
# * {boolean} _embedded - Return embedded resources in response
|
238
|
+
#
|
239
|
+
# Responses:
|
240
|
+
# * 200 - Updated data table information (https://api.losant.com/#/definitions/dataTable)
|
241
|
+
#
|
242
|
+
# Errors:
|
243
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
244
|
+
# * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error)
|
245
|
+
def remove_column(params = {})
|
246
|
+
params = Utils.symbolize_hash_keys(params)
|
247
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
248
|
+
headers = {}
|
249
|
+
body = nil
|
250
|
+
|
251
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
252
|
+
raise ArgumentError.new("dataTableId is required") unless params.has_key?(:dataTableId)
|
253
|
+
raise ArgumentError.new("columnName is required") unless params.has_key?(:columnName)
|
254
|
+
|
255
|
+
query_params[:columnName] = params[:columnName] if params.has_key?(:columnName)
|
256
|
+
headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
|
257
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
258
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
259
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
260
|
+
|
261
|
+
path = "/applications/#{params[:applicationId]}/data-tables/#{params[:dataTableId]}/column"
|
262
|
+
|
263
|
+
@client.request(
|
264
|
+
method: :delete,
|
265
|
+
path: path,
|
266
|
+
query: query_params,
|
267
|
+
headers: headers,
|
268
|
+
body: body)
|
269
|
+
end
|
270
|
+
|
271
|
+
end
|
272
|
+
end
|
@@ -0,0 +1,180 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2017 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
|
+
|
25
|
+
# Class containing all the actions for the Data Table Row Resource
|
26
|
+
class DataTableRow
|
27
|
+
|
28
|
+
def initialize(client)
|
29
|
+
@client = client
|
30
|
+
end
|
31
|
+
|
32
|
+
# Deletes a data table row
|
33
|
+
#
|
34
|
+
# Authentication:
|
35
|
+
# The client must be configured with a valid api
|
36
|
+
# access token to call this action. The token
|
37
|
+
# must include at least one of the following scopes:
|
38
|
+
# all.Application, all.Organization, all.User, dataTableRow.*, or dataTableRow.delete.
|
39
|
+
#
|
40
|
+
# Parameters:
|
41
|
+
# * {string} applicationId - ID associated with the application
|
42
|
+
# * {string} dataTableId - ID associated with the data table
|
43
|
+
# * {string} rowId - ID associated with the data table row
|
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 - If data table row was successfully deleted (https://api.losant.com/#/definitions/success)
|
51
|
+
#
|
52
|
+
# Errors:
|
53
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
54
|
+
# * 404 - Error if data table row was not found (https://api.losant.com/#/definitions/error)
|
55
|
+
def delete(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("applicationId is required") unless params.has_key?(:applicationId)
|
62
|
+
raise ArgumentError.new("dataTableId is required") unless params.has_key?(:dataTableId)
|
63
|
+
raise ArgumentError.new("rowId is required") unless params.has_key?(:rowId)
|
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]}/data-tables/#{params[:dataTableId]}/rows/#{params[:rowId]}"
|
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 the data table row
|
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, dataTableRow.*, or dataTableRow.get.
|
87
|
+
#
|
88
|
+
# Parameters:
|
89
|
+
# * {string} applicationId - ID associated with the application
|
90
|
+
# * {string} dataTableId - ID associated with the data table
|
91
|
+
# * {string} rowId - ID associated with the data table row
|
92
|
+
# * {string} losantdomain - Domain scope of request (rarely needed)
|
93
|
+
# * {boolean} _actions - Return resource actions in response
|
94
|
+
# * {boolean} _links - Return resource link in response
|
95
|
+
# * {boolean} _embedded - Return embedded resources in response
|
96
|
+
#
|
97
|
+
# Responses:
|
98
|
+
# * 200 - Data table row information (https://api.losant.com/#/definitions/dataTableRow)
|
99
|
+
#
|
100
|
+
# Errors:
|
101
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
102
|
+
# * 404 - Error if data table row was not found (https://api.losant.com/#/definitions/error)
|
103
|
+
def get(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("applicationId is required") unless params.has_key?(:applicationId)
|
110
|
+
raise ArgumentError.new("dataTableId is required") unless params.has_key?(:dataTableId)
|
111
|
+
raise ArgumentError.new("rowId is required") unless params.has_key?(:rowId)
|
112
|
+
|
113
|
+
headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
|
114
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
115
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
116
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
117
|
+
|
118
|
+
path = "/applications/#{params[:applicationId]}/data-tables/#{params[:dataTableId]}/rows/#{params[:rowId]}"
|
119
|
+
|
120
|
+
@client.request(
|
121
|
+
method: :get,
|
122
|
+
path: path,
|
123
|
+
query: query_params,
|
124
|
+
headers: headers,
|
125
|
+
body: body)
|
126
|
+
end
|
127
|
+
|
128
|
+
# Updates the data table row
|
129
|
+
#
|
130
|
+
# Authentication:
|
131
|
+
# The client must be configured with a valid api
|
132
|
+
# access token to call this action. The token
|
133
|
+
# must include at least one of the following scopes:
|
134
|
+
# all.Application, all.Organization, all.User, dataTableRow.*, or dataTableRow.patch.
|
135
|
+
#
|
136
|
+
# Parameters:
|
137
|
+
# * {string} applicationId - ID associated with the application
|
138
|
+
# * {string} dataTableId - ID associated with the data table
|
139
|
+
# * {string} rowId - ID associated with the data table row
|
140
|
+
# * {hash} dataTableRow - Object containing updated properties for the data table row (https://api.losant.com/#/definitions/dataTableRowInsertUpdate)
|
141
|
+
# * {string} losantdomain - Domain scope of request (rarely needed)
|
142
|
+
# * {boolean} _actions - Return resource actions in response
|
143
|
+
# * {boolean} _links - Return resource link in response
|
144
|
+
# * {boolean} _embedded - Return embedded resources in response
|
145
|
+
#
|
146
|
+
# Responses:
|
147
|
+
# * 200 - Updated data table row information (https://api.losant.com/#/definitions/dataTableRow)
|
148
|
+
#
|
149
|
+
# Errors:
|
150
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
151
|
+
# * 404 - Error if data table row was not found (https://api.losant.com/#/definitions/error)
|
152
|
+
def patch(params = {})
|
153
|
+
params = Utils.symbolize_hash_keys(params)
|
154
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
155
|
+
headers = {}
|
156
|
+
body = nil
|
157
|
+
|
158
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
159
|
+
raise ArgumentError.new("dataTableId is required") unless params.has_key?(:dataTableId)
|
160
|
+
raise ArgumentError.new("rowId is required") unless params.has_key?(:rowId)
|
161
|
+
raise ArgumentError.new("dataTableRow is required") unless params.has_key?(:dataTableRow)
|
162
|
+
|
163
|
+
body = params[:dataTableRow] if params.has_key?(:dataTableRow)
|
164
|
+
headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
|
165
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
166
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
167
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
168
|
+
|
169
|
+
path = "/applications/#{params[:applicationId]}/data-tables/#{params[:dataTableId]}/rows/#{params[:rowId]}"
|
170
|
+
|
171
|
+
@client.request(
|
172
|
+
method: :patch,
|
173
|
+
path: path,
|
174
|
+
query: query_params,
|
175
|
+
headers: headers,
|
176
|
+
body: body)
|
177
|
+
end
|
178
|
+
|
179
|
+
end
|
180
|
+
end
|
@@ -0,0 +1,192 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2017 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
|
+
|
25
|
+
# Class containing all the actions for the Data Table Rows Resource
|
26
|
+
class DataTableRows
|
27
|
+
|
28
|
+
def initialize(client)
|
29
|
+
@client = client
|
30
|
+
end
|
31
|
+
|
32
|
+
# Returns the rows for a data table
|
33
|
+
#
|
34
|
+
# Authentication:
|
35
|
+
# The client must be configured with a valid api
|
36
|
+
# access token to call this action. The token
|
37
|
+
# must include at least one of the following scopes:
|
38
|
+
# all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, dataTableRows.*, or dataTableRows.get.
|
39
|
+
#
|
40
|
+
# Parameters:
|
41
|
+
# * {string} applicationId - ID associated with the application
|
42
|
+
# * {string} dataTableId - ID associated with the data table
|
43
|
+
# * {string} sortColumn - Column to sort the rows by
|
44
|
+
# * {string} sortDirection - Direction to sort the rows by. Accepted values are: asc, desc
|
45
|
+
# * {string} limit - How many rows to return
|
46
|
+
# * {string} offset - How many rows to skip
|
47
|
+
# * {string} losantdomain - Domain scope of request (rarely needed)
|
48
|
+
# * {boolean} _actions - Return resource actions in response
|
49
|
+
# * {boolean} _links - Return resource link in response
|
50
|
+
# * {boolean} _embedded - Return embedded resources in response
|
51
|
+
#
|
52
|
+
# Responses:
|
53
|
+
# * 200 - Collection of data table rows (https://api.losant.com/#/definitions/dataTableRows)
|
54
|
+
#
|
55
|
+
# Errors:
|
56
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
57
|
+
# * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error)
|
58
|
+
def get(params = {})
|
59
|
+
params = Utils.symbolize_hash_keys(params)
|
60
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
61
|
+
headers = {}
|
62
|
+
body = nil
|
63
|
+
|
64
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
65
|
+
raise ArgumentError.new("dataTableId is required") unless params.has_key?(:dataTableId)
|
66
|
+
|
67
|
+
query_params[:sortColumn] = params[:sortColumn] if params.has_key?(:sortColumn)
|
68
|
+
query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection)
|
69
|
+
query_params[:limit] = params[:limit] if params.has_key?(:limit)
|
70
|
+
query_params[:offset] = params[:offset] if params.has_key?(:offset)
|
71
|
+
headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
|
72
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
73
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
74
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
75
|
+
|
76
|
+
path = "/applications/#{params[:applicationId]}/data-tables/#{params[:dataTableId]}/rows"
|
77
|
+
|
78
|
+
@client.request(
|
79
|
+
method: :get,
|
80
|
+
path: path,
|
81
|
+
query: query_params,
|
82
|
+
headers: headers,
|
83
|
+
body: body)
|
84
|
+
end
|
85
|
+
|
86
|
+
# Inserts a new row into a data table
|
87
|
+
#
|
88
|
+
# Authentication:
|
89
|
+
# The client must be configured with a valid api
|
90
|
+
# access token to call this action. The token
|
91
|
+
# must include at least one of the following scopes:
|
92
|
+
# all.Application, all.Organization, all.User, dataTableRows.*, or dataTableRows.post.
|
93
|
+
#
|
94
|
+
# Parameters:
|
95
|
+
# * {string} applicationId - ID associated with the application
|
96
|
+
# * {string} dataTableId - ID associated with the data table
|
97
|
+
# * {hash} dataTableRow - The row to insert (https://api.losant.com/#/definitions/dataTableRowInsertUpdate)
|
98
|
+
# * {string} losantdomain - Domain scope of request (rarely needed)
|
99
|
+
# * {boolean} _actions - Return resource actions in response
|
100
|
+
# * {boolean} _links - Return resource link in response
|
101
|
+
# * {boolean} _embedded - Return embedded resources in response
|
102
|
+
#
|
103
|
+
# Responses:
|
104
|
+
# * 201 - Successfully created data table row (https://api.losant.com/#/definitions/dataTableRow)
|
105
|
+
#
|
106
|
+
# Errors:
|
107
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
108
|
+
# * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error)
|
109
|
+
def post(params = {})
|
110
|
+
params = Utils.symbolize_hash_keys(params)
|
111
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
112
|
+
headers = {}
|
113
|
+
body = nil
|
114
|
+
|
115
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
116
|
+
raise ArgumentError.new("dataTableId is required") unless params.has_key?(:dataTableId)
|
117
|
+
raise ArgumentError.new("dataTableRow is required") unless params.has_key?(:dataTableRow)
|
118
|
+
|
119
|
+
body = params[:dataTableRow] if params.has_key?(:dataTableRow)
|
120
|
+
headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
|
121
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
122
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
123
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
124
|
+
|
125
|
+
path = "/applications/#{params[:applicationId]}/data-tables/#{params[:dataTableId]}/rows"
|
126
|
+
|
127
|
+
@client.request(
|
128
|
+
method: :post,
|
129
|
+
path: path,
|
130
|
+
query: query_params,
|
131
|
+
headers: headers,
|
132
|
+
body: body)
|
133
|
+
end
|
134
|
+
|
135
|
+
# Queries for rows from a data table
|
136
|
+
#
|
137
|
+
# Authentication:
|
138
|
+
# The client must be configured with a valid api
|
139
|
+
# access token to call this action. The token
|
140
|
+
# must include at least one of the following scopes:
|
141
|
+
# all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, dataTableRows.*, or dataTableRows.query.
|
142
|
+
#
|
143
|
+
# Parameters:
|
144
|
+
# * {string} applicationId - ID associated with the application
|
145
|
+
# * {string} dataTableId - ID associated with the data table
|
146
|
+
# * {string} sortColumn - Column to sort the rows by
|
147
|
+
# * {string} sortDirection - Direction to sort the rows by. Accepted values are: asc, desc
|
148
|
+
# * {string} limit - How many rows to return
|
149
|
+
# * {string} offset - How many rows to skip
|
150
|
+
# * {hash} query - Query to apply to filter the data table (https://api.losant.com/#/definitions/dataTableQuery)
|
151
|
+
# * {string} losantdomain - Domain scope of request (rarely needed)
|
152
|
+
# * {boolean} _actions - Return resource actions in response
|
153
|
+
# * {boolean} _links - Return resource link in response
|
154
|
+
# * {boolean} _embedded - Return embedded resources in response
|
155
|
+
#
|
156
|
+
# Responses:
|
157
|
+
# * 200 - Collection of data table rows (https://api.losant.com/#/definitions/dataTableRows)
|
158
|
+
#
|
159
|
+
# Errors:
|
160
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
161
|
+
# * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error)
|
162
|
+
def query(params = {})
|
163
|
+
params = Utils.symbolize_hash_keys(params)
|
164
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
165
|
+
headers = {}
|
166
|
+
body = nil
|
167
|
+
|
168
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
169
|
+
raise ArgumentError.new("dataTableId is required") unless params.has_key?(:dataTableId)
|
170
|
+
|
171
|
+
query_params[:sortColumn] = params[:sortColumn] if params.has_key?(:sortColumn)
|
172
|
+
query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection)
|
173
|
+
query_params[:limit] = params[:limit] if params.has_key?(:limit)
|
174
|
+
query_params[:offset] = params[:offset] if params.has_key?(:offset)
|
175
|
+
body = params[:query] if params.has_key?(:query)
|
176
|
+
headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
|
177
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
178
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
179
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
180
|
+
|
181
|
+
path = "/applications/#{params[:applicationId]}/data-tables/#{params[:dataTableId]}/rows/query"
|
182
|
+
|
183
|
+
@client.request(
|
184
|
+
method: :post,
|
185
|
+
path: path,
|
186
|
+
query: query_params,
|
187
|
+
headers: headers,
|
188
|
+
body: body)
|
189
|
+
end
|
190
|
+
|
191
|
+
end
|
192
|
+
end
|