appwrite 5.0.0 → 7.0.0.pre.RC2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/lib/appwrite/client.rb +32 -11
  3. data/lib/appwrite/id.rb +11 -0
  4. data/lib/appwrite/input_file.rb +33 -0
  5. data/lib/appwrite/models/account.rb +82 -0
  6. data/lib/appwrite/models/algo_argon2.rb +37 -0
  7. data/lib/appwrite/models/algo_bcrypt.rb +22 -0
  8. data/lib/appwrite/models/algo_md5.rb +22 -0
  9. data/lib/appwrite/models/algo_phpass.rb +22 -0
  10. data/lib/appwrite/models/algo_scrypt.rb +42 -0
  11. data/lib/appwrite/models/algo_scrypt_modified.rb +37 -0
  12. data/lib/appwrite/models/algo_sha.rb +22 -0
  13. data/lib/appwrite/models/attribute_datetime.rb +57 -0
  14. data/lib/appwrite/models/bucket.rb +25 -25
  15. data/lib/appwrite/models/collection.rb +25 -15
  16. data/lib/appwrite/models/database.rb +42 -0
  17. data/lib/appwrite/models/database_list.rb +32 -0
  18. data/lib/appwrite/models/deployment.rb +10 -5
  19. data/lib/appwrite/models/document.rb +15 -10
  20. data/lib/appwrite/models/execution.rb +20 -10
  21. data/lib/appwrite/models/file.rb +15 -15
  22. data/lib/appwrite/models/function.rb +12 -12
  23. data/lib/appwrite/models/index.rb +1 -1
  24. data/lib/appwrite/models/membership.rb +10 -0
  25. data/lib/appwrite/models/session.rb +5 -0
  26. data/lib/appwrite/models/team.rb +10 -5
  27. data/lib/appwrite/models/token.rb +5 -0
  28. data/lib/appwrite/models/user.rb +35 -0
  29. data/lib/appwrite/models/variable.rb +52 -0
  30. data/lib/appwrite/models/variable_list.rb +32 -0
  31. data/lib/appwrite/permission.rb +21 -0
  32. data/lib/appwrite/query.rb +43 -14
  33. data/lib/appwrite/role.rb +31 -0
  34. data/lib/appwrite/services/account.rb +250 -103
  35. data/lib/appwrite/services/avatars.rb +73 -56
  36. data/lib/appwrite/services/databases.rb +1425 -0
  37. data/lib/appwrite/services/functions.rb +381 -176
  38. data/lib/appwrite/services/health.rb +34 -10
  39. data/lib/appwrite/services/locale.rb +25 -7
  40. data/lib/appwrite/services/storage.rb +195 -193
  41. data/lib/appwrite/services/teams.rb +138 -128
  42. data/lib/appwrite/services/users.rb +610 -130
  43. data/lib/appwrite.rb +19 -2
  44. metadata +22 -6
  45. data/lib/appwrite/file.rb +0 -17
  46. data/lib/appwrite/services/database.rb +0 -1047
@@ -3,32 +3,29 @@
3
3
  module Appwrite
4
4
  class Teams < Service
5
5
 
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
6
10
  # Get a list of all the teams in which the current user is a member. You can
7
11
  # use the parameters to filter your results.
8
12
  #
9
13
  # In admin mode, this endpoint returns a list of all the teams in the current
10
14
  # project. [Learn more about different API modes](/docs/admin).
11
15
  #
12
- # @param [string] search Search term to filter your list results. Max length: 256 chars.
13
- # @param [number] limit Maximum number of teams to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
14
- # @param [number] offset Offset value. The default value is 0. Use this param to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)
15
- # @param [string] cursor ID of the team used as the starting point for the query, excluding the team itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)
16
- # @param [string] cursor_direction Direction of the cursor.
17
- # @param [string] order_type Order result by ASC or DESC order.
16
+ # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total
17
+ # @param [String] search Search term to filter your list results. Max length: 256 chars.
18
18
  #
19
19
  # @return [TeamList]
20
- def list(search: nil, limit: nil, offset: nil, cursor: nil, cursor_direction: nil, order_type: nil)
20
+ def list(queries: nil, search: nil)
21
+
21
22
  path = '/teams'
22
23
 
