losant_rest 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,10 +6,53 @@ parameters and the potential responses.
6
6
 
7
7
  ##### Contents
8
8
 
9
+ * [Delete](#delete)
9
10
  * [Export](#export)
10
11
  * [Get](#get)
11
12
  * [Post](#post)
12
13
  * [Query](#query)
14
+ * [Truncate](#truncate)
15
+
16
+ <br/>
17
+
18
+ ## Delete
19
+
20
+ Delete rows from a data table
21
+
22
+ ```ruby
23
+ result = client.data_table_rows.delete(
24
+ applicationId: my_application_id,
25
+ dataTableId: my_data_table_id)
26
+
27
+ puts result
28
+ ```
29
+
30
+ #### Authentication
31
+ The client must be configured with a valid api access token to call this
32
+ action. The token must include at least one of the following scopes:
33
+ all.Application, all.Organization, all.User, dataTableRows.*, or dataTableRows.delete.
34
+
35
+ #### Available Parameters
36
+
37
+ | Name | Type | Required | Description | Default | Example |
38
+ | ---- | ---- | -------- | ----------- | ------- | ------- |
39
+ | applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
40
+ | dataTableId | string | Y | ID associated with the data table | | 575ed78e7ae143cd83dc4aab |
41
+ | query | [Data Table Query](_schemas.md#data-table-query) | N | Query to apply to filter the data table | | [Data Table Query Example](_schemas.md#data-table-query-example) |
42
+ | limit | string | N | Limit number of rows to delete from data table | 1000 | 10 |
43
+
44
+ #### Successful Responses
45
+
46
+ | Code | Type | Description |
47
+ | ---- | ---- | ----------- |
48
+ | 200 | [Data Table Rows Delete](_schemas.md#data-table-rows-delete) | If request successfully deletes a set of Data Table rows |
49
+
50
+ #### Error Responses
51
+
52
+ | Code | Type | Description |
53
+ | ---- | ---- | ----------- |
54
+ | 400 | [Error](_schemas.md#error) | Error if malformed request |
55
+ | 404 | [Error](_schemas.md#error) | Error if data table was not found |
13
56
 
14
57
  <br/>
15
58
 
@@ -28,7 +71,7 @@ puts result
28
71
  #### Authentication
29
72
  The client must be configured with a valid api access token to call this
30
73
  action. The token must include at least one of the following scopes:
31
- all.Application, all.Organization, all.User, dataTableRows.*, or dataTableRows.export.
74
+ all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, dataTableRows.*, or dataTableRows.export.
32
75
 
33
76
  #### Available Parameters
34
77
 
@@ -178,3 +221,42 @@ all.Application, all.Application.read, all.Organization, all.Organization.read,
178
221
  | ---- | ---- | ----------- |
179
222
  | 400 | [Error](_schemas.md#error) | Error if malformed request |
180
223
  | 404 | [Error](_schemas.md#error) | Error if data table was not found |
224
+
225
+ <br/>
226
+
227
+ ## Truncate
228
+
229
+ Delete all data in the data table
230
+
231
+ ```ruby
232
+ result = client.data_table_rows.truncate(
233
+ applicationId: my_application_id,
234
+ dataTableId: my_data_table_id)
235
+
236
+ puts result
237
+ ```
238
+
239
+ #### Authentication
240
+ The client must be configured with a valid api access token to call this
241
+ action. The token must include at least one of the following scopes:
242
+ all.Application, all.Organization, all.User, dataTableRows.*, or dataTableRows.truncate.
243
+
244
+ #### Available Parameters
245
+
246
+ | Name | Type | Required | Description | Default | Example |
247
+ | ---- | ---- | -------- | ----------- | ------- | ------- |
248
+ | applicationId | string | Y | ID associated with the application | | 575ec8687ae143cd83dc4a97 |
249
+ | dataTableId | string | Y | ID associated with the data table | | 575ed78e7ae143cd83dc4aab |
250
+
251
+ #### Successful Responses
252
+
253
+ | Code | Type | Description |
254
+ | ---- | ---- | ----------- |
255
+ | 200 | [Success](_schemas.md#success) | If request successfully deleted **all** rows in the data table, this will **not** send workflow data table deletion triggers |
256
+
257
+ #### Error Responses
258
+
259
+ | Code | Type | Description |
260
+ | ---- | ---- | ----------- |
261
+ | 400 | [Error](_schemas.md#error) | Error if malformed request |
262
+ | 404 | [Error](_schemas.md#error) | Error if data table was not found |
@@ -27,7 +27,7 @@ module LosantRest
27
27
  #
28
28
  # User API for accessing Losant data
29
29
  #
30
- # Built For Version 1.9.0
30
+ # Built For Version 1.9.2
31
31
  class Client
32
32
  attr_accessor :auth_token, :url
33
33
 
@@ -234,7 +234,7 @@ module LosantRest
234
234
 
235
235
  headers["Accept"] = "application/json"
236
236
  headers["Content-Type"] = "application/json"
237
- headers["Accept-Version"] = "^1.9.0"
237
+ headers["Accept-Version"] = "^1.9.2"
238
238
  headers["Authorization"] = "Bearer #{self.auth_token}" if self.auth_token
239
239
  path = self.url + options.fetch(:path, "")
240
240
 
@@ -29,13 +29,63 @@ module LosantRest
29
29
  @client = client
30
30
  end
31
31
 
32
+ # Delete rows from 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.Organization, all.User, dataTableRows.*, or dataTableRows.delete.
39
+ #
40
+ # Parameters:
41
+ # * {string} applicationId - ID associated with the application
42
+ # * {string} dataTableId - ID associated with the data table
43
+ # * {hash} query - Query to apply to filter the data table (https://api.losant.com/#/definitions/dataTableQuery)
44
+ # * {string} limit - Limit number of rows to delete from data table
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 Data Table rows (https://api.losant.com/#/definitions/dataTableRowsDelete)
52
+ #
53
+ # Errors:
54
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
55
+ # * 404 - Error if data table 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("dataTableId is required") unless params.has_key?(:dataTableId)
64
+
65
+ body = params[:query] if params.has_key?(:query)
66
+ query_params[:limit] = params[:limit] if params.has_key?(:limit)
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]}/data-tables/#{params[:dataTableId]}/rows/delete"
73
+
74
+ @client.request(
75
+ method: :post,
76
+ path: path,
77
+ query: query_params,
78
+ headers: headers,
79
+ body: body)
80
+ end
81
+
32
82
  # Request an export of the data table's data
33
83
  #
34
84
  # Authentication:
35
85
  # The client must be configured with a valid api
36
86
  # access token to call this action. The token
37
87
  # must include at least one of the following scopes:
38
- # all.Application, all.Organization, all.User, dataTableRows.*, or dataTableRows.export.
88
+ # all.Application, all.Application.read, all.Organization, all.Organization.read, all.User, all.User.read, dataTableRows.*, or dataTableRows.export.
39
89
  #
40
90
  # Parameters:
41
91
  # * {string} applicationId - ID associated with the application
@@ -236,5 +286,51 @@ module LosantRest
236
286
  body: body)
237
287
  end
238
288
 
289
+ # Delete all data in the data table
290
+ #
291
+ # Authentication:
292
+ # The client must be configured with a valid api
293
+ # access token to call this action. The token
294
+ # must include at least one of the following scopes:
295
+ # all.Application, all.Organization, all.User, dataTableRows.*, or dataTableRows.truncate.
296
+ #
297
+ # Parameters:
298
+ # * {string} applicationId - ID associated with the application
299
+ # * {string} dataTableId - ID associated with the data table
300
+ # * {string} losantdomain - Domain scope of request (rarely needed)
301
+ # * {boolean} _actions - Return resource actions in response
302
+ # * {boolean} _links - Return resource link in response
303
+ # * {boolean} _embedded - Return embedded resources in response
304
+ #
305
+ # Responses:
306
+ # * 200 - If request successfully deleted **all** rows in the data table, this will **not** send workflow data table deletion triggers (https://api.losant.com/#/definitions/success)
307
+ #
308
+ # Errors:
309
+ # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
310
+ # * 404 - Error if data table was not found (https://api.losant.com/#/definitions/error)
311
+ def truncate(params = {})
312
+ params = Utils.symbolize_hash_keys(params)
313
+ query_params = { _actions: false, _links: true, _embedded: true }
314
+ headers = {}
315
+ body = nil
316
+
317
+ raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
318
+ raise ArgumentError.new("dataTableId is required") unless params.has_key?(:dataTableId)
319
+
320
+ headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
321
+ query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
322
+ query_params[:_links] = params[:_links] if params.has_key?(:_links)
323
+ query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
324
+
325
+ path = "/applications/#{params[:applicationId]}/data-tables/#{params[:dataTableId]}/rows/truncate"
326
+
327
+ @client.request(
328
+ method: :post,
329
+ path: path,
330
+ query: query_params,
331
+ headers: headers,
332
+ body: body)
333
+ end
334
+
239
335
  end
240
336
  end
@@ -21,5 +21,5 @@
21
21
  # SOFTWARE.
22
22
 
23
23
  module LosantRest
24
- VERSION = "1.4.0"
24
+ VERSION = "1.4.1"
25
25
  end
@@ -64,7 +64,7 @@
64
64
  "json": {
65
65
  "type": "string",
66
66
  "minLength": 1,
67
- "maxLength": 2048
67
+ "maxLength": 32767
68
68
  }
69
69
  },
70
70
  "additionalProperties": false,
@@ -149,6 +149,87 @@
149
149
  "additionalProperties": false
150
150
  },
151
151
  "maxItems": 100
152
+ },
153
+ "archiveConfig": {
154
+ "type": "object",
155
+ "properties": {
156
+ "directory": {
157
+ "type": "string",
158
+ "max": 255
159
+ },
160
+ "whiteList": {
161
+ "type": "array",
162
+ "items": {
163
+ "type": "string",
164
+ "pattern": "^[A-Fa-f\\d]{24}$"
165
+ },
166
+ "max": 100
167
+ },
168
+ "blackList": {
169
+ "type": "array",
170
+ "items": {
171
+ "type": "string",
172
+ "pattern": "^[A-Fa-f\\d]{24}$"
173
+ },
174
+ "max": 100
175
+ },
176
+ "s3": {
177
+ "type": "object",
178
+ "properties": {
179
+ "bucket": {
180
+ "type": "string",
181
+ "max": 255
182
+ },
183
+ "accessKeyId": {
184
+ "type": "string",
185
+ "min": 16,
186
+ "max": 128
187
+ },
188
+ "secretAccessKey": {
189
+ "type": "string",
190
+ "min": 16,
191
+ "max": 128
192
+ },
193
+ "region": {
194
+ "type": "string",
195
+ "max": 128
196
+ }
197
+ },
198
+ "required": [
199
+ "bucket",
200
+ "accessKeyId",
201
+ "secretAccessKey",
202
+ "region"
203
+ ],
204
+ "additionalProperties": false
205
+ },
206
+ "gcs": {
207
+ "type": "object",
208
+ "properties": {
209
+ "projectId": {
210
+ "type": "string",
211
+ "minLength": 1,
212
+ "maxLength": 1024
213
+ },
214
+ "keyJson": {
215
+ "type": "string",
216
+ "maxLength": 32767,
217
+ "minLength": 50
218
+ },
219
+ "bucket": {
220
+ "type": "string",
221
+ "max": 255
222
+ }
223
+ },
224
+ "required": [
225
+ "projectId",
226
+ "keyJson",
227
+ "bucket"
228
+ ],
229
+ "additionalProperties": false
230
+ }
231
+ },
232
+ "additionalProperties": false
152
233
  }
153
234
  }
154
235
  }
@@ -83,6 +83,9 @@
83
83
  "dataTableRows.get",
84
84
  "dataTableRows.post",
85
85
  "dataTableRows.query",
86
+ "dataTableRows.export",
87
+ "dataTableRows.delete",
88
+ "dataTableRows.truncate",
86
89
  "dataTables.get",
87
90
  "dataTables.post",
88
91
  "device.delete",
@@ -37,7 +37,7 @@
37
37
  "json": {
38
38
  "type": "string",
39
39
  "minLength": 1,
40
- "maxLength": 2048
40
+ "maxLength": 32767
41
41
  }
42
42
  },
43
43
  "additionalProperties": false,
@@ -75,6 +75,87 @@
75
75
  "additionalProperties": false
76
76
  },
77
77
  "maxItems": 100
78
+ },
79
+ "archiveConfig": {
80
+ "type": "object",
81
+ "properties": {
82
+ "directory": {
83
+ "type": "string",
84
+ "max": 255
85
+ },
86
+ "whiteList": {
87
+ "type": "array",
88
+ "items": {
89
+ "type": "string",
90
+ "pattern": "^[A-Fa-f\\d]{24}$"
91
+ },
92
+ "max": 100
93
+ },
94
+ "blackList": {
95
+ "type": "array",
96
+ "items": {
97
+ "type": "string",
98
+ "pattern": "^[A-Fa-f\\d]{24}$"
99
+ },
100
+ "max": 100
101
+ },
102
+ "s3": {
103
+ "type": "object",
104
+ "properties": {
105
+ "bucket": {
106
+ "type": "string",
107
+ "max": 255
108
+ },
109
+ "accessKeyId": {
110
+ "type": "string",
111
+ "min": 16,
112
+ "max": 128
113
+ },
114
+ "secretAccessKey": {
115
+ "type": "string",
116
+ "min": 16,
117
+ "max": 128
118
+ },
119
+ "region": {
120
+ "type": "string",
121
+ "max": 128
122
+ }
123
+ },
124
+ "required": [
125
+ "bucket",
126
+ "accessKeyId",
127
+ "secretAccessKey",
128
+ "region"
129
+ ],
130
+ "additionalProperties": false
131
+ },
132
+ "gcs": {
133
+ "type": "object",
134
+ "properties": {
135
+ "projectId": {
136
+ "type": "string",
137
+ "minLength": 1,
138
+ "maxLength": 1024
139
+ },
140
+ "keyJson": {
141
+ "type": "string",
142
+ "maxLength": 32767,
143
+ "minLength": 50
144
+ },
145
+ "bucket": {
146
+ "type": "string",
147
+ "max": 255
148
+ }
149
+ },
150
+ "required": [
151
+ "projectId",
152
+ "keyJson",
153
+ "bucket"
154
+ ],
155
+ "additionalProperties": false
156
+ }
157
+ },
158
+ "additionalProperties": false
78
159
  }
79
160
  },
80
161
  "additionalProperties": false
@@ -41,7 +41,7 @@
41
41
  "json": {
42
42
  "type": "string",
43
43
  "minLength": 1,
44
- "maxLength": 2048
44
+ "maxLength": 32767
45
45
  }
46
46
  },
47
47
  "additionalProperties": false,
@@ -50,6 +50,87 @@
50
50
  "json"
51
51
  ]
52
52
  }
53
+ },
54
+ "archiveConfig": {
55
+ "type": "object",
56
+ "properties": {
57
+ "directory": {
58
+ "type": "string",
59
+ "max": 255
60
+ },
61
+ "whiteList": {
62
+ "type": "array",
63
+ "items": {
64
+ "type": "string",
65
+ "pattern": "^[A-Fa-f\\d]{24}$"
66
+ },
67
+ "max": 100
68
+ },
69
+ "blackList": {
70
+ "type": "array",
71
+ "items": {
72
+ "type": "string",
73
+ "pattern": "^[A-Fa-f\\d]{24}$"
74
+ },
75
+ "max": 100
76
+ },
77
+ "s3": {
78
+ "type": "object",
79
+ "properties": {
80
+ "bucket": {
81
+ "type": "string",
82
+ "max": 255
83
+ },
84
+ "accessKeyId": {
85
+ "type": "string",
86
+ "min": 16,
87
+ "max": 128
88
+ },
89
+ "secretAccessKey": {
90
+ "type": "string",
91
+ "min": 16,
92
+ "max": 128
93
+ },
94
+ "region": {
95
+ "type": "string",
96
+ "max": 128
97
+ }
98
+ },
99
+ "required": [
100
+ "bucket",
101
+ "accessKeyId",
102
+ "secretAccessKey",
103
+ "region"
104
+ ],
105
+ "additionalProperties": false
106
+ },
107
+ "gcs": {
108
+ "type": "object",
109
+ "properties": {
110
+ "projectId": {
111
+ "type": "string",
112
+ "minLength": 1,
113
+ "maxLength": 1024
114
+ },
115
+ "keyJson": {
116
+ "type": "string",
117
+ "maxLength": 32767,
118
+ "minLength": 50
119
+ },
120
+ "bucket": {
121
+ "type": "string",
122
+ "max": 255
123
+ }
124
+ },
125
+ "required": [
126
+ "projectId",
127
+ "keyJson",
128
+ "bucket"
129
+ ],
130
+ "additionalProperties": false
131
+ }
132
+ },
133
+ "additionalProperties": false
53
134
  }
