appwrite 23.0.0 → 23.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 (87) hide show
  1. checksums.yaml +4 -4
  2. data/lib/appwrite/client.rb +28 -2
  3. data/lib/appwrite/enums/auth_method.rb +13 -0
  4. data/lib/appwrite/enums/build_runtime.rb +1 -0
  5. data/lib/appwrite/enums/email_template_locale.rb +137 -0
  6. data/lib/appwrite/enums/email_template_type.rb +13 -0
  7. data/lib/appwrite/enums/o_auth_provider.rb +5 -0
  8. data/lib/appwrite/enums/project_policy.rb +15 -0
  9. data/lib/appwrite/enums/proxy_resource_type.rb +8 -0
  10. data/lib/appwrite/enums/proxy_rule_deployment_resource_type.rb +8 -0
  11. data/lib/appwrite/enums/proxy_rule_status.rb +9 -0
  12. data/lib/appwrite/enums/runtime.rb +1 -0
  13. data/lib/appwrite/enums/scopes.rb +44 -31
  14. data/lib/appwrite/enums/secure.rb +8 -0
  15. data/lib/appwrite/enums/status_code.rb +10 -0
  16. data/lib/appwrite/models/attribute_bigint.rb +96 -0
  17. data/lib/appwrite/models/block.rb +28 -3
  18. data/lib/appwrite/models/column_bigint.rb +96 -0
  19. data/lib/appwrite/models/email_template.rb +62 -0
  20. data/lib/appwrite/models/email_template_list.rb +32 -0
  21. data/lib/appwrite/models/ephemeral_key.rb +67 -0
  22. data/lib/appwrite/models/membership.rb +5 -0
  23. data/lib/appwrite/models/mock_number.rb +18 -8
  24. data/lib/appwrite/models/mock_number_list.rb +32 -0
  25. data/lib/appwrite/models/o_auth2_amazon.rb +42 -0
  26. data/lib/appwrite/models/o_auth2_apple.rb +52 -0
  27. data/lib/appwrite/models/o_auth2_auth0.rb +47 -0
  28. data/lib/appwrite/models/o_auth2_authentik.rb +47 -0
  29. data/lib/appwrite/models/o_auth2_autodesk.rb +42 -0
  30. data/lib/appwrite/models/o_auth2_bitbucket.rb +42 -0
  31. data/lib/appwrite/models/o_auth2_bitly.rb +42 -0
  32. data/lib/appwrite/models/o_auth2_box.rb +42 -0
  33. data/lib/appwrite/models/o_auth2_dailymotion.rb +42 -0
  34. data/lib/appwrite/models/o_auth2_discord.rb +42 -0
  35. data/lib/appwrite/models/o_auth2_disqus.rb +42 -0
  36. data/lib/appwrite/models/o_auth2_dropbox.rb +42 -0
  37. data/lib/appwrite/models/o_auth2_etsy.rb +42 -0
  38. data/lib/appwrite/models/o_auth2_facebook.rb +42 -0
  39. data/lib/appwrite/models/o_auth2_figma.rb +42 -0
  40. data/lib/appwrite/models/o_auth2_fusion_auth.rb +47 -0
  41. data/lib/appwrite/models/o_auth2_github.rb +42 -0
  42. data/lib/appwrite/models/o_auth2_gitlab.rb +47 -0
  43. data/lib/appwrite/models/o_auth2_google.rb +42 -0
  44. data/lib/appwrite/models/o_auth2_keycloak.rb +52 -0
  45. data/lib/appwrite/models/o_auth2_kick.rb +42 -0
  46. data/lib/appwrite/models/o_auth2_linkedin.rb +42 -0
  47. data/lib/appwrite/models/o_auth2_microsoft.rb +47 -0
  48. data/lib/appwrite/models/o_auth2_notion.rb +42 -0
  49. data/lib/appwrite/models/o_auth2_oidc.rb +62 -0
  50. data/lib/appwrite/models/o_auth2_okta.rb +52 -0
  51. data/lib/appwrite/models/o_auth2_paypal.rb +42 -0
  52. data/lib/appwrite/models/o_auth2_podio.rb +42 -0
  53. data/lib/appwrite/models/o_auth2_provider_list.rb +32 -0
  54. data/lib/appwrite/models/o_auth2_salesforce.rb +42 -0
  55. data/lib/appwrite/models/o_auth2_slack.rb +42 -0
  56. data/lib/appwrite/models/o_auth2_spotify.rb +42 -0
  57. data/lib/appwrite/models/o_auth2_stripe.rb +42 -0
  58. data/lib/appwrite/models/o_auth2_tradeshift.rb +42 -0
  59. data/lib/appwrite/models/o_auth2_twitch.rb +42 -0
  60. data/lib/appwrite/models/o_auth2_word_press.rb +42 -0
  61. data/lib/appwrite/models/o_auth2_x.rb +42 -0
  62. data/lib/appwrite/models/o_auth2_yahoo.rb +42 -0
  63. data/lib/appwrite/models/o_auth2_yandex.rb +42 -0
  64. data/lib/appwrite/models/o_auth2_zoho.rb +42 -0
  65. data/lib/appwrite/models/o_auth2_zoom.rb +42 -0
  66. data/lib/appwrite/models/policy_list.rb +32 -0
  67. data/lib/appwrite/models/policy_membership_privacy.rb +52 -0
  68. data/lib/appwrite/models/policy_password_dictionary.rb +32 -0
  69. data/lib/appwrite/models/policy_password_history.rb +32 -0
  70. data/lib/appwrite/models/policy_password_personal_data.rb +32 -0
  71. data/lib/appwrite/models/policy_session_alert.rb +32 -0
  72. data/lib/appwrite/models/policy_session_duration.rb +32 -0
  73. data/lib/appwrite/models/policy_session_invalidation.rb +32 -0
  74. data/lib/appwrite/models/policy_session_limit.rb +32 -0
  75. data/lib/appwrite/models/policy_user_limit.rb +32 -0
  76. data/lib/appwrite/models/project.rb +20 -5
  77. data/lib/appwrite/models/proxy_rule.rb +127 -0
  78. data/lib/appwrite/models/proxy_rule_list.rb +32 -0
  79. data/lib/appwrite/services/account.rb +1 -1
  80. data/lib/appwrite/services/databases.rb +126 -0
  81. data/lib/appwrite/services/functions.rb +13 -7
  82. data/lib/appwrite/services/project.rb +2695 -288
  83. data/lib/appwrite/services/proxy.rb +303 -0
  84. data/lib/appwrite/services/sites.rb +13 -7
  85. data/lib/appwrite/services/tables_db.rb +120 -0
  86. data/lib/appwrite.rb +69 -0
  87. metadata +71 -2