23
24
  params = {
25
+ queries: queries,
24
26
  search: search,
25
- limit: limit,
26
- offset: offset,
27
- cursor: cursor,
28
- cursorDirection: cursor_direction,
29
- orderType: order_type,
30
27
  }
31
-
28
+
32
29
  headers = {
33
30
  "content-type": 'application/json',
34
31
  }
@@ -42,23 +39,17 @@ module Appwrite
42
39
  )
43
40
  end
44
41
 
42
+
45
43
  # Create a new team. The user who creates the team will automatically be
46
44
  # assigned as the owner of the team. Only the users with the owner role can
47
45
  # invite new members, add new owners and delete or update the team.
48
46
  #
49
- # @param [string] team_id Team ID. Choose your own unique ID or pass the string &quot;unique()&quot; to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can&#039;t start with a special char. Max length is 36 chars.
50
- # @param [string] name Team name. Max length: 128 chars.
51
- # @param [array] roles Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.
47
+ # @param [String] team_id Team ID. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
48
+ # @param [String] name Team name. Max length: 128 chars.
49
+ # @param [Array] roles Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.
52
50
  #
53
51
  # @return [Team]
54
52
  def create(team_id:, name:, roles: nil)
55
- if team_id.nil?
56
- raise Appwrite::Exception.new('Missing required parameter: "teamId"')
57
- end
58
-
59
- if name.nil?
60
- raise Appwrite::Exception.new('Missing required parameter: "name"')
61
- end
62
53
 
63
54
  path = '/teams'
64
55
 
@@ -67,10 +58,18 @@ module Appwrite
67
58
  name: name,
68
59
  roles: roles,
69
60
  }
70
-
61
+
71
62
  headers = {
72
63
  "content-type": 'application/json',
73
64
  }
65
+ if team_id.nil?
66
+ raise Appwrite::Exception.new('Missing required parameter: "teamId"')
67
+ end
68
+
69
+ if name.nil?
70
+ raise Appwrite::Exception.new('Missing required parameter: "name"')
71
+ end
72
+
74
73
 
75
74
  @client.call(
76
75
  method: 'POST',
@@ -81,25 +80,27 @@ module Appwrite
81
80
  )
82
81
  end
83
82
 
83
+
84
84
  # Get a team by its ID. All team members have read access for this resource.
85
85
  #
86
- # @param [string] team_id Team ID.
86
+ # @param [String] team_id Team ID.
87
87
  #
88
88
  # @return [Team]
89
89
  def get(team_id:)
90
- if team_id.nil?
91
- raise Appwrite::Exception.new('Missing required parameter: "teamId"')
92
- end
93
90
 
94
91
  path = '/teams/{teamId}'
95
- .gsub('{teamId}', team_id)
96
92
 
97
93
  params = {
98
94
  }
99
-
95
+
100
96
  headers = {
101
97
  "content-type": 'application/json',
102
98
  }
99
+ if team_id.nil?
100
+ raise Appwrite::Exception.new('Missing required parameter: "teamId"')
101
+ end
102
+
103
+ .gsub('{teamId}', team_id)
103
104
 
104
105
  @client.call(
105
106
  method: 'GET',
@@ -110,32 +111,34 @@ module Appwrite
110
111
  )
111
112
  end
112
113
 
114
+
113
115
  # Update a team using its ID. Only members with the owner role can update the
114
116
  # team.
115
117
  #
116
- # @param [string] team_id Team ID.
117
- # @param [string] name New team name. Max length: 128 chars.
118
+ # @param [String] team_id Team ID.
119
+ # @param [String] name New team name. Max length: 128 chars.
118
120
  #
119
121
  # @return [Team]
120
122
  def update(team_id:, name:)
121
- if team_id.nil?
122
- raise Appwrite::Exception.new('Missing required parameter: "teamId"')
123
- end
124
-
125
- if name.nil?
126
- raise Appwrite::Exception.new('Missing required parameter: "name"')
127
- end
128
123
 
129
124
  path = '/teams/{teamId}'
130
- .gsub('{teamId}', team_id)
131
125
 
132
126
  params = {
133
127
  name: name,
134
128
  }
135
-
129
+
136
130
  headers = {
137
131
  "content-type": 'application/json',
138
132
  }
