appwrite 2.1.1 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,15 +1,26 @@
1
1
  module Appwrite
2
2
  class Database < Service
3
3
 
4
- def list_collections(search: '', limit: 25, offset: 0, order_type: 'ASC')
4
+ def list_collections(search: nil, limit: nil, offset: nil, order_type: nil)
5
5
  path = '/database/collections'
6
6
 
7
- params = {
8
- 'search': search,
9
- 'limit': limit,
10
- 'offset': offset,
11
- 'orderType': order_type
12
- }
7
+ params = {}
8
+
9
+ if !search.nil?
10
+ params[:search] = search
11
+ end
12
+
13
+ if !limit.nil?
14
+ params[:limit] = limit
15
+ end
16
+
17
+ if !offset.nil?
18
+ params[:offset] = offset
19
+ end
20
+
21
+ if !order_type.nil?
22
+ params[:orderType] = order_type
23
+ end
13
24
 
14
25
  return @client.call('get', path, {
15
26
  'content-type' => 'application/json',
@@ -17,14 +28,41 @@ module Appwrite
17
28
  end
18
29
 
19
30
  def create_collection(name:, read:, write:, rules:)
31
+ if name.nil?
32
+ raise Appwrite::Exception.new('Missing required parameter: "name"')
33
+ end
34
+
35
+ if read.nil?
36
+ raise Appwrite::Exception.new('Missing required parameter: "read"')
37
+ end
38
+
39
+ if write.nil?
40
+ raise Appwrite::Exception.new('Missing required parameter: "write"')
41
+ end
42
+
43
+ if rules.nil?
44
+ raise Appwrite::Exception.new('Missing required parameter: "rules"')
45
+ end
46
+
20
47
  path = '/database/collections'
21
48
 
22
- params = {
23
- 'name': name,
24
- 'read': read,
25
- 'write': write,
26
- 'rules': rules
27
- }
49
+ params = {}
50
+
51
+ if !name.nil?
52
+ params[:name] = name
53
+ end
54
+
55
+ if !read.nil?
56
+ params[:read] = read
57
+ end
58
+
59
+ if !write.nil?
60
+ params[:write] = write
61
+ end
62
+
63
+ if !rules.nil?
64
+ params[:rules] = rules
65
+ end
28
66
 
29
67
  return @client.call('post', path, {
30
68
  'content-type' => 'application/json',
@@ -32,27 +70,49 @@ module Appwrite
32
70
  end
33
71
 
34
72
  def get_collection(collection_id:)
73
+ if collection_id.nil?
74
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
75
+ end
76
+
35
77
  path = '/database/collections/{collectionId}'
36
78
  .gsub('{collectionId}', collection_id)
37
79
 
38
- params = {
39
- }
80
+ params = {}
40
81
 
41
82
  return @client.call('get', path, {
42
83
  'content-type' => 'application/json',
43
84
  }, params);
44
85
  end
45
86
 
46
- def update_collection(collection_id:, name:, read: [], write: [], rules: [])
87
+ def update_collection(collection_id:, name:, read: nil, write: nil, rules: nil)
88
+ if collection_id.nil?
89
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
90
+ end
91
+
92
+ if name.nil?
93
+ raise Appwrite::Exception.new('Missing required parameter: "name"')
94
+ end
95
+
47
96
  path = '/database/collections/{collectionId}'
48
97
  .gsub('{collectionId}', collection_id)
49
98
 
50
- params = {
51
- 'name': name,
52
- 'read': read,
53
- 'write': write,
54
- 'rules': rules
55
- }
99
+ params = {}
100
+
101
+ if !name.nil?
102
+ params[:name] = name
103
+ end
104
+
105
+ if !read.nil?
106
+ params[:read] = read
107
+ end
108
+
109
+ if !write.nil?
110
+ params[:write] = write
111
+ end
112
+
113
+ if !rules.nil?
114
+ params[:rules] = rules
115
+ end
56
116
 
57
117
  return @client.call('put', path, {
58
118
  'content-type' => 'application/json',
@@ -60,48 +120,100 @@ module Appwrite
60
120
  end
61
121
 
62
122
  def delete_collection(collection_id:)
123
+ if collection_id.nil?
124
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
125
+ end
126
+
63
127
  path = '/database/collections/{collectionId}'
64
128
  .gsub('{collectionId}', collection_id)
65
129
 
66
- params = {
67
- }
130
+ params = {}
68
131
 
69
132
  return @client.call('delete', path, {
70
133
  'content-type' => 'application/json',
71
134
  }, params);
72
135
  end
73
136
 
74
- def list_documents(collection_id:, filters: [], limit: 25, offset: 0, order_field: '', order_type: 'ASC', order_cast: 'string', search: '')
137
+ def list_documents(collection_id:, filters: nil, limit: nil, offset: nil, order_field: nil, order_type: nil, order_cast: nil, search: nil)
138
+ if collection_id.nil?
139
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
140
+ end
141
+
75
142
  path = '/database/collections/{collectionId}/documents'
76
143
  .gsub('{collectionId}', collection_id)
77
144
 
78
- params = {
79
- 'filters': filters,
80
- 'limit': limit,
81
- 'offset': offset,
82
- 'orderField': order_field,
83
- 'orderType': order_type,
84
- 'orderCast': order_cast,
85
- 'search': search
86
- }
145
+ params = {}
146
+
147
+ if !filters.nil?
148
+ params[:filters] = filters
149
+ end
150
+
151
+ if !limit.nil?
152
+ params[:limit] = limit
153
+ end
154
+
155
+ if !offset.nil?
156
+ params[:offset] = offset
157
+ end
158
+
159
+ if !order_field.nil?
160
+ params[:orderField] = order_field
161
+ end
162
+
163
+ if !order_type.nil?
164
+ params[:orderType] = order_type
165
+ end
166
+
167
+ if !order_cast.nil?
168
+ params[:orderCast] = order_cast
169
+ end
170
+
171
+ if !search.nil?
172
+ params[:search] = search
173
+ end
87
174
 
88
175
  return @client.call('get', path, {
89
176
  'content-type' => 'application/json',
90
177
  }, params);
91
178
  end
92
179
 
93
- def create_document(collection_id:, data:, read: [], write: [], parent_document: '', parent_property: '', parent_property_type: 'assign')
180
+ def create_document(collection_id:, data:, read: nil, write: nil, parent_document: nil, parent_property: nil, parent_property_type: nil)
181
+ if collection_id.nil?
182
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
183
+ end
184
+
185
+ if data.nil?
186
+ raise Appwrite::Exception.new('Missing required parameter: "data"')
187
+ end
188
+
94
189
  path = '/database/collections/{collectionId}/documents'
95
190
  .gsub('{collectionId}', collection_id)
96
191
 
97
- params = {
98
- 'data': data,
99
- 'read': read,
100
- 'write': write,
101
- 'parentDocument': parent_document,
102
- 'parentProperty': parent_property,
103
- 'parentPropertyType': parent_property_type
104
- }
192
+ params = {}
193
+
194
+ if !data.nil?
195
+ params[:data] = data
196
+ end
197
+
198
+ if !read.nil?
199
+ params[:read] = read
200
+ end
201
+
202
+ if !write.nil?
203
+ params[:write] = write
204
+ end
205
+
206
+ if !parent_document.nil?
207
+ params[:parentDocument] = parent_document
208
+ end
209
+
210
+ if !parent_property.nil?
211
+ params[:parentProperty] = parent_property
212
+ end
213
+
214
+ if !parent_property_type.nil?
215
+ params[:parentPropertyType] = parent_property_type
216
+ end
105
217
 
106
218
  return @client.call('post', path, {
107
219
  'content-type' => 'application/json',
@@ -109,28 +221,55 @@ module Appwrite
109
221
  end
110
222
 
111
223
  def get_document(collection_id:, document_id:)
224
+ if collection_id.nil?
225
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
226
+ end
227
+
228
+ if document_id.nil?
229
+ raise Appwrite::Exception.new('Missing required parameter: "documentId"')
230
+ end
231
+
112
232
  path = '/database/collections/{collectionId}/documents/{documentId}'
113
233
  .gsub('{collectionId}', collection_id)
114
234
  .gsub('{documentId}', document_id)
115
235
 
116
- params = {
117
- }
236
+ params = {}
118
237
 
119
238
  return @client.call('get', path, {
120
239
  'content-type' => 'application/json',
121
240
  }, params);
122
241
  end
123
242
 
124
- def update_document(collection_id:, document_id:, data:, read: [], write: [])
243
+ def update_document(collection_id:, document_id:, data:, read: nil, write: nil)
244
+ if collection_id.nil?
245
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
246
+ end
247
+
248
+ if document_id.nil?
249
+ raise Appwrite::Exception.new('Missing required parameter: "documentId"')
250
+ end
251
+
252
+ if data.nil?
253
+ raise Appwrite::Exception.new('Missing required parameter: "data"')
254
+ end
255
+
125
256
  path = '/database/collections/{collectionId}/documents/{documentId}'
126
257
  .gsub('{collectionId}', collection_id)
127
258
  .gsub('{documentId}', document_id)
128
259
 
129
- params = {
130
- 'data': data,
131
- 'read': read,
132
- 'write': write
133
- }
260
+ params = {}
261
+
262
+ if !data.nil?
263
+ params[:data] = data
264
+ end
265
+
266
+ if !read.nil?
267
+ params[:read] = read
268
+ end
269
+
270
+ if !write.nil?
271
+ params[:write] = write
272
+ end
134
273
 
135
274
  return @client.call('patch', path, {
136
275
  'content-type' => 'application/json',
@@ -138,12 +277,19 @@ module Appwrite
138
277
  end
139
278
 
140
279
  def delete_document(collection_id:, document_id:)
280
+ if collection_id.nil?
281
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
282
+ end
283
+
284
+ if document_id.nil?
285
+ raise Appwrite::Exception.new('Missing required parameter: "documentId"')
286
+ end
287
+
141
288
  path = '/database/collections/{collectionId}/documents/{documentId}'
142
289
  .gsub('{collectionId}', collection_id)
143
290
  .gsub('{documentId}', document_id)
144
291
 
145
- params = {
146
- }
292
+ params = {}
147
293
 
148
294
  return @client.call('delete', path, {
149
295
  'content-type' => 'application/json',
@@ -1,33 +1,76 @@
1
1
  module Appwrite
2
2
  class Functions < Service
3
3
 
4
- def list(search: '', limit: 25, offset: 0, order_type: 'ASC')
4
+ def list(search: nil, limit: nil, offset: nil, order_type: nil)
5
5
  path = '/functions'
6
6
 
7
- params = {
8
- 'search': search,
9
- 'limit': limit,
10
- 'offset': offset,
11
- 'orderType': order_type
12
- }
7
+ params = {}
8
+
9
+ if !search.nil?
10
+ params[:search] = search
11
+ end
12
+
13
+ if !limit.nil?
14
+ params[:limit] = limit
15
+ end
16
+
17
+ if !offset.nil?
18
+ params[:offset] = offset
19
+ end
20
+
21
+ if !order_type.nil?
22
+ params[:orderType] = order_type
23
+ end
13
24
 
14
25
  return @client.call('get', path, {
15
26
  'content-type' => 'application/json',
16
27
  }, params);
17
28
  end
18
29
 
19
- def create(name:, execute:, env:, vars: {}, events: [], schedule: '', timeout: 15)
30
+ def create(name:, execute:, env:, vars: nil, events: nil, schedule: nil, timeout: nil)
31
+ if name.nil?
32
+ raise Appwrite::Exception.new('Missing required parameter: "name"')
33
+ end
34
+
35
+ if execute.nil?
36
+ raise Appwrite::Exception.new('Missing required parameter: "execute"')
37
+ end
38
+
39
+ if env.nil?
40
+ raise Appwrite::Exception.new('Missing required parameter: "env"')
41
+ end
42
+
20
43
  path = '/functions'
21
44
 
22
- params = {
23
- 'name': name,
24
- 'execute': execute,
25
- 'env': env,
26
- 'vars': vars,
27
- 'events': events,
28
- 'schedule': schedule,
29
- 'timeout': timeout
30
- }
45
+ params = {}
46
+
47
+ if !name.nil?
48
+ params[:name] = name
49
+ end
50
+
51
+ if !execute.nil?
52
+ params[:execute] = execute
53
+ end
54
+
55
+ if !env.nil?
56
+ params[:env] = env
57
+ end
58
+
59
+ if !vars.nil?
60
+ params[:vars] = vars
61
+ end
62
+
63
+ if !events.nil?
64
+ params[:events] = events
65
+ end
66
+
67
+ if !schedule.nil?
68
+ params[:schedule] = schedule
69
+ end
70
+
71
+ if !timeout.nil?
72
+ params[:timeout] = timeout
73
+ end
31
74
 
32
75
  return @client.call('post', path, {
33
76
  'content-type' => 'application/json',
@@ -35,29 +78,61 @@ module Appwrite
35
78
  end
36
79
 
37
80
  def get(function_id:)
81
+ if function_id.nil?
82
+ raise Appwrite::Exception.new('Missing required parameter: "functionId"')
83
+ end
84
+
38
85
  path = '/functions/{functionId}'
39
86
  .gsub('{functionId}', function_id)
40
87
 
41
- params = {
42
- }
88
+ params = {}
43
89
 
44
90
  return @client.call('get', path, {
45
91
  'content-type' => 'application/json',
46
92
  }, params);
47
93
  end
48
94
 
49
- def update(function_id:, name:, execute:, vars: {}, events: [], schedule: '', timeout: 15)
95
+ def update(function_id:, name:, execute:, vars: nil, events: nil, schedule: nil, timeout: nil)
96
+ if function_id.nil?
97
+ raise Appwrite::Exception.new('Missing required parameter: "functionId"')
98
+ end
99
+
100
+ if name.nil?
101
+ raise Appwrite::Exception.new('Missing required parameter: "name"')
102
+ end
103
+
104
+ if execute.nil?
105
+ raise Appwrite::Exception.new('Missing required parameter: "execute"')
106
+ end
107
+
50
108
  path = '/functions/{functionId}'
51
109
  .gsub('{functionId}', function_id)
52
110
 
53
- params = {
54
- 'name': name,
55
- 'execute': execute,
56
- 'vars': vars,
57
- 'events': events,
58
- 'schedule': schedule,
59
- 'timeout': timeout
60
- }
111
+ params = {}
112
+
113
+ if !name.nil?
114
+ params[:name] = name
115
+ end
116
+
117
+ if !execute.nil?
118
+ params[:execute] = execute
119
+ end
120
+
121
+ if !vars.nil?
122
+ params[:vars] = vars
123
+ end
124
+
125
+ if !events.nil?
126
+ params[:events] = events
127
+ end
128
+
129
+ if !schedule.nil?
130
+ params[:schedule] = schedule
131
+ end
132
+
133
+ if !timeout.nil?
134
+ params[:timeout] = timeout
135
+ end
61
136
 
62
137
  return @client.call('put', path, {
63
138
  'content-type' => 'application/json',
@@ -65,40 +140,64 @@ module Appwrite
65
140
  end
66
141
 
67
142
  def delete(function_id:)
143
+ if function_id.nil?
144
+ raise Appwrite::Exception.new('Missing required parameter: "functionId"')
145
+ end
146
+
68
147
  path = '/functions/{functionId}'
69
148
  .gsub('{functionId}', function_id)
70
149
 
71
- params = {
72
- }
150
+ params = {}
73
151
 
74
152
  return @client.call('delete', path, {
75
153
  'content-type' => 'application/json',
76
154
  }, params);
77
155
  end
78
156
 
79
- def list_executions(function_id:, search: '', limit: 25, offset: 0, order_type: 'ASC')
157
+ def list_executions(function_id:, search: nil, limit: nil, offset: nil, order_type: nil)
158
+ if function_id.nil?
159
+ raise Appwrite::Exception.new('Missing required parameter: "functionId"')
160
+ end
161
+
80
162
  path = '/functions/{functionId}/executions'
81
163
  .gsub('{functionId}', function_id)
82
164
 
83
- params = {
84
- 'search': search,
85
- 'limit': limit,
86
- 'offset': offset,
87
- 'orderType': order_type
88
- }
165
+ params = {}
166
+
167
+ if !search.nil?
168
+ params[:search] = search
169
+ end
170
+
171
+ if !limit.nil?
172
+ params[:limit] = limit
173
+ end
174
+
175
+ if !offset.nil?
176
+ params[:offset] = offset
177
+ end
178
+
179
+ if !order_type.nil?
180
+ params[:orderType] = order_type
181
+ end
89
182
 
90
183
  return @client.call('get', path, {
91
184
  'content-type' => 'application/json',
92
185
  }, params);
93
186
  end
94
187
 
95
- def create_execution(function_id:, data: '')
188
+ def create_execution(function_id:, data: nil)
189
+ if function_id.nil?
190
+ raise Appwrite::Exception.new('Missing required parameter: "functionId"')
191
+ end
192
+
96
193
  path = '/functions/{functionId}/executions'
97
194
  .gsub('{functionId}', function_id)
98
195
 
99
- params = {
100
- 'data': data
101
- }
196
+ params = {}
197
+
198
+ if !data.nil?
199
+ params[:data] = data
200
+ end
102
201
 
103
202
  return @client.call('post', path, {
104
203
  'content-type' => 'application/json',
@@ -106,12 +205,19 @@ module Appwrite
106
205
  end
107
206
 
108
207
  def get_execution(function_id:, execution_id:)
208
+ if function_id.nil?
209
+ raise Appwrite::Exception.new('Missing required parameter: "functionId"')
210
+ end
211
+
212
+ if execution_id.nil?
213
+ raise Appwrite::Exception.new('Missing required parameter: "executionId"')
214
+ end
215
+
109
216
  path = '/functions/{functionId}/executions/{executionId}'
110
217
  .gsub('{functionId}', function_id)
111
218
  .gsub('{executionId}', execution_id)
112
219
 
113
- params = {
114
- }
220
+ params = {}
115
221
 
116
222
  return @client.call('get', path, {
117
223
  'content-type' => 'application/json',
@@ -119,28 +225,53 @@ module Appwrite
119
225
  end
120
226
 
121
227
  def update_tag(function_id:, tag:)
228
+ if function_id.nil?
229
+ raise Appwrite::Exception.new('Missing required parameter: "functionId"')
230
+ end
231
+
232
+ if tag.nil?
233
+ raise Appwrite::Exception.new('Missing required parameter: "tag"')
234
+ end
235
+
122
236
  path = '/functions/{functionId}/tag'
123
237
  .gsub('{functionId}', function_id)
124
238
 
125
- params = {
126
- 'tag': tag
127
- }
239
+ params = {}
240
+
241
+ if !tag.nil?
242
+ params[:tag] = tag
243
+ end
128
244
 
129
245
  return @client.call('patch', path, {
130
246
  'content-type' => 'application/json',
131
247
  }, params);
132
248
  end
133
249
 
134
- def list_tags(function_id:, search: '', limit: 25, offset: 0, order_type: 'ASC')
250
+ def list_tags(function_id:, search: nil, limit: nil, offset: nil, order_type: nil)
251
+ if function_id.nil?
252
+ raise Appwrite::Exception.new('Missing required parameter: "functionId"')
253
+ end
254
+
135
255
  path = '/functions/{functionId}/tags'
136
256
  .gsub('{functionId}', function_id)
137
257
 
138
- params = {
139
- 'search': search,
140
- 'limit': limit,
141
- 'offset': offset,
142
- 'orderType': order_type
143
- }
258
+ params = {}
259
+
260
+ if !search.nil?
261
+ params[:search] = search
262
+ end
263
+
264
+ if !limit.nil?
265
+ params[:limit] = limit
266
+ end
267
+
268
+ if !offset.nil?
269
+ params[:offset] = offset
270
+ end
271
+
272
+ if !order_type.nil?
273
+ params[:orderType] = order_type
274
+ end
144
275
 
145
276
  return @client.call('get', path, {
146
277
  'content-type' => 'application/json',
@@ -148,13 +279,30 @@ module Appwrite
148
279
  end
149
280
 
150
281
  def create_tag(function_id:, command:, code:)
282
+ if function_id.nil?
283
+ raise Appwrite::Exception.new('Missing required parameter: "functionId"')
284
+ end
285
+
286
+ if command.nil?
287
+ raise Appwrite::Exception.new('Missing required parameter: "command"')
288
+ end
289
+
290
+ if code.nil?
291
+ raise Appwrite::Exception.new('Missing required parameter: "code"')
292
+ end
293
+
151
294
  path = '/functions/{functionId}/tags'
152
295
  .gsub('{functionId}', function_id)
153
296
 
154
- params = {
155
- 'command': command,
156
- 'code': code
157
- }
297
+ params = {}
298
+
299
+ if !command.nil?
300
+ params[:command] = command
301
+ end
302
+
303
+ if !code.nil?
304
+ params[:code] = code
305
+ end
158
306
 
159
307
  return @client.call('post', path, {
160
308
  'content-type' => 'multipart/form-data',
@@ -162,12 +310,19 @@ module Appwrite
162
310
  end
163
311
 
164
312
  def get_tag(function_id:, tag_id:)
313
+ if function_id.nil?
314
+ raise Appwrite::Exception.new('Missing required parameter: "functionId"')
315
+ end
316
+
317
+ if tag_id.nil?
318
+ raise Appwrite::Exception.new('Missing required parameter: "tagId"')
319
+ end
320
+
165
321
  path = '/functions/{functionId}/tags/{tagId}'
166
322
  .gsub('{functionId}', function_id)
167
323
  .gsub('{tagId}', tag_id)
168
324
 
169
- params = {
170
- }
325
+ params = {}
171
326
 
172
327
  return @client.call('get', path, {
173
328
  'content-type' => 'application/json',
@@ -175,12 +330,19 @@ module Appwrite
175
330
  end
176
331
 
177
332
  def delete_tag(function_id:, tag_id:)
333
+ if function_id.nil?
334
+ raise Appwrite::Exception.new('Missing required parameter: "functionId"')
335
+ end
336
+
337
+ if tag_id.nil?
338
+ raise Appwrite::Exception.new('Missing required parameter: "tagId"')
339
+ end
340
+
178
341
  path = '/functions/{functionId}/tags/{tagId}'
179
342
  .gsub('{functionId}', function_id)
180
343
  .gsub('{tagId}', tag_id)
181
344
 
182
- params = {
183
- }
345
+ params = {}
184
346
 
185
347
  return @client.call('delete', path, {
186
348
  'content-type' => 'application/json',