appwrite 30.1.0 → 30.3.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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/lib/appwrite/client.rb +16 -2
  3. data/lib/appwrite/enums/appwrite_migration_resource.rb +1 -0
  4. data/lib/appwrite/enums/image_format.rb +1 -0
  5. data/lib/appwrite/enums/o_auth_provider.rb +3 -0
  6. data/lib/appwrite/enums/project_auth_method_id.rb +1 -0
  7. data/lib/appwrite/enums/project_key_scopes.rb +12 -0
  8. data/lib/appwrite/enums/project_ldap_encryption.rb +9 -0
  9. data/lib/appwrite/enums/project_o_auth_provider_id.rb +3 -0
  10. data/lib/appwrite/enums/project_policy_id.rb +1 -0
  11. data/lib/appwrite/models/activity_event.rb +9 -4
  12. data/lib/appwrite/models/device.rb +58 -0
  13. data/lib/appwrite/models/domain_price.rb +8 -3
  14. data/lib/appwrite/models/environment.rb +48 -0
  15. data/lib/appwrite/models/environment_list.rb +33 -0
  16. data/lib/appwrite/models/o_auth2_naver.rb +43 -0
  17. data/lib/appwrite/models/o_auth2_vipps.rb +43 -0
  18. data/lib/appwrite/models/organization.rb +16 -1
  19. data/lib/appwrite/models/policy_account_devices.rb +33 -0
  20. data/lib/appwrite/models/project.rb +91 -1
  21. data/lib/appwrite/models/project_auth_method.rb +1 -0
  22. data/lib/appwrite/models/proxy_rule.rb +11 -1
  23. data/lib/appwrite/models/session.rb +6 -1
  24. data/lib/appwrite/models/site.rb +14 -4
  25. data/lib/appwrite/models/waf_rule_bypass.rb +8 -3
  26. data/lib/appwrite/models/waf_rule_challenge.rb +5 -0
  27. data/lib/appwrite/models/waf_rule_deny.rb +8 -3
  28. data/lib/appwrite/models/waf_rule_rate_limit.rb +5 -0
  29. data/lib/appwrite/models/waf_rule_redirect.rb +5 -0
  30. data/lib/appwrite/services/account.rb +206 -1
  31. data/lib/appwrite/services/avatars.rb +5 -2
  32. data/lib/appwrite/services/domains.rb +7 -6
  33. data/lib/appwrite/services/project.rb +402 -21
  34. data/lib/appwrite/services/proxy.rb +154 -1
  35. data/lib/appwrite/services/sites.rb +44 -0
  36. data/lib/appwrite/services/storage.rb +7 -4
  37. data/lib/appwrite/services/waf.rb +40 -10
  38. data/lib/appwrite.rb +7 -0
  39. metadata +9 -2
@@ -301,6 +301,161 @@ module Appwrite
301
301
  )
302
302
  end
303
303
 