133
+ if team_id.nil?
134
+ raise Appwrite::Exception.new('Missing required parameter: "teamId"')
135
+ end
136
+
137
+ if name.nil?
138
+ raise Appwrite::Exception.new('Missing required parameter: "name"')
139
+ end
140
+
141
+ .gsub('{teamId}', team_id)
139
142
 
140
143
  @client.call(
141
144
  method: 'PUT',
@@ -146,26 +149,28 @@ module Appwrite
146
149
  )
147
150
  end
148
151
 
152
+
149
153
  # Delete a team using its ID. Only team members with the owner role can
150
154
  # delete the team.
151
155
  #
152
- # @param [string] team_id Team ID.
156
+ # @param [String] team_id Team ID.
153
157
  #
154
158
  # @return []
155
159
  def delete(team_id:)
156
- if team_id.nil?
157
- raise Appwrite::Exception.new('Missing required parameter: "teamId"')
158
- end
159
160
 
160
161
  path = '/teams/{teamId}'
161
- .gsub('{teamId}', team_id)
162
162
 
163
163
  params = {
164
164
  }
165
-
165
+
166
166
  headers = {
167
167
  "content-type": 'application/json',
168
168
  }
169
+ if team_id.nil?
170
+ raise Appwrite::Exception.new('Missing required parameter: "teamId"')
171
+ end
172
+
173
+ .gsub('{teamId}', team_id)
169
174
 
170
175
  @client.call(
171
176
  method: 'DELETE',
@@ -175,38 +180,32 @@ module Appwrite
175
180
  )
176
181
  end
177
182
 
183
+
178
184
  # Use this endpoint to list a team's members using the team's ID. All team
179
185
  # members have read access to this endpoint.
180
186
  #
181
- # @param [string] team_id Team ID.
182
- # @param [string] search Search term to filter your list results. Max length: 256 chars.
183
- # @param [number] limit Maximum number of memberships to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.
184
- # @param [number] offset Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)
185
- # @param [string] cursor ID of the membership used as the starting point for the query, excluding the membership itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)
186
- # @param [string] cursor_direction Direction of the cursor.
187
- # @param [string] order_type Order result by ASC or DESC order.
187
+ # @param [String] team_id Team ID.
188
+ # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm
189
+ # @param [String] search Search term to filter your list results. Max length: 256 chars.
188
190
  #
189
191
  # @return [MembershipList]
190
- def get_memberships(team_id:, search: nil, limit: nil, offset: nil, cursor: nil, cursor_direction: nil, order_type: nil)
191
- if team_id.nil?
192
- raise Appwrite::Exception.new('Missing required parameter: "teamId"')
193
- end
192
+ def get_memberships(team_id:, queries: nil, search: nil)
194
193
 
195
194
  path = '/teams/{teamId}/memberships'
196
- .gsub('{teamId}', team_id)
197
195
 
198
196
  params = {
197
+ queries: queries,
199
198
  search: search,
200
- limit: limit,
201
- offset: offset,
202
- cursor: cursor,
203
- cursorDirection: cursor_direction,
204
- orderType: order_type,
205
199
  }
206
-
200
+
207
201
  headers = {
208
202
  "content-type": 'application/json',
209
203
  }
204
+ if team_id.nil?
205
+ raise Appwrite::Exception.new('Missing required parameter: "teamId"')
206
+ end
207
+
208
+ .gsub('{teamId}', team_id)
210
209
 
211
210
  @client.call(
212
211
  method: 'GET',
@@ -217,6 +216,7 @@ module Appwrite
217
216
  )
218
217
  end
219
218
 
219
+
220
220
  # Invite a new member to join your team. If initiated from the client SDK, an
221
221
  # email with a link to join the team will be sent to the member's email
222
222
  # address and an account will be created for them should they not be signed
@@ -233,14 +233,27 @@ module Appwrite
233
233
  # the only valid redirect URL's are the once from domains you have set when
234
234
  # adding your platforms in the console interface.
235
235
  #