54
135
  },
55
136
  "additionalProperties": false,
@@ -71,7 +71,7 @@
71
71
  "json": {
72
72
  "type": "string",
73
73
  "minLength": 1,
74
- "maxLength": 2048
74
+ "maxLength": 32767
75
75
  }
76
76
  },
77
77
  "additionalProperties": false,
@@ -156,6 +156,87 @@
156
156
  "additionalProperties": false
157
157
  },
158
158
  "maxItems": 100
159
+ },
160
+ "archiveConfig": {
161
+ "type": "object",
162
+ "properties": {
163
+ "directory": {
164
+ "type": "string",
165
+ "max": 255
166
+ },
167
+ "whiteList": {
168
+ "type": "array",
169
+ "items": {
170
+ "type": "string",
171
+ "pattern": "^[A-Fa-f\\d]{24}$"
172
+ },
173
+ "max": 100
174
+ },
175
+ "blackList": {
176
+ "type": "array",
177
+ "items": {
178
+ "type": "string",
179
+ "pattern": "^[A-Fa-f\\d]{24}$"
180
+ },
181
+ "max": 100
182
+ },
183
+ "s3": {
184
+ "type": "object",
185
+ "properties": {
186
+ "bucket": {
187
+ "type": "string",
188
+ "max": 255
189
+ },
190
+ "accessKeyId": {
191
+ "type": "string",
192
+ "min": 16,
193
+ "max": 128
194
+ },
195
+ "secretAccessKey": {
196
+ "type": "string",
197
+ "min": 16,
198
+ "max": 128
199
+ },
200
+ "region": {
201
+ "type": "string",
202
+ "max": 128
203
+ }
204
+ },
205
+ "required": [
206
+ "bucket",
207
+ "accessKeyId",
208
+ "secretAccessKey",
209
+ "region"
210
+ ],
211
+ "additionalProperties": false
212
+ },
213
+ "gcs": {
214
+ "type": "object",
215
+ "properties": {
216
+ "projectId": {
217
+ "type": "string",
218
+ "minLength": 1,
219
+ "maxLength": 1024
220
+ },
221
+ "keyJson": {
222
+ "type": "string",
223
+ "maxLength": 32767,
224
+ "minLength": 50
225
+ },
226
+ "bucket": {
227
+ "type": "string",
228
+ "max": 255
229
+ }
230
+ },
231
+ "required": [
232
+ "projectId",
233
+ "keyJson",
234
+ "bucket"
235
+ ],
236
+ "additionalProperties": false
237
+ }
238
+ },
239
+ "additionalProperties": false
159
240
  }
160
241
  }
161
242
  }
@@ -0,0 +1,9 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema#",
3
+ "type": "object",
4
+ "properties": {
5
+ "removed": {
6
+ "type": "Number"
7
+ }
8
+ }
9
+ }