appwrite 23.0.0 → 24.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 (112) hide show
  1. checksums.yaml +4 -4
  2. data/lib/appwrite/client.rb +28 -2
  3. data/lib/appwrite/enums/build_runtime.rb +1 -0
  4. data/lib/appwrite/enums/o_auth2_google_prompt.rb +9 -0
  5. data/lib/appwrite/enums/o_auth_provider.rb +3 -0
  6. data/lib/appwrite/enums/project_auth_method_id.rb +13 -0
  7. data/lib/appwrite/enums/project_email_template_id.rb +13 -0
  8. data/lib/appwrite/enums/project_email_template_locale.rb +137 -0
  9. data/lib/appwrite/enums/project_key_scopes.rb +100 -0
  10. data/lib/appwrite/enums/project_o_auth2_google_prompt.rb +9 -0
  11. data/lib/appwrite/enums/project_o_auth_provider_id.rb +51 -0
  12. data/lib/appwrite/enums/project_policy_id.rb +15 -0
  13. data/lib/appwrite/enums/{protocol_id.rb → project_protocol_id.rb} +1 -1
  14. data/lib/appwrite/enums/{service_id.rb → project_service_id.rb} +2 -1
  15. data/lib/appwrite/enums/project_smtp_secure.rb +8 -0
  16. data/lib/appwrite/enums/proxy_resource_type.rb +8 -0
  17. data/lib/appwrite/enums/proxy_rule_deployment_resource_type.rb +8 -0
  18. data/lib/appwrite/enums/proxy_rule_status.rb +9 -0
  19. data/lib/appwrite/enums/runtime.rb +1 -0
  20. data/lib/appwrite/enums/scopes.rb +51 -31
  21. data/lib/appwrite/enums/status_code.rb +10 -0
  22. data/lib/appwrite/models/attribute_bigint.rb +96 -0
  23. data/lib/appwrite/models/block.rb +28 -3
  24. data/lib/appwrite/models/column_bigint.rb +96 -0
  25. data/lib/appwrite/models/database.rb +2 -2
  26. data/lib/appwrite/models/email_template.rb +62 -0
  27. data/lib/appwrite/models/email_template_list.rb +32 -0
  28. data/lib/appwrite/models/ephemeral_key.rb +67 -0
  29. data/lib/appwrite/models/insight.rb +107 -0
  30. data/lib/appwrite/models/insight_cta.rb +42 -0
  31. data/lib/appwrite/models/insight_list.rb +32 -0
  32. data/lib/appwrite/models/membership.rb +5 -0
  33. data/lib/appwrite/models/mock_number.rb +18 -8
  34. data/lib/appwrite/models/mock_number_list.rb +32 -0
  35. data/lib/appwrite/models/o_auth2_amazon.rb +42 -0
  36. data/lib/appwrite/models/o_auth2_apple.rb +52 -0
  37. data/lib/appwrite/models/o_auth2_auth0.rb +47 -0
  38. data/lib/appwrite/models/o_auth2_authentik.rb +47 -0
  39. data/lib/appwrite/models/o_auth2_autodesk.rb +42 -0
  40. data/lib/appwrite/models/o_auth2_bitbucket.rb +42 -0
  41. data/lib/appwrite/models/o_auth2_bitly.rb +42 -0
  42. data/lib/appwrite/models/o_auth2_box.rb +42 -0
  43. data/lib/appwrite/models/o_auth2_dailymotion.rb +42 -0
  44. data/lib/appwrite/models/o_auth2_discord.rb +42 -0
  45. data/lib/appwrite/models/o_auth2_disqus.rb +42 -0
  46. data/lib/appwrite/models/o_auth2_dropbox.rb +42 -0
  47. data/lib/appwrite/models/o_auth2_etsy.rb +42 -0
  48. data/lib/appwrite/models/o_auth2_facebook.rb +42 -0
  49. data/lib/appwrite/models/o_auth2_figma.rb +42 -0
  50. data/lib/appwrite/models/o_auth2_fusion_auth.rb +47 -0
  51. data/lib/appwrite/models/o_auth2_github.rb +42 -0
  52. data/lib/appwrite/models/o_auth2_gitlab.rb +47 -0
  53. data/lib/appwrite/models/o_auth2_google.rb +47 -0
  54. data/lib/appwrite/models/o_auth2_keycloak.rb +52 -0
  55. data/lib/appwrite/models/o_auth2_kick.rb +42 -0
  56. data/lib/appwrite/models/o_auth2_linkedin.rb +42 -0
  57. data/lib/appwrite/models/o_auth2_microsoft.rb +47 -0
  58. data/lib/appwrite/models/o_auth2_notion.rb +42 -0
  59. data/lib/appwrite/models/o_auth2_oidc.rb +62 -0
  60. data/lib/appwrite/models/o_auth2_okta.rb +52 -0
  61. data/lib/appwrite/models/o_auth2_paypal.rb +42 -0
  62. data/lib/appwrite/models/o_auth2_podio.rb +42 -0
  63. data/lib/appwrite/models/o_auth2_provider_list.rb +32 -0
  64. data/lib/appwrite/models/o_auth2_salesforce.rb +42 -0
  65. data/lib/appwrite/models/o_auth2_slack.rb +42 -0
  66. data/lib/appwrite/models/o_auth2_spotify.rb +42 -0
  67. data/lib/appwrite/models/o_auth2_stripe.rb +42 -0
  68. data/lib/appwrite/models/o_auth2_tradeshift.rb +42 -0
  69. data/lib/appwrite/models/o_auth2_twitch.rb +42 -0
  70. data/lib/appwrite/models/o_auth2_word_press.rb +42 -0
  71. data/lib/appwrite/models/o_auth2_x.rb +42 -0
  72. data/lib/appwrite/models/o_auth2_yahoo.rb +42 -0
  73. data/lib/appwrite/models/o_auth2_yandex.rb +42 -0
  74. data/lib/appwrite/models/o_auth2_zoho.rb +42 -0
  75. data/lib/appwrite/models/o_auth2_zoom.rb +42 -0
  76. data/lib/appwrite/models/policy_list.rb +32 -0
  77. data/lib/appwrite/models/policy_membership_privacy.rb +52 -0
  78. data/lib/appwrite/models/policy_password_dictionary.rb +32 -0
  79. data/lib/appwrite/models/policy_password_history.rb +32 -0
  80. data/lib/appwrite/models/policy_password_personal_data.rb +32 -0
  81. data/lib/appwrite/models/policy_session_alert.rb +32 -0
  82. data/lib/appwrite/models/policy_session_duration.rb +32 -0
  83. data/lib/appwrite/models/policy_session_invalidation.rb +32 -0
  84. data/lib/appwrite/models/policy_session_limit.rb +32 -0
  85. data/lib/appwrite/models/policy_user_limit.rb +32 -0
  86. data/lib/appwrite/models/presence.rb +71 -0
  87. data/lib/appwrite/models/presence_list.rb +36 -0
  88. data/lib/appwrite/models/project.rb +25 -280
  89. data/lib/appwrite/models/project_auth_method.rb +53 -0
  90. data/lib/appwrite/models/project_protocol.rb +49 -0
  91. data/lib/appwrite/models/project_service.rb +64 -0
  92. data/lib/appwrite/models/proxy_rule.rb +127 -0
  93. data/lib/appwrite/models/proxy_rule_list.rb +32 -0
  94. data/lib/appwrite/models/report.rb +82 -0
  95. data/lib/appwrite/models/report_list.rb +32 -0
  96. data/lib/appwrite/models/usage_event.rb +72 -0
  97. data/lib/appwrite/models/usage_event_list.rb +32 -0
  98. data/lib/appwrite/models/usage_gauge.rb +37 -0
  99. data/lib/appwrite/models/usage_gauge_list.rb +32 -0
  100. data/lib/appwrite/services/account.rb +1 -1
  101. data/lib/appwrite/services/advisor.rb +173 -0
  102. data/lib/appwrite/services/databases.rb +126 -0
  103. data/lib/appwrite/services/functions.rb +13 -7
  104. data/lib/appwrite/services/presences.rb +199 -0
  105. data/lib/appwrite/services/project.rb +2817 -292
  106. data/lib/appwrite/services/proxy.rb +303 -0
  107. data/lib/appwrite/services/sites.rb +13 -7
  108. data/lib/appwrite/services/tables_db.rb +120 -0
  109. data/lib/appwrite/services/usage.rb +86 -0
  110. data/lib/appwrite.rb +92 -3
  111. metadata +94 -5
  112. data/lib/appwrite/models/auth_provider.rb +0 -47
