appwrite 7.1.0 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/lib/appwrite/client.rb +2 -2
  3. data/lib/appwrite/models/algo_argon2.rb +5 -0
  4. data/lib/appwrite/models/algo_bcrypt.rb +5 -0
  5. data/lib/appwrite/models/algo_md5.rb +5 -0
  6. data/lib/appwrite/models/algo_phpass.rb +5 -0
  7. data/lib/appwrite/models/algo_scrypt.rb +5 -0
  8. data/lib/appwrite/models/algo_scrypt_modified.rb +5 -0
  9. data/lib/appwrite/models/algo_sha.rb +5 -0
  10. data/lib/appwrite/models/attribute_boolean.rb +5 -0
  11. data/lib/appwrite/models/attribute_datetime.rb +5 -0
  12. data/lib/appwrite/models/attribute_email.rb +5 -0
  13. data/lib/appwrite/models/attribute_enum.rb +5 -0
  14. data/lib/appwrite/models/attribute_float.rb +5 -0
  15. data/lib/appwrite/models/attribute_integer.rb +5 -0
  16. data/lib/appwrite/models/attribute_ip.rb +5 -0
  17. data/lib/appwrite/models/attribute_relationship.rb +82 -0
  18. data/lib/appwrite/models/attribute_string.rb +5 -0
  19. data/lib/appwrite/models/attribute_url.rb +5 -0
  20. data/lib/appwrite/models/database.rb +8 -3
  21. data/lib/appwrite/models/deployment.rb +65 -10
  22. data/lib/appwrite/models/execution.rb +40 -20
  23. data/lib/appwrite/models/function.rb +53 -13
  24. data/lib/appwrite/models/headers.rb +32 -0
  25. data/lib/appwrite/models/health_status.rb +5 -0
  26. data/lib/appwrite/models/identity.rb +72 -0
  27. data/lib/appwrite/models/identity_list.rb +32 -0
  28. data/lib/appwrite/models/index.rb +5 -0
  29. data/lib/appwrite/models/locale_code.rb +32 -0
  30. data/lib/appwrite/models/locale_code_list.rb +32 -0
  31. data/lib/appwrite/models/team.rb +8 -3
  32. data/lib/appwrite/models/user.rb +16 -6
  33. data/lib/appwrite/models/variable.rb +10 -5
  34. data/lib/appwrite/query.rb +41 -17
  35. data/lib/appwrite/services/account.rb +120 -65
  36. data/lib/appwrite/services/avatars.rb +14 -14
  37. data/lib/appwrite/services/databases.rb +834 -188
  38. data/lib/appwrite/services/functions.rb +150 -74
  39. data/lib/appwrite/services/graphql.rb +71 -0
  40. data/lib/appwrite/services/health.rb +71 -22
  41. data/lib/appwrite/services/locale.rb +39 -14
  42. data/lib/appwrite/services/storage.rb +43 -42
  43. data/lib/appwrite/services/teams.rb +123 -50
  44. data/lib/appwrite/services/users.rb +158 -60
  45. data/lib/appwrite.rb +7 -1
  46. metadata +10 -4
  47. data/lib/appwrite/models/account.rb +0 -82
@@ -8,17 +8,14 @@ module Appwrite
8
8
  end
9
9
 
10
10
  # Get a list of all the teams in which the current user is a member. You can
11
- # use the parameters to filter your results.
12
- #
13
- # In admin mode, this endpoint returns a list of all the teams in the current
14
- # project. [Learn more about different API modes](/docs/admin).
11
+ # use the parameters to filter your results.
15
12
  #
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
13
+ # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total
17
14
  # @param [String] search Search term to filter your list results. Max length: 256 chars.
18
15
  #
19
16
  # @return [TeamList]
20
17
  def list(queries: nil, search: nil)
21
- path = '/teams'
18
+ api_path = '/teams'
22
19
 