304
+ # Create an account switching device. A device is a container, scoped to one
305
+ # browser or app install, that holds multiple sessions and tracks which one
306
+ # is active. Once a device exists, session creation endpoints attach the new
307
+ # session to it automatically, so a single browser can stay signed in to
308
+ # several accounts and switch between them. A device holds at most one
309
+ # session per user: signing in again as a user it already holds replaces that
310
+ # user's session. The device lives as long as its newest session.
311
+ #
312
+ # The device secret is returned in a cookie. Run this on app start: if the
313
+ # browser already has a valid device, the existing one is returned with the
314
+ # same status code instead of an error, so it is always safe to call.
315
+ #
316
+ # Every session that joins the device rotates the device secret and re-issues
317
+ # the cookie, so an earlier copy of the secret stops working. A client that
318
+ # keeps the secret itself, rather than relying on the cookie, must replace it
319
+ # from each session response.
320
+ #
321
+ #
322
+ # @return [Device]
323
+ def create_device()
324
+ api_path = '/account/devices'
325
+
326
+ api_params = {}
327
+
328
+ api_headers = {
329
+ "X-Appwrite-Project": @client.get_config('project'),
330
+ "content-type": 'application/json',
331
+ "accept": 'application/json',
332
+ }
333
+
334
+ @client.call(
335
+ method: 'POST',
336
+ path: api_path,
337
+ headers: api_headers,
338
+ params: api_params,
339
+ response_type: Models::Device
340
+ )
341
+ end
342
+
343
+ # Get the account switching device for the current browser, including every
344
+ # session it holds, the name of the user each session belongs to, and the ID
345
+ # of the active session. Use the string 'current' to reference the current
346
+ # browser's device.
347
+ #
348
+ # @param [String] device_id Device ID. Use the string 'current' to reference the device of the current browser.
349
+ #
350
+ # @return [Device]
351
+ def get_device(
352
+ device_id:
353
+ )
354
+ if device_id.nil? || device_id == ''
355
+ raise Appwrite::Exception.new('Missing required parameter: "deviceId"')
356
+ end
357
+
358
+ api_path = '/account/devices/{deviceId}'
359
+ .gsub('{deviceId}', @client.encode_path(device_id))
360
+
361
+ api_params = {}
362
+
363
+ api_headers = {
364
+ "X-Appwrite-Project": @client.get_config('project'),
365
+ "accept": 'application/json',
366
+ }
367
+
368
+ @client.call(
369
+ method: 'GET',
370
+ path: api_path,
371
+ headers: api_headers,
372
+ params: api_params,
373
+ response_type: Models::Device
374
+ )
375
+ end
376
+
377
+ # Delete the account switching device for the current browser. Every session
378
+ # the device holds is signed out, each firing its own session delete event,
379
+ # the device is removed, and both the device and session cookies are cleared.
380
+ # Use the string 'current' to reference the current browser's device.
381
+ #
382
+ # @param [String] device_id Device ID. Use the string 'current' to reference the device of the current browser.
383
+ #
384
+ # @return []
385
+ def delete_device(
386
+ device_id:
387
+ )
388
+ if device_id.nil? || device_id == ''
389
+ raise Appwrite::Exception.new('Missing required parameter: "deviceId"')
390
+ end
391
+
392
+ api_path = '/account/devices/{deviceId}'
393
+ .gsub('{deviceId}', @client.encode_path(device_id))
394
+
395
+ api_params = {}
396
+
397
+ api_headers = {
398
+ "X-Appwrite-Project": @client.get_config('project'),
399
+ "content-type": 'application/json',
400
+ "accept": 'application/json',
401
+ }
402
+
403
+ @client.call(
404
+ method: 'DELETE',
405
+ path: api_path,
406
+ headers: api_headers,
407
+ params: api_params,
408
+ )
409
+ end
410
+
411
+ # Switch the active account on an account switching device to one of the
412
+ # sessions it holds. The chosen session becomes active and its secret is
413
+ # written to the browser's session cookie, so subsequent requests
414
+ # authenticate as that account. Use the string 'current' to reference the
415
+ # current browser's device.
416
+ #
417
+ # Switching rotates the chosen session's secret. Any other holder of that
418
+ # session, such as a copy kept elsewhere, stops working, so a session should
419
+ # not be shared across devices.
420
+ #
421
+ # @param [String] device_id Device ID. Use the string 'current' to reference the device of the current browser.
422
+ # @param [String] session_id ID of the session, held by the device, to make active.
423
+ #
424
+ # @return [Session]
425
+ def update_device_session(
426
+ device_id:,
427
+ session_id:
428
+ )
429
+ if device_id.nil? || device_id == ''
430
+ raise Appwrite::Exception.new('Missing required parameter: "deviceId"')
431
+ end
432
+
433
+ if session_id.nil?
434
+ raise Appwrite::Exception.new('Missing required parameter: "sessionId"')
435
+ end
436
+
437
+ api_path = '/account/devices/{deviceId}/session'
438
+ .gsub('{deviceId}', @client.encode_path(device_id))
439
+
440
+ api_params = {
441
+ sessionId: session_id,
442
+ }
443
+
444
+ api_headers = {
445
+ "X-Appwrite-Project": @client.get_config('project'),
446
+ "content-type": 'application/json',
447
+ "accept": 'application/json',
448
+ }
449
+
450
+ @client.call(
451
+ method: 'PATCH',
452
+ path: api_path,
453
+ headers: api_headers,
454
+ params: api_params,
455
+ response_type: Models::Session
456
+ )
457
+ end
458
+
304
459
  # Update currently logged in user account email address. After changing user
