appwrite 24.1.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 +109 -32
  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
@@ -30,6 +30,8 @@ module Appwrite
30
30
  attr_reader :provider_branch
31
31
  attr_reader :provider_root_directory
32
32
  attr_reader :provider_silent_mode
33
+ attr_reader :provider_branches
34
+ attr_reader :provider_paths
33
35
  attr_reader :build_specification
34
36
  attr_reader :runtime_specification
35
37
  attr_reader :build_runtime
@@ -64,6 +66,8 @@ module Appwrite
64
66
  provider_branch:,
65
67
  provider_root_directory:,
66
68
  provider_silent_mode:,
69
+ provider_branches:,
70
+ provider_paths:,
67
71
  build_specification:,
68
72
  runtime_specification:,
69
73
  build_runtime:,
@@ -97,6 +101,8 @@ module Appwrite
97
101
  @provider_branch = provider_branch
98
102
  @provider_root_directory = provider_root_directory
99
103
  @provider_silent_mode = provider_silent_mode
104
+ @provider_branches = provider_branches
105
+ @provider_paths = provider_paths
100
106
  @build_specification = build_specification
101
107
  @runtime_specification = runtime_specification
102
108
  @build_runtime = build_runtime
@@ -133,6 +139,8 @@ module Appwrite
133
139
  provider_branch: map["providerBranch"],
134
140
  provider_root_directory: map["providerRootDirectory"],
135
141
  provider_silent_mode: map["providerSilentMode"],
142
+ provider_branches: map["providerBranches"],
143
+ provider_paths: map["providerPaths"],
136
144
  build_specification: map["buildSpecification"],
137
145
  runtime_specification: map["runtimeSpecification"],
138
146
  build_runtime: map["buildRuntime"],
@@ -170,6 +178,8 @@ module Appwrite
170
178
  "providerBranch": @provider_branch,
171
179
  "providerRootDirectory": @provider_root_directory,
172
180
  "providerSilentMode": @provider_silent_mode,
181
+ "providerBranches": @provider_branches,
182
+ "providerPaths": @provider_paths,
173
183
  "buildSpecification": @build_specification,
174
184
  "runtimeSpecification": @runtime_specification,
175
185
  "buildRuntime": @build_runtime,
@@ -6,22 +6,30 @@ module Appwrite
6
6
  attr_reader :metric
7
7
  attr_reader :value
8
8
  attr_reader :time
9
+ attr_reader :resource_type
10
+ attr_reader :resource_id
9
11
 
10
12
  def initialize(
11
13
  metric:,
12
14
  value:,
13
- time:
15
+ time:,
16
+ resource_type:,
17
+ resource_id:
14
18
  )
15
19
  @metric = metric
16
20
  @value = value
17
21
  @time = time
22
+ @resource_type = resource_type
23
+ @resource_id = resource_id
18
24
  end
19
25
 
20
26
  def self.from(map:)
21
27
  UsageGauge.new(
22
28
  metric: map["metric"],
23
29
  value: map["value"],
24
- time: map["time"]
30
+ time: map["time"],
31
+ resource_type: map["resourceType"],
32
+ resource_id: map["resourceId"]
25
33
  )
26
34
  end
27
35
 
@@ -29,7 +37,9 @@ module Appwrite
29
37
  {
30
38
  "metric": @metric,
31
39
  "value": @value,
32
- "time": @time
40
+ "time": @time,
41
+ "resourceType": @resource_type,
42
+ "resourceId": @resource_id
33
43
  }
34
44
  end
35
45
  end
@@ -305,7 +305,7 @@ module Appwrite
305
305
  # @param [Integer] viewport_width Browser viewport width. Pass an integer between 1 to 1920. Defaults to 1280.
306
306
  # @param [Integer] viewport_height Browser viewport height. Pass an integer between 1 to 1080. Defaults to 720.
307
307
  # @param [Float] scale Browser scale factor. Pass a number between 0.1 to 3. Defaults to 1.
308
- # @param [Theme] theme Browser theme. Pass "light" or "dark". Defaults to "light".
308
+ # @param [BrowserTheme] theme Browser theme. Pass "light" or "dark". Defaults to "light".
309
309
  # @param [String] user_agent Custom user agent string. Defaults to browser default.
310
310
  # @param [] fullpage Capture full page scroll. Pass 0 for viewport only, or 1 for full page. Defaults to 0.
311
311
  # @param [String] locale Browser locale (e.g., "en-US", "fr-FR"). Defaults to browser default.
@@ -59,12 +59,14 @@ module Appwrite
59
59
  # @param [String] provider_branch Production branch for the repo linked to the function.