@@ -0,0 +1,127 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class ProxyRule
6
+ attr_reader :id
7
+ attr_reader :created_at
8
+ attr_reader :updated_at
9
+ attr_reader :domain
10
+ attr_reader :type
11
+ attr_reader :trigger
12
+ attr_reader :redirect_url
13
+ attr_reader :redirect_status_code
14
+ attr_reader :deployment_id
15
+ attr_reader :deployment_resource_type
16
+ attr_reader :deployment_resource_id
17
+ attr_reader :deployment_vcs_provider_branch
18
+ attr_reader :status
19
+ attr_reader :logs
20
+ attr_reader :renew_at
21
+
22
+ def initialize(
23
+ id:,
24
+ created_at:,
25
+ updated_at:,
26
+ domain:,
27
+ type:,
28
+ trigger:,
29
+ redirect_url:,
30
+ redirect_status_code:,
31
+ deployment_id:,
32
+ deployment_resource_type: ,
33
+ deployment_resource_id:,
34
+ deployment_vcs_provider_branch:,
35
+ status:,
36
+ logs:,
37
+ renew_at:
38
+ )
39
+ @id = id
40
+ @created_at = created_at
41
+ @updated_at = updated_at
42
+ @domain = domain
43
+ @type = type
44
+ @trigger = trigger
45
+ @redirect_url = redirect_url
46
+ @redirect_status_code = redirect_status_code
47
+ @deployment_id = deployment_id
48
+ @deployment_resource_type = deployment_resource_type.nil? ? deployment_resource_type : validate_deployment_resource_type(deployment_resource_type)
49
+ @deployment_resource_id = deployment_resource_id
50
+ @deployment_vcs_provider_branch = deployment_vcs_provider_branch
51
+ @status = validate_status(status)
52
+ @logs = logs
53
+ @renew_at = renew_at
54
+ end
55
+
56
+ def self.from(map:)
57
+ ProxyRule.new(
58
+ id: map["$id"],
59
+ created_at: map["$createdAt"],
60
+ updated_at: map["$updatedAt"],
61
+ domain: map["domain"],
62
+ type: map["type"],
63
+ trigger: map["trigger"],
64
+ redirect_url: map["redirectUrl"],
65
+ redirect_status_code: map["redirectStatusCode"],
66
+ deployment_id: map["deploymentId"],
67
+ deployment_resource_type: map["deploymentResourceType"],
68
+ deployment_resource_id: map["deploymentResourceId"],
69
+ deployment_vcs_provider_branch: map["deploymentVcsProviderBranch"],
70
+ status: map["status"],
71
+ logs: map["logs"],
72
+ renew_at: map["renewAt"]
73
+ )
74
+ end
75
+
76
+ def to_map
77
+ {
78
+ "$id": @id,
79
+ "$createdAt": @created_at,
80
+ "$updatedAt": @updated_at,
81
+ "domain": @domain,
82
+ "type": @type,
83
+ "trigger": @trigger,
84
+ "redirectUrl": @redirect_url,
85
+ "redirectStatusCode": @redirect_status_code,
86
+ "deploymentId": @deployment_id,
87
+ "deploymentResourceType": @deployment_resource_type,
88
+ "deploymentResourceId": @deployment_resource_id,
89
+ "deploymentVcsProviderBranch": @deployment_vcs_provider_branch,
90
+ "status": @status,
91
+ "logs": @logs,
92
+ "renewAt": @renew_at
93
+ }
94
+ end
95
+
96
+ private
97
+
98
+ def validate_deployment_resource_type(deployment_resource_type)
99
+ valid_deployment_resource_type = [
100
+ Appwrite::Enums::ProxyRuleDeploymentResourceType::FUNCTION,
101
+ Appwrite::Enums::ProxyRuleDeploymentResourceType::SITE,
102
+ ]
103
+
104
+ unless valid_deployment_resource_type.include?(deployment_resource_type)
105
+ raise ArgumentError, "Invalid " + deployment_resource_type + ". Must be one of: " + valid_deployment_resource_type.join(', ')
106
+ end
107
+
108
+ deployment_resource_type
109
+ end
110
+
111
+ def validate_status(status)
112
+ valid_status = [
113
+ Appwrite::Enums::ProxyRuleStatus::UNVERIFIED,
114
+ Appwrite::Enums::ProxyRuleStatus::VERIFYING,
115
+ Appwrite::Enums::ProxyRuleStatus::VERIFIED,
116
+ ]
117
+
118
+ unless valid_status.include?(status)
119
+ raise ArgumentError, "Invalid " + status + ". Must be one of: " + valid_status.join(', ')
120
+ end
121
+
122
+ status
123
+ end
124
+
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,32 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class ProxyRuleList
6
+ attr_reader :total
7
+ attr_reader :rules
8
+
9
+ def initialize(
10
+ total:,
11
+ rules:
12
+ )
13
+ @total = total
14
+ @rules = rules
15
+ end
16
+
17
+ def self.from(map:)
18
+ ProxyRuleList.new(
19
+ total: map["total"],
20
+ rules: map["rules"].map { |it| ProxyRule.from(map: it) }
21
+ )
22
+ end
23
+
24
+ def to_map
25
+ {
26
+ "total": @total,
27
+ "rules": @rules.map { |it| it.to_map }
28
+ }
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1275,7 +1275,7 @@ module Appwrite
1275
1275
  # about session
