appwrite 24.2.0 → 25.1.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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/lib/appwrite/client.rb +19 -3
  3. data/lib/appwrite/enums/backup_services.rb +1 -0
  4. data/lib/appwrite/enums/{theme.rb → browser_theme.rb} +1 -1
  5. data/lib/appwrite/enums/build_runtime.rb +2 -3
  6. data/lib/appwrite/enums/{name.rb → health_queue_name.rb} +1 -1
  7. data/lib/appwrite/enums/organization_key_scopes.rb +16 -0
  8. data/lib/appwrite/enums/project_key_scopes.rb +2 -0
  9. data/lib/appwrite/enums/project_o_auth_provider_id.rb +0 -2
  10. data/lib/appwrite/enums/project_policy_id.rb +4 -0
  11. data/lib/appwrite/enums/region.rb +12 -0
  12. data/lib/appwrite/enums/runtime.rb +2 -3
  13. data/lib/appwrite/enums/status_code.rb +4 -4
  14. data/lib/appwrite/models/activity_event.rb +20 -20
  15. data/lib/appwrite/models/function.rb +10 -0
  16. data/lib/appwrite/models/policy_deny_aliased_email.rb +32 -0
  17. data/lib/appwrite/models/policy_deny_disposable_email.rb +32 -0
  18. data/lib/appwrite/models/policy_deny_free_email.rb +32 -0
  19. data/lib/appwrite/models/policy_password_strength.rb +52 -0
  20. data/lib/appwrite/models/presence.rb +2 -6
  21. data/lib/appwrite/models/presence_list.rb +0 -4
  22. data/lib/appwrite/models/project.rb +58 -13
  23. data/lib/appwrite/models/project_list.rb +32 -0
  24. data/lib/appwrite/models/site.rb +10 -0
  25. data/lib/appwrite/models/usage_gauge.rb +13 -3
  26. data/lib/appwrite/services/account.rb +46 -1
  27. data/lib/appwrite/services/activities.rb +2 -0
  28. data/lib/appwrite/services/advisor.rb +5 -0
  29. data/lib/appwrite/services/avatars.rb +9 -1
  30. data/lib/appwrite/services/backups.rb +12 -0
  31. data/lib/appwrite/services/databases.rb +71 -0
  32. data/lib/appwrite/services/functions.rb +36 -2
  33. data/lib/appwrite/services/graphql.rb +2 -0
  34. data/lib/appwrite/services/health.rb +52 -1
  35. data/lib/appwrite/services/locale.rb +8 -0
  36. data/lib/appwrite/services/messaging.rb +150 -0
  37. data/lib/appwrite/services/organization.rb +359 -0
  38. data/lib/appwrite/services/presences.rb +6 -1
  39. data/lib/appwrite/services/project.rb +214 -12
  40. data/lib/appwrite/services/proxy.rb +8 -0
  41. data/lib/appwrite/services/sites.rb +35 -2
  42. data/lib/appwrite/services/storage.rb +13 -0
  43. data/lib/appwrite/services/tables_db.rb +71 -0
  44. data/lib/appwrite/services/teams.rb +13 -0
  45. data/lib/appwrite/services/tokens.rb +5 -0
  46. data/lib/appwrite/services/usage.rb +12 -10
  47. data/lib/appwrite/services/users.rb +43 -0
  48. data/lib/appwrite/services/webhooks.rb +6 -0
  49. data/lib/appwrite.rb +13 -6
  50. metadata +12 -5
  51. data/lib/appwrite/enums/scopes.rb +0 -100