236
- # @param [string] team_id Team ID.
237
- # @param [string] email Email of the new team member.
238
- # @param [array] roles Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.
239
- # @param [string] url URL to redirect the user back to your app from the invitation email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
240
- # @param [string] name Name of the new team member. Max length: 128 chars.
236
+ # @param [String] team_id Team ID.
237
+ # @param [String] email Email of the new team member.
238
+ # @param [Array] roles Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.
239
+ # @param [String] url URL to redirect the user back to your app from the invitation email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.
240
+ # @param [String] name Name of the new team member. Max length: 128 chars.
241
241
  #
242
242
  # @return [Membership]
243
243
  def create_membership(team_id:, email:, roles:, url:, name: nil)
244
+
245
+ path = '/teams/{teamId}/memberships'
246
+
247
+ params = {
248
+ email: email,
249
+ roles: roles,
250
+ url: url,
251
+ name: name,
252
+ }
253
+
254
+ headers = {
255
+ "content-type": 'application/json',
256
+ }
244
257
  if team_id.nil?
245
258
  raise Appwrite::Exception.new('Missing required parameter: "teamId"')
246
259
  end
@@ -257,20 +270,8 @@ module Appwrite
257
270
  raise Appwrite::Exception.new('Missing required parameter: "url"')
258
271
  end
259
272
 
260
- path = '/teams/{teamId}/memberships'
261
273
  .gsub('{teamId}', team_id)
262
274
 
263
- params = {
264
- email: email,
265
- roles: roles,
266
- url: url,
267
- name: name,
268
- }
269
-
270
- headers = {
271
- "content-type": 'application/json',
272
- }
273
-
274
275
  @client.call(
275
276
  method: 'POST',
276
277
  path: path,
@@ -280,14 +281,24 @@ module Appwrite
280
281
  )
281
282
  end
282
283
 
284
+
283
285
  # Get a team member by the membership unique id. All team members have read
284
286
  # access for this resource.
285
287
  #
286
- # @param [string] team_id Team ID.
287
- # @param [string] membership_id Membership ID.
288
+ # @param [String] team_id Team ID.
289
+ # @param [String] membership_id Membership ID.
288
290
  #
289
291
  # @return [MembershipList]
290
292
  def get_membership(team_id:, membership_id:)
293
+
294
+ path = '/teams/{teamId}/memberships/{membershipId}'
295
+
296
+ params = {
297
+ }
298
+
299
+ headers = {
300
+ "content-type": 'application/json',
301
+ }
291
302
  if team_id.nil?
292
303
  raise Appwrite::Exception.new('Missing required parameter: "teamId"')
293
304
  end
@@ -296,17 +307,9 @@ module Appwrite
296
307
  raise Appwrite::Exception.new('Missing required parameter: "membershipId"')
297
308
  end
298
309
 
299
- path = '/teams/{teamId}/memberships/{membershipId}'
300
310
  .gsub('{teamId}', team_id)
301
311
  .gsub('{membershipId}', membership_id)
302
312
 
303
- params = {
304
- }
305
-
306
- headers = {
307
- "content-type": 'application/json',
308
- }
309
-
310
313
  @client.call(
311
314
  method: 'GET',
312
315
  path: path,
@@ -316,16 +319,27 @@ module Appwrite
316
319
  )
317
320
  end
318
321
 
322
+
319
323
  # Modify the roles of a team member. Only team members with the owner role
320
324
  # have access to this endpoint. Learn more about [roles and
321
325
  # permissions](/docs/permissions).
322
326
  #
323
- # @param [string] team_id Team ID.
324
- # @param [string] membership_id Membership ID.
325
- # @param [array] roles An array of strings. Use this param to set the user&#039;s roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.
327
+ # @param [String] team_id Team ID.
328
+ # @param [String] membership_id Membership ID.
329
+ # @param [Array] roles An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.
326
330
  #
327
331
  # @return [Membership]
328
332
  def update_membership_roles(team_id:, membership_id:, roles:)
333
+
334
+ path = '/teams/{teamId}/memberships/{membershipId}'
335
+
336
+ params = {
337
+ roles: roles,
338
+ }
339
+
340
+ headers = {
341
+ "content-type": 'application/json',
342
+ }
329
343
  if team_id.nil?
330
344
  raise Appwrite::Exception.new('Missing required parameter: "teamId"')
331
345
  end
@@ -338,18 +352,9 @@ module Appwrite
338
352
  raise Appwrite::Exception.new('Missing required parameter: "roles"')
