appwrite 20.1.0 → 21.0.1

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 (46) hide show
  1. checksums.yaml +4 -4
  2. data/lib/appwrite/client.rb +1 -2
  3. data/lib/appwrite/enums/backup_services.rb +9 -0
  4. data/lib/appwrite/enums/browser_permission.rb +26 -0
  5. data/lib/appwrite/enums/build_runtime.rb +22 -3
  6. data/lib/appwrite/enums/deployment_status.rb +1 -0
  7. data/lib/appwrite/enums/name.rb +1 -0
  8. data/lib/appwrite/enums/o_auth_provider.rb +0 -1
  9. data/lib/appwrite/enums/order_by.rb +8 -0
  10. data/lib/appwrite/enums/runtime.rb +22 -3
  11. data/lib/appwrite/enums/scopes.rb +72 -0
  12. data/lib/appwrite/models/activity_event.rb +182 -0
  13. data/lib/appwrite/models/activity_event_list.rb +32 -0
  14. data/lib/appwrite/models/attribute_longtext.rb +91 -0
  15. data/lib/appwrite/models/attribute_mediumtext.rb +91 -0
  16. data/lib/appwrite/models/attribute_text.rb +91 -0
  17. data/lib/appwrite/models/attribute_varchar.rb +96 -0
  18. data/lib/appwrite/models/backup_archive.rb +82 -0
  19. data/lib/appwrite/models/backup_archive_list.rb +32 -0
  20. data/lib/appwrite/models/backup_policy.rb +77 -0
  21. data/lib/appwrite/models/backup_policy_list.rb +32 -0
  22. data/lib/appwrite/models/backup_restoration.rb +77 -0
  23. data/lib/appwrite/models/backup_restoration_list.rb +32 -0
  24. data/lib/appwrite/models/bucket.rb +8 -3
  25. data/lib/appwrite/models/collection.rb +13 -3
  26. data/lib/appwrite/models/column_longtext.rb +91 -0
  27. data/lib/appwrite/models/column_mediumtext.rb +91 -0
  28. data/lib/appwrite/models/column_text.rb +91 -0
  29. data/lib/appwrite/models/column_varchar.rb +96 -0
  30. data/lib/appwrite/models/database.rb +13 -3
  31. data/lib/appwrite/models/deployment.rb +1 -0
  32. data/lib/appwrite/models/file.rb +13 -3
  33. data/lib/appwrite/models/health_status_list.rb +32 -0
  34. data/lib/appwrite/models/table.rb +13 -3
  35. data/lib/appwrite/query.rb +52 -0
  36. data/lib/appwrite/services/account.rb +3 -1
  37. data/lib/appwrite/services/activities.rb +64 -0
  38. data/lib/appwrite/services/avatars.rb +1 -1
  39. data/lib/appwrite/services/backups.rb +383 -0
  40. data/lib/appwrite/services/databases.rb +456 -15
  41. data/lib/appwrite/services/health.rb +151 -6
  42. data/lib/appwrite/services/storage.rb +8 -8
  43. data/lib/appwrite/services/tables_db.rb +461 -10
  44. data/lib/appwrite.rb +24 -2
  45. metadata +27 -5
  46. data/lib/appwrite/enums/output.rb +0 -13
@@ -180,12 +180,14 @@ module Appwrite
180
180
  # from its creation and will be invalid if the user will logout in that time
181
181
  # frame.
182
182
  #
183
+ # @param [Integer] duration Time in seconds before JWT expires. Default duration is 900 seconds, and maximum is 3600 seconds.
183
184
  #
184
185
  # @return [Jwt]
185
- def create_jwt()
186
+ def create_jwt(duration: nil)
186
187
  api_path = '/account/jwts'
187
188
 
188
189
  api_params = {
190
+ duration: duration,
189
191
  }
190
192
 