305
460
  # address, the user confirmation status will get reset. A new confirmation
306
461
  # email is not sent automatically however you can use the send confirmation
@@ -1613,6 +1768,56 @@ module Appwrite
1613
1768
  )
1614
1769
  end
1615
1770
 
1771
+ # Allow the user to login into their account by providing the username and
1772
+ # password they use in the project's LDAP directory. The directory verifies
1773
+ # the password; on the first sign-in an account is created from the directory
1774
+ # entry, and on later sign-ins the name, email and phone follow the
1775
+ # directory. This endpoint requires LDAP to be configured and enabled for the
1776
+ # project. A user is limited to 10 active sessions at a time by default.
1777
+ # [Learn more about session
1778
+ # limits](https://appwrite.io/docs/authentication-security#limits).
1779
+ #
1780
+ # @param [String] username Directory username, matched against the username attribute of the project's LDAP configuration.
1781
+ # @param [String] password Directory password.
1782
+ # @param [Integer] duration Session length in seconds. Minimum is 60 seconds, and it cannot exceed the project maximum session length. Defaults to the project maximum session length.
1783
+ #
1784
+ # @return [Session]
1785
+ def create_ldap_session(
1786
+ username:,
1787
+ password:,
1788
+ duration: nil
1789
+ )
1790
+ if username.nil?
1791
+ raise Appwrite::Exception.new('Missing required parameter: "username"')
1792
+ end
1793
+
1794
+ if password.nil?
1795
+ raise Appwrite::Exception.new('Missing required parameter: "password"')
1796
+ end
1797
+
1798
+ api_path = '/account/sessions/ldap'
1799
+
1800
+ api_params = {
1801
+ username: username,
1802
+ password: password,
1803
+ duration: duration,
1804
+ }
1805
+
1806
+ api_headers = {
1807
+ "X-Appwrite-Project": @client.get_config('project'),
1808
+ "content-type": 'application/json',
1809
+ "accept": 'application/json',
1810
+ }
1811
+
1812
+ @client.call(
1813
+ method: 'POST',
1814
+ path: api_path,
1815
+ headers: api_headers,
1816
+ params: api_params,
1817
+ response_type: Models::Session
1818
+ )
1819
+ end
1820
+
1616
1821
  #
1617
1822
  # @deprecated This API has been deprecated since 1.6.0. Please use `Account.createSession` instead.
1618
1823
  #
@@ -2006,7 +2211,7 @@ module Appwrite
2006
2211
  # about session
2007
2212
  # limits](https://appwrite.io/docs/authentication-security#limits).
2008
2213
  #
2009
- # @param [OAuthProvider] provider OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, webflow, wordpress, x, yahoo, yammer, yandex, zoho, zoom.
2214
+ # @param [OAuthProvider] provider OAuth2 Provider. Currently, supported providers are: amazon, apple, appwrite, auth0, authentik, autodesk, bitbucket, bitly, box, cloudflare, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, huggingface, kakao, keycloak, kick, linkedin, microsoft, naver, notion, oidc, okta, paypal, paypalSandbox, podio, resend, salesforce, slack, spotify, stripe, tiktok, tradeshift, tradeshiftBox, twitch, vipps, vippsSandbox, webflow, wordpress, x, yahoo, yammer, yandex, zoho, zoom.
2010
2215
  # @param [String] success URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's 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.
2011
2216
  # @param [String] failure URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's 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.
2012
2217
  # @param [Array] scopes A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long.
@@ -470,6 +470,9 @@ module Appwrite
470
470
  # both dimensions are 0, the API provides an image at original size. If
471
471
  # dimensions are not specified, the default viewport size is 1280x720px.
472
472
  #
