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