diff --git a/CHANGELOG.md b/CHANGELOG.md index bdf22ea1..78e27c2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Change Log +## 27.0.0 + +* Breaking: removed `account.createJWT`; use `users.createJWT` instead. A leaked JWT could mint further JWTs, letting a credential outlive its own expiry — a session cannot duplicate itself to live forever either +* Breaking: removed `project.createKey`. A leaked key could mint further hidden keys, making a compromise far harder to contain and revoke +* Breaking: `activities.listEvents` `queries` now takes an array instead of a string +* Added: `embeddings` service with `createTextEmbeddings`, plus the `EmbeddingModel` enum +* Added: TablesDB migration methods `listMigrations`, `createMigration`, `getMigration`, `deleteMigration`, `cutoverMigration`, and `listOperations` +* Added: `proxy.createInvalidation` for purging cached edge responses, plus the `InvalidationType` enum +* Added: `apps.deleteInstallation` +* Added: `users.getMFAChallenge` and the `MfaChallengeSecret` model +* Added: `project.updateMFAFactorsPolicy` and the `PolicyMfaFactors` model +* Added: `client.setOrganization` for organization-scoped requests +* Added: `folder` parameter to `storage.createFile` +* Added: `syncMode` parameter to `tablesDB.create` and `tablesDB.update`, and `specification` to `tablesDB.update` +* Added: `installationScopes` parameter to `project.updateOAuth2Server` +* Added: `custom` authentication factor, `node-26` runtime, `mfa-factors` project policy, and the `embeddings.write` and `proxy.invalidations.write` key scopes +* Updated: response format to `1.9.6` + ## 26.1.0 * Added: `Apps` service for managing OAuth2 applications, keys, and installations diff --git a/README.md b/README.md index 9b885056..5f92ccbc 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Appwrite Ruby SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-ruby.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.9.5-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.9.6-blue.svg?style=flat-square) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) diff --git a/appwrite.gemspec b/appwrite.gemspec index bc428bcb..477ba729 100644 --- a/appwrite.gemspec +++ b/appwrite.gemspec @@ -1,7 +1,7 @@ Gem::Specification.new do |spec| spec.name = 'appwrite' - spec.version = '26.1.0' + spec.version = '27.0.0' spec.license = 'BSD-3-Clause' spec.summary = 'Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API' spec.author = 'Appwrite Team' diff --git a/docs/examples/activities/list-events.md b/docs/examples/activities/list-events.md index 1d7fddd6..dd1ea354 100644 --- a/docs/examples/activities/list-events.md +++ b/docs/examples/activities/list-events.md @@ -11,6 +11,6 @@ client = Client.new activities = Activities.new(client) result = activities.list_events( - queries: '' # optional + queries: [] # optional ) ``` diff --git a/docs/examples/apps/create-installation-token.md b/docs/examples/apps/create-installation-token.md index 7c71cecc..4a4ea253 100644 --- a/docs/examples/apps/create-installation-token.md +++ b/docs/examples/apps/create-installation-token.md @@ -6,7 +6,7 @@ include Appwrite client = Client.new .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint .set_project('') # Your project ID - .set_key('') # Your secret API key + .set_session('') # The user session to authenticate with apps = Apps.new(client) diff --git a/docs/examples/account/create-jwt.md b/docs/examples/apps/delete-installation.md similarity index 68% rename from docs/examples/account/create-jwt.md rename to docs/examples/apps/delete-installation.md index 2c722b01..d975728d 100644 --- a/docs/examples/account/create-jwt.md +++ b/docs/examples/apps/delete-installation.md @@ -8,9 +8,10 @@ client = Client.new .set_project('') # Your project ID .set_session('') # The user session to authenticate with -account = Account.new(client) +apps = Apps.new(client) -result = account.create_jwt( - duration: 0 # optional +result = apps.delete_installation( + app_id: '', + installation_id: '' ) ``` diff --git a/docs/examples/apps/get-installation.md b/docs/examples/apps/get-installation.md index 5db2961b..08a949cf 100644 --- a/docs/examples/apps/get-installation.md +++ b/docs/examples/apps/get-installation.md @@ -6,7 +6,7 @@ include Appwrite client = Client.new .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint .set_project('') # Your project ID - .set_key('') # Your secret API key + .set_session('') # The user session to authenticate with apps = Apps.new(client) diff --git a/docs/examples/apps/list-installations.md b/docs/examples/apps/list-installations.md index da01dc8e..81becbcf 100644 --- a/docs/examples/apps/list-installations.md +++ b/docs/examples/apps/list-installations.md @@ -6,7 +6,7 @@ include Appwrite client = Client.new .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint .set_project('') # Your project ID - .set_key('') # Your secret API key + .set_session('') # The user session to authenticate with apps = Apps.new(client) diff --git a/docs/examples/embeddings/create-text-embeddings.md b/docs/examples/embeddings/create-text-embeddings.md new file mode 100644 index 00000000..facbe573 --- /dev/null +++ b/docs/examples/embeddings/create-text-embeddings.md @@ -0,0 +1,18 @@ +```ruby +require 'appwrite' + +include Appwrite +include Appwrite::Enums + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +embeddings = Embeddings.new(client) + +result = embeddings.create_text_embeddings( + texts: [], + model: EmbeddingModel::NOMIC_EMBED_TEXT # optional +) +``` diff --git a/docs/examples/project/create-key.md b/docs/examples/project/update-mfa-factors-policy.md similarity index 59% rename from docs/examples/project/create-key.md rename to docs/examples/project/update-mfa-factors-policy.md index 0721a6b2..1849b161 100644 --- a/docs/examples/project/create-key.md +++ b/docs/examples/project/update-mfa-factors-policy.md @@ -2,7 +2,6 @@ require 'appwrite' include Appwrite -include Appwrite::Enums client = Client.new .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -11,10 +10,10 @@ client = Client.new project = Project.new(client) -result = project.create_key( - key_id: '', - name: '', - scopes: [ProjectKeyScopes::PROJECT_READ], - expire: '2020-10-15T06:38:00.000+00:00' # optional +result = project.update_mfa_factors_policy( + totp: false, # optional + email: false, # optional + phone: false, # optional + custom: false # optional ) ``` diff --git a/docs/examples/project/update-o-auth-2-server.md b/docs/examples/project/update-o-auth-2-server.md index 92a56d27..cfa1a0ab 100644 --- a/docs/examples/project/update-o-auth-2-server.md +++ b/docs/examples/project/update-o-auth-2-server.md @@ -25,6 +25,7 @@ result = project.update_o_auth2_server( user_code_length: 6, # optional user_code_format: 'numeric', # optional device_code_duration: 60, # optional - default_scopes: [] # optional + default_scopes: [], # optional + installation_scopes: [] # optional ) ``` diff --git a/docs/examples/project/update-session-duration-policy.md b/docs/examples/project/update-session-duration-policy.md index 5a27a77c..ba8f1cb3 100644 --- a/docs/examples/project/update-session-duration-policy.md +++ b/docs/examples/project/update-session-duration-policy.md @@ -11,6 +11,6 @@ client = Client.new project = Project.new(client) result = project.update_session_duration_policy( - duration: 5 + duration: 60 ) ``` diff --git a/docs/examples/project/update-user-limit-policy.md b/docs/examples/project/update-user-limit-policy.md index 1116435e..145906a3 100644 --- a/docs/examples/project/update-user-limit-policy.md +++ b/docs/examples/project/update-user-limit-policy.md @@ -11,6 +11,6 @@ client = Client.new project = Project.new(client) result = project.update_user_limit_policy( - total: 1 + total: 0 ) ``` diff --git a/docs/examples/proxy/create-invalidation.md b/docs/examples/proxy/create-invalidation.md new file mode 100644 index 00000000..3b2858f4 --- /dev/null +++ b/docs/examples/proxy/create-invalidation.md @@ -0,0 +1,19 @@ +```ruby +require 'appwrite' + +include Appwrite +include Appwrite::Enums + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +proxy = Proxy.new(client) + +result = proxy.create_invalidation( + domain: '', + type: InvalidationType::TAG, + reference: '' # optional +) +``` diff --git a/docs/examples/storage/create-file.md b/docs/examples/storage/create-file.md index 0e03b082..cef34640 100644 --- a/docs/examples/storage/create-file.md +++ b/docs/examples/storage/create-file.md @@ -16,6 +16,7 @@ result = storage.create_file( bucket_id: '', file_id: '', file: InputFile.from_path('dir/file.png'), - permissions: [Permission.read(Role.any())] # optional + permissions: [Permission.read(Role.any())], # optional + folder: '' # optional ) ``` diff --git a/docs/examples/tablesdb/create-migration.md b/docs/examples/tablesdb/create-migration.md new file mode 100644 index 00000000..a7f085bd --- /dev/null +++ b/docs/examples/tablesdb/create-migration.md @@ -0,0 +1,18 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +tables_db = TablesDB.new(client) + +result = tables_db.create_migration( + database_id: '', + specification: 's-1vcpu-1gb', + auto_cutover: false # optional +) +``` diff --git a/docs/examples/tablesdb/create.md b/docs/examples/tablesdb/create.md index 433b5b72..e68bb0a3 100644 --- a/docs/examples/tablesdb/create.md +++ b/docs/examples/tablesdb/create.md @@ -15,6 +15,7 @@ result = tables_db.create( name: '', enabled: false, # optional specification: 'serverless', # optional - replicas: 0 # optional + replicas: 0, # optional + sync_mode: 'async' # optional ) ``` diff --git a/docs/examples/tablesdb/cutover-migration.md b/docs/examples/tablesdb/cutover-migration.md new file mode 100644 index 00000000..62879a07 --- /dev/null +++ b/docs/examples/tablesdb/cutover-migration.md @@ -0,0 +1,17 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +tables_db = TablesDB.new(client) + +result = tables_db.cutover_migration( + database_id: '', + migration_id: '' +) +``` diff --git a/docs/examples/tablesdb/delete-migration.md b/docs/examples/tablesdb/delete-migration.md new file mode 100644 index 00000000..d806b825 --- /dev/null +++ b/docs/examples/tablesdb/delete-migration.md @@ -0,0 +1,17 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +tables_db = TablesDB.new(client) + +result = tables_db.delete_migration( + database_id: '', + migration_id: '' +) +``` diff --git a/docs/examples/tablesdb/get-migration.md b/docs/examples/tablesdb/get-migration.md new file mode 100644 index 00000000..5c9763fb --- /dev/null +++ b/docs/examples/tablesdb/get-migration.md @@ -0,0 +1,17 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +tables_db = TablesDB.new(client) + +result = tables_db.get_migration( + database_id: '', + migration_id: '' +) +``` diff --git a/docs/examples/tablesdb/list-migrations.md b/docs/examples/tablesdb/list-migrations.md new file mode 100644 index 00000000..3d92f789 --- /dev/null +++ b/docs/examples/tablesdb/list-migrations.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +tables_db = TablesDB.new(client) + +result = tables_db.list_migrations( + database_id: '' +) +``` diff --git a/docs/examples/tablesdb/list-operations.md b/docs/examples/tablesdb/list-operations.md new file mode 100644 index 00000000..ac41c176 --- /dev/null +++ b/docs/examples/tablesdb/list-operations.md @@ -0,0 +1,19 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +tables_db = TablesDB.new(client) + +result = tables_db.list_operations( + database_id: '', + status: 'running', # optional + limit: 1, # optional + offset: 0 # optional +) +``` diff --git a/docs/examples/tablesdb/update.md b/docs/examples/tablesdb/update.md index 4257090a..d13b8caf 100644 --- a/docs/examples/tablesdb/update.md +++ b/docs/examples/tablesdb/update.md @@ -14,6 +14,8 @@ result = tables_db.update( database_id: '', name: '', # optional enabled: false, # optional - replicas: 0 # optional + specification: 'serverless', # optional + replicas: 0, # optional + sync_mode: 'async' # optional ) ``` diff --git a/docs/examples/users/get-mfa-challenge.md b/docs/examples/users/get-mfa-challenge.md new file mode 100644 index 00000000..dbdbad3b --- /dev/null +++ b/docs/examples/users/get-mfa-challenge.md @@ -0,0 +1,17 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +users = Users.new(client) + +result = users.get_mfa_challenge( + user_id: '', + challenge_id: '' +) +``` diff --git a/lib/appwrite.rb b/lib/appwrite.rb index 03d3826f..64a08f3b 100644 --- a/lib/appwrite.rb +++ b/lib/appwrite.rb @@ -57,9 +57,11 @@ require_relative 'appwrite/models/target_list' require_relative 'appwrite/models/transaction_list' require_relative 'appwrite/models/specification_list' +require_relative 'appwrite/models/embedding_list' require_relative 'appwrite/models/insight_list' require_relative 'appwrite/models/report_list' require_relative 'appwrite/models/database' +require_relative 'appwrite/models/embedding' require_relative 'appwrite/models/collection' require_relative 'appwrite/models/attribute_list' require_relative 'appwrite/models/attribute_string' @@ -194,6 +196,7 @@ require_relative 'appwrite/models/policy_session_limit' require_relative 'appwrite/models/policy_user_limit' require_relative 'appwrite/models/policy_membership_privacy' +require_relative 'appwrite/models/policy_mfa_factors' require_relative 'appwrite/models/platform_web' require_relative 'appwrite/models/platform_apple' require_relative 'appwrite/models/platform_android' @@ -211,6 +214,7 @@ require_relative 'appwrite/models/proxy_rule' require_relative 'appwrite/models/email_template' require_relative 'appwrite/models/mfa_challenge' +require_relative 'appwrite/models/mfa_challenge_secret' require_relative 'appwrite/models/mfa_recovery_codes' require_relative 'appwrite/models/mfa_type' require_relative 'appwrite/models/mfa_factors' @@ -234,10 +238,14 @@ require_relative 'appwrite/models/billing_plan_dedicated_database_limits' require_relative 'appwrite/models/billing_plan_supported_addons' require_relative 'appwrite/models/block' +require_relative 'appwrite/models/database_migration' require_relative 'appwrite/models/dedicated_database' require_relative 'appwrite/models/database_status' require_relative 'appwrite/models/dedicated_database_member' +require_relative 'appwrite/models/dedicated_database_operation' +require_relative 'appwrite/models/dedicated_database_operation_list' require_relative 'appwrite/models/dedicated_database_replicas' +require_relative 'appwrite/models/proxy_invalidation' require_relative 'appwrite/models/organization' require_relative 'appwrite/models/backup_policy' require_relative 'appwrite/models/policy_deny_aliased_email' @@ -278,6 +286,7 @@ require_relative 'appwrite/models/backup_archive_list' require_relative 'appwrite/models/backup_policy_list' require_relative 'appwrite/models/backup_restoration_list' +require_relative 'appwrite/models/database_migration_list' require_relative 'appwrite/models/apps_list' require_relative 'appwrite/models/app_secret_list' require_relative 'appwrite/models/app_scope_list' @@ -299,6 +308,7 @@ require_relative 'appwrite/enums/relation_mutate' require_relative 'appwrite/enums/databases_index_type' require_relative 'appwrite/enums/order_by' +require_relative 'appwrite/enums/embedding_model' require_relative 'appwrite/enums/runtime' require_relative 'appwrite/enums/project_key_scopes' require_relative 'appwrite/enums/template_reference_type' @@ -319,6 +329,7 @@ require_relative 'appwrite/enums/project_smtp_secure' require_relative 'appwrite/enums/project_email_template_id' require_relative 'appwrite/enums/project_email_template_locale' +require_relative 'appwrite/enums/invalidation_type' require_relative 'appwrite/enums/status_code' require_relative 'appwrite/enums/proxy_resource_type' require_relative 'appwrite/enums/framework' @@ -351,6 +362,7 @@ require_relative 'appwrite/services/avatars' require_relative 'appwrite/services/backups' require_relative 'appwrite/services/databases' +require_relative 'appwrite/services/embeddings' require_relative 'appwrite/services/functions' require_relative 'appwrite/services/graphql' require_relative 'appwrite/services/locale' diff --git a/lib/appwrite/client.rb b/lib/appwrite/client.rb index aeae118a..dfaae3a3 100644 --- a/lib/appwrite/client.rb +++ b/lib/appwrite/client.rb @@ -15,8 +15,8 @@ def initialize 'x-sdk-name'=> 'Ruby', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'ruby', - 'x-sdk-version'=> '26.1.0', - 'X-Appwrite-Response-Format' => '1.9.5' + 'x-sdk-version'=> '27.0.0', + 'X-Appwrite-Response-Format' => '1.9.6' } @endpoint = 'https://cloud.appwrite.io/v1' @config = {} @@ -49,6 +49,20 @@ def set_key(value) self end + # Set Organization + # + # Your organization ID + # + # @param [String] value The value to set for the Organization header + # + # @return [self] + def set_organization(value) + add_header('x-appwrite-organization', value) + @config['organization'] = value + + self + end + # Set JWT # # Your secret JSON Web Token diff --git a/lib/appwrite/enums/authentication_factor.rb b/lib/appwrite/enums/authentication_factor.rb index 8376b956..48669786 100644 --- a/lib/appwrite/enums/authentication_factor.rb +++ b/lib/appwrite/enums/authentication_factor.rb @@ -5,6 +5,7 @@ module AuthenticationFactor PHONE = 'phone' TOTP = 'totp' RECOVERYCODE = 'recoverycode' + CUSTOM = 'custom' end end end \ No newline at end of file diff --git a/lib/appwrite/enums/build_runtime.rb b/lib/appwrite/enums/build_runtime.rb index 89f54786..ae67f362 100644 --- a/lib/appwrite/enums/build_runtime.rb +++ b/lib/appwrite/enums/build_runtime.rb @@ -11,6 +11,7 @@ module BuildRuntime NODE_23 = 'node-23' NODE_24 = 'node-24' NODE_25 = 'node-25' + NODE_26 = 'node-26' PHP_8_0 = 'php-8.0' PHP_8_1 = 'php-8.1' PHP_8_2 = 'php-8.2' diff --git a/lib/appwrite/enums/embedding_model.rb b/lib/appwrite/enums/embedding_model.rb new file mode 100644 index 00000000..7fce0ea6 --- /dev/null +++ b/lib/appwrite/enums/embedding_model.rb @@ -0,0 +1,10 @@ +module Appwrite + module Enums + module EmbeddingModel + NOMIC_EMBED_TEXT = 'nomic-embed-text' + EMBEDDING_GEMMA = 'embedding-gemma' + ALL_MINILM = 'all-minilm' + BGE_SMALL = 'bge-small' + end + end +end \ No newline at end of file diff --git a/lib/appwrite/enums/invalidation_type.rb b/lib/appwrite/enums/invalidation_type.rb new file mode 100644 index 00000000..d8fca7c9 --- /dev/null +++ b/lib/appwrite/enums/invalidation_type.rb @@ -0,0 +1,9 @@ +module Appwrite + module Enums + module InvalidationType + TAG = 'tag' + PATH = 'path' + ALL = 'all' + end + end +end \ No newline at end of file diff --git a/lib/appwrite/enums/project_key_scopes.rb b/lib/appwrite/enums/project_key_scopes.rb index a7ed8076..7a7670c9 100644 --- a/lib/appwrite/enums/project_key_scopes.rb +++ b/lib/appwrite/enums/project_key_scopes.rb @@ -35,6 +35,7 @@ module ProjectKeyScopes INDEXES_WRITE = 'indexes.write' ROWS_READ = 'rows.read' ROWS_WRITE = 'rows.write' + EMBEDDINGS_WRITE = 'embeddings.write' COLLECTIONS_READ = 'collections.read' COLLECTIONS_WRITE = 'collections.write' ATTRIBUTES_READ = 'attributes.read' @@ -99,6 +100,7 @@ module ProjectKeyScopes WAFRULES_READ = 'wafRules.read' WAFRULES_WRITE = 'wafRules.write' EVENTS_READ = 'events.read' + PROXY_INVALIDATIONS_WRITE = 'proxy.invalidations.write' APPS_READ = 'apps.read' APPS_WRITE = 'apps.write' OAUTH2_READ = 'oauth2.read' diff --git a/lib/appwrite/enums/project_policy_id.rb b/lib/appwrite/enums/project_policy_id.rb index 738292d4..d3052189 100644 --- a/lib/appwrite/enums/project_policy_id.rb +++ b/lib/appwrite/enums/project_policy_id.rb @@ -11,6 +11,7 @@ module ProjectPolicyId SESSION_LIMIT = 'session-limit' USER_LIMIT = 'user-limit' MEMBERSHIP_PRIVACY = 'membership-privacy' + MFA_FACTORS = 'mfa-factors' DENY_ALIASED_EMAIL = 'deny-aliased-email' DENY_DISPOSABLE_EMAIL = 'deny-disposable-email' DENY_FREE_EMAIL = 'deny-free-email' diff --git a/lib/appwrite/enums/runtime.rb b/lib/appwrite/enums/runtime.rb index 0fba21f2..bf2c4e20 100644 --- a/lib/appwrite/enums/runtime.rb +++ b/lib/appwrite/enums/runtime.rb @@ -11,6 +11,7 @@ module Runtime NODE_23 = 'node-23' NODE_24 = 'node-24' NODE_25 = 'node-25' + NODE_26 = 'node-26' PHP_8_0 = 'php-8.0' PHP_8_1 = 'php-8.1' PHP_8_2 = 'php-8.2' diff --git a/lib/appwrite/models/billing_plan.rb b/lib/appwrite/models/billing_plan.rb index aac36f6f..5e7bd7d8 100644 --- a/lib/appwrite/models/billing_plan.rb +++ b/lib/appwrite/models/billing_plan.rb @@ -84,7 +84,7 @@ def initialize( storage:, image_transformations:, screenshots_generated:, - members:, + members: , webhooks:, waf_rules:, projects:, @@ -108,7 +108,7 @@ def initialize( topics:, auth_phone:, domains:, - activity_logs:, + activity_logs: , usage_logs:, usage_logs_intervals: , project_inactivity_days:, @@ -132,10 +132,10 @@ def initialize( supports_free_email_validation:, supports_corporate_email_validation:, supports_project_specific_roles:, - backups_enabled:, + backups_enabled: , usage_per_project:, supported_addons:, - backup_policies:, + backup_policies: , deployment_size:, build_size:, databases_allow_encrypt:, diff --git a/lib/appwrite/models/billing_plan_addon.rb b/lib/appwrite/models/billing_plan_addon.rb index 5569f8a5..b128cf19 100644 --- a/lib/appwrite/models/billing_plan_addon.rb +++ b/lib/appwrite/models/billing_plan_addon.rb @@ -7,8 +7,8 @@ class BillingPlanAddon attr_reader :projects def initialize( - seats:, - projects: + seats: , + projects: ) @seats = seats @projects = projects @@ -16,15 +16,15 @@ def initialize( def self.from(map:) BillingPlanAddon.new( - seats: BillingPlanAddonDetails.from(map: map["seats"]), - projects: BillingPlanAddonDetails.from(map: map["projects"]) + seats: map["seats"].nil? ? nil : BillingPlanAddonDetails.from(map: map["seats"]), + projects: map["projects"].nil? ? nil : BillingPlanAddonDetails.from(map: map["projects"]) ) end def to_map { - "seats": @seats.to_map, - "projects": @projects.to_map + "seats": @seats&.to_map, + "projects": @projects&.to_map } end end diff --git a/lib/appwrite/models/billing_plan_addon_details.rb b/lib/appwrite/models/billing_plan_addon_details.rb index 7ca96ab1..72335b4c 100644 --- a/lib/appwrite/models/billing_plan_addon_details.rb +++ b/lib/appwrite/models/billing_plan_addon_details.rb @@ -17,7 +17,7 @@ def initialize( plan_included:, limit:, type:, - currency:, + currency: , price:, value:, invoice_desc: diff --git a/lib/appwrite/models/database_migration.rb b/lib/appwrite/models/database_migration.rb new file mode 100644 index 00000000..afd0ce65 --- /dev/null +++ b/lib/appwrite/models/database_migration.rb @@ -0,0 +1,102 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class DatabaseMigration + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :project_id + attr_reader :database_id + attr_reader :specification + attr_reader :phase + attr_reader :attempt + attr_reader :last_error + attr_reader :lag_documents + attr_reader :verified_at + attr_reader :cutover_at + attr_reader :soak_until + attr_reader :auto_cutover + attr_reader :cutover_requested + attr_reader :paused + + def initialize( + id:, + created_at:, + updated_at:, + project_id:, + database_id:, + specification:, + phase:, + attempt:, + last_error:, + lag_documents:, + verified_at:, + cutover_at:, + soak_until:, + auto_cutover:, + cutover_requested:, + paused: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @project_id = project_id + @database_id = database_id + @specification = specification + @phase = phase + @attempt = attempt + @last_error = last_error + @lag_documents = lag_documents + @verified_at = verified_at + @cutover_at = cutover_at + @soak_until = soak_until + @auto_cutover = auto_cutover + @cutover_requested = cutover_requested + @paused = paused + end + + def self.from(map:) + DatabaseMigration.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + project_id: map["projectId"], + database_id: map["databaseId"], + specification: map["specification"], + phase: map["phase"], + attempt: map["attempt"], + last_error: map["lastError"], + lag_documents: map["lagDocuments"], + verified_at: map["verifiedAt"], + cutover_at: map["cutoverAt"], + soak_until: map["soakUntil"], + auto_cutover: map["autoCutover"], + cutover_requested: map["cutoverRequested"], + paused: map["paused"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "projectId": @project_id, + "databaseId": @database_id, + "specification": @specification, + "phase": @phase, + "attempt": @attempt, + "lastError": @last_error, + "lagDocuments": @lag_documents, + "verifiedAt": @verified_at, + "cutoverAt": @cutover_at, + "soakUntil": @soak_until, + "autoCutover": @auto_cutover, + "cutoverRequested": @cutover_requested, + "paused": @paused + } + end + end + end +end diff --git a/lib/appwrite/models/database_migration_list.rb b/lib/appwrite/models/database_migration_list.rb new file mode 100644 index 00000000..aa238ba0 --- /dev/null +++ b/lib/appwrite/models/database_migration_list.rb @@ -0,0 +1,32 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class DatabaseMigrationList + attr_reader :total + attr_reader :migrations + + def initialize( + total:, + migrations: + ) + @total = total + @migrations = migrations + end + + def self.from(map:) + DatabaseMigrationList.new( + total: map["total"], + migrations: map["migrations"].map { |it| DatabaseMigration.from(map: it) } + ) + end + + def to_map + { + "total": @total, + "migrations": @migrations.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/models/database_status.rb b/lib/appwrite/models/database_status.rb index 3807f173..4ed60bf7 100644 --- a/lib/appwrite/models/database_status.rb +++ b/lib/appwrite/models/database_status.rb @@ -9,6 +9,12 @@ class DatabaseStatus attr_reader :version attr_reader :uptime attr_reader :connections + attr_reader :sync_mode + attr_reader :effective_sync_mode + attr_reader :sync_degraded + attr_reader :sync_acknowledgements + attr_reader :sync_standby_count + attr_reader :sync_state_confirmed attr_reader :replicas attr_reader :volumes @@ -19,6 +25,12 @@ def initialize( version:, uptime:, connections:, + sync_mode:, + effective_sync_mode: , + sync_degraded:, + sync_acknowledgements:, + sync_standby_count:, + sync_state_confirmed: , replicas:, volumes: ) @@ -28,6 +40,12 @@ def initialize( @version = version @uptime = uptime @connections = connections + @sync_mode = sync_mode + @effective_sync_mode = effective_sync_mode + @sync_degraded = sync_degraded + @sync_acknowledgements = sync_acknowledgements + @sync_standby_count = sync_standby_count + @sync_state_confirmed = sync_state_confirmed @replicas = replicas @volumes = volumes end @@ -40,6 +58,12 @@ def self.from(map:) version: map["version"], uptime: map["uptime"], connections: DatabaseStatusConnections.from(map: map["connections"]), + sync_mode: map["syncMode"], + effective_sync_mode: map["effectiveSyncMode"], + sync_degraded: map["syncDegraded"], + sync_acknowledgements: map["syncAcknowledgements"], + sync_standby_count: map["syncStandbyCount"], + sync_state_confirmed: map["syncStateConfirmed"], replicas: map["replicas"].map { |it| DatabaseStatusReplica.from(map: it) }, volumes: map["volumes"].map { |it| DatabaseStatusVolume.from(map: it) } ) @@ -53,6 +77,12 @@ def to_map "version": @version, "uptime": @uptime, "connections": @connections.to_map, + "syncMode": @sync_mode, + "effectiveSyncMode": @effective_sync_mode, + "syncDegraded": @sync_degraded, + "syncAcknowledgements": @sync_acknowledgements, + "syncStandbyCount": @sync_standby_count, + "syncStateConfirmed": @sync_state_confirmed, "replicas": @replicas.map { |it| it.to_map }, "volumes": @volumes.map { |it| it.to_map } } diff --git a/lib/appwrite/models/dedicated_database.rb b/lib/appwrite/models/dedicated_database.rb index 43d3e8d8..d53b19fa 100644 --- a/lib/appwrite/models/dedicated_database.rb +++ b/lib/appwrite/models/dedicated_database.rb @@ -33,7 +33,6 @@ class DedicatedDatabase attr_reader :node_pool attr_reader :replicas attr_reader :sync_mode - attr_reader :cross_region_replicas attr_reader :network_max_connections attr_reader :network_idle_timeout_seconds attr_reader :network_ip_allowlist @@ -84,7 +83,6 @@ def initialize( node_pool:, replicas:, sync_mode:, - cross_region_replicas:, network_max_connections:, network_idle_timeout_seconds:, network_ip_allowlist:, @@ -134,7 +132,6 @@ def initialize( @node_pool = node_pool @replicas = replicas @sync_mode = sync_mode - @cross_region_replicas = cross_region_replicas @network_max_connections = network_max_connections @network_idle_timeout_seconds = network_idle_timeout_seconds @network_ip_allowlist = network_ip_allowlist @@ -187,7 +184,6 @@ def self.from(map:) node_pool: map["nodePool"], replicas: map["replicas"], sync_mode: map["syncMode"], - cross_region_replicas: map["crossRegionReplicas"], network_max_connections: map["networkMaxConnections"], network_idle_timeout_seconds: map["networkIdleTimeoutSeconds"], network_ip_allowlist: map["networkIPAllowlist"], @@ -241,7 +237,6 @@ def to_map "nodePool": @node_pool, "replicas": @replicas, "syncMode": @sync_mode, - "crossRegionReplicas": @cross_region_replicas, "networkMaxConnections": @network_max_connections, "networkIdleTimeoutSeconds": @network_idle_timeout_seconds, "networkIPAllowlist": @network_ip_allowlist, diff --git a/lib/appwrite/models/dedicated_database_member.rb b/lib/appwrite/models/dedicated_database_member.rb index 3f88817b..dcb0a6d8 100644 --- a/lib/appwrite/models/dedicated_database_member.rb +++ b/lib/appwrite/models/dedicated_database_member.rb @@ -12,7 +12,7 @@ def initialize( id:, role:, status:, - lag_seconds: + lag_seconds: ) @id = id @role = role diff --git a/lib/appwrite/models/dedicated_database_operation.rb b/lib/appwrite/models/dedicated_database_operation.rb new file mode 100644 index 00000000..b5f9d8b0 --- /dev/null +++ b/lib/appwrite/models/dedicated_database_operation.rb @@ -0,0 +1,77 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class DedicatedDatabaseOperation + attr_reader :id + attr_reader :created_at + attr_reader :database_id + attr_reader :type + attr_reader :status + attr_reader :attempts + attr_reader :requested_at + attr_reader :started_at + attr_reader :completed_at + attr_reader :error_code + attr_reader :error_message + + def initialize( + id:, + created_at:, + database_id:, + type:, + status:, + attempts:, + requested_at: , + started_at: , + completed_at: , + error_code:, + error_message: + ) + @id = id + @created_at = created_at + @database_id = database_id + @type = type + @status = status + @attempts = attempts + @requested_at = requested_at + @started_at = started_at + @completed_at = completed_at + @error_code = error_code + @error_message = error_message + end + + def self.from(map:) + DedicatedDatabaseOperation.new( + id: map["$id"], + created_at: map["$createdAt"], + database_id: map["databaseId"], + type: map["type"], + status: map["status"], + attempts: map["attempts"], + requested_at: map["requestedAt"], + started_at: map["startedAt"], + completed_at: map["completedAt"], + error_code: map["errorCode"], + error_message: map["errorMessage"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "databaseId": @database_id, + "type": @type, + "status": @status, + "attempts": @attempts, + "requestedAt": @requested_at, + "startedAt": @started_at, + "completedAt": @completed_at, + "errorCode": @error_code, + "errorMessage": @error_message + } + end + end + end +end diff --git a/lib/appwrite/models/dedicated_database_operation_list.rb b/lib/appwrite/models/dedicated_database_operation_list.rb new file mode 100644 index 00000000..8ed7a8c1 --- /dev/null +++ b/lib/appwrite/models/dedicated_database_operation_list.rb @@ -0,0 +1,32 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class DedicatedDatabaseOperationList + attr_reader :total + attr_reader :operations + + def initialize( + total:, + operations: + ) + @total = total + @operations = operations + end + + def self.from(map:) + DedicatedDatabaseOperationList.new( + total: map["total"], + operations: map["operations"].map { |it| DedicatedDatabaseOperation.from(map: it) } + ) + end + + def to_map + { + "total": @total, + "operations": @operations.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/models/dedicated_database_replicas.rb b/lib/appwrite/models/dedicated_database_replicas.rb index 3cbdc5cc..7773340a 100644 --- a/lib/appwrite/models/dedicated_database_replicas.rb +++ b/lib/appwrite/models/dedicated_database_replicas.rb @@ -5,15 +5,30 @@ module Models class DedicatedDatabaseReplicas attr_reader :replicas attr_reader :sync_mode + attr_reader :effective_sync_mode + attr_reader :sync_degraded + attr_reader :sync_acknowledgements + attr_reader :sync_standby_count + attr_reader :sync_state_confirmed attr_reader :members def initialize( replicas:, sync_mode:, + effective_sync_mode: , + sync_degraded:, + sync_acknowledgements:, + sync_standby_count:, + sync_state_confirmed: , members: ) @replicas = replicas @sync_mode = sync_mode + @effective_sync_mode = effective_sync_mode + @sync_degraded = sync_degraded + @sync_acknowledgements = sync_acknowledgements + @sync_standby_count = sync_standby_count + @sync_state_confirmed = sync_state_confirmed @members = members end @@ -21,6 +36,11 @@ def self.from(map:) DedicatedDatabaseReplicas.new( replicas: map["replicas"], sync_mode: map["syncMode"], + effective_sync_mode: map["effectiveSyncMode"], + sync_degraded: map["syncDegraded"], + sync_acknowledgements: map["syncAcknowledgements"], + sync_standby_count: map["syncStandbyCount"], + sync_state_confirmed: map["syncStateConfirmed"], members: map["members"].map { |it| DedicatedDatabaseMember.from(map: it) } ) end @@ -29,6 +49,11 @@ def to_map { "replicas": @replicas, "syncMode": @sync_mode, + "effectiveSyncMode": @effective_sync_mode, + "syncDegraded": @sync_degraded, + "syncAcknowledgements": @sync_acknowledgements, + "syncStandbyCount": @sync_standby_count, + "syncStateConfirmed": @sync_state_confirmed, "members": @members.map { |it| it.to_map } } end diff --git a/lib/appwrite/models/dedicated_database_specification_pricing.rb b/lib/appwrite/models/dedicated_database_specification_pricing.rb index ed68de88..e9a679b7 100644 --- a/lib/appwrite/models/dedicated_database_specification_pricing.rb +++ b/lib/appwrite/models/dedicated_database_specification_pricing.rb @@ -6,20 +6,17 @@ class DedicatedDatabaseSpecificationPricing attr_reader :storage_overage_rate attr_reader :bandwidth_overage_rate attr_reader :replica_rate - attr_reader :cross_region_replica_rate attr_reader :pitr_rate def initialize( storage_overage_rate:, bandwidth_overage_rate:, replica_rate:, - cross_region_replica_rate:, pitr_rate: ) @storage_overage_rate = storage_overage_rate @bandwidth_overage_rate = bandwidth_overage_rate @replica_rate = replica_rate - @cross_region_replica_rate = cross_region_replica_rate @pitr_rate = pitr_rate end @@ -28,7 +25,6 @@ def self.from(map:) storage_overage_rate: map["storageOverageRate"], bandwidth_overage_rate: map["bandwidthOverageRate"], replica_rate: map["replicaRate"], - cross_region_replica_rate: map["crossRegionReplicaRate"], pitr_rate: map["pitrRate"] ) end @@ -38,7 +34,6 @@ def to_map "storageOverageRate": @storage_overage_rate, "bandwidthOverageRate": @bandwidth_overage_rate, "replicaRate": @replica_rate, - "crossRegionReplicaRate": @cross_region_replica_rate, "pitrRate": @pitr_rate } end diff --git a/lib/appwrite/models/embedding.rb b/lib/appwrite/models/embedding.rb new file mode 100644 index 00000000..991b6e57 --- /dev/null +++ b/lib/appwrite/models/embedding.rb @@ -0,0 +1,42 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class Embedding + attr_reader :model + attr_reader :dimension + attr_reader :embedding + attr_reader :error + + def initialize( + model:, + dimension:, + embedding:, + error: + ) + @model = model + @dimension = dimension + @embedding = embedding + @error = error + end + + def self.from(map:) + Embedding.new( + model: map["model"], + dimension: map["dimension"], + embedding: map["embedding"], + error: map["error"] + ) + end + + def to_map + { + "model": @model, + "dimension": @dimension, + "embedding": @embedding, + "error": @error + } + end + end + end +end diff --git a/lib/appwrite/models/embedding_list.rb b/lib/appwrite/models/embedding_list.rb new file mode 100644 index 00000000..770ca0e5 --- /dev/null +++ b/lib/appwrite/models/embedding_list.rb @@ -0,0 +1,32 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class EmbeddingList + attr_reader :total + attr_reader :embeddings + + def initialize( + total:, + embeddings: + ) + @total = total + @embeddings = embeddings + end + + def self.from(map:) + EmbeddingList.new( + total: map["total"], + embeddings: map["embeddings"].map { |it| Embedding.from(map: it) } + ) + end + + def to_map + { + "total": @total, + "embeddings": @embeddings.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/models/file.rb b/lib/appwrite/models/file.rb index a356c10a..525a88b3 100644 --- a/lib/appwrite/models/file.rb +++ b/lib/appwrite/models/file.rb @@ -9,6 +9,8 @@ class File attr_reader :updated_at attr_reader :permissions attr_reader :name + attr_reader :folder + attr_reader :key attr_reader :signature attr_reader :mime_type attr_reader :size_original @@ -25,6 +27,8 @@ def initialize( updated_at:, permissions:, name:, + folder:, + key:, signature:, mime_type:, size_original:, @@ -40,6 +44,8 @@ def initialize( @updated_at = updated_at @permissions = permissions @name = name + @folder = folder + @key = key @signature = signature @mime_type = mime_type @size_original = size_original @@ -58,6 +64,8 @@ def self.from(map:) updated_at: map["$updatedAt"], permissions: map["$permissions"], name: map["name"], + folder: map["folder"], + key: map["key"], signature: map["signature"], mime_type: map["mimeType"], size_original: map["sizeOriginal"], @@ -77,6 +85,8 @@ def to_map "$updatedAt": @updated_at, "$permissions": @permissions, "name": @name, + "folder": @folder, + "key": @key, "signature": @signature, "mimeType": @mime_type, "sizeOriginal": @size_original, diff --git a/lib/appwrite/models/mfa_challenge_secret.rb b/lib/appwrite/models/mfa_challenge_secret.rb new file mode 100644 index 00000000..e17abe4c --- /dev/null +++ b/lib/appwrite/models/mfa_challenge_secret.rb @@ -0,0 +1,47 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class MfaChallengeSecret + attr_reader :id + attr_reader :created_at + attr_reader :user_id + attr_reader :expire + attr_reader :code + + def initialize( + id:, + created_at:, + user_id:, + expire:, + code: + ) + @id = id + @created_at = created_at + @user_id = user_id + @expire = expire + @code = code + end + + def self.from(map:) + MfaChallengeSecret.new( + id: map["$id"], + created_at: map["$createdAt"], + user_id: map["userId"], + expire: map["expire"], + code: map["code"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "userId": @user_id, + "expire": @expire, + "code": @code + } + end + end + end +end diff --git a/lib/appwrite/models/mfa_factors.rb b/lib/appwrite/models/mfa_factors.rb index 583bba0e..ed0d6e1e 100644 --- a/lib/appwrite/models/mfa_factors.rb +++ b/lib/appwrite/models/mfa_factors.rb @@ -7,17 +7,20 @@ class MfaFactors attr_reader :phone attr_reader :email attr_reader :recovery_code + attr_reader :custom def initialize( totp:, phone:, email:, - recovery_code: + recovery_code:, + custom: ) @totp = totp @phone = phone @email = email @recovery_code = recovery_code + @custom = custom end def self.from(map:) @@ -25,7 +28,8 @@ def self.from(map:) totp: map["totp"], phone: map["phone"], email: map["email"], - recovery_code: map["recoveryCode"] + recovery_code: map["recoveryCode"], + custom: map["custom"] ) end @@ -34,7 +38,8 @@ def to_map "totp": @totp, "phone": @phone, "email": @email, - "recoveryCode": @recovery_code + "recoveryCode": @recovery_code, + "custom": @custom } end end diff --git a/lib/appwrite/models/organization.rb b/lib/appwrite/models/organization.rb index 2cdbe8e0..d3aa9fe9 100644 --- a/lib/appwrite/models/organization.rb +++ b/lib/appwrite/models/organization.rb @@ -46,7 +46,7 @@ def initialize( name:, total:, prefs:, - billing_budget:, + billing_budget: , budget_alerts:, billing_plan:, billing_plan_id:, @@ -55,23 +55,23 @@ def initialize( billing_start_date:, billing_current_invoice_date:, billing_next_invoice_date:, - billing_trial_start_date:, + billing_trial_start_date: , billing_trial_days:, billing_aggregation_id:, billing_invoice_id:, payment_method_id:, - billing_address_id:, - backup_payment_method_id:, + billing_address_id: , + backup_payment_method_id: , status:, - remarks:, - agreement_baa:, - program_manager_name:, - program_manager_calendar:, - program_discord_channel_name:, - program_discord_channel_url:, + remarks: , + agreement_baa: , + program_manager_name: , + program_manager_calendar: , + program_discord_channel_name: , + program_discord_channel_url: , billing_limits: , - billing_plan_downgrade:, - billing_tax_id:, + billing_plan_downgrade: , + billing_tax_id: , marked_for_deletion:, platform:, projects: diff --git a/lib/appwrite/models/policy_mfa_factors.rb b/lib/appwrite/models/policy_mfa_factors.rb new file mode 100644 index 00000000..158c12ff --- /dev/null +++ b/lib/appwrite/models/policy_mfa_factors.rb @@ -0,0 +1,47 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class PolicyMfaFactors + attr_reader :id + attr_reader :totp + attr_reader :email + attr_reader :phone + attr_reader :custom + + def initialize( + id:, + totp:, + email:, + phone:, + custom: + ) + @id = id + @totp = totp + @email = email + @phone = phone + @custom = custom + end + + def self.from(map:) + PolicyMfaFactors.new( + id: map["$id"], + totp: map["totp"], + email: map["email"], + phone: map["phone"], + custom: map["custom"] + ) + end + + def to_map + { + "$id": @id, + "totp": @totp, + "email": @email, + "phone": @phone, + "custom": @custom + } + end + end + end +end diff --git a/lib/appwrite/models/project.rb b/lib/appwrite/models/project.rb index 94f7bb10..bf6fc02e 100644 --- a/lib/appwrite/models/project.rb +++ b/lib/appwrite/models/project.rb @@ -36,6 +36,7 @@ class Project attr_reader :o_auth2_server_authorization_url attr_reader :o_auth2_server_scopes attr_reader :o_auth2_server_default_scopes + attr_reader :o_auth2_server_installation_scopes attr_reader :o_auth2_server_authorization_details_types attr_reader :o_auth2_server_access_token_duration attr_reader :o_auth2_server_refresh_token_duration @@ -83,6 +84,7 @@ def initialize( o_auth2_server_authorization_url: , o_auth2_server_scopes: , o_auth2_server_default_scopes: , + o_auth2_server_installation_scopes: , o_auth2_server_authorization_details_types: , o_auth2_server_access_token_duration: , o_auth2_server_refresh_token_duration: , @@ -129,6 +131,7 @@ def initialize( @o_auth2_server_authorization_url = o_auth2_server_authorization_url @o_auth2_server_scopes = o_auth2_server_scopes @o_auth2_server_default_scopes = o_auth2_server_default_scopes + @o_auth2_server_installation_scopes = o_auth2_server_installation_scopes @o_auth2_server_authorization_details_types = o_auth2_server_authorization_details_types @o_auth2_server_access_token_duration = o_auth2_server_access_token_duration @o_auth2_server_refresh_token_duration = o_auth2_server_refresh_token_duration @@ -178,6 +181,7 @@ def self.from(map:) o_auth2_server_authorization_url: map["oAuth2ServerAuthorizationUrl"], o_auth2_server_scopes: map["oAuth2ServerScopes"], o_auth2_server_default_scopes: map["oAuth2ServerDefaultScopes"], + o_auth2_server_installation_scopes: map["oAuth2ServerInstallationScopes"], o_auth2_server_authorization_details_types: map["oAuth2ServerAuthorizationDetailsTypes"], o_auth2_server_access_token_duration: map["oAuth2ServerAccessTokenDuration"], o_auth2_server_refresh_token_duration: map["oAuth2ServerRefreshTokenDuration"], @@ -228,6 +232,7 @@ def to_map "oAuth2ServerAuthorizationUrl": @o_auth2_server_authorization_url, "oAuth2ServerScopes": @o_auth2_server_scopes, "oAuth2ServerDefaultScopes": @o_auth2_server_default_scopes, + "oAuth2ServerInstallationScopes": @o_auth2_server_installation_scopes, "oAuth2ServerAuthorizationDetailsTypes": @o_auth2_server_authorization_details_types, "oAuth2ServerAccessTokenDuration": @o_auth2_server_access_token_duration, "oAuth2ServerRefreshTokenDuration": @o_auth2_server_refresh_token_duration, diff --git a/lib/appwrite/models/proxy_invalidation.rb b/lib/appwrite/models/proxy_invalidation.rb new file mode 100644 index 00000000..d87b4b19 --- /dev/null +++ b/lib/appwrite/models/proxy_invalidation.rb @@ -0,0 +1,42 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class ProxyInvalidation + attr_reader :domain + attr_reader :type + attr_reader :reference + attr_reader :status + + def initialize( + domain:, + type:, + reference:, + status: + ) + @domain = domain + @type = type + @reference = reference + @status = status + end + + def self.from(map:) + ProxyInvalidation.new( + domain: map["domain"], + type: map["type"], + reference: map["reference"], + status: map["status"] + ) + end + + def to_map + { + "domain": @domain, + "type": @type, + "reference": @reference, + "status": @status + } + end + end + end +end diff --git a/lib/appwrite/models/usage_billing_plan.rb b/lib/appwrite/models/usage_billing_plan.rb index ec694844..23521586 100644 --- a/lib/appwrite/models/usage_billing_plan.rb +++ b/lib/appwrite/models/usage_billing_plan.rb @@ -18,15 +18,15 @@ class UsageBillingPlan def initialize( bandwidth:, executions:, - member:, + member: , realtime:, realtime_messages:, - realtime_bandwidth:, + realtime_bandwidth: , storage:, users:, gb_hours:, image_transformations:, - credits: + credits: ) @bandwidth = bandwidth @executions = executions @@ -45,15 +45,15 @@ def self.from(map:) UsageBillingPlan.new( bandwidth: AdditionalResource.from(map: map["bandwidth"]), executions: AdditionalResource.from(map: map["executions"]), - member: AdditionalResource.from(map: map["member"]), + member: map["member"].nil? ? nil : AdditionalResource.from(map: map["member"]), realtime: AdditionalResource.from(map: map["realtime"]), realtime_messages: AdditionalResource.from(map: map["realtimeMessages"]), - realtime_bandwidth: AdditionalResource.from(map: map["realtimeBandwidth"]), + realtime_bandwidth: map["realtimeBandwidth"].nil? ? nil : AdditionalResource.from(map: map["realtimeBandwidth"]), storage: AdditionalResource.from(map: map["storage"]), users: AdditionalResource.from(map: map["users"]), gb_hours: AdditionalResource.from(map: map["GBHours"]), image_transformations: AdditionalResource.from(map: map["imageTransformations"]), - credits: AdditionalResource.from(map: map["credits"]) + credits: map["credits"].nil? ? nil : AdditionalResource.from(map: map["credits"]) ) end @@ -61,15 +61,15 @@ def to_map { "bandwidth": @bandwidth.to_map, "executions": @executions.to_map, - "member": @member.to_map, + "member": @member&.to_map, "realtime": @realtime.to_map, "realtimeMessages": @realtime_messages.to_map, - "realtimeBandwidth": @realtime_bandwidth.to_map, + "realtimeBandwidth": @realtime_bandwidth&.to_map, "storage": @storage.to_map, "users": @users.to_map, "GBHours": @gb_hours.to_map, "imageTransformations": @image_transformations.to_map, - "credits": @credits.to_map + "credits": @credits&.to_map } end end diff --git a/lib/appwrite/services/account.rb b/lib/appwrite/services/account.rb index b917162f..7b2bcb73 100644 --- a/lib/appwrite/services/account.rb +++ b/lib/appwrite/services/account.rb @@ -397,38 +397,6 @@ def delete_identity(identity_id:) end - # Use this endpoint to create a JSON Web Token. You can use the resulting JWT - # to authenticate on behalf of the current user when working with the - # Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes - # from its creation and will be invalid if the user will logout in that time - # frame. - # - # @param [Integer] duration Time in seconds before JWT expires. Default duration is 900 seconds, and maximum is 3600 seconds. - # - # @return [Jwt] - def create_jwt(duration: nil) - api_path = '/account/jwts' - - api_params = { - duration: duration, - } - - api_headers = { - "X-Appwrite-Project": @client.get_config('project'), - "content-type": 'application/json', - "accept": 'application/json', - } - - @client.call( - method: 'POST', - path: api_path, - headers: api_headers, - params: api_params, - response_type: Models::Jwt - ) - - end - # Get the list of latest security activity logs for the currently logged in # user. Each log returns user IP address, location and date and time of log. # @@ -600,7 +568,7 @@ def delete_mfa_authenticator(type:) # [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) # method. # - # @param [AuthenticationFactor] factor Factor used for verification. Must be one of following: `email`, `phone`, `totp`, `recoveryCode`. + # @param [AuthenticationFactor] factor Factor used for verification. Must be one of following: `email`, `phone`, `totp`, `recoveryCode`, `custom`. # # @return [MfaChallenge] def create_mfa_challenge(factor:) diff --git a/lib/appwrite/services/activities.rb b/lib/appwrite/services/activities.rb index e14db113..27b91242 100644 --- a/lib/appwrite/services/activities.rb +++ b/lib/appwrite/services/activities.rb @@ -9,7 +9,7 @@ def initialize(client) # List all events for selected filters. # - # @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. + # @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 attributes such as userId, teamId, etc. # # @return [ActivityEventList] def list_events(queries: nil) diff --git a/lib/appwrite/services/apps.rb b/lib/appwrite/services/apps.rb index bc96e462..b55b8d88 100644 --- a/lib/appwrite/services/apps.rb +++ b/lib/appwrite/services/apps.rb @@ -164,7 +164,7 @@ def list_o_auth2_scopes() # Get an application by its unique ID. # - # @param [String] app_id Application unique ID or HTTPS client ID metadata document URL. + # @param [String] app_id Application unique ID. # # @return [App] def get(app_id:) @@ -213,7 +213,7 @@ def get(app_id:) # @param [Array] post_logout_redirect_uris Post-logout redirect URIs for OpenID Connect RP-Initiated Logout. Each must be an https URL, an http loopback URL, or a private-use scheme URI, and must not contain a fragment. After ending the user session, the logout endpoint only redirects to URIs in this list. # @param [String] type OAuth2 client type. Use `public` for SPAs, mobile, and native apps that cannot keep a `client_secret` — PKCE is then required at the token endpoint. Use `confidential` for server-side clients that present a `client_secret`. Defaults to `confidential`. # @param [] device_flow Allow this client to use the OAuth2 Device Authorization Grant (RFC 8628) for input-constrained devices such as TVs and CLIs. Defaults to false. - # @param [Array] installation_scopes Scopes the application requests when installed on a team. Organization-level and project-level scopes only; use the list scopes endpoint with `type=installation` to discover available values. Maximum of 100 scopes are allowed. + # @param [Array] installation_scopes Scopes the application requests when installed on a team. Only scopes allowed by the project's OAuth2 server installation scopes configuration are accepted; use the list installation scopes endpoint to discover available values. Maximum of 100 scopes are allowed. # @param [String] installation_redirect_url URL users are redirected to after creating or updating an installation of this application. Must be an https URL, an http loopback URL (localhost, 127.0.0.1, [::1]), or a private-use scheme URI, and must not contain a fragment. Leave empty for no redirect. # # @return [App] @@ -299,7 +299,8 @@ def delete(app_id:) end # List installations of an application. Requires an app key sent in the - # `X-Appwrite-Key` header alongside the `X-Appwrite-App` header. + # `X-Appwrite-Key` header alongside the `X-Appwrite-App` header, or a caller + # with update access to the app. # # @param [String] app_id Application unique ID. # @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. @@ -335,7 +336,8 @@ def list_installations(app_id:, queries: nil, total: nil) end # Get an installation of an application by its unique ID. Requires an app key - # sent in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header. + # sent in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header, + # or a caller with update access to the app. # # @param [String] app_id Application unique ID. # @param [String] installation_id Installation unique ID. @@ -372,13 +374,53 @@ def get_installation(app_id:, installation_id:) end + # Delete an installation of an application by its unique ID. Requires a + # caller with update access to the app. Previously issued installation access + # tokens are revoked. + # + # @param [String] app_id Application unique ID. + # @param [String] installation_id Installation unique ID. + # + # @return [] + def delete_installation(app_id:, installation_id:) + api_path = '/apps/{appId}/installations/{installationId}' + .gsub('{appId}', app_id) + .gsub('{installationId}', installation_id) + + if app_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "appId"') + end + + if installation_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "installationId"') + end + + api_params = { + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, + ) + + end + # Create a token for an installation of an application. Requires an app key - # sent in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header. - # The returned token carries the scopes and authorization details granted to - # the installation, and can be used as an `Authorization: Bearer` header - # everywhere OAuth2 access tokens are accepted. Multiple tokens can be active - # for the same installation at once; each token stays valid until it expires - # or the installation is updated or deleted. + # sent in the `X-Appwrite-Key` header alongside the `X-Appwrite-App` header, + # or a caller with update access to the app. The returned token carries the + # scopes and authorization details granted to the installation, and can be + # used as an `Authorization: Bearer` header everywhere OAuth2 access tokens + # are accepted. Multiple tokens can be active for the same installation at + # once; each token stays valid until it expires or the installation is + # updated or deleted. # # @param [String] app_id Application unique ID. # @param [String] installation_id Installation unique ID. diff --git a/lib/appwrite/services/backups.rb b/lib/appwrite/services/backups.rb index f923d951..10a8b3eb 100644 --- a/lib/appwrite/services/backups.rb +++ b/lib/appwrite/services/backups.rb @@ -318,9 +318,10 @@ def delete_policy(policy_id:) # Create and trigger a new restoration for a backup on a project. # # For a backup of one database, the restoration resolves its destination - # before it is queued. Pass `newResourceId` to restore into that database ID, - # including the archived database ID to overwrite it. When `newResourceId` is - # omitted, a new database ID is generated and returned in `options`. + # before it is queued. When `newResourceId` is omitted, the archived database + # is restored in place and its own ID is returned in `options`. Pass a + # different `newResourceId` to restore alongside it as a new database + # instead. # # The restoration migration records the archived database in `resourceId` and # `resourceType`, and the resolved database in `destinationResourceId` and @@ -337,14 +338,19 @@ def delete_policy(policy_id:) # operational `resourceType` of a table migration is not rewritten to # `tablesdb`. # - # When restoring a DocumentsDB or VectorsDB database to a new resource from a - # dedicated source, the restore provisions a fresh dedicated backing database - # at the source database's own specification. + # When restoring a DocumentsDB or VectorsDB database from a dedicated source, + # the restore provisions a fresh dedicated backing database at the source + # database's own specification and lands the data there. An in-place restore + # swaps the database onto that backing only once the restore has succeeded, + # and retires the backing it displaced only once that swap is confirmed, so + # the source keeps serving its own data until the restored data is in place + # and any failure leaves it untouched. A serverless source has no dedicated + # backing to clone and restores onto the archived database instead. # # # @param [String] archive_id Backup archive ID to restore # @param [Array] services Array of services to restore - # @param [String] new_resource_id Destination resource ID. Omit to generate a new ID, or pass the archived resource ID to overwrite it. 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. + # @param [String] new_resource_id Destination resource ID. Omit to restore the archived resource in place, or pass a different ID to restore alongside it as a new resource. 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. # @param [String] new_resource_name Database name. Max length: 128 chars. # # @return [BackupRestoration] diff --git a/lib/appwrite/services/databases.rb b/lib/appwrite/services/databases.rb index c4f6341c..57466163 100644 --- a/lib/appwrite/services/databases.rb +++ b/lib/appwrite/services/databases.rb @@ -453,7 +453,7 @@ def list_collections(database_id:, queries: nil, search: nil, total: nil) # @param [Array] permissions An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). # @param [] document_security Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). # @param [] enabled Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. - # @param [Array] attributes Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, integer, float, boolean, datetime), size (integer, required for string type), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. + # @param [Array] attributes Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, double, boolean, datetime, point, linestring, polygon, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. # @param [Array] indexes Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). # # @return [Collection] @@ -2275,11 +2275,11 @@ def update_polygon_attribute(database_id:, collection_id:, key:, required:, defa # @param [String] database_id Database ID. # @param [String] collection_id Collection ID. # @param [String] related_collection_id Related Collection ID. - # @param [RelationshipType] type Relation type + # @param [RelationshipType] type Relationship type. Possible values are: oneToOne, oneToMany, manyToOne, manyToMany. # @param [] two_way Is Two Way? # @param [String] key Attribute Key. # @param [String] two_way_key Two Way Attribute Key. - # @param [RelationMutate] on_delete Constraints option + # @param [RelationMutate] on_delete Delete constraint. Possible values are: cascade, restrict, setNull. # # @return [AttributeRelationship] def create_relationship_attribute(database_id:, collection_id:, related_collection_id:, type:, two_way: nil, key: nil, two_way_key: nil, on_delete: nil) @@ -2338,7 +2338,7 @@ def create_relationship_attribute(database_id:, collection_id:, related_collecti # @param [String] database_id Database ID. # @param [String] collection_id Collection ID. # @param [String] key Attribute Key. - # @param [RelationMutate] on_delete Constraints option + # @param [RelationMutate] on_delete Delete constraint. Possible values are: cascade, restrict, setNull. # @param [String] new_key New Attribute Key. # # @return [AttributeRelationship] diff --git a/lib/appwrite/services/embeddings.rb b/lib/appwrite/services/embeddings.rb new file mode 100644 index 00000000..5056314f --- /dev/null +++ b/lib/appwrite/services/embeddings.rb @@ -0,0 +1,48 @@ +#frozen_string_literal: true + +module Appwrite + class Embeddings < Service + + def initialize(client) + @client = client + end + + # Generate vector embeddings for an array of text using the selected + # embedding model. Use the returned vectors to power semantic search and + # similarity queries against your vector collections. + # + # + # @param [Array] texts Array of text to generate embeddings. + # @param [EmbeddingModel] model The embedding model to use for generating vector embeddings. + # + # @return [EmbeddingList] + def create_text_embeddings(texts:, model: nil) + api_path = '/embeddings/text' + + if texts.nil? + raise Appwrite::Exception.new('Missing required parameter: "texts"') + end + + api_params = { + texts: texts, + model: model, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::EmbeddingList + ) + + end + + end +end diff --git a/lib/appwrite/services/functions.rb b/lib/appwrite/services/functions.rb index 20132479..c0a16a74 100644 --- a/lib/appwrite/services/functions.rb +++ b/lib/appwrite/services/functions.rb @@ -151,7 +151,7 @@ def list_runtimes() # List allowed function specifications for this instance. # - # @param [String] type Specification type to list. Can be one of: runtimes, builds. + # @param [String] type Specification type to list. Can be one of: runtimes, builds. Defaults to runtimes. # # @return [SpecificationList] def list_specifications(type: nil) diff --git a/lib/appwrite/services/project.rb b/lib/appwrite/services/project.rb index d1eee8ff..ada33927 100644 --- a/lib/appwrite/services/project.rb +++ b/lib/appwrite/services/project.rb @@ -123,56 +123,6 @@ def list_keys(queries: nil, total: nil) end - # Create a new API key. It's recommended to have multiple API keys with - # strict scopes for separate functions within your project. - # - # You can also create an ephemeral API key if you need a short-lived key - # instead. - # - # @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. - # @param [String] name Key name. Max length: 128 chars. - # @param [Array] scopes Key scopes list. Maximum of 200 scopes are allowed. - # @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. - # - # @return [Key] - def create_key(key_id:, name:, scopes:, expire: nil) - api_path = '/project/keys' - - if key_id.nil? - raise Appwrite::Exception.new('Missing required parameter: "keyId"') - end - - if name.nil? - raise Appwrite::Exception.new('Missing required parameter: "name"') - end - - if scopes.nil? - raise Appwrite::Exception.new('Missing required parameter: "scopes"') - end - - api_params = { - keyId: key_id, - name: name, - scopes: scopes, - expire: expire, - } - - api_headers = { - "X-Appwrite-Project": @client.get_config('project'), - "content-type": 'application/json', - "accept": 'application/json', - } - - @client.call( - method: 'POST', - path: api_path, - headers: api_headers, - params: api_params, - response_type: Models::Key - ) - - end - # Create a new ephemeral API key. It's recommended to have multiple API keys # with strict scopes for separate functions within your project. # @@ -576,9 +526,10 @@ def list_o_auth2_providers(queries: nil, total: nil) # @param [String] user_code_format Character set for device flow user codes: `numeric` (digits only — best for numeric keypads and TV remotes), `alphabetic` (letters only), or `alphanumeric` (letters and digits — highest entropy per character). Defaults to `alphanumeric`. # @param [Integer] device_code_duration Lifetime in seconds of device flow device codes and user codes. Device codes are intentionally short-lived. Leave empty to use default 600. # @param [Array] default_scopes List of OAuth2 scopes used when an authorization request omits the scope parameter. Every default scope must also be allowed by the OAuth2 server. Maximum of 100 scopes are allowed, each up to 128 characters long. + # @param [Array] installation_scopes List of scopes an application may request when installed on a team. Omitting the parameter clears the list, so no installation scopes can be granted. Maximum of 100 scopes are allowed, each up to 128 characters long. # # @return [Project] - def update_o_auth2_server(enabled:, authorization_url:, scopes: nil, authorization_details_types: nil, access_token_duration: nil, refresh_token_duration: nil, public_access_token_duration: nil, public_refresh_token_duration: nil, installation_access_token_duration: nil, confidential_pkce: nil, verification_url: nil, user_code_length: nil, user_code_format: nil, device_code_duration: nil, default_scopes: nil) + def update_o_auth2_server(enabled:, authorization_url:, scopes: nil, authorization_details_types: nil, access_token_duration: nil, refresh_token_duration: nil, public_access_token_duration: nil, public_refresh_token_duration: nil, installation_access_token_duration: nil, confidential_pkce: nil, verification_url: nil, user_code_length: nil, user_code_format: nil, device_code_duration: nil, default_scopes: nil, installation_scopes: nil) api_path = '/project/oauth2-server' if enabled.nil? @@ -605,6 +556,7 @@ def update_o_auth2_server(enabled:, authorization_url:, scopes: nil, authorizati userCodeFormat: user_code_format, deviceCodeDuration: device_code_duration, defaultScopes: default_scopes, + installationScopes: installation_scopes, } api_headers = { @@ -3051,6 +3003,44 @@ def update_membership_privacy_policy(user_id: nil, user_email: nil, user_phone: end + # Updating this policy allows you to control which factors users can use to + # complete an MFA challenge. Disabled factors cannot be used to create a + # challenge and are reported as unavailable when listing factors. The custom + # factor is disabled by default; enable it to deliver challenge codes through + # your own channel. Recovery codes always remain available as a fallback. + # + # @param [] totp Set to true to allow TOTP to complete an MFA challenge, or false to disable it. + # @param [] email Set to true to allow email to complete an MFA challenge, or false to disable it. + # @param [] phone Set to true to allow phone (SMS) to complete an MFA challenge, or false to disable it. + # @param [] custom Set to true to allow the custom factor to complete an MFA challenge, or false to disable it. + # + # @return [Project] + def update_mfa_factors_policy(totp: nil, email: nil, phone: nil, custom: nil) + api_path = '/project/policies/mfa-factors' + + api_params = { + totp: totp, + email: email, + phone: phone, + custom: custom, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Project + ) + + end + # Updating this policy allows you to control if new passwords are checked # against most common passwords dictionary. When enabled, and user changes # their password, password must not be contained in the dictionary. @@ -3095,7 +3085,7 @@ def update_password_dictionary_policy(enabled:) # users, and it will only start to collect and enforce the policy on password # changes since the policy is enabled. # - # @param [Integer] total Set the password history length per user. Value can be between 1 and 5000, or null to disable the limit. + # @param [Integer] total Set the password history length per user. Value can be between 1 and 20, or null to disable the limit. # # @return [Project] def update_password_history_policy(total:) @@ -3235,7 +3225,7 @@ def update_session_alert_policy(enabled:) # Update maximum duration how long sessions created within a project should # stay active for. # - # @param [Integer] duration Maximum session length in seconds. Minium allowed value is 5 second, and maximum is 1 year, which is 31536000 seconds. + # @param [Integer] duration Maximum session length in seconds. Minium allowed value is 60 seconds, and maximum is 1 year, which is 31536000 seconds. # # @return [Project] def update_session_duration_policy(duration:) @@ -3302,7 +3292,7 @@ def update_session_invalidation_policy(enabled:) # Update the maximum number of sessions allowed per user. When the limit is # hit, the oldest session will be deleted to make room for new one. # - # @param [Integer] total Set the maximum number of sessions allowed per user. Value can be between 1 and 5000, or null to disable the limit. + # @param [Integer] total Set the maximum number of sessions allowed per user. Value can be between 1 and 100. # # @return [Project] def update_session_limit_policy(total:) @@ -3336,7 +3326,7 @@ def update_session_limit_policy(total:) # amount of existing users already exceeded the limit, all users remain # active, but new user sign up will be prohibited. # - # @param [Integer] total Set the maximum number of users allowed in the project. Value can be between 1 and 5000, or null to disable the limit. + # @param [Integer] total Set the maximum number of users allowed in the project. Value can be between 0 and 10000. Use 0 or null to disable the limit. # # @return [Project] def update_user_limit_policy(total:) @@ -3369,9 +3359,9 @@ def update_user_limit_policy(total:) # Get a policy by its unique ID. This endpoint returns the current # configuration for the requested project policy. # - # @param [ProjectPolicyId] policy_id Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. + # @param [ProjectPolicyId] policy_id Policy ID. Can be one of: password-dictionary, password-history, password-strength, password-personal-data, session-alert, session-duration, session-invalidation, session-limit, user-limit, membership-privacy, mfa-factors, deny-aliased-email, deny-disposable-email, deny-free-email, deny-corporate-email. # - # @return [PolicyPasswordDictionary, PolicyPasswordHistory, PolicyPasswordStrength, PolicyPasswordPersonalData, PolicySessionAlert, PolicySessionDuration, PolicySessionInvalidation, PolicySessionLimit, PolicyUserLimit, PolicyMembershipPrivacy, PolicyDenyAliasedEmail, PolicyDenyDisposableEmail, PolicyDenyFreeEmail, PolicyDenyCorporateEmail] + # @return [PolicyPasswordDictionary, PolicyPasswordHistory, PolicyPasswordStrength, PolicyPasswordPersonalData, PolicySessionAlert, PolicySessionDuration, PolicySessionInvalidation, PolicySessionLimit, PolicyUserLimit, PolicyMembershipPrivacy, PolicyMfaFactors, PolicyDenyAliasedEmail, PolicyDenyDisposableEmail, PolicyDenyFreeEmail, PolicyDenyCorporateEmail] def get_policy(policy_id:) api_path = '/project/policies/{policyId}' .gsub('{policyId}', policy_id) @@ -3449,6 +3439,11 @@ def get_policy(policy_id:) return Models::PolicyMembershipPrivacy.from(map: response) end + if response['$id'] == 'mfa-factors' + + return Models::PolicyMfaFactors.from(map: response) + end + if response['$id'] == 'deny-aliased-email' return Models::PolicyDenyAliasedEmail.from(map: response) diff --git a/lib/appwrite/services/proxy.rb b/lib/appwrite/services/proxy.rb index 8fa472e8..206c395a 100644 --- a/lib/appwrite/services/proxy.rb +++ b/lib/appwrite/services/proxy.rb @@ -7,6 +7,50 @@ def initialize(client) @client = client end + # Create a new CDN cache invalidation for a domain. Executes a hard purge of + # cached content. + # + # Depending on type, the invalidation purges a single cache tag, a single URL + # path, or all cached content for the domain. + # + # @param [String] domain Domain name. + # @param [InvalidationType] type Type of reference passed. Allowed values are: tag, path, all + # @param [String] reference Reference to invalidate. Depending on type this can be: cache tag name (up to 128 characters), URL path (up to 2048 characters). Not required when type is all. + # + # @return [ProxyInvalidation] + def create_invalidation(domain:, type:, reference: nil) + api_path = '/proxy/invalidations' + + if domain.nil? + raise Appwrite::Exception.new('Missing required parameter: "domain"') + end + + if type.nil? + raise Appwrite::Exception.new('Missing required parameter: "type"') + end + + api_params = { + domain: domain, + type: type, + reference: reference, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::ProxyInvalidation + ) + + end + # Get a list of all the proxy rules. You can use the query params to filter # your results. # diff --git a/lib/appwrite/services/sites.rb b/lib/appwrite/services/sites.rb index bc93d5b7..b6028f09 100644 --- a/lib/appwrite/services/sites.rb +++ b/lib/appwrite/services/sites.rb @@ -155,7 +155,7 @@ def list_frameworks() # List allowed site specifications for this instance. # - # @param [String] type Specification type to list. Can be one of: runtimes, builds. + # @param [String] type Specification type to list. Can be one of: runtimes, builds. Defaults to runtimes. # # @return [SpecificationList] def list_specifications(type: nil) diff --git a/lib/appwrite/services/storage.rb b/lib/appwrite/services/storage.rb index fcc5a98c..705617f1 100644 --- a/lib/appwrite/services/storage.rb +++ b/lib/appwrite/services/storage.rb @@ -217,7 +217,7 @@ def delete_bucket(bucket_id:) # your results. # # @param [String] bucket_id Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). - # @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, signature, mimeType, sizeOriginal, chunksTotal, chunksUploaded + # @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, folder, signature, mimeType, sizeOriginal, chunksTotal, chunksUploaded # @param [String] search Search term to filter your list results. Max length: 256 chars. # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # @@ -274,9 +274,10 @@ def list_files(bucket_id:, queries: nil, search: nil, total: nil) # @param [String] file_id File 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. # @param [file] file Binary file. Appwrite SDKs provide helpers to handle file input. [Learn about file input](https://appwrite.io/docs/products/storage/upload-download#input-file). # @param [Array] permissions An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). + # @param [String] folder Virtual folder to place the file in, for example "photos/2026". Nest folders with `/`. Defaults to the bucket root. # # @return [File] - def create_file(bucket_id:, file_id:, file:, permissions: nil, on_progress: nil) + def create_file(bucket_id:, file_id:, file:, permissions: nil, folder: nil, on_progress: nil) api_path = '/storage/buckets/{bucketId}/files' .gsub('{bucketId}', bucket_id) @@ -296,6 +297,7 @@ def create_file(bucket_id:, file_id:, file:, permissions: nil, on_progress: nil) fileId: file_id, file: file, permissions: permissions, + folder: folder, } api_headers = { diff --git a/lib/appwrite/services/tables_db.rb b/lib/appwrite/services/tables_db.rb index 8144d9b7..ed032867 100644 --- a/lib/appwrite/services/tables_db.rb +++ b/lib/appwrite/services/tables_db.rb @@ -47,9 +47,10 @@ def list(queries: nil, search: nil, total: nil) # @param [] enabled Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. # @param [String] specification Database specification. Defaults to `serverless`, which creates the database on the shared pool. Any other value provisions a dedicated database on that specification. # @param [Integer] replicas Number of high availability replicas (0-5) for the dedicated database backing this database. Requires a dedicated `specification`; must be 0 for a serverless database. High availability is enabled when greater than 0. + # @param [String] sync_mode Replication sync mode for the dedicated database backing this database. Requires a dedicated `specification`; the mode is only in force once there is at least one replica. Allowed values: async, sync, quorum. # # @return [Database] - def create(database_id:, name:, enabled: nil, specification: nil, replicas: nil) + def create(database_id:, name:, enabled: nil, specification: nil, replicas: nil, sync_mode: nil) api_path = '/tablesdb' if database_id.nil? @@ -66,6 +67,7 @@ def create(database_id:, name:, enabled: nil, specification: nil, replicas: nil) enabled: enabled, specification: specification, replicas: replicas, + syncMode: sync_mode, } api_headers = { @@ -334,10 +336,12 @@ def get(database_id:) # @param [String] database_id Database ID. # @param [String] name Database name. Max length: 128 chars. # @param [] enabled Is database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. + # @param [String] specification Database specification. Resizing between dedicated specifications changes cpu, memory, storage and the connection ceiling via a rolling cutover with zero downtime. Moving a `serverless` database onto a dedicated specification is a data migration, not a resize. # @param [Integer] replicas Number of high availability replicas (0-5) for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification. High availability is enabled when greater than 0. + # @param [String] sync_mode Replication sync mode for the dedicated database backing this database. Only valid when the database is backed by a dedicated specification; the mode is only in force once there is at least one replica. Allowed values: async, sync, quorum. # # @return [Database] - def update(database_id:, name: nil, enabled: nil, replicas: nil) + def update(database_id:, name: nil, enabled: nil, specification: nil, replicas: nil, sync_mode: nil) api_path = '/tablesdb/{databaseId}' .gsub('{databaseId}', database_id) @@ -348,7 +352,9 @@ def update(database_id:, name: nil, enabled: nil, replicas: nil) api_params = { name: name, enabled: enabled, + specification: specification, replicas: replicas, + syncMode: sync_mode, } api_headers = { @@ -400,7 +406,9 @@ def delete(database_id:) # Trigger a manual failover for a dedicated database with high availability # enabled. Promotes a replica to primary. The failover runs asynchronously; - # poll the database document for status updates. + # poll the database document for status updates. A database left + # mid-operation by a failover that did not finish also accepts this call as a + # repair, provided `targetReplicaId` names the member to promote. # # @param [String] database_id Database ID. # @param [String] target_replica_id Target replica ID to promote. If not specified, the healthiest replica is selected. @@ -434,6 +442,238 @@ def create_failover(database_id:, target_replica_id: nil) end + # List the dedicated migrations for a TablesDB database. A database has at + # most one in-flight migration. + # + # @param [String] database_id Database ID. + # + # @return [DatabaseMigrationList] + def list_migrations(database_id:) + api_path = '/tablesdb/{databaseId}/migrations' + .gsub('{databaseId}', database_id) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + api_params = { + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DatabaseMigrationList + ) + + end + + # Start migrating a serverless TablesDB database onto a dedicated MySQL + # compute. Data is copied to the target while the source stays live, with a + # brief read-only window during cutover. + # + # @param [String] database_id Database ID. + # @param [String] specification Dedicated compute specification to provision as the migration target (e.g. s-2vcpu-4gb). The migration always targets a dedicated compute, so `serverless` is not accepted. + # @param [] auto_cutover Whether to cut over automatically once the copy is verified. When disabled the migration parks at ready_to_cutover and holds there until the cutover is performed manually. + # + # @return [DatabaseMigration] + def create_migration(database_id:, specification:, auto_cutover: nil) + api_path = '/tablesdb/{databaseId}/migrations' + .gsub('{databaseId}', database_id) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if specification.nil? + raise Appwrite::Exception.new('Missing required parameter: "specification"') + end + + api_params = { + specification: specification, + autoCutover: auto_cutover, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DatabaseMigration + ) + + end + + # Get a single dedicated migration for a TablesDB database by its ID. + # + # @param [String] database_id Database ID. + # @param [String] migration_id Migration ID. + # + # @return [DatabaseMigration] + def get_migration(database_id:, migration_id:) + api_path = '/tablesdb/{databaseId}/migrations/{migrationId}' + .gsub('{databaseId}', database_id) + .gsub('{migrationId}', migration_id) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if migration_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "migrationId"') + end + + api_params = { + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DatabaseMigration + ) + + end + + # Abort an in-flight TablesDB dedicated migration. Only allowed before + # cutover; once the migration has cut over it cannot be aborted. + # + # @param [String] database_id Database ID. + # @param [String] migration_id Migration ID. + # + # @return [] + def delete_migration(database_id:, migration_id:) + api_path = '/tablesdb/{databaseId}/migrations/{migrationId}' + .gsub('{databaseId}', database_id) + .gsub('{migrationId}', migration_id) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if migration_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "migrationId"') + end + + api_params = { + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, + ) + + end + + # Cut a verified TablesDB migration over to its dedicated compute. Only + # applies to a migration created with `autoCutover` disabled, which waits at + # `ready_to_cutover` until this is called. The routing flip happens shortly + # after this returns, with a brief read-only window. One call buys one + # attempt: a cutover that fails a check returns the migration to `verifying` + # and parks it again, so call this once more to retry. + # + # @param [String] database_id Database ID. + # @param [String] migration_id Migration ID. + # + # @return [DatabaseMigration] + def cutover_migration(database_id:, migration_id:) + api_path = '/tablesdb/{databaseId}/migrations/{migrationId}/cutover' + .gsub('{databaseId}', database_id) + .gsub('{migrationId}', migration_id) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if migration_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "migrationId"') + end + + api_params = { + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "content-type": 'application/json', + "accept": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DatabaseMigration + ) + + end + + # List the lifecycle operations recorded for a dedicated database, newest + # first. Every provision, update, restore, backup and replication action is + # recorded here with its outcome, including an attempt that was abandoned + # because another worker took over the database. + # + # @param [String] database_id Database ID. + # @param [String] status Filter by operation status. + # @param [Integer] limit Maximum number of operations to return. + # @param [Integer] offset Number of operations to skip. + # + # @return [DedicatedDatabaseOperationList] + def list_operations(database_id:, status: nil, limit: nil, offset: nil) + api_path = '/tablesdb/{databaseId}/operations' + .gsub('{databaseId}', database_id) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + api_params = { + status: status, + limit: limit, + offset: offset, + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::DedicatedDatabaseOperationList + ) + + end + # Get high availability status for a dedicated database. Returns replica # statuses, replication lag, and sync mode. # @@ -548,7 +788,7 @@ def list_tables(database_id:, queries: nil, search: nil, total: nil) # @param [Array] permissions An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). # @param [] row_security Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). # @param [] enabled Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. - # @param [Array] columns Array of column definitions to create. Each column should contain: key (string), type (string: string, integer, float, boolean, datetime, relationship), size (integer, required for string type), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. + # @param [Array] columns Array of column definitions to create. Each column should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, double, boolean, datetime, point, linestring, polygon, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options. # @param [Array] indexes Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional). # # @return [Table] @@ -2276,11 +2516,11 @@ def update_polygon_column(database_id:, table_id:, key:, required:, default: nil # @param [String] database_id Database ID. # @param [String] table_id Table ID. # @param [String] related_table_id Related Table ID. - # @param [RelationshipType] type Relation type + # @param [RelationshipType] type Relationship type. Possible values are: oneToOne, oneToMany, manyToOne, manyToMany. # @param [] two_way Is Two Way? # @param [String] key Column Key. # @param [String] two_way_key Two Way Column Key. - # @param [RelationMutate] on_delete Constraints option + # @param [RelationMutate] on_delete Delete constraint. Possible values are: cascade, restrict, setNull. # # @return [ColumnRelationship] def create_relationship_column(database_id:, table_id:, related_table_id:, type:, two_way: nil, key: nil, two_way_key: nil, on_delete: nil) @@ -2964,7 +3204,7 @@ def delete_column(database_id:, table_id:, key:) # @param [String] database_id Database ID. # @param [String] table_id Table ID. # @param [String] key Column Key. - # @param [RelationMutate] on_delete Constraints option + # @param [RelationMutate] on_delete Delete constraint. Possible values are: cascade, restrict, setNull. # @param [String] new_key New Column Key. # # @return [ColumnRelationship] diff --git a/lib/appwrite/services/users.rb b/lib/appwrite/services/users.rb index 472df7f3..a3c19251 100644 --- a/lib/appwrite/services/users.rb +++ b/lib/appwrite/services/users.rb @@ -908,6 +908,44 @@ def delete_mfa_authenticator(user_id:, type:) end + # Get a custom MFA challenge for a user, including the code to be delivered + # through your own channel. + # + # @param [String] user_id User ID. + # @param [String] challenge_id ID of the challenge. + # + # @return [MfaChallengeSecret] + def get_mfa_challenge(user_id:, challenge_id:) + api_path = '/users/{userId}/mfa/challenges/{challengeId}' + .gsub('{userId}', user_id) + .gsub('{challengeId}', challenge_id) + + if user_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "userId"') + end + + if challenge_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "challengeId"') + end + + api_params = { + } + + api_headers = { + "X-Appwrite-Project": @client.get_config('project'), + "accept": 'application/json', + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::MfaChallengeSecret + ) + + end + # List the factors available on the account to be used as a MFA challange. # # @param [String] user_id User ID.