@@ -0,0 +1,359 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ class Organization < Service
5
+
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ # Get a list of all API keys from the current organization.
11
+ #
12
+ # @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: expire, accessedAt, name, scopes
13
+ # @param [] total When set to false, the total count returned will be 0 and will not be calculated.
14
+ #
15
+ # @return [KeyList]
16
+ def list_keys(queries: nil, total: nil)
17
+ api_path = '/organization/keys'
18
+
19
+ api_params = {
20
+ queries: queries,
21
+ total: total,
22
+ }
23
+
24
+ api_headers = {
25
+ "X-Appwrite-Project": @client.get_config('project'),
26
+ }
27
+
28
+ @client.call(
29
+ method: 'GET',
30
+ path: api_path,
31
+ headers: api_headers,
32
+ params: api_params,
33
+ response_type: Models::KeyList
34
+ )
35
+
36
+ end
37
+
38
+ # Create a new organization API key.
39
+ #
40
+ # @param [String] key_id Key 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.
41
+ # @param [String] name Key name. Max length: 128 chars.
42
+ # @param [Array] scopes Key scopes list. Maximum of 100 scopes are allowed.
43
+ # @param [String] expire Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration.
44
+ #
45
+ # @return [Key]
46
+ def create_key(key_id:, name:, scopes:, expire: nil)
47
+ api_path = '/organization/keys'
48
+
49
+ if key_id.nil?
50
+ raise Appwrite::Exception.new('Missing required parameter: "keyId"')
51
+ end
52
+
53
+ if name.nil?
54
+ raise Appwrite::Exception.new('Missing required parameter: "name"')
55
+ end
56
+
57
+ if scopes.nil?
58
+ raise Appwrite::Exception.new('Missing required parameter: "scopes"')
59
+ end
60
+
61
+ api_params = {
62
+ keyId: key_id,
63
+ name: name,
64
+ scopes: scopes,
65
+ expire: expire,
66
+ }
67
+
68
+ api_headers = {
69
+ "X-Appwrite-Project": @client.get_config('project'),
70
+ "content-type": 'application/json',
71
+ }
72
+
73
+ @client.call(
74
+ method: 'POST',
75
+ path: api_path,
76
+ headers: api_headers,
77
+ params: api_params,
78
+ response_type: Models::Key
79
+ )
80
+
81
+ end
82
+
83
+ # Get a key by its unique ID. This endpoint returns details about a specific
84
+ # API key in your organization including its scopes.
85
+ #
86
+ # @param [String] key_id Key unique ID.
87
+ #
88
+ # @return [Key]
89
+ def get_key(key_id:)
90
+ api_path = '/organization/keys/{keyId}'
91
+ .gsub('{keyId}', key_id)
92
+
93
+ if key_id.nil?
94
+ raise Appwrite::Exception.new('Missing required parameter: "keyId"')
95
+ end
96
+
97
+ api_params = {
98
+ }
99
+
100
+ api_headers = {
101
+ "X-Appwrite-Project": @client.get_config('project'),
102
+ }
103
+
104
+ @client.call(
105
+ method: 'GET',
106
+ path: api_path,
107
+ headers: api_headers,
108
+ params: api_params,
109
+ response_type: Models::Key
110
+ )
111
+
112
+ end
113
+
114
+ # Update a key by its unique ID. Use this endpoint to update the name,
115
+ # scopes, or expiration time of an API key.
116
+ #
117
+ # @param [String] key_id Key unique ID.
118
+ # @param [String] name Key name. Max length: 128 chars.
119
+ # @param [Array] scopes Key scopes list. Maximum of 100 scopes are allowed.
120
+ # @param [String] expire Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration.
121
+ #
122
+ # @return [Key]
123
+ def update_key(key_id:, name:, scopes:, expire: nil)
124
+ api_path = '/organization/keys/{keyId}'
125
+ .gsub('{keyId}', key_id)
126
+
127
+ if key_id.nil?
128
+ raise Appwrite::Exception.new('Missing required parameter: "keyId"')
129
+ end
130
+
131
+ if name.nil?
132
+ raise Appwrite::Exception.new('Missing required parameter: "name"')
133
+ end
134
+
135
+ if scopes.nil?
136
+ raise Appwrite::Exception.new('Missing required parameter: "scopes"')
137
+ end
138
+
139
+ api_params = {
140
+ name: name,
141
+ scopes: scopes,
142
+ expire: expire,
143
+ }
144
+
145
+ api_headers = {
146
+ "X-Appwrite-Project": @client.get_config('project'),
147
+ "content-type": 'application/json',
148
+ }
149
+
150
+ @client.call(
151
+ method: 'PUT',
152
+ path: api_path,
153
+ headers: api_headers,
154
+ params: api_params,
155
+ response_type: Models::Key
156
+ )
157
+
158
+ end
159
+
160
+ # Delete a key by its unique ID. Once deleted, the key can no longer be used
161
+ # to authenticate API calls.
162
+ #
163
+ # @param [String] key_id Key unique ID.
164
+ #
165
+ # @return []
166
+ def delete_key(key_id:)
167
+ api_path = '/organization/keys/{keyId}'
168
+ .gsub('{keyId}', key_id)
169
+
170
+ if key_id.nil?
171
+ raise Appwrite::Exception.new('Missing required parameter: "keyId"')
172
+ end
173
+
174
+ api_params = {
175
+ }
176
+
177
+ api_headers = {
178
+ "X-Appwrite-Project": @client.get_config('project'),
179
+ "content-type": 'application/json',
180
+ }
181
+
182
+ @client.call(
183
+ method: 'DELETE',
184
+ path: api_path,
185
+ headers: api_headers,
186
+ params: api_params,
187
+ )
188
+
189
+ end
190
+
191
+ # Get a list of all projects. You can use the query params to filter your
192
+ # results.
193
+ #
194
+ # @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, teamId, labels, search
195
+ # @param [String] search Search term to filter your list results. Max length: 256 chars.
196
+ # @param [] total When set to false, the total count returned will be 0 and will not be calculated.
197
+ #
198
+ # @return [ProjectList]
199
+ def list_projects(queries: nil, search: nil, total: nil)
200
+ api_path = '/organization/projects'
201
+
202
+ api_params = {
203
+ queries: queries,
204
+ search: search,
205
+ total: total,
206
+ }
207
+
208
+ api_headers = {
209
+ "X-Appwrite-Project": @client.get_config('project'),
210
+ }
211
+
212
+ @client.call(
213
+ method: 'GET',
214
+ path: api_path,
215
+ headers: api_headers,
216
+ params: api_params,
217
+ response_type: Models::ProjectList
218
+ )
219
+
220
+ end
221
+
222
+ # Create a new project.
223
+ #
224
+ # @param [String] project_id Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, and hyphen. Can't start with a special char. Max length is 36 chars.
225
+ # @param [String] name Project name. Max length: 128 chars.
226
+ # @param [Region] region Project Region.
227
+ #
228
+ # @return [Project]
229
+ def create_project(project_id:, name:, region: nil)
230
+ api_path = '/organization/projects'
231
+
232
+ if project_id.nil?
233
+ raise Appwrite::Exception.new('Missing required parameter: "projectId"')
234
+ end
235
+
236
+ if name.nil?
237
+ raise Appwrite::Exception.new('Missing required parameter: "name"')
238
+ end
239
+
240
+ api_params = {
241
+ projectId: project_id,
242
+ name: name,
243
+ region: region,
244
+ }
245
+
246
+ api_headers = {
247
+ "X-Appwrite-Project": @client.get_config('project'),
248
+ "content-type": 'application/json',
249
+ }
250
+
251
+ @client.call(
252
+ method: 'POST',
253
+ path: api_path,
254
+ headers: api_headers,
255
+ params: api_params,
256
+ response_type: Models::Project
257
+ )
258
+
259
+ end
260
+
261
+ # Get a project.
262
+ #
263
+ # @param [String] project_id Project unique ID.
264
+ #
265
+ # @return [Project]
266
+ def get_project(project_id:)
267
+ api_path = '/organization/projects/{projectId}'
268
+ .gsub('{projectId}', project_id)
269
+
270
+ if project_id.nil?
271
+ raise Appwrite::Exception.new('Missing required parameter: "projectId"')
272
+ end
273
+
274
+ api_params = {
275
+ }
276
+
277
+ api_headers = {
278
+ "X-Appwrite-Project": @client.get_config('project'),
279
+ }
280
+
281
+ @client.call(
282
+ method: 'GET',
283
+ path: api_path,
284
+ headers: api_headers,
285
+ params: api_params,
286
+ response_type: Models::Project
287
+ )
288
+
289
+ end
290
+
291
+ # Update a project by its unique ID.
292
+ #
293
+ # @param [String] project_id Project unique ID.
294
+ # @param [String] name Project name. Max length: 128 chars.
295
+ #
296
+ # @return [Project]
297
+ def update_project(project_id:, name:)
298
+ api_path = '/organization/projects/{projectId}'
299
+ .gsub('{projectId}', project_id)
300
+
301
+ if project_id.nil?
302
+ raise Appwrite::Exception.new('Missing required parameter: "projectId"')
303
+ end
304
+
305
+ if name.nil?
306
+ raise Appwrite::Exception.new('Missing required parameter: "name"')
307
+ end
308
+
309
+ api_params = {
310
+ name: name,
311
+ }
312
+
313
+ api_headers = {
314
+ "X-Appwrite-Project": @client.get_config('project'),
315
+ "content-type": 'application/json',
316
+ }
317
+
318
+ @client.call(
319
+ method: 'PATCH',
320
+ path: api_path,
321
+ headers: api_headers,
322
+ params: api_params,
323
+ response_type: Models::Project
324
+ )
325
+
326
+ end
327
+
328
+ # Delete a project by its unique ID.
329
+ #
330
+ # @param [String] project_id Project unique ID.
331
+ #
332
+ # @return []
333
+ def delete_project(project_id:)
334
+ api_path = '/organization/projects/{projectId}'
335
+ .gsub('{projectId}', project_id)
336
+
337
+ if project_id.nil?
338
+ raise Appwrite::Exception.new('Missing required parameter: "projectId"')
339
+ end
340
+
341
+ api_params = {
342
+ }
343
+
344
+ api_headers = {
345
+ "X-Appwrite-Project": @client.get_config('project'),
346
+ "content-type": 'application/json',
347
+ }
348
+
349
+ @client.call(
350
+ method: 'DELETE',
351
+ path: api_path,
352
+ headers: api_headers,
353
+ params: api_params,
354
+ )
355
+
356
+ end
357
+
358
+ end
359
+ end
@@ -25,6 +25,7 @@ module Appwrite
25
25
  }