191
193
  api_headers = {
@@ -0,0 +1,64 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ class Activities < Service
5
+
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ # List all events for selected filters.
11
+ #
12
+ # @param [String] 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 attributes such as userId, teamId, etc.
13
+ #
14
+ # @return [ActivityEventList]
15
+ def list_events(queries: nil)
16
+ api_path = '/activities/events'
17
+
18
+ api_params = {
19
+ queries: queries,
20
+ }
21
+
22
+ api_headers = {
23
+ }
24
+
25
+ @client.call(
26
+ method: 'GET',
27
+ path: api_path,
28
+ headers: api_headers,
29
+ params: api_params,
30
+ response_type: Models::ActivityEventList
31
+ )
32
+ end
33
+
34
+ # Get event by ID.
35
+ #
36
+ #
37
+ # @param [String] event_id Event ID.
38
+ #
39
+ # @return [ActivityEvent]
40
+ def get_event(event_id:)
41
+ api_path = '/activities/events/{eventId}'
42
+ .gsub('{eventId}', event_id)
43
+
44
+ if event_id.nil?
45
+ raise Appwrite::Exception.new('Missing required parameter: "eventId"')
46
+ end
47
+
48
+ api_params = {
49
+ }
50
+
51
+ api_headers = {
52
+ }
53
+
54
+ @client.call(
55
+ method: 'GET',
56
+ path: api_path,
57
+ headers: api_headers,
58
+ params: api_params,
59
+ response_type: Models::ActivityEvent
60
+ )
61
+ end
62
+
63
+ end
64
+ end
@@ -312,7 +312,7 @@ module Appwrite
312
312
  # @param [Integer] width Output image width. Pass 0 to use original width, or an integer between 1 to 2000. Defaults to 0 (original width).
313
313
  # @param [Integer] height Output image height. Pass 0 to use original height, or an integer between 1 to 2000. Defaults to 0 (original height).
314
314
  # @param [Integer] quality Screenshot quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.
315
- # @param [Output] output Output format type (jpeg, jpg, png, gif and webp).
315
+ # @param [ImageFormat] output Output format type (jpeg, jpg, png, gif and webp).
316
316
  #
317
317
  # @return []
318
318
  def get_screenshot(url:, headers: nil, viewport_width: nil, viewport_height: nil, scale: nil, theme: nil, user_agent: nil, fullpage: nil, locale: nil, timezone: nil, latitude: nil, longitude: nil, accuracy: nil, touch: nil, permissions: nil, sleep: nil, width: nil, height: nil, quality: nil, output: nil)
@@ -0,0 +1,383 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ class Backups < Service
5
+
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ # List all archives for a project.
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.
13
+ #
14
+ # @return [BackupArchiveList]
15
+ def list_archives(queries: nil)
16
+ api_path = '/backups/archives'
17
+
18
+ api_params = {
19
+ queries: queries,
20
+ }
21
+
22
+ api_headers = {
23
+ }
24
+
25
+ @client.call(
26
+ method: 'GET',
27
+ path: api_path,
28
+ headers: api_headers,
29
+ params: api_params,
30
+ response_type: Models::BackupArchiveList
31
+ )
32
+ end
33
+
34
+ # Create a new archive asynchronously for a project.
35
+ #
36
+ # @param [Array] services Array of services to backup
37
+ # @param [String] resource_id Resource ID. When set, only this single resource will be backed up.
38
+ #
39
+ # @return [BackupArchive]
40
+ def create_archive(services:, resource_id: nil)
41
+ api_path = '/backups/archives'
42
+
43
+ if services.nil?
44
+ raise Appwrite::Exception.new('Missing required parameter: "services"')
45
+ end
46
+
47
+ api_params = {
48
+ services: services,
49
+ resourceId: resource_id,
50
+ }
51
+
52
+ api_headers = {
53
+ "content-type": 'application/json',
54
+ }
55
+
56
+ @client.call(
57
+ method: 'POST',
58
+ path: api_path,
59
+ headers: api_headers,
60
+ params: api_params,
61
+ response_type: Models::BackupArchive
62
+ )
63
+ end
64
+
65
+ # Get a backup archive using it's ID.
66
+ #
67
+ # @param [String] archive_id Archive ID. Choose a custom ID`. 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.
68
+ #
69
+ # @return [BackupArchive]
70
+ def get_archive(archive_id:)
71
+ api_path = '/backups/archives/{archiveId}'
72
+ .gsub('{archiveId}', archive_id)
73
+
74
+ if archive_id.nil?
75
+ raise Appwrite::Exception.new('Missing required parameter: "archiveId"')
76
+ end
77
+
78
+ api_params = {
79
+ }
80
+
81
+ api_headers = {
82
+ }
83
+
84
+ @client.call(
85
+ method: 'GET',
86
+ path: api_path,
87
+ headers: api_headers,
88
+ params: api_params,
89
+ response_type: Models::BackupArchive
90
+ )
91
+ end
92
+
93
+ # Delete an existing archive for a project.
94
+ #
95
+ # @param [String] archive_id Policy 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.
96
+ #
97
+ # @return []
98
+ def delete_archive(archive_id:)
99
+ api_path = '/backups/archives/{archiveId}'
100
+ .gsub('{archiveId}', archive_id)
101
+
102
+ if archive_id.nil?
103
+ raise Appwrite::Exception.new('Missing required parameter: "archiveId"')
104
+ end
105
+
106
+ api_params = {
107
+ }
108
+
109
+ api_headers = {
110
+ "content-type": 'application/json',
111
+ }
112
+
113
+ @client.call(
114
+ method: 'DELETE',
115
+ path: api_path,
116
+ headers: api_headers,
117
+ params: api_params,
118
+ )
119
+ end
120
+
121
+ # List all policies for a project.
122
+ #
123
+ # @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.
124
+ #
125
+ # @return [BackupPolicyList]
126
+ def list_policies(queries: nil)
127
+ api_path = '/backups/policies'
128
+
129
+ api_params = {
130
+ queries: queries,
131
+ }
132
+
133
+ api_headers = {
134
+ }
135
+
136
+ @client.call(
137
+ method: 'GET',
138
+ path: api_path,
139
+ headers: api_headers,
140
+ params: api_params,
141
+ response_type: Models::BackupPolicyList
142
+ )
143
+ end
144
+
145
+ # Create a new backup policy.
146
+ #
147
+ # @param [String] policy_id Policy 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.
148
+ # @param [Array] services Array of services to backup
149
+ # @param [Integer] retention Days to keep backups before deletion
150
+ # @param [String] schedule Schedule CRON syntax.
151
+ # @param [String] name Policy name. Max length: 128 chars.
152
+ # @param [String] resource_id Resource ID. When set, only this single resource will be backed up.
153
+ # @param [] enabled Is policy enabled? When set to 'disabled', no backups will be taken
154
+ #
155
+ # @return [BackupPolicy]
156
+ def create_policy(policy_id:, services:, retention:, schedule:, name: nil, resource_id: nil, enabled: nil)
157
+ api_path = '/backups/policies'
158
+
159
+ if policy_id.nil?
160
+ raise Appwrite::Exception.new('Missing required parameter: "policyId"')
161
+ end
162
+
163
+ if services.nil?
164
+ raise Appwrite::Exception.new('Missing required parameter: "services"')
165
+ end
166
+
167
+ if retention.nil?
168
+ raise Appwrite::Exception.new('Missing required parameter: "retention"')
169
+ end
170
+
171
+ if schedule.nil?
172
+ raise Appwrite::Exception.new('Missing required parameter: "schedule"')
173
+ end
174
+
175
+ api_params = {
176
+ policyId: policy_id,
177
+ name: name,
178
+ services: services,
179
+ resourceId: resource_id,
180
+ enabled: enabled,
181
+ retention: retention,
182
+ schedule: schedule,
183
+ }
184
+
185
+ api_headers = {
186
+ "content-type": 'application/json',
187
+ }
188
+
189
+ @client.call(
190
+ method: 'POST',
191
+ path: api_path,
192
+ headers: api_headers,
193
+ params: api_params,
194
+ response_type: Models::BackupPolicy
195
+ )
196
+ end
197
+
198
+ # Get a backup policy using it's ID.
199
+ #
200
+ # @param [String] policy_id Policy ID. Choose a custom ID`. 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.
201
+ #
202
+ # @return [BackupPolicy]
203
+ def get_policy(policy_id:)
204
+ api_path = '/backups/policies/{policyId}'
205
+ .gsub('{policyId}', policy_id)
206
+
207
+ if policy_id.nil?
208
+ raise Appwrite::Exception.new('Missing required parameter: "policyId"')
209
+ end
210
+
211
+ api_params = {
212
+ }
213
+
214
+ api_headers = {
215
+ }
216
+
217
+ @client.call(
218
+ method: 'GET',
219
+ path: api_path,
220
+ headers: api_headers,
221
+ params: api_params,
222
+ response_type: Models::BackupPolicy
223
+ )
224
+ end
225
+
226
+ # Update an existing policy using it's ID.
227
+ #
228
+ # @param [String] policy_id Policy ID. Choose a custom ID`. 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.
229
+ # @param [String] name Policy name. Max length: 128 chars.
230
+ # @param [Integer] retention Days to keep backups before deletion
231
+ # @param [String] schedule Cron expression
232
+ # @param [] enabled Is Backup enabled? When set to 'disabled', No backup will be taken
233
+ #
234
+ # @return [BackupPolicy]
235
+ def update_policy(policy_id:, name: nil, retention: nil, schedule: nil, enabled: nil)
236
+ api_path = '/backups/policies/{policyId}'
237
+ .gsub('{policyId}', policy_id)
238
+
239
+ if policy_id.nil?
240
+ raise Appwrite::Exception.new('Missing required parameter: "policyId"')
241
+ end
242
+
243
+ api_params = {
244
+ name: name,
245
+ retention: retention,
246
+ schedule: schedule,
247
+ enabled: enabled,
248
+ }
249
+
250
+ api_headers = {
251
+ "content-type": 'application/json',
252
+ }
253
+
254
+ @client.call(
255
+ method: 'PATCH',
256
+ path: api_path,
257
+ headers: api_headers,
258
+ params: api_params,
259
+ response_type: Models::BackupPolicy
260
+ )
261
+ end
262
+
263
+ # Delete a policy using it's ID.
264
+ #
265
+ # @param [String] policy_id Policy 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.
266
+ #
267
+ # @return []
268
+ def delete_policy(policy_id:)
269
+ api_path = '/backups/policies/{policyId}'
270
+ .gsub('{policyId}', policy_id)
271
+
272
+ if policy_id.nil?
273
+ raise Appwrite::Exception.new('Missing required parameter: "policyId"')
274
+ end
275
+
276
+ api_params = {
277
+ }
278
+
279
+ api_headers = {
280
+ "content-type": 'application/json',
281
+ }
282
+
283
+ @client.call(
284
+ method: 'DELETE',
285
+ path: api_path,
286
+ headers: api_headers,
287
+ params: api_params,
288
+ )
289
+ end
290
+
291
+ # Create and trigger a new restoration for a backup on a project.
292
+ #
293
+ # @param [String] archive_id Backup archive ID to restore
294
+ # @param [Array] services Array of services to restore
295
+ # @param [String] new_resource_id Unique 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.
296
+ # @param [String] new_resource_name Database name. Max length: 128 chars.
297
+ #
298
+ # @return [BackupRestoration]
299
+ def create_restoration(archive_id:, services:, new_resource_id: nil, new_resource_name: nil)
300
+ api_path = '/backups/restoration'
301
+
302
+ if archive_id.nil?
303
+ raise Appwrite::Exception.new('Missing required parameter: "archiveId"')
304
+ end
305
+
306
+ if services.nil?
307
+ raise Appwrite::Exception.new('Missing required parameter: "services"')
308
+ end
309
+
310
+ api_params = {
311
+ archiveId: archive_id,
312
+ services: services,
313
+ newResourceId: new_resource_id,
314
+ newResourceName: new_resource_name,
315
+ }
316
+
317
+ api_headers = {
318
+ "content-type": 'application/json',
319
+ }
320
+
321
+ @client.call(
322
+ method: 'POST',
323
+ path: api_path,
324
+ headers: api_headers,
325
+ params: api_params,
326
+ response_type: Models::BackupRestoration
327
+ )
328
+ end
329
+
330
+ # List all backup restorations for a project.
331
+ #
332
+ # @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.
333
+ #
334
+ # @return [BackupRestorationList]
335
+ def list_restorations(queries: nil)
336
+ api_path = '/backups/restorations'
337
+
338
+ api_params = {
339
+ queries: queries,
340
+ }
341
+
342
+ api_headers = {
343
+ }
344
+
345
+ @client.call(
346
+ method: 'GET',
347
+ path: api_path,
348
+ headers: api_headers,
349
+ params: api_params,
350
+ response_type: Models::BackupRestorationList
351
+ )
352
+ end
353
+
354
+ # Get the current status of a backup restoration.
355
+ #
356
+ # @param [String] restoration_id Restoration ID. Choose a custom ID`. 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.
357
+ #
358
+ # @return [BackupRestoration]
359
+ def get_restoration(restoration_id:)
360
+ api_path = '/backups/restorations/{restorationId}'
361
+ .gsub('{restorationId}', restoration_id)
362
+
363
+ if restoration_id.nil?
364
+ raise Appwrite::Exception.new('Missing required parameter: "restorationId"')
365
+ end
366
+
367
+ api_params = {
368
+ }
369
+
370
+ api_headers = {
371
+ }
372
+
373
+ @client.call(
374
+ method: 'GET',
375
+ path: api_path,
376
+ headers: api_headers,
377
+ params: api_params,
378
+ response_type: Models::BackupRestoration
379
+ )
380
+ end
381
+
382
+ end
383
+ end