339
353
  end
340
354
 
341
- path = '/teams/{teamId}/memberships/{membershipId}'
342
355
  .gsub('{teamId}', team_id)
343
356
  .gsub('{membershipId}', membership_id)
344
357
 
345
- params = {
346
- roles: roles,
347
- }
348
-
349
- headers = {
350
- "content-type": 'application/json',
351
- }
352
-
353
358
  @client.call(
354
359
  method: 'PATCH',
355
360
  path: path,
@@ -359,15 +364,25 @@ module Appwrite
359
364
  )
360
365
  end
361
366
 
367
+
362
368
  # This endpoint allows a user to leave a team or for a team owner to delete
363
369
  # the membership of any other team member. You can also use this endpoint to
364
370
  # delete a user membership even if it is not accepted.
365
371
  #
366
- # @param [string] team_id Team ID.
367
- # @param [string] membership_id Membership ID.
372
+ # @param [String] team_id Team ID.
373
+ # @param [String] membership_id Membership ID.
368
374
  #
369
375
  # @return []
370
376
  def delete_membership(team_id:, membership_id:)
377
+
378
+ path = '/teams/{teamId}/memberships/{membershipId}'
379
+
380
+ params = {
381
+ }
382
+
383
+ headers = {
384
+ "content-type": 'application/json',
385
+ }
371
386
  if team_id.nil?
372
387
  raise Appwrite::Exception.new('Missing required parameter: "teamId"')
373
388
  end
@@ -376,17 +391,9 @@ module Appwrite
376
391
  raise Appwrite::Exception.new('Missing required parameter: "membershipId"')
377
392
  end
378
393
 
379
- path = '/teams/{teamId}/memberships/{membershipId}'
380
394
  .gsub('{teamId}', team_id)
381
395
  .gsub('{membershipId}', membership_id)
382
396
 
383
- params = {
384
- }
385
-
386
- headers = {
387
- "content-type": 'application/json',
388
- }
389
-
390
397
  @client.call(
391
398
  method: 'DELETE',
392
399
  path: path,
@@ -395,6 +402,7 @@ module Appwrite
395
402
  )
396
403
  end
397
404
 
405
+
398
406
  # Use this endpoint to allow a user to accept an invitation to join a team
399
407
  # after being redirected back to your app from the invitation email received
400
408
  # by the user.
@@ -403,13 +411,24 @@ module Appwrite
403
411
  # created.
404
412
  #
405
413
  #
406
- # @param [string] team_id Team ID.
407
- # @param [string] membership_id Membership ID.
408
- # @param [string] user_id User ID.
409
- # @param [string] secret Secret key.
414
+ # @param [String] team_id Team ID.
415
+ # @param [String] membership_id Membership ID.
416
+ # @param [String] user_id User ID.
417
+ # @param [String] secret Secret key.
410
418
  #
411
419
  # @return [Membership]
412
420
  def update_membership_status(team_id:, membership_id:, user_id:, secret:)
421
+
422
+ path = '/teams/{teamId}/memberships/{membershipId}/status'
423
+
424
+ params = {
425
+ userId: user_id,
426
+ secret: secret,
427
+ }
428
+
429
+ headers = {
430
+ "content-type": 'application/json',
431
+ }
413
432
  if team_id.nil?
414
433
  raise Appwrite::Exception.new('Missing required parameter: "teamId"')
415
434
  end
@@ -426,19 +445,9 @@ module Appwrite
426
445
  raise Appwrite::Exception.new('Missing required parameter: "secret"')
427
446
  end
428
447
 
429
- path = '/teams/{teamId}/memberships/{membershipId}/status'
430
448
  .gsub('{teamId}', team_id)
431
449
  .gsub('{membershipId}', membership_id)
432
450
 
433
- params = {
434
- userId: user_id,
435
- secret: secret,
436
- }
437
-
438
- headers = {
439
- "content-type": 'application/json',
440
- }
441
-
442
451
  @client.call(
443
452
  method: 'PATCH',
444
453
  path: path,
@@ -448,5 +457,6 @@ module Appwrite
448
457
  )
449
458
  end
450
459
 
460
+
451
461
  end
452
462
  end