473
+ # Set `output` to `auto` to receive avif or webp when the `Accept` header of
474
+ # your request supports it, falling back to png.
475
+ #
473
476
  # @param [String] url Website URL which you want to capture.
474
477
  # @param [Hash] headers HTTP headers to send with the browser request. Only Accept and Accept-Language are allowed. Defaults to empty.
475
478
  # @param [Integer] viewport_width Browser viewport width. Pass an integer between 1 to 1920. Defaults to 1280.
@@ -489,7 +492,7 @@ module Appwrite
489
492
  # @param [Integer] width Output image width. Pass 0 to use original width, or an integer between 1 to 2000. Defaults to 0 (original width).
490
493
  # @param [Integer] height Output image height. Pass 0 to use original height, or an integer between 1 to 2000. Defaults to 0 (original height).
491
494
  # @param [Integer] quality Screenshot quality. Pass an integer between 0 to 100. Defaults to keep existing image quality.
492
- # @param [ImageFormat] output Output format type (jpeg, jpg, png, gif and webp).
495
+ # @param [ImageFormat] output Output format type (jpeg, jpg, png, gif, webp, heic and avif). Pass auto to serve avif or webp when the Accept header of your request supports it, falling back to png.
493
496
  #
494
497
  # @return []
495
498
  def get_screenshot(
@@ -545,7 +548,7 @@ module Appwrite
545
548
 
546
549
  api_headers = {
547
550
  "X-Appwrite-Project": @client.get_config('project'),
548
- "accept": 'image/png',
551
+ "accept": 'image/*',
549
552
  }
550
553
 
551
554
  @client.call(
@@ -128,10 +128,11 @@ module Appwrite
128
128
  # domain names. Availability is resolved for all domains in a single
129
129
  # registrar lookup. Unavailable domains have a null price for new
130
130
  # registrations, but can still be priced for renewal, transfer, or trade.
131
- # Every priced domain also carries its renewal price for the same period, so
132
- # a separate renewal lookup is not needed. A domain whose price could not be
133
- # resolved, for example because its TLD is not supported, is returned with a
134
- # null price.
131
+ # Available domains have a null price for transfers, since an unregistered
132
+ # domain cannot be transferred, and the reason says so. Every priced domain
133
+ # also carries its renewal price for the same period, so a separate renewal
134
+ # lookup is not needed. A domain whose price could not be resolved, for
135
+ # example because its TLD is not supported, is returned with a null price.
135
136
  #
136
137
  # @param [Array] domains Domain names to check availability and price for. Maximum of 50 domains per request.
137
138
  # @param [Integer] period_years Number of years to calculate the domain price for. Must be at least 1.
@@ -1262,7 +1263,7 @@ module Appwrite
1262
1263
  # to 'example.wordpress.com'.
1263
1264
  #
1264
1265
  # @param [String] domain_id Domain unique ID.
1265
- # @param [String] name Record name relative to the domain, such as `www`, or `@` for the domain itself. A full name ending in the domain is also accepted and stored relative to it.
1266
+ # @param [String] name Record name relative to the domain, such as `www`. A CNAME cannot be at the domain itself; use an ALIAS record there. A full name ending in the domain is also accepted and stored relative to it.
1266
1267
  # @param [String] value Canonical target for this CNAME record.
1267
1268
  # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647.
1268
1269
  # @param [String] comment A comment for this record.
@@ -1320,7 +1321,7 @@ module Appwrite
1320
1321
  #
1321
1322
  # @param [String] domain_id Domain unique ID.
1322
1323
  # @param [String] record_id DNS record unique ID.
1323
- # @param [String] name Record name relative to the domain, such as `www`, or `@` for the domain itself. A full name ending in the domain is also accepted and stored relative to it.
1324
+ # @param [String] name Record name relative to the domain, such as `www`. A CNAME cannot be at the domain itself; use an ALIAS record there. A full name ending in the domain is also accepted and stored relative to it.
1324
1325
  # @param [String] value Canonical target for this CNAME record.
1325
1326
  # @param [Integer] ttl Time to live, in seconds. Must be between 1 and 2147483647.
1326
1327
  # @param [String] comment A comment for this record.