1276
1276
  # limits](https://appwrite.io/docs/authentication-security#limits).
1277
1277
  #
1278
- # @param [OAuthProvider] provider OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom.
1278
+ # @param [OAuthProvider] provider OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, fusionauth, github, gitlab, google, keycloak, kick, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom.
1279
1279
  # @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.
1280
1280
  # @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.
1281
1281
  # @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.
@@ -626,6 +626,132 @@ module Appwrite
626
626
 
627
627
  end
628
628
 
629
+ #
630
+ # @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createBigIntColumn` instead.
631
+ #
632
+ # Create a bigint attribute. Optionally, minimum and maximum values can be
633
+ # provided.
634
+ #
635
+ #
636
+ # @param [String] database_id Database ID.
637
+ # @param [String] collection_id Collection ID.
638
+ # @param [String] key Attribute Key.
639
+ # @param [] required Is attribute required?
640
+ # @param [Integer] min Minimum value
641
+ # @param [Integer] max Maximum value
642
+ # @param [Integer] default Default value. Cannot be set when attribute is required.
643
+ # @param [] array Is attribute an array?
644
+ #
645
+ # @return [AttributeBigint]
646
+ def create_big_int_attribute(database_id:, collection_id:, key:, required:, min: nil, max: nil, default: nil, array: nil)
647
+ api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint'
648
+ .gsub('{databaseId}', database_id)
649
+ .gsub('{collectionId}', collection_id)
650
+
651
+ if database_id.nil?
652
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
653
+ end
654
+
655
+ if collection_id.nil?
656
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
657
+ end
658
+
659
+ if key.nil?
660
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
661
+ end
662
+
663
+ if required.nil?
664
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
665
+ end
666
+
667
+ api_params = {
668
+ key: key,
669
+ required: required,
670
+ min: min,
671
+ max: max,
672
+ default: default,
673
+ array: array,
674
+ }
675
+
676
+ api_headers = {
677
+ "content-type": 'application/json',
678
+ }
679
+
680
+ @client.call(
681
+ method: 'POST',
682
+ path: api_path,
683
+ headers: api_headers,
684
+ params: api_params,
685
+ response_type: Models::AttributeBigint
686
+ )
687
+
688
+ end
689
+
690
+ #
691
+ # @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateBigIntColumn` instead.
692
+ #
693
+ # Update a bigint attribute. Changing the `default` value will not update
694
+ # already existing documents.
695
+ #
696
+ #
697
+ # @param [String] database_id Database ID.
698
+ # @param [String] collection_id Collection ID.
699
+ # @param [String] key Attribute Key.
700
+ # @param [] required Is attribute required?
701
+ # @param [Integer] default Default value. Cannot be set when attribute is required.
702
+ # @param [Integer] min Minimum value
703
+ # @param [Integer] max Maximum value
704
+ # @param [String] new_key New Attribute Key.
705
+ #
706
+ # @return [AttributeBigint]
707
+ def update_big_int_attribute(database_id:, collection_id:, key:, required:, default:, min: nil, max: nil, new_key: nil)
708
+ api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/bigint/{key}'
709
+ .gsub('{databaseId}', database_id)
710
+ .gsub('{collectionId}', collection_id)
711
+ .gsub('{key}', key)
712
+
713
+ if database_id.nil?
714
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
715
+ end
716
+
717
+ if collection_id.nil?
718
+ raise Appwrite::Exception.new('Missing required parameter: "collectionId"')
719
+ end
720
+
721
+ if key.nil?
722
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
723
+ end
724
+
725
+ if required.nil?
726
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
727
+ end
728
+
729
+ if default.nil?
730
+ raise Appwrite::Exception.new('Missing required parameter: "default"')
731
+ end
732
+
733
+ api_params = {
734
+ required: required,
735
+ min: min,
736
+ max: max,
737
+ default: default,
738
+ newKey: new_key,
739
+ }
740
+
741
+ api_headers = {
742
+ "content-type": 'application/json',
743
+ }
744
+
745
+ @client.call(
746
+ method: 'PATCH',
747
+ path: api_path,
748
+ headers: api_headers,
749
+ params: api_params,
750
+ response_type: Models::AttributeBigint
751
+ )
752
+
753
+ end
754
+
629
755
  #