60
60
  # @param [] provider_silent_mode Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests.
61
61
  # @param [String] provider_root_directory Path to function code in the linked repo.
62
+ # @param [Array] provider_branches List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches.
63
+ # @param [Array] provider_paths List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes.
62
64
  # @param [String] build_specification Build specification for the function deployments.
63
65
  # @param [String] runtime_specification Runtime specification for the function executions.
64
66
  # @param [Integer] deployment_retention Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept.
65
67
  #
66
68
  # @return [Function]
67
- def create(function_id:, name:, runtime:, execute: nil, events: nil, schedule: nil, timeout: nil, enabled: nil, logging: nil, entrypoint: nil, commands: nil, scopes: nil, installation_id: nil, provider_repository_id: nil, provider_branch: nil, provider_silent_mode: nil, provider_root_directory: nil, build_specification: nil, runtime_specification: nil, deployment_retention: nil)
69
+ def create(function_id:, name:, runtime:, execute: nil, events: nil, schedule: nil, timeout: nil, enabled: nil, logging: nil, entrypoint: nil, commands: nil, scopes: nil, installation_id: nil, provider_repository_id: nil, provider_branch: nil, provider_silent_mode: nil, provider_root_directory: nil, provider_branches: nil, provider_paths: nil, build_specification: nil, runtime_specification: nil, deployment_retention: nil)
68
70
  api_path = '/functions'
69
71
 
70
72
  if function_id.nil?
@@ -97,6 +99,8 @@ module Appwrite
97
99
  providerBranch: provider_branch,
98
100
  providerSilentMode: provider_silent_mode,
99
101
  providerRootDirectory: provider_root_directory,
102
+ providerBranches: provider_branches,
103
+ providerPaths: provider_paths,
100
104
  buildSpecification: build_specification,
101
105
  runtimeSpecification: runtime_specification,
102
106
  deploymentRetention: deployment_retention,
@@ -210,12 +214,14 @@ module Appwrite
210
214
  # @param [String] provider_branch Production branch for the repo linked to the function
211
215
  # @param [] provider_silent_mode Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests.
212
216
  # @param [String] provider_root_directory Path to function code in the linked repo.
217
+ # @param [Array] provider_branches List of branch name patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all branches.
218
+ # @param [Array] provider_paths List of file path patterns to trigger automatic deployments. Supports wildcards. Leave empty to deploy on all file changes.
213
219
  # @param [String] build_specification Build specification for the function deployments.
214
220
  # @param [String] runtime_specification Runtime specification for the function executions.
215
221
  # @param [Integer] deployment_retention Days to keep non-active deployments before deletion. Value 0 means all deployments will be kept.
216
222
  #
217
223
  # @return [Function]
218
- def update(function_id:, name:, runtime: nil, execute: nil, events: nil, schedule: nil, timeout: nil, enabled: nil, logging: nil, entrypoint: nil, commands: nil, scopes: nil, installation_id: nil, provider_repository_id: nil, provider_branch: nil, provider_silent_mode: nil, provider_root_directory: nil, build_specification: nil, runtime_specification: nil, deployment_retention: nil)
224
+ def update(function_id:, name:, runtime: nil, execute: nil, events: nil, schedule: nil, timeout: nil, enabled: nil, logging: nil, entrypoint: nil, commands: nil, scopes: nil, installation_id: nil, provider_repository_id: nil, provider_branch: nil, provider_silent_mode: nil, provider_root_directory: nil, provider_branches: nil, provider_paths: nil, build_specification: nil, runtime_specification: nil, deployment_retention: nil)
219
225
  api_path = '/functions/{functionId}'
220
226
  .gsub('{functionId}', function_id)
221
227
 
@@ -244,6 +250,8 @@ module Appwrite
244
250
  providerBranch: provider_branch,
245
251
  providerSilentMode: provider_silent_mode,
246
252
  providerRootDirectory: provider_root_directory,
253
+ providerBranches: provider_branches,
254
+ providerPaths: provider_paths,
247
255
  buildSpecification: build_specification,
248
256
  runtimeSpecification: runtime_specification,
249
257
  deploymentRetention: deployment_retention,
@@ -314,7 +314,7 @@ module Appwrite
314
314
  # Returns the amount of failed jobs in a given queue.
315
315
  #
316
316
  #
317
- # @param [Name] name The name of the queue
317
+ # @param [HealthQueueName] name The name of the queue
318
318
  # @param [Integer] threshold Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000.
319
319
  #
320
320
  # @return [HealthQueue]
@@ -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