appwrite 6.0.0 → 7.0.0.pre.RC1

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