630
756
  # @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createBooleanColumn` instead.
631
757
  #
@@ -879,9 +879,11 @@ module Appwrite
879
879
  # Get a list of all variables of a specific function.
880
880
  #
881
881
  # @param [String] function_id Function unique ID.
882
+ # @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: key, resourceType, resourceId, secret
883
+ # @param [] total When set to false, the total count returned will be 0 and will not be calculated.
882
884
  #
883
885
  # @return [VariableList]
884
- def list_variables(function_id:)
886
+ def list_variables(function_id:, queries: nil, total: nil)
885
887
  api_path = '/functions/{functionId}/variables'
886
888
  .gsub('{functionId}', function_id)
887
889
 
@@ -890,6 +892,8 @@ module Appwrite
890
892
  end
891
893
 
892
894
  api_params = {
895
+ queries: queries,
896
+ total: total,
893
897
  }
894
898
 
895
899
  api_headers = {
@@ -909,12 +913,13 @@ module Appwrite
909
913
  # in the function at runtime as environment variables.
910
914
  #
911
915
  # @param [String] function_id Function unique ID.
916
+ # @param [String] variable_id Variable 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.
912
917
  # @param [String] key Variable key. Max length: 255 chars.
913
918
  # @param [String] value Variable value. Max length: 8192 chars.
914
919
  # @param [] secret Secret variables can be updated or deleted, but only functions can read them during build and runtime.
915
920
  #
916
921
  # @return [Variable]
917
- def create_variable(function_id:, key:, value:, secret: nil)
922
+ def create_variable(function_id:, variable_id:, key:, value:, secret: nil)
918
923
  api_path = '/functions/{functionId}/variables'
919
924
  .gsub('{functionId}', function_id)
920
925
 
@@ -922,6 +927,10 @@ module Appwrite
922
927
  raise Appwrite::Exception.new('Missing required parameter: "functionId"')
923
928
  end
924
929
 
930
+ if variable_id.nil?
931
+ raise Appwrite::Exception.new('Missing required parameter: "variableId"')
932
+ end
933
+
925
934
  if key.nil?
926
935
  raise Appwrite::Exception.new('Missing required parameter: "key"')
927
936
  end
@@ -931,6 +940,7 @@ module Appwrite
931
940
  end
932
941
 
933
942
  api_params = {
943
+ variableId: variable_id,
934
944
  key: key,
935
945
  value: value,
936
946
  secret: secret,
@@ -994,7 +1004,7 @@ module Appwrite
994
1004
  # @param [] secret Secret variables can be updated or deleted, but only functions can read them during build and runtime.
995
1005
  #
996
1006
  # @return [Variable]
997
- def update_variable(function_id:, variable_id:, key:, value: nil, secret: nil)
1007
+ def update_variable(function_id:, variable_id:, key: nil, value: nil, secret: nil)
998
1008
  api_path = '/functions/{functionId}/variables/{variableId}'
999
1009
  .gsub('{functionId}', function_id)
1000
1010
  .gsub('{variableId}', variable_id)
@@ -1007,10 +1017,6 @@ module Appwrite
1007
1017
  raise Appwrite::Exception.new('Missing required parameter: "variableId"')
1008
1018
  end
1009
1019
 
1010
- if key.nil?
1011
- raise Appwrite::Exception.new('Missing required parameter: "key"')
1012
- end
1013
-
1014
1020
  api_params = {
1015
1021
  key: key,
1016
1022
  value: value,