26
26
 
27
27
  api_headers = {
28
+ "X-Appwrite-Project": @client.get_config('project'),
28
29
  }
29
30
 
30
31
  @client.call(
@@ -56,6 +57,7 @@ module Appwrite
56
57
  }
57
58
 
58
59
  api_headers = {
60
+ "X-Appwrite-Project": @client.get_config('project'),
59
61
  }
60
62
 
61
63
  @client.call(
@@ -104,6 +106,7 @@ module Appwrite
104
106
  }
105
107
 
106
108
  api_headers = {
109
+ "X-Appwrite-Project": @client.get_config('project'),
107
110
  "content-type": 'application/json',
108
111
  }
109
112
 
@@ -130,7 +133,7 @@ module Appwrite
130
133
  # @param [] purge When true, purge cached responses used by list presences endpoint.
131
134
  #
132
135
  # @return [Presence]
133
- def update_presence(presence_id:, user_id:, status: nil, expires_at: nil, metadata: nil, permissions: nil, purge: nil)
136
+ def update(presence_id:, user_id:, status: nil, expires_at: nil, metadata: nil, permissions: nil, purge: nil)
134
137
  api_path = '/presences/{presenceId}'
135
138
  .gsub('{presenceId}', presence_id)
136
139
 
@@ -152,6 +155,7 @@ module Appwrite
152
155
  }
153
156
 
154
157
  api_headers = {
158
+ "X-Appwrite-Project": @client.get_config('project'),
155
159
  "content-type": 'application/json',
156
160
  }
157
161
 
@@ -183,6 +187,7 @@ module Appwrite
183
187
  }
184
188
 
185
189
  api_headers = {
190
+ "X-Appwrite-Project": @client.get_config('project'),
186
191
  "content-type": 'application/json',
187
192
  }
188
193