@@ -0,0 +1,303 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ class Proxy < Service
5
+
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ # Get a list of all the proxy rules. You can use the query params to filter
11
+ # your results.
12
+ #
13
+ # @param [Array] 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 the following attributes: domain, type, trigger, deploymentResourceType, deploymentResourceId, deploymentId, deploymentVcsProviderBranch
14
+ # @param [] total When set to false, the total count returned will be 0 and will not be calculated.
15
+ #
16
+ # @return [ProxyRuleList]
17
+ def list_rules(queries: nil, total: nil)
18
+ api_path = '/proxy/rules'
19
+
20
+ api_params = {
21
+ queries: queries,
22
+ total: total,
23
+ }
24
+
25
+ api_headers = {
26
+ }
27
+
28
+ @client.call(
29
+ method: 'GET',
30
+ path: api_path,
31
+ headers: api_headers,
32
+ params: api_params,
33
+ response_type: Models::ProxyRuleList
34
+ )
35
+
36
+ end
37
+
38
+ # Create a new proxy rule for serving Appwrite's API on custom domain.
39
+ #
40
+ # Rule ID is automatically generated as MD5 hash of a rule domain for
41
+ # performance purposes.
42
+ #
43
+ # @param [String] domain Domain name.
44
+ #
45
+ # @return [ProxyRule]
46
+ def create_api_rule(domain:)
47
+ api_path = '/proxy/rules/api'
48
+
49
+ if domain.nil?
50
+ raise Appwrite::Exception.new('Missing required parameter: "domain"')
51
+ end
52
+
53
+ api_params = {
54
+ domain: domain,
55
+ }
56
+
57
+ api_headers = {
58
+ "content-type": 'application/json',
59
+ }
60
+
61
+ @client.call(
62
+ method: 'POST',
63
+ path: api_path,
64
+ headers: api_headers,
65
+ params: api_params,
66
+ response_type: Models::ProxyRule
67
+ )
68
+
69
+ end
70
+
71
+ # Create a new proxy rule for executing Appwrite Function on custom domain.
72
+ #
73
+ # Rule ID is automatically generated as MD5 hash of a rule domain for
74
+ # performance purposes.
75
+ #
76
+ # @param [String] domain Domain name.
77
+ # @param [String] function_id ID of function to be executed.
78
+ # @param [String] branch Name of VCS branch to deploy changes automatically
79
+ #
80
+ # @return [ProxyRule]
81
+ def create_function_rule(domain:, function_id:, branch: nil)
82
+ api_path = '/proxy/rules/function'
83
+
84
+ if domain.nil?
85
+ raise Appwrite::Exception.new('Missing required parameter: "domain"')
86
+ end
87
+
88
+ if function_id.nil?
89
+ raise Appwrite::Exception.new('Missing required parameter: "functionId"')
90
+ end
91
+
92
+ api_params = {
93
+ domain: domain,
94
+ functionId: function_id,
95
+ branch: branch,
96
+ }
97
+
98
+ api_headers = {
99
+ "content-type": 'application/json',
100
+ }
101
+
102
+ @client.call(
103
+ method: 'POST',
104
+ path: api_path,
105
+ headers: api_headers,
106
+ params: api_params,
107
+ response_type: Models::ProxyRule
108
+ )
109
+
110
+ end
111
+
112
+ # Create a new proxy rule for to redirect from custom domain to another
113
+ # domain.
114
+ #
115
+ # Rule ID is automatically generated as MD5 hash of a rule domain for
116
+ # performance purposes.
117
+ #
118
+ # @param [String] domain Domain name.
119
+ # @param [String] url Target URL of redirection
120
+ # @param [StatusCode] status_code Status code of redirection
121
+ # @param [String] resource_id ID of parent resource.
122
+ # @param [ProxyResourceType] resource_type Type of parent resource.
123
+ #
124
+ # @return [ProxyRule]
125
+ def create_redirect_rule(domain:, url:, status_code:, resource_id:, resource_type:)
126
+ api_path = '/proxy/rules/redirect'
127
+
128
+ if domain.nil?
129
+ raise Appwrite::Exception.new('Missing required parameter: "domain"')
130
+ end
131
+
132
+ if url.nil?
133
+ raise Appwrite::Exception.new('Missing required parameter: "url"')
134
+ end
135
+
136
+ if status_code.nil?
137
+ raise Appwrite::Exception.new('Missing required parameter: "statusCode"')
138
+ end
139
+
140
+ if resource_id.nil?
141
+ raise Appwrite::Exception.new('Missing required parameter: "resourceId"')
142
+ end
143
+
144
+ if resource_type.nil?
145
+ raise Appwrite::Exception.new('Missing required parameter: "resourceType"')
146
+ end
147
+
148
+ api_params = {
149
+ domain: domain,
150
+ url: url,
151
+ statusCode: status_code,
152
+ resourceId: resource_id,
153
+ resourceType: resource_type,
154
+ }
155
+
156
+ api_headers = {
157
+ "content-type": 'application/json',
158
+ }
159
+
160
+ @client.call(
161
+ method: 'POST',
162
+ path: api_path,
163
+ headers: api_headers,
164
+ params: api_params,
165
+ response_type: Models::ProxyRule
166
+ )
167
+
168
+ end
169
+
170
+ # Create a new proxy rule for serving Appwrite Site on custom domain.
171
+ #
172
+ # Rule ID is automatically generated as MD5 hash of a rule domain for
173
+ # performance purposes.
174
+ #
175
+ # @param [String] domain Domain name.
176
+ # @param [String] site_id ID of site to be executed.
177
+ # @param [String] branch Name of VCS branch to deploy changes automatically
178
+ #
179
+ # @return [ProxyRule]
180
+ def create_site_rule(domain:, site_id:, branch: nil)
181
+ api_path = '/proxy/rules/site'
182
+
183
+ if domain.nil?
184
+ raise Appwrite::Exception.new('Missing required parameter: "domain"')
185
+ end
186
+
187
+ if site_id.nil?
188
+ raise Appwrite::Exception.new('Missing required parameter: "siteId"')
189
+ end
190
+
191
+ api_params = {
192
+ domain: domain,
193
+ siteId: site_id,
194
+ branch: branch,
195
+ }
196
+
197
+ api_headers = {
198
+ "content-type": 'application/json',
199
+ }
200
+
201
+ @client.call(
202
+ method: 'POST',
203
+ path: api_path,
204
+ headers: api_headers,
205
+ params: api_params,
206
+ response_type: Models::ProxyRule
207
+ )
208
+
209
+ end
210
+
211
+ # Get a proxy rule by its unique ID.
212
+ #
213
+ # @param [String] rule_id Rule ID.
214
+ #
215
+ # @return [ProxyRule]
216
+ def get_rule(rule_id:)
217
+ api_path = '/proxy/rules/{ruleId}'
218
+ .gsub('{ruleId}', rule_id)
219
+
220
+ if rule_id.nil?
221
+ raise Appwrite::Exception.new('Missing required parameter: "ruleId"')
222
+ end
223
+
224
+ api_params = {
225
+ }
226
+
227
+ api_headers = {
228
+ }
229
+
230
+ @client.call(
231
+ method: 'GET',
232
+ path: api_path,
233
+ headers: api_headers,
234
+ params: api_params,
235
+ response_type: Models::ProxyRule
236
+ )
237
+
238
+ end
239
+
240
+ # Delete a proxy rule by its unique ID.
241
+ #
242
+ # @param [String] rule_id Rule ID.
243
+ #
244
+ # @return []
245
+ def delete_rule(rule_id:)
246
+ api_path = '/proxy/rules/{ruleId}'
247
+ .gsub('{ruleId}', rule_id)
248
+
249
+ if rule_id.nil?
250
+ raise Appwrite::Exception.new('Missing required parameter: "ruleId"')
251
+ end
252
+
253
+ api_params = {
254
+ }
255
+
256
+ api_headers = {
257
+ "content-type": 'application/json',
258
+ }
259
+
260
+ @client.call(
261
+ method: 'DELETE',
262
+ path: api_path,
263
+ headers: api_headers,
264
+ params: api_params,
265
+ )
266
+
267
+ end
268
+
269
+ # If not succeeded yet, retry verification process of a proxy rule domain.
270
+ # This endpoint triggers domain verification by checking DNS records. If
271
+ # verification is successful, a TLS certificate will be automatically
272
+ # provisioned for the domain asynchronously in the background.
273
+ #
274
+ # @param [String] rule_id Rule ID.
275
+ #
276
+ # @return [ProxyRule]
277
+ def update_rule_status(rule_id:)
278
+ api_path = '/proxy/rules/{ruleId}/status'
279
+ .gsub('{ruleId}', rule_id)
280
+
281
+ if rule_id.nil?
282
+ raise Appwrite::Exception.new('Missing required parameter: "ruleId"')
283
+ end
284
+
285
+ api_params = {
286
+ }
287
+
288
+ api_headers = {
289
+ "content-type": 'application/json',
290
+ }
291
+
292
+ @client.call(
293
+ method: 'PATCH',
294
+ path: api_path,
295
+ headers: api_headers,
296
+ params: api_params,
297
+ response_type: Models::ProxyRule
298
+ )
299
+
300
+ end
301
+
302
+ end
303
+ end
@@ -833,9 +833,11 @@ module Appwrite
833
833
  # Get a list of all variables of a specific site.