23
20
  params = {
24
21
  queries: queries,
@@ -31,7 +28,7 @@ module Appwrite
31
28
 
32
29
  @client.call(
33
30
  method: 'GET',
34
- path: path,
31
+ path: api_path,
35
32
  headers: headers,
36
33
  params: params,
37
34
  response_type: Models::TeamList
@@ -43,13 +40,13 @@ module Appwrite
43
40
  # assigned as the owner of the team. Only the users with the owner role can
44
41
  # invite new members, add new owners and delete or update the team.
45
42
  #
46
- # @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.
43
+ # @param [String] team_id Team ID. Choose a custom ID or generate a random ID with `ID.unique()`. 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.
47
44
  # @param [String] name Team name. Max length: 128 chars.
48
45
  # @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.
49
46
  #
50
47
  # @return [Team]
51
48
  def create(team_id:, name:, roles: nil)
52
- path = '/teams'
49
+ api_path = '/teams'
53
50
 
54
51
  if team_id.nil?
55
52
  raise Appwrite::Exception.new('Missing required parameter: "teamId"')
@@ -71,7 +68,7 @@ module Appwrite
71
68
 
72
69
  @client.call(
73
70
  method: 'POST',
74
- path: path,
71
+ path: api_path,
75
72
  headers: headers,
76
73
  params: params,
77
74
  response_type: Models::Team
@@ -85,7 +82,7 @@ module Appwrite
85
82
  #
86
83
  # @return [Team]
87
84
  def get(team_id:)
88
- path = '/teams/{teamId}'
85
+ api_path = '/teams/{teamId}'
89
86
  .gsub('{teamId}', team_id)
90
87
 
91
88
  if team_id.nil?
@@ -101,7 +98,7 @@ module Appwrite
101
98
 
102
99
  @client.call(
103
100
  method: 'GET',
104
- path: path,
101
+ path: api_path,
105
102
  headers: headers,
106
103
  params: params,
107
104
  response_type: Models::Team
@@ -109,15 +106,14 @@ module Appwrite
109
106
  end
110
107
 
111
108
 
112
- # Update a team using its ID. Only members with the owner role can update the
113
- # team.
109
+ # Update the team's name by its unique ID.
114
110
  #
115
111
  # @param [String] team_id Team ID.
116
112
  # @param [String] name New team name. Max length: 128 chars.
117
113
  #
118
114
  # @return [Team]
119
- def update(team_id:, name:)
120
- path = '/teams/{teamId}'
115
+ def update_name(team_id:, name:)
116
+ api_path = '/teams/{teamId}'
121
117
  .gsub('{teamId}', team_id)
122
118
 
123
119
  if team_id.nil?
@@ -138,7 +134,7 @@ module Appwrite
138
134
 
139
135
  @client.call(
140
136
  method: 'PUT',
141
- path: path,
137
+ path: api_path,
142
138
  headers: headers,
143
139
  params: params,
144
140
  response_type: Models::Team
@@ -153,7 +149,7 @@ module Appwrite
153
149
  #
154
150
  # @return []
155
151
  def delete(team_id:)
156
- path = '/teams/{teamId}'
152
+ api_path = '/teams/{teamId}'
157
153
  .gsub('{teamId}', team_id)
158
154
 
159
155
  if team_id.nil?
@@ -169,7 +165,7 @@ module Appwrite
169
165
 
170
166
  @client.call(
171
167
  method: 'DELETE',
172
- path: path,
168
+ path: api_path,
173
169
  headers: headers,
174
170
  params: params,
175
171
  )
@@ -180,12 +176,12 @@ module Appwrite
180
176
  # members have read access to this endpoint.
181
177
  #
182
178
  # @param [String] team_id Team ID.
183
- # @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
179
+ # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm
184
180
  # @param [String] search Search term to filter your list results. Max length: 256 chars.
185
181
  #
186
182
  # @return [MembershipList]
187
183
  def list_memberships(team_id:, queries: nil, search: nil)
188
- path = '/teams/{teamId}/memberships'
184
+ api_path = '/teams/{teamId}/memberships'
189
185
  .gsub('{teamId}', team_id)
190
186
 
191
187
  if team_id.nil?
@@ -203,7 +199,7 @@ module Appwrite
203
199
 
204
200
  @client.call(
205
201
  method: 'GET',
206
- path: path,
202
+ path: api_path,
207
203
  headers: headers,
208
204
  params: params,
209
205
  response_type: Models::MembershipList
@@ -211,41 +207,45 @@ module Appwrite
211
207
  end
212
208
 
213
209
 
214
- # Invite a new member to join your team. If initiated from the client SDK, an
215
- # email with a link to join the team will be sent to the member's email
216
- # address and an account will be created for them should they not be signed
217
- # up already. If initiated from server-side SDKs, the new member will
218
- # automatically be added to the team.
210
+ # Invite a new member to join your team. Provide an ID for existing users, or
211
+ # invite unregistered users using an email or phone number. If initiated from
212
+ # a Client SDK, Appwrite will send an email or sms with a link to join the
213
+ # team to the invited user, and an account will be created for them if one
214
+ # doesn't exist. If initiated from a Server SDK, the new member will be added
215
+ # automatically to the team.
219
216
  #
220
- # Use the 'url' parameter to redirect the user from the invitation email back
221
- # to your app. When the user is redirected, use the [Update Team Membership
217
+ # You only need to provide one of a user ID, email, or phone number. Appwrite
218
+ # will prioritize accepting the user ID > email > phone number if you provide
219
+ # more than one of these parameters.
220
+ #
221
+ # Use the `url` parameter to redirect the user from the invitation email to
222
+ # your app. After the user is redirected, use the [Update Team Membership
222
223
  # Status](/docs/client/teams#teamsUpdateMembershipStatus) endpoint to allow
223
224
  # the user to accept the invitation to the team.
224
225
  #
225
226
  # Please note that to avoid a [Redirect
226
227
  # Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
227
- # the only valid redirect URL's are the once from domains you have set when
228
- # adding your platforms in the console interface.
228
+ # Appwrite will accept the only redirect URLs under the domains you have
229
+ # added as a platform on the Appwrite Console.
230
+ #
229
231
  #
230
232
  # @param [String] team_id Team ID.
231
- # @param [String] email Email of the new team member.
232
233
  # @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.
233
234
  # @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.
235
+ # @param [String] email Email of the new team member.
236
+ # @param [String] user_id ID of the user to be added to a team.
237
+ # @param [String] phone Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.
234
238
  # @param [String] name Name of the new team member. Max length: 128 chars.
235
239
  #
236
240
  # @return [Membership]
237
- def create_membership(team_id:, email:, roles:, url:, name: nil)
238
- path = '/teams/{teamId}/memberships'
241
+ def create_membership(team_id:, roles:, url:, email: nil, user_id: nil, phone: nil, name: nil)
242
+ api_path = '/teams/{teamId}/memberships'
239
243
  .gsub('{teamId}', team_id)
240
244
 
241
245
  if team_id.nil?
242
246
  raise Appwrite::Exception.new('Missing required parameter: "teamId"')
243
247
  end
244
248
 
245
- if email.nil?
246
- raise Appwrite::Exception.new('Missing required parameter: "email"')
247
- end
248
-
249
249
  if roles.nil?
250
250
  raise Appwrite::Exception.new('Missing required parameter: "roles"')
251
251
  end
@@ -256,6 +256,8 @@ module Appwrite
256
256
 
257
257
  params = {
258
258
  email: email,
259
+ userId: user_id,
260
+ phone: phone,
259
261
  roles: roles,
260
262
  url: url,
261
263
  name: name,
@@ -267,7 +269,7 @@ module Appwrite
267
269
 
268
270
  @client.call(
269
271
  method: 'POST',
270
- path: path,
272
+ path: api_path,
271
273
  headers: headers,
272
274
  params: params,
273
275
  response_type: Models::Membership
@@ -281,9 +283,9 @@ module Appwrite
281
283
  # @param [String] team_id Team ID.
282
284
  # @param [String] membership_id Membership ID.
283
285
  #
284
- # @return [MembershipList]
286
+ # @return [Membership]
285
287
  def get_membership(team_id:, membership_id:)
286
- path = '/teams/{teamId}/memberships/{membershipId}'
288
+ api_path = '/teams/{teamId}/memberships/{membershipId}'
287
289
  .gsub('{teamId}', team_id)
288
290
  .gsub('{membershipId}', membership_id)
289
291
 
@@ -304,10 +306,10 @@ module Appwrite
304
306
 
305
307
  @client.call(
306
308
  method: 'GET',
307
- path: path,
309
+ path: api_path,
308
310
  headers: headers,
309
311
  params: params,
310
- response_type: Models::MembershipList
312
+ response_type: Models::Membership
311
313
  )
312
314
  end
313
315
 
@@ -315,14 +317,15 @@ module Appwrite
315
317
  # Modify the roles of a team member. Only team members with the owner role
316
318
  # have access to this endpoint. Learn more about [roles and
317
319
  # permissions](/docs/permissions).
320
+ #
318
321
  #
319
322
  # @param [String] team_id Team ID.
320
323
  # @param [String] membership_id Membership ID.
321
324
  # @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.
322
325
  #
323
326
  # @return [Membership]
324
- def update_membership_roles(team_id:, membership_id:, roles:)
325
- path = '/teams/{teamId}/memberships/{membershipId}'
327
+ def update_membership(team_id:, membership_id:, roles:)
328
+ api_path = '/teams/{teamId}/memberships/{membershipId}'
326
329
  .gsub('{teamId}', team_id)
327
330
  .gsub('{membershipId}', membership_id)
328
331
 
@@ -348,7 +351,7 @@ module Appwrite
348
351
 
349
352
  @client.call(
350
353
  method: 'PATCH',
351
- path: path,
354
+ path: api_path,
352
355
  headers: headers,
353
356
  params: params,
354
357
  response_type: Models::Membership
@@ -365,7 +368,7 @@ module Appwrite
365
368
  #
366
369
  # @return []
367
370
  def delete_membership(team_id:, membership_id:)
368
- path = '/teams/{teamId}/memberships/{membershipId}'
371
+ api_path = '/teams/{teamId}/memberships/{membershipId}'
369
372
  .gsub('{teamId}', team_id)
370
373
  .gsub('{membershipId}', membership_id)
371
374
 
@@ -386,7 +389,7 @@ module Appwrite
386
389
 
387
390
  @client.call(
388
391
  method: 'DELETE',
389
- path: path,
392
+ path: api_path,
390
393
  headers: headers,
391
394
  params: params,
392
395
  )
@@ -408,7 +411,7 @@ module Appwrite
408
411
  #
409
412
  # @return [Membership]
410
413
  def update_membership_status(team_id:, membership_id:, user_id:, secret:)
411
- path = '/teams/{teamId}/memberships/{membershipId}/status'
414
+ api_path = '/teams/{teamId}/memberships/{membershipId}/status'
412
415
  .gsub('{teamId}', team_id)
413
416
  .gsub('{membershipId}', membership_id)
414
417
 
@@ -439,7 +442,7 @@ module Appwrite
439
442
 
440
443
  @client.call(
441
444
  method: 'PATCH',
442
- path: path,
445
+ path: api_path,
443
446
  headers: headers,
444
447
  params: params,
445
448
  response_type: Models::Membership
@@ -447,5 +450,75 @@ module Appwrite
447
450
  end
448
451
 
449
452
 
453
+ # Get the team's shared preferences by its unique ID. If a preference doesn't
454
+ # need to be shared by all team members, prefer storing them in [user
455
+ # preferences](/docs/client/account#accountGetPrefs).
456
+ #
457
+ # @param [String] team_id Team ID.
458
+ #
459
+ # @return [Preferences]
460
+ def get_prefs(team_id:)
461
+ api_path = '/teams/{teamId}/prefs'
462
+ .gsub('{teamId}', team_id)
463
+
464
+ if team_id.nil?
465
+ raise Appwrite::Exception.new('Missing required parameter: "teamId"')
466
+ end
467
+
468
+ params = {
469
+ }
470
+
471
+ headers = {
472
+ "content-type": 'application/json',
473
+ }
474
+
475
+ @client.call(
476
+ method: 'GET',
477
+ path: api_path,
478
+ headers: headers,
479
+ params: params,
480
+ response_type: Models::Preferences
481
+ )
482
+ end
483
+
484
+
485
+ # Update the team's preferences by its unique ID. The object you pass is
486
+ # stored as is and replaces any previous value. The maximum allowed prefs
487
+ # size is 64kB and throws an error if exceeded.
488
+ #
489
+ # @param [String] team_id Team ID.
490
+ # @param [Hash] prefs Prefs key-value JSON object.
491
+ #
492
+ # @return [Preferences]
493
+ def update_prefs(team_id:, prefs:)
494
+ api_path = '/teams/{teamId}/prefs'
495
+ .gsub('{teamId}', team_id)
496
+
497
+ if team_id.nil?
498
+ raise Appwrite::Exception.new('Missing required parameter: "teamId"')
499
+ end
500
+
501
+ if prefs.nil?
502
+ raise Appwrite::Exception.new('Missing required parameter: "prefs"')
503
+ end
504
+
505
+ params = {
506
+ prefs: prefs,
507
+ }
508
+
509
+ headers = {
510
+ "content-type": 'application/json',
511
+ }
512
+
513
+ @client.call(
514
+ method: 'PUT',
515
+ path: api_path,
516
+ headers: headers,
517
+ params: params,
518
+ response_type: Models::Preferences
519
+ )
520
+ end
521
+
522
+
450
523
  end
451
524
  end