834
834
  #
835
835
  # @param [String] site_id Site unique ID.
836
+ # @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
837
+ # @param [] total When set to false, the total count returned will be 0 and will not be calculated.
836
838
  #
837
839
  # @return [VariableList]
838
- def list_variables(site_id:)
840
+ def list_variables(site_id:, queries: nil, total: nil)
839
841
  api_path = '/sites/{siteId}/variables'
840
842
  .gsub('{siteId}', site_id)
841
843
 
@@ -844,6 +846,8 @@ module Appwrite
844
846
  end
845
847
 
846
848
  api_params = {
849
+ queries: queries,
850
+ total: total,
847
851
  }
848
852
 
849
853
  api_headers = {
@@ -863,12 +867,13 @@ module Appwrite
863
867
  # and runtime (server-side rendering) as environment variables.
864
868
  #
865
869
  # @param [String] site_id Site unique ID.
870
+ # @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.
866
871
  # @param [String] key Variable key. Max length: 255 chars.
867
872
  # @param [String] value Variable value. Max length: 8192 chars.
868
873
  # @param [] secret Secret variables can be updated or deleted, but only sites can read them during build and runtime.
869
874
  #
870
875
  # @return [Variable]
871
- def create_variable(site_id:, key:, value:, secret: nil)
876
+ def create_variable(site_id:, variable_id:, key:, value:, secret: nil)
872
877
  api_path = '/sites/{siteId}/variables'
873
878
  .gsub('{siteId}', site_id)
874
879
 
@@ -876,6 +881,10 @@ module Appwrite
876
881
  raise Appwrite::Exception.new('Missing required parameter: "siteId"')
877
882
  end
878
883
 
884
+ if variable_id.nil?
885
+ raise Appwrite::Exception.new('Missing required parameter: "variableId"')
886
+ end
887
+
879
888
  if key.nil?
880
889
  raise Appwrite::Exception.new('Missing required parameter: "key"')
881
890
  end
@@ -885,6 +894,7 @@ module Appwrite
885
894
  end
886
895
 
887
896
  api_params = {
897
+ variableId: variable_id,
888
898
  key: key,
889
899
  value: value,
890
900
  secret: secret,
@@ -948,7 +958,7 @@ module Appwrite
948
958
  # @param [] secret Secret variables can be updated or deleted, but only sites can read them during build and runtime.
949
959
  #
950
960
  # @return [Variable]
951
- def update_variable(site_id:, variable_id:, key:, value: nil, secret: nil)
961
+ def update_variable(site_id:, variable_id:, key: nil, value: nil, secret: nil)
952
962
  api_path = '/sites/{siteId}/variables/{variableId}'
953
963
  .gsub('{siteId}', site_id)
954
964
  .gsub('{variableId}', variable_id)
@@ -961,10 +971,6 @@ module Appwrite
961
971
  raise Appwrite::Exception.new('Missing required parameter: "variableId"')
962
972
  end
963
973
 
964
- if key.nil?
965
- raise Appwrite::Exception.new('Missing required parameter: "key"')
966
- end
967
-
968
974
  api_params = {
969
975
  key: key,
970
976
  value: value,
@@ -593,6 +593,126 @@ module Appwrite
593
593
 
594
594
  end
595
595
 
596
+ # Create a bigint column. Optionally, minimum and maximum values can be
597
+ # provided.
598
+ #
599
+ #
600
+ # @param [String] database_id Database ID.
601
+ # @param [String] table_id Table ID.
602
+ # @param [String] key Column Key.
603
+ # @param [] required Is column required?
604
+ # @param [Integer] min Minimum value
605
+ # @param [Integer] max Maximum value
606
+ # @param [Integer] default Default value. Cannot be set when column is required.
607
+ # @param [] array Is column an array?
608
+ #
609
+ # @return [ColumnBigint]
610
+ def create_big_int_column(database_id:, table_id:, key:, required:, min: nil, max: nil, default: nil, array: nil)
611
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint'
612
+ .gsub('{databaseId}', database_id)
613
+ .gsub('{tableId}', table_id)
614
+
615
+ if database_id.nil?
616
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
617
+ end
618
+
619
+ if table_id.nil?
620
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
621
+ end
622
+
623
+ if key.nil?
624
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
625
+ end
626
+
627
+ if required.nil?
628
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
629
+ end
630
+
631
+ api_params = {
632
+ key: key,
633
+ required: required,
634
+ min: min,
635
+ max: max,
636
+ default: default,
637
+ array: array,
638
+ }
639
+
640
+ api_headers = {
641
+ "content-type": 'application/json',
642
+ }
643
+
644
+ @client.call(
645
+ method: 'POST',
646
+ path: api_path,
647
+ headers: api_headers,
648
+ params: api_params,
649
+ response_type: Models::ColumnBigint
650
+ )
651
+
652
+ end
653
+
654
+ # Update a bigint column. Changing the `default` value will not update
655
+ # already existing rows.
656
+ #
657
+ #
658
+ # @param [String] database_id Database ID.
659
+ # @param [String] table_id Table ID.
660
+ # @param [String] key Column Key.
661
+ # @param [] required Is column required?
662
+ # @param [Integer] default Default value. Cannot be set when column is required.
663
+ # @param [Integer] min Minimum value
664
+ # @param [Integer] max Maximum value
665
+ # @param [String] new_key New Column Key.
666
+ #
667
+ # @return [ColumnBigint]
668
+ def update_big_int_column(database_id:, table_id:, key:, required:, default:, min: nil, max: nil, new_key: nil)
669
+ api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/bigint/{key}'
670
+ .gsub('{databaseId}', database_id)
671
+ .gsub('{tableId}', table_id)
672
+ .gsub('{key}', key)
673
+
674
+ if database_id.nil?
675
+ raise Appwrite::Exception.new('Missing required parameter: "databaseId"')
676
+ end
677
+
678
+ if table_id.nil?
679
+ raise Appwrite::Exception.new('Missing required parameter: "tableId"')
680
+ end
681
+
682
+ if key.nil?
683
+ raise Appwrite::Exception.new('Missing required parameter: "key"')
684
+ end
685
+
686
+ if required.nil?
687
+ raise Appwrite::Exception.new('Missing required parameter: "required"')
688
+ end
689
+
690
+ if default.nil?
691
+ raise Appwrite::Exception.new('Missing required parameter: "default"')
692
+ end
693
+
694
+ api_params = {
695
+ required: required,
696
+ min: min,
697
+ max: max,
698
+ default: default,
699
+ newKey: new_key,
700
+ }
701
+
702
+ api_headers = {
703
+ "content-type": 'application/json',
704
+ }
705
+
706
+ @client.call(
707
+ method: 'PATCH',
708
+ path: api_path,
709
+ headers: api_headers,
710
+ params: api_params,
711
+ response_type: Models::ColumnBigint
712
+ )
713
+
714
+ end
715
+
596
716
  # Create a boolean column.
597
717
  #
598
718
  #
@@ -0,0 +1,86 @@
1
+ #frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ class Usage < Service
5
+
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ # Query usage event metrics from the usage database. Returns individual event
11
+ # rows with full metadata. Pass Query objects as JSON strings to filter,
12
+ # paginate, and order results. Supported query methods: equal,
13
+ # greaterThanEqual, lessThanEqual, orderAsc, orderDesc, limit, offset.
14
+ # Supported filter attributes: metric, path, method, status, resource,
15
+ # resourceId, country, userAgent, time (these match the underlying column
16
+ # names — note that the response surfaces `resource` as `resourceType` and
17
+ # `country` as `countryCode`). When no time filter is supplied the endpoint
18
+ # defaults to the last 7 days. Default `limit(100)` is applied if none is
19
+ # given; user-supplied limits are capped at 500. The `total` field is capped
20
+ # at 5000 to keep counts predictable — pass `total=false` to skip the count
21
+ # entirely.
22
+ #
23
+ # @param [Array] queries Array of query strings as JSON. Supported: equal("metric", [...]), equal("path", [...]), equal("method", [...]), equal("status", [...]), equal("resource", [...]), equal("resourceId", [...]), equal("country", [...]), equal("userAgent", [...]), greaterThanEqual("time", "..."), lessThanEqual("time", "..."), orderAsc("time"), orderDesc("time"), limit(N), offset(N).
24
+ # @param [] total When set to false, the total count returned will be 0 and will not be calculated.
25
+ #
26
+ # @return [UsageEventList]
27
+ def list_events(queries: nil, total: nil)
28
+ api_path = '/usage/events'
29
+
30
+ api_params = {
31
+ queries: queries,
32
+ total: total,
33
+ }
34
+
35
+ api_headers = {
36
+ }
37
+
38
+ @client.call(
39
+ method: 'GET',
40
+ path: api_path,
41
+ headers: api_headers,
42
+ params: api_params,
43
+ response_type: Models::UsageEventList
44
+ )
45
+
46
+ end
47
+
48
+ # Query usage gauge metrics (point-in-time resource snapshots) from the usage
49
+ # database. Returns individual gauge snapshots with metric, value, and
50
+ # timestamp. Pass Query objects as JSON strings to filter, paginate, and
51
+ # order results. Supported query methods: equal, greaterThanEqual,
52
+ # lessThanEqual, orderAsc, orderDesc, limit, offset. Supported filter
53
+ # attributes: metric, time. Use `orderDesc("time"), limit(1)` to fetch the
54
+ # most recent snapshot. When no time filter is supplied the endpoint defaults
55
+ # to the last 7 days. Default `limit(100)` is applied if none is given;
56
+ # user-supplied limits are capped at 500. The `total` field is capped at 5000
57
+ # to keep counts predictable — pass `total=false` to skip the count
58
+ # entirely.
59
+ #
60
+ # @param [Array] queries Array of query strings as JSON. Supported: equal("metric", [...]), greaterThanEqual("time", "..."), lessThanEqual("time", "..."), orderAsc("time"), orderDesc("time"), limit(N), offset(N).
61
+ # @param [] total When set to false, the total count returned will be 0 and will not be calculated.
62
+ #
63
+ # @return [UsageGaugeList]
64
+ def list_gauges(queries: nil, total: nil)
65
+ api_path = '/usage/gauges'
66
+
67
+ api_params = {
68
+ queries: queries,
69
+ total: total,
70
+ }
71
+
72
+ api_headers = {
73
+ }
74
+
75
+ @client.call(
76
+ method: 'GET',
77
+ path: api_path,
78
+ headers: api_headers,
79
+ params: api_params,
80
+ response_type: Models::UsageGaugeList
81
+ )
82
+
83
+ end
84
+
85
+ end
86
+ end