From 8bb0dd53d34fb94bd95345c5a37af18c62be93fa Mon Sep 17 00:00:00 2001 From: root Date: Mon, 2 Feb 2026 12:06:50 +0000 Subject: [PATCH 1/3] Add array-based enum parameters --- CHANGELOG.md | 4 ++ LICENSE | 2 +- README.md | 4 +- appwrite.gemspec | 4 +- docs/examples/account/create-jwt.md | 4 +- docs/examples/avatars/get-screenshot.md | 8 +-- docs/examples/databases/create-index.md | 2 +- docs/examples/databases/update-collection.md | 2 +- docs/examples/databases/update-document.md | 8 ++- docs/examples/databases/update-documents.md | 8 ++- docs/examples/databases/update.md | 2 +- docs/examples/databases/upsert-document.md | 8 ++- docs/examples/functions/create.md | 2 +- docs/examples/functions/update.md | 2 +- docs/examples/health/get-queue-audits.md | 14 +++++ docs/examples/tablesdb/create-index.md | 2 +- docs/examples/tablesdb/update-row.md | 8 ++- docs/examples/tablesdb/update-rows.md | 8 ++- docs/examples/tablesdb/update-table.md | 2 +- docs/examples/tablesdb/update.md | 2 +- docs/examples/tablesdb/upsert-row.md | 8 ++- docs/examples/teams/create-membership.md | 3 +- docs/examples/teams/update-membership.md | 3 +- lib/appwrite.rb | 8 ++- lib/appwrite/client.rb | 3 +- lib/appwrite/enums/browser_permission.rb | 26 +++++++++ lib/appwrite/enums/deployment_status.rb | 1 + lib/appwrite/enums/name.rb | 1 + lib/appwrite/enums/o_auth_provider.rb | 1 - lib/appwrite/enums/order_by.rb | 8 +++ lib/appwrite/enums/output.rb | 13 ----- lib/appwrite/enums/roles.rb | 9 +++ lib/appwrite/enums/scopes.rb | 61 ++++++++++++++++++++ lib/appwrite/models/bucket.rb | 11 +++- lib/appwrite/models/deployment.rb | 1 + lib/appwrite/models/file.rb | 16 ++++- lib/appwrite/models/health_status_list.rb | 32 ++++++++++ lib/appwrite/query.rb | 34 +++++++++++ lib/appwrite/services/account.rb | 4 +- lib/appwrite/services/avatars.rb | 2 +- lib/appwrite/services/databases.rb | 19 ++---- lib/appwrite/services/health.rb | 37 ++++++++++-- lib/appwrite/services/storage.rb | 12 ++-- lib/appwrite/services/tables_db.rb | 13 +---- 44 files changed, 333 insertions(+), 89 deletions(-) create mode 100644 docs/examples/health/get-queue-audits.md create mode 100644 lib/appwrite/enums/browser_permission.rb create mode 100644 lib/appwrite/enums/order_by.rb delete mode 100644 lib/appwrite/enums/output.rb create mode 100644 lib/appwrite/enums/roles.rb create mode 100644 lib/appwrite/enums/scopes.rb create mode 100644 lib/appwrite/models/health_status_list.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 61856a1..3c19c0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 21.0.0 + +* Add array-based enum parameters (e.g., `permissions: Array`). + ## 20.1.0 * Added ability to create columns and indexes synchronously while creating a table diff --git a/LICENSE b/LICENSE index c1602fc..6f8702b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2025 Appwrite (https://appwrite.io) and individual contributors. +Copyright (c) 2026 Appwrite (https://appwrite.io) and individual contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/README.md b/README.md index 10803b5..dcf2d09 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ # 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.8.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.8.1-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) **This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-ruby/releases).** -Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Ruby SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) +Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Ruby SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) ![Appwrite](https://github.com/appwrite/appwrite/raw/main/public/images/github.png) diff --git a/appwrite.gemspec b/appwrite.gemspec index 9b7c7d8..99ad695 100644 --- a/appwrite.gemspec +++ b/appwrite.gemspec @@ -1,9 +1,9 @@ Gem::Specification.new do |spec| spec.name = 'appwrite' - spec.version = '20.1.0' + spec.version = '21.0.0' spec.license = 'BSD-3-Clause' - spec.summary = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API' + 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' spec.homepage = 'https://appwrite.io/support' spec.email = 'team@appwrite.io' diff --git a/docs/examples/account/create-jwt.md b/docs/examples/account/create-jwt.md index 682c247..481add5 100644 --- a/docs/examples/account/create-jwt.md +++ b/docs/examples/account/create-jwt.md @@ -9,4 +9,6 @@ client = Client.new account = Account.new(client) -result = account.create_jwt() +result = account.create_jwt( + duration: 0 # optional +) diff --git a/docs/examples/avatars/get-screenshot.md b/docs/examples/avatars/get-screenshot.md index 0271404..c69be26 100644 --- a/docs/examples/avatars/get-screenshot.md +++ b/docs/examples/avatars/get-screenshot.md @@ -19,19 +19,19 @@ result = avatars.get_screenshot( viewport_width: 1920, # optional viewport_height: 1080, # optional scale: 2, # optional - theme: Theme::LIGHT, # optional + theme: Theme::DARK, # optional user_agent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15', # optional fullpage: true, # optional locale: 'en-US', # optional - timezone: Timezone::AFRICA_ABIDJAN, # optional + timezone: Timezone::AMERICA_NEW_YORK, # optional latitude: 37.7749, # optional longitude: -122.4194, # optional accuracy: 100, # optional touch: true, # optional - permissions: ["geolocation","notifications"], # optional + permissions: [BrowserPermission::GEOLOCATION, BrowserPermission::NOTIFICATIONS], # optional sleep: 3, # optional width: 800, # optional height: 600, # optional quality: 85, # optional - output: Output::JPG # optional + output: ImageFormat::JPEG # optional ) diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index 18c2f0e..409b2d2 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -16,6 +16,6 @@ result = databases.create_index( key: '', type: IndexType::KEY, attributes: [], - orders: [], # optional + orders: [OrderBy::ASC], # optional lengths: [] # optional ) diff --git a/docs/examples/databases/update-collection.md b/docs/examples/databases/update-collection.md index 6928b9a..0972f66 100644 --- a/docs/examples/databases/update-collection.md +++ b/docs/examples/databases/update-collection.md @@ -14,7 +14,7 @@ databases = Databases.new(client) result = databases.update_collection( database_id: '', collection_id: '', - name: '', + name: '', # optional permissions: [Permission.read(Role.any())], # optional document_security: false, # optional enabled: false # optional diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index 5a1eb56..0f736a1 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -15,7 +15,13 @@ result = databases.update_document( database_id: '', collection_id: '', document_id: '', - data: {}, # optional + data: { + "username" => "walter.obrien", + "email" => "walter.obrien@example.com", + "fullName" => "Walter O'Brien", + "age" => 33, + "isAdmin" => false + }, # optional permissions: [Permission.read(Role.any())], # optional transaction_id: '' # optional ) diff --git a/docs/examples/databases/update-documents.md b/docs/examples/databases/update-documents.md index c85f594..00bdc9a 100644 --- a/docs/examples/databases/update-documents.md +++ b/docs/examples/databases/update-documents.md @@ -12,7 +12,13 @@ databases = Databases.new(client) result = databases.update_documents( database_id: '', collection_id: '', - data: {}, # optional + data: { + "username" => "walter.obrien", + "email" => "walter.obrien@example.com", + "fullName" => "Walter O'Brien", + "age" => 33, + "isAdmin" => false + }, # optional queries: [], # optional transaction_id: '' # optional ) diff --git a/docs/examples/databases/update.md b/docs/examples/databases/update.md index e5c02a1..781004e 100644 --- a/docs/examples/databases/update.md +++ b/docs/examples/databases/update.md @@ -11,6 +11,6 @@ databases = Databases.new(client) result = databases.update( database_id: '', - name: '', + name: '', # optional enabled: false # optional ) diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index fa2f1cd..07c7b7e 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -15,7 +15,13 @@ result = databases.upsert_document( database_id: '', collection_id: '', document_id: '', - data: {}, + data: { + "username" => "walter.obrien", + "email" => "walter.obrien@example.com", + "fullName" => "Walter O'Brien", + "age" => 30, + "isAdmin" => false + }, # optional permissions: [Permission.read(Role.any())], # optional transaction_id: '' # optional ) diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index ce16a2b..e9d9c42 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -22,7 +22,7 @@ result = functions.create( logging: false, # optional entrypoint: '', # optional commands: '', # optional - scopes: [], # optional + scopes: [Scopes::SESSIONS_WRITE], # optional installation_id: '', # optional provider_repository_id: '', # optional provider_branch: '', # optional diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index 91d8436..137c75b 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -22,7 +22,7 @@ result = functions.update( logging: false, # optional entrypoint: '', # optional commands: '', # optional - scopes: [], # optional + scopes: [Scopes::SESSIONS_WRITE], # optional installation_id: '', # optional provider_repository_id: '', # optional provider_branch: '', # optional diff --git a/docs/examples/health/get-queue-audits.md b/docs/examples/health/get-queue-audits.md new file mode 100644 index 0000000..8fc3bc4 --- /dev/null +++ b/docs/examples/health/get-queue-audits.md @@ -0,0 +1,14 @@ +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 + +health = Health.new(client) + +result = health.get_queue_audits( + threshold: null # optional +) diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md index f7c2d0e..6cbf094 100644 --- a/docs/examples/tablesdb/create-index.md +++ b/docs/examples/tablesdb/create-index.md @@ -16,6 +16,6 @@ result = tables_db.create_index( key: '', type: IndexType::KEY, columns: [], - orders: [], # optional + orders: [OrderBy::ASC], # optional lengths: [] # optional ) diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md index fc6fca6..16e8acc 100644 --- a/docs/examples/tablesdb/update-row.md +++ b/docs/examples/tablesdb/update-row.md @@ -15,7 +15,13 @@ result = tables_db.update_row( database_id: '', table_id: '', row_id: '', - data: {}, # optional + data: { + "username" => "walter.obrien", + "email" => "walter.obrien@example.com", + "fullName" => "Walter O'Brien", + "age" => 33, + "isAdmin" => false + }, # optional permissions: [Permission.read(Role.any())], # optional transaction_id: '' # optional ) diff --git a/docs/examples/tablesdb/update-rows.md b/docs/examples/tablesdb/update-rows.md index 7c538a1..c82754d 100644 --- a/docs/examples/tablesdb/update-rows.md +++ b/docs/examples/tablesdb/update-rows.md @@ -12,7 +12,13 @@ tables_db = TablesDB.new(client) result = tables_db.update_rows( database_id: '', table_id: '', - data: {}, # optional + data: { + "username" => "walter.obrien", + "email" => "walter.obrien@example.com", + "fullName" => "Walter O'Brien", + "age" => 33, + "isAdmin" => false + }, # optional queries: [], # optional transaction_id: '' # optional ) diff --git a/docs/examples/tablesdb/update-table.md b/docs/examples/tablesdb/update-table.md index 5385e00..d7cb30f 100644 --- a/docs/examples/tablesdb/update-table.md +++ b/docs/examples/tablesdb/update-table.md @@ -14,7 +14,7 @@ tables_db = TablesDB.new(client) result = tables_db.update_table( database_id: '', table_id: '', - name: '', + name: '', # optional permissions: [Permission.read(Role.any())], # optional row_security: false, # optional enabled: false # optional diff --git a/docs/examples/tablesdb/update.md b/docs/examples/tablesdb/update.md index 787d5c1..f054b24 100644 --- a/docs/examples/tablesdb/update.md +++ b/docs/examples/tablesdb/update.md @@ -11,6 +11,6 @@ tables_db = TablesDB.new(client) result = tables_db.update( database_id: '', - name: '', + name: '', # optional enabled: false # optional ) diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md index 6201834..11210f3 100644 --- a/docs/examples/tablesdb/upsert-row.md +++ b/docs/examples/tablesdb/upsert-row.md @@ -15,7 +15,13 @@ result = tables_db.upsert_row( database_id: '', table_id: '', row_id: '', - data: {}, # optional + data: { + "username" => "walter.obrien", + "email" => "walter.obrien@example.com", + "fullName" => "Walter O'Brien", + "age" => 33, + "isAdmin" => false + }, # optional permissions: [Permission.read(Role.any())], # optional transaction_id: '' # optional ) diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index 6c0faba..f46b9d5 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -1,6 +1,7 @@ require 'appwrite' include Appwrite +include Appwrite::Enums client = Client.new .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -11,7 +12,7 @@ teams = Teams.new(client) result = teams.create_membership( team_id: '', - roles: [], + roles: [Roles::ADMIN], email: 'email@example.com', # optional user_id: '', # optional phone: '+12065550100', # optional diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md index 92b69b1..2c355c0 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -1,6 +1,7 @@ require 'appwrite' include Appwrite +include Appwrite::Enums client = Client.new .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint @@ -12,5 +13,5 @@ teams = Teams.new(client) result = teams.update_membership( team_id: '', membership_id: '', - roles: [] + roles: [Roles::ADMIN] ) diff --git a/lib/appwrite.rb b/lib/appwrite.rb index e3243c4..2b5c519 100644 --- a/lib/appwrite.rb +++ b/lib/appwrite.rb @@ -41,6 +41,7 @@ require_relative 'appwrite/models/currency_list' require_relative 'appwrite/models/phone_list' require_relative 'appwrite/models/variable_list' +require_relative 'appwrite/models/health_status_list' require_relative 'appwrite/models/locale_code_list' require_relative 'appwrite/models/provider_list' require_relative 'appwrite/models/message_list' @@ -144,11 +145,14 @@ require_relative 'appwrite/enums/flag' require_relative 'appwrite/enums/theme' require_relative 'appwrite/enums/timezone' -require_relative 'appwrite/enums/output' +require_relative 'appwrite/enums/browser_permission' +require_relative 'appwrite/enums/image_format' require_relative 'appwrite/enums/relationship_type' require_relative 'appwrite/enums/relation_mutate' require_relative 'appwrite/enums/index_type' +require_relative 'appwrite/enums/order_by' require_relative 'appwrite/enums/runtime' +require_relative 'appwrite/enums/scopes' require_relative 'appwrite/enums/template_reference_type' require_relative 'appwrite/enums/vcs_reference_type' require_relative 'appwrite/enums/deployment_download_type' @@ -161,7 +165,7 @@ require_relative 'appwrite/enums/adapter' require_relative 'appwrite/enums/compression' require_relative 'appwrite/enums/image_gravity' -require_relative 'appwrite/enums/image_format' +require_relative 'appwrite/enums/roles' require_relative 'appwrite/enums/password_hash' require_relative 'appwrite/enums/messaging_provider_type' require_relative 'appwrite/enums/database_type' diff --git a/lib/appwrite/client.rb b/lib/appwrite/client.rb index bc09ceb..1e69ad0 100644 --- a/lib/appwrite/client.rb +++ b/lib/appwrite/client.rb @@ -15,7 +15,7 @@ def initialize 'x-sdk-name'=> 'Ruby', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'ruby', - 'x-sdk-version'=> '20.1.0', + 'x-sdk-version'=> '21.0.0', 'X-Appwrite-Response-Format' => '1.8.0' } @endpoint = 'https://cloud.appwrite.io/v1' @@ -123,7 +123,6 @@ def set_self_signed(self_signed = true) self end - # Add Header # # @param [String] key The key for the header to add diff --git a/lib/appwrite/enums/browser_permission.rb b/lib/appwrite/enums/browser_permission.rb new file mode 100644 index 0000000..e8dabec --- /dev/null +++ b/lib/appwrite/enums/browser_permission.rb @@ -0,0 +1,26 @@ +module Appwrite + module Enums + module BrowserPermission + GEOLOCATION = 'geolocation' + CAMERA = 'camera' + MICROPHONE = 'microphone' + NOTIFICATIONS = 'notifications' + MIDI = 'midi' + PUSH = 'push' + CLIPBOARD_READ = 'clipboard-read' + CLIPBOARD_WRITE = 'clipboard-write' + PAYMENT_HANDLER = 'payment-handler' + USB = 'usb' + BLUETOOTH = 'bluetooth' + ACCELEROMETER = 'accelerometer' + GYROSCOPE = 'gyroscope' + MAGNETOMETER = 'magnetometer' + AMBIENT_LIGHT_SENSOR = 'ambient-light-sensor' + BACKGROUND_SYNC = 'background-sync' + PERSISTENT_STORAGE = 'persistent-storage' + SCREEN_WAKE_LOCK = 'screen-wake-lock' + WEB_SHARE = 'web-share' + XR_SPATIAL_TRACKING = 'xr-spatial-tracking' + end + end +end \ No newline at end of file diff --git a/lib/appwrite/enums/deployment_status.rb b/lib/appwrite/enums/deployment_status.rb index 192ca6b..92442c0 100644 --- a/lib/appwrite/enums/deployment_status.rb +++ b/lib/appwrite/enums/deployment_status.rb @@ -5,6 +5,7 @@ module DeploymentStatus PROCESSING = 'processing' BUILDING = 'building' READY = 'ready' + CANCELED = 'canceled' FAILED = 'failed' end end diff --git a/lib/appwrite/enums/name.rb b/lib/appwrite/enums/name.rb index 0e18cbb..21c2b72 100644 --- a/lib/appwrite/enums/name.rb +++ b/lib/appwrite/enums/name.rb @@ -11,6 +11,7 @@ module Name V1_WEBHOOKS = 'v1-webhooks' V1_CERTIFICATES = 'v1-certificates' V1_BUILDS = 'v1-builds' + V1_SCREENSHOTS = 'v1-screenshots' V1_MESSAGING = 'v1-messaging' V1_MIGRATIONS = 'v1-migrations' end diff --git a/lib/appwrite/enums/o_auth_provider.rb b/lib/appwrite/enums/o_auth_provider.rb index 8621b65..9a75276 100644 --- a/lib/appwrite/enums/o_auth_provider.rb +++ b/lib/appwrite/enums/o_auth_provider.rb @@ -40,7 +40,6 @@ module OAuthProvider YANDEX = 'yandex' ZOHO = 'zoho' ZOOM = 'zoom' - MOCK = 'mock' end end end \ No newline at end of file diff --git a/lib/appwrite/enums/order_by.rb b/lib/appwrite/enums/order_by.rb new file mode 100644 index 0000000..053de36 --- /dev/null +++ b/lib/appwrite/enums/order_by.rb @@ -0,0 +1,8 @@ +module Appwrite + module Enums + module OrderBy + ASC = 'asc' + DESC = 'desc' + end + end +end \ No newline at end of file diff --git a/lib/appwrite/enums/output.rb b/lib/appwrite/enums/output.rb deleted file mode 100644 index fa255a8..0000000 --- a/lib/appwrite/enums/output.rb +++ /dev/null @@ -1,13 +0,0 @@ -module Appwrite - module Enums - module Output - JPG = 'jpg' - JPEG = 'jpeg' - PNG = 'png' - WEBP = 'webp' - HEIC = 'heic' - AVIF = 'avif' - GIF = 'gif' - end - end -end \ No newline at end of file diff --git a/lib/appwrite/enums/roles.rb b/lib/appwrite/enums/roles.rb new file mode 100644 index 0000000..7090e68 --- /dev/null +++ b/lib/appwrite/enums/roles.rb @@ -0,0 +1,9 @@ +module Appwrite + module Enums + module Roles + ADMIN = 'admin' + DEVELOPER = 'developer' + OWNER = 'owner' + end + end +end \ No newline at end of file diff --git a/lib/appwrite/enums/scopes.rb b/lib/appwrite/enums/scopes.rb new file mode 100644 index 0000000..55d17a4 --- /dev/null +++ b/lib/appwrite/enums/scopes.rb @@ -0,0 +1,61 @@ +module Appwrite + module Enums + module Scopes + SESSIONS_WRITE = 'sessions.write' + USERS_READ = 'users.read' + USERS_WRITE = 'users.write' + TEAMS_READ = 'teams.read' + TEAMS_WRITE = 'teams.write' + DATABASES_READ = 'databases.read' + DATABASES_WRITE = 'databases.write' + COLLECTIONS_READ = 'collections.read' + COLLECTIONS_WRITE = 'collections.write' + TABLES_READ = 'tables.read' + TABLES_WRITE = 'tables.write' + ATTRIBUTES_READ = 'attributes.read' + ATTRIBUTES_WRITE = 'attributes.write' + COLUMNS_READ = 'columns.read' + COLUMNS_WRITE = 'columns.write' + INDEXES_READ = 'indexes.read' + INDEXES_WRITE = 'indexes.write' + DOCUMENTS_READ = 'documents.read' + DOCUMENTS_WRITE = 'documents.write' + ROWS_READ = 'rows.read' + ROWS_WRITE = 'rows.write' + FILES_READ = 'files.read' + FILES_WRITE = 'files.write' + BUCKETS_READ = 'buckets.read' + BUCKETS_WRITE = 'buckets.write' + FUNCTIONS_READ = 'functions.read' + FUNCTIONS_WRITE = 'functions.write' + SITES_READ = 'sites.read' + SITES_WRITE = 'sites.write' + LOG_READ = 'log.read' + LOG_WRITE = 'log.write' + EXECUTION_READ = 'execution.read' + EXECUTION_WRITE = 'execution.write' + LOCALE_READ = 'locale.read' + AVATARS_READ = 'avatars.read' + HEALTH_READ = 'health.read' + PROVIDERS_READ = 'providers.read' + PROVIDERS_WRITE = 'providers.write' + MESSAGES_READ = 'messages.read' + MESSAGES_WRITE = 'messages.write' + TOPICS_READ = 'topics.read' + TOPICS_WRITE = 'topics.write' + SUBSCRIBERS_READ = 'subscribers.read' + SUBSCRIBERS_WRITE = 'subscribers.write' + TARGETS_READ = 'targets.read' + TARGETS_WRITE = 'targets.write' + RULES_READ = 'rules.read' + RULES_WRITE = 'rules.write' + MIGRATIONS_READ = 'migrations.read' + MIGRATIONS_WRITE = 'migrations.write' + VCS_READ = 'vcs.read' + VCS_WRITE = 'vcs.write' + ASSISTANT_READ = 'assistant.read' + TOKENS_READ = 'tokens.read' + TOKENS_WRITE = 'tokens.write' + end + end +end \ No newline at end of file diff --git a/lib/appwrite/models/bucket.rb b/lib/appwrite/models/bucket.rb index 42f3df2..ab45b57 100644 --- a/lib/appwrite/models/bucket.rb +++ b/lib/appwrite/models/bucket.rb @@ -16,6 +16,7 @@ class Bucket attr_reader :encryption attr_reader :antivirus attr_reader :transformations + attr_reader :total_size def initialize( id:, @@ -30,7 +31,8 @@ def initialize( compression:, encryption:, antivirus:, - transformations: + transformations:, + total_size: ) @id = id @created_at = created_at @@ -45,6 +47,7 @@ def initialize( @encryption = encryption @antivirus = antivirus @transformations = transformations + @total_size = total_size end def self.from(map:) @@ -61,7 +64,8 @@ def self.from(map:) compression: map["compression"], encryption: map["encryption"], antivirus: map["antivirus"], - transformations: map["transformations"] + transformations: map["transformations"], + total_size: map["totalSize"] ) end @@ -79,7 +83,8 @@ def to_map "compression": @compression, "encryption": @encryption, "antivirus": @antivirus, - "transformations": @transformations + "transformations": @transformations, + "totalSize": @total_size } end end diff --git a/lib/appwrite/models/deployment.rb b/lib/appwrite/models/deployment.rb index 8311235..2dc1835 100644 --- a/lib/appwrite/models/deployment.rb +++ b/lib/appwrite/models/deployment.rb @@ -161,6 +161,7 @@ def validate_status(status) Appwrite::Enums::DeploymentStatus::PROCESSING, Appwrite::Enums::DeploymentStatus::BUILDING, Appwrite::Enums::DeploymentStatus::READY, + Appwrite::Enums::DeploymentStatus::CANCELED, Appwrite::Enums::DeploymentStatus::FAILED, ] diff --git a/lib/appwrite/models/file.rb b/lib/appwrite/models/file.rb index fa58884..53a964e 100644 --- a/lib/appwrite/models/file.rb +++ b/lib/appwrite/models/file.rb @@ -14,6 +14,8 @@ class File attr_reader :size_original attr_reader :chunks_total attr_reader :chunks_uploaded + attr_reader :encryption + attr_reader :compression def initialize( id:, @@ -26,7 +28,9 @@ def initialize( mime_type:, size_original:, chunks_total:, - chunks_uploaded: + chunks_uploaded:, + encryption:, + compression: ) @id = id @bucket_id = bucket_id @@ -39,6 +43,8 @@ def initialize( @size_original = size_original @chunks_total = chunks_total @chunks_uploaded = chunks_uploaded + @encryption = encryption + @compression = compression end def self.from(map:) @@ -53,7 +59,9 @@ def self.from(map:) mime_type: map["mimeType"], size_original: map["sizeOriginal"], chunks_total: map["chunksTotal"], - chunks_uploaded: map["chunksUploaded"] + chunks_uploaded: map["chunksUploaded"], + encryption: map["encryption"], + compression: map["compression"] ) end @@ -69,7 +77,9 @@ def to_map "mimeType": @mime_type, "sizeOriginal": @size_original, "chunksTotal": @chunks_total, - "chunksUploaded": @chunks_uploaded + "chunksUploaded": @chunks_uploaded, + "encryption": @encryption, + "compression": @compression } end end diff --git a/lib/appwrite/models/health_status_list.rb b/lib/appwrite/models/health_status_list.rb new file mode 100644 index 0000000..256c5d9 --- /dev/null +++ b/lib/appwrite/models/health_status_list.rb @@ -0,0 +1,32 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class HealthStatusList + attr_reader :total + attr_reader :statuses + + def initialize( + total:, + statuses: + ) + @total = total + @statuses = statuses + end + + def self.from(map:) + HealthStatusList.new( + total: map["total"], + statuses: map["statuses"].map { |it| HealthStatus.from(map: it) } + ) + end + + def to_map + { + "total": @total, + "statuses": @statuses.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/query.rb b/lib/appwrite/query.rb index 10da764..cc58d5c 100644 --- a/lib/appwrite/query.rb +++ b/lib/appwrite/query.rb @@ -36,6 +36,15 @@ def not_equal(attribute, value) return Query.new("notEqual", attribute, value).to_s end + # Filter resources where attribute matches a regular expression pattern. + # + # @param attribute [String] The attribute to filter on. + # @param pattern [String] The regular expression pattern to match. + # @return [String] The query string. + def regex(attribute, pattern) + return Query.new("regex", attribute, pattern).to_s + end + def less_than(attribute, value) return Query.new("lessThan", attribute, value).to_s end @@ -60,6 +69,22 @@ def is_not_null(attribute) return Query.new("isNotNull", attribute, nil).to_s end + # Filter resources where the specified attributes exist. + # + # @param attributes [Array] The list of attributes that must exist. + # @return [String] The query string. + def exists(attributes) + return Query.new("exists", nil, attributes).to_s + end + + # Filter resources where the specified attributes do not exist. + # + # @param attributes [Array] The list of attributes that must not exist. + # @return [String] The query string. + def not_exists(attributes) + return Query.new("notExists", nil, attributes).to_s + end + def between(attribute, start, ending) return Query.new("between", attribute, [start, ending]).to_s end @@ -164,6 +189,15 @@ def and(queries) return Query.new("and", nil, queries.map { |query| JSON.parse(query) }).to_s end + # Filter array elements where at least one element matches all the specified queries. + # + # @param attribute [String] The attribute containing the array to filter on. + # @param queries [Array] The list of query strings to match against array elements. + # @return [String] The query string. + def elem_match(attribute, queries) + return Query.new("elemMatch", attribute, queries.map { |query| JSON.parse(query) }).to_s + end + def distance_equal(attribute, values, distance, meters = true) return Query.new("distanceEqual", attribute, [[values, distance, meters]]).to_s end diff --git a/lib/appwrite/services/account.rb b/lib/appwrite/services/account.rb index f291d9c..fd0c6c3 100644 --- a/lib/appwrite/services/account.rb +++ b/lib/appwrite/services/account.rb @@ -180,12 +180,14 @@ def delete_identity(identity_id:) # 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() + def create_jwt(duration: nil) api_path = '/account/jwts' api_params = { + duration: duration, } api_headers = { diff --git a/lib/appwrite/services/avatars.rb b/lib/appwrite/services/avatars.rb index fba6855..e100c0c 100644 --- a/lib/appwrite/services/avatars.rb +++ b/lib/appwrite/services/avatars.rb @@ -312,7 +312,7 @@ def get_qr(text:, size: nil, margin: nil, download: nil) # @param [Integer] width Output image width. Pass 0 to use original width, or an integer between 1 to 2000. Defaults to 0 (original width). # @param [Integer] height Output image height. Pass 0 to use original height, or an integer between 1 to 2000. Defaults to 0 (original height). # @param [Integer] quality Screenshot quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. - # @param [Output] output Output format type (jpeg, jpg, png, gif and webp). + # @param [ImageFormat] output Output format type (jpeg, jpg, png, gif and webp). # # @return [] def get_screenshot(url:, headers: nil, viewport_width: nil, viewport_height: nil, scale: nil, theme: nil, user_agent: nil, fullpage: nil, locale: nil, timezone: nil, latitude: nil, longitude: nil, accuracy: nil, touch: nil, permissions: nil, sleep: nil, width: nil, height: nil, quality: nil, output: nil) diff --git a/lib/appwrite/services/databases.rb b/lib/appwrite/services/databases.rb index 0c01f9a..5cd5e68 100644 --- a/lib/appwrite/services/databases.rb +++ b/lib/appwrite/services/databases.rb @@ -291,7 +291,7 @@ def get(database_id:) # @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. # # @return [Database] - def update(database_id:, name:, enabled: nil) + def update(database_id:, name: nil, enabled: nil) api_path = '/databases/{databaseId}' .gsub('{databaseId}', database_id) @@ -299,10 +299,6 @@ def update(database_id:, name:, enabled: nil) raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if name.nil? - raise Appwrite::Exception.new('Missing required parameter: "name"') - end - api_params = { name: name, enabled: enabled, @@ -499,7 +495,7 @@ def get_collection(database_id:, collection_id:) # @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. # # @return [Collection] - def update_collection(database_id:, collection_id:, name:, permissions: nil, document_security: nil, enabled: nil) + def update_collection(database_id:, collection_id:, name: nil, permissions: nil, document_security: nil, enabled: nil) api_path = '/databases/{databaseId}/collections/{collectionId}' .gsub('{databaseId}', database_id) .gsub('{collectionId}', collection_id) @@ -512,10 +508,6 @@ def update_collection(database_id:, collection_id:, name:, permissions: nil, doc raise Appwrite::Exception.new('Missing required parameter: "collectionId"') end - if name.nil? - raise Appwrite::Exception.new('Missing required parameter: "name"') - end - api_params = { name: name, permissions: permissions, @@ -2108,6 +2100,7 @@ def get_attribute(database_id:, collection_id:, key:) path: api_path, headers: api_headers, params: api_params, + response_type: Models::AttributeBoolean ) end @@ -2557,7 +2550,7 @@ def get_document(database_id:, collection_id:, document_id:, queries: nil, trans # @param [String] transaction_id Transaction ID for staging the operation. # # @return [Document] - def upsert_document(database_id:, collection_id:, document_id:, data:, permissions: nil, transaction_id: nil) + def upsert_document(database_id:, collection_id:, document_id:, data: nil, permissions: nil, transaction_id: nil) api_path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' .gsub('{databaseId}', database_id) .gsub('{collectionId}', collection_id) @@ -2575,10 +2568,6 @@ def upsert_document(database_id:, collection_id:, document_id:, data:, permissio raise Appwrite::Exception.new('Missing required parameter: "documentId"') end - if data.nil? - raise Appwrite::Exception.new('Missing required parameter: "data"') - end - api_params = { data: data, permissions: permissions, diff --git a/lib/appwrite/services/health.rb b/lib/appwrite/services/health.rb index 1375b8b..57712e1 100644 --- a/lib/appwrite/services/health.rb +++ b/lib/appwrite/services/health.rb @@ -55,7 +55,7 @@ def get_antivirus() # successful. # # - # @return [HealthStatus] + # @return [HealthStatusList] def get_cache() api_path = '/health/cache' @@ -70,7 +70,7 @@ def get_cache() path: api_path, headers: api_headers, params: api_params, - response_type: Models::HealthStatus + response_type: Models::HealthStatusList ) end @@ -101,7 +101,7 @@ def get_certificate(domain: nil) # Check the Appwrite database servers are up and connection is successful. # # - # @return [HealthStatus] + # @return [HealthStatusList] def get_db() api_path = '/health/db' @@ -116,14 +116,14 @@ def get_db() path: api_path, headers: api_headers, params: api_params, - response_type: Models::HealthStatus + response_type: Models::HealthStatusList ) end # Check the Appwrite pub-sub servers are up and connection is successful. # # - # @return [HealthStatus] + # @return [HealthStatusList] def get_pub_sub() api_path = '/health/pubsub' @@ -138,7 +138,32 @@ def get_pub_sub() path: api_path, headers: api_headers, params: api_params, - response_type: Models::HealthStatus + response_type: Models::HealthStatusList + ) + end + + # Get the number of audit logs that are waiting to be processed in the + # Appwrite internal queue server. + # + # @param [Integer] threshold Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. + # + # @return [HealthQueue] + def get_queue_audits(threshold: nil) + api_path = '/health/queue/audits' + + api_params = { + threshold: threshold, + } + + api_headers = { + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::HealthQueue ) end diff --git a/lib/appwrite/services/storage.rb b/lib/appwrite/services/storage.rb index a5323d1..0e02927 100644 --- a/lib/appwrite/services/storage.rb +++ b/lib/appwrite/services/storage.rb @@ -45,7 +45,7 @@ def list_buckets(queries: nil, search: nil, total: nil) # @param [] enabled Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. # @param [Integer] maximum_file_size Maximum file size allowed in bytes. Maximum allowed value is 30MB. # @param [Array] allowed_file_extensions Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. - # @param [Compression] compression Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + # @param [Compression] compression Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled # @param [] encryption Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled # @param [] antivirus Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled # @param [] transformations Are image transformations enabled? @@ -127,7 +127,7 @@ def get_bucket(bucket_id:) # @param [] enabled Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. # @param [Integer] maximum_file_size Maximum file size allowed in bytes. Maximum allowed value is 30MB. # @param [Array] allowed_file_extensions Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. - # @param [Compression] compression Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled + # @param [Compression] compression Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled # @param [] encryption Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled # @param [] antivirus Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled # @param [] transformations Are image transformations enabled? @@ -337,10 +337,10 @@ def get_file(bucket_id:, file_id:) # Update a file by its unique ID. Only users with write permissions have # access to update this resource. # - # @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 [String] file_id File unique ID. - # @param [String] name Name of the file - # @param [Array] permissions An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + # @param [String] bucket_id Bucket unique ID. + # @param [String] file_id File ID. + # @param [String] name File name. + # @param [Array] permissions An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). # # @return [File] def update_file(bucket_id:, file_id:, name: nil, permissions: nil) diff --git a/lib/appwrite/services/tables_db.rb b/lib/appwrite/services/tables_db.rb index 4c657ab..74151c5 100644 --- a/lib/appwrite/services/tables_db.rb +++ b/lib/appwrite/services/tables_db.rb @@ -279,7 +279,7 @@ def get(database_id:) # @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. # # @return [Database] - def update(database_id:, name:, enabled: nil) + def update(database_id:, name: nil, enabled: nil) api_path = '/tablesdb/{databaseId}' .gsub('{databaseId}', database_id) @@ -287,10 +287,6 @@ def update(database_id:, name:, enabled: nil) raise Appwrite::Exception.new('Missing required parameter: "databaseId"') end - if name.nil? - raise Appwrite::Exception.new('Missing required parameter: "name"') - end - api_params = { name: name, enabled: enabled, @@ -472,7 +468,7 @@ def get_table(database_id:, table_id:) # @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. # # @return [Table] - def update_table(database_id:, table_id:, name:, permissions: nil, row_security: nil, enabled: nil) + def update_table(database_id:, table_id:, name: nil, permissions: nil, row_security: nil, enabled: nil) api_path = '/tablesdb/{databaseId}/tables/{tableId}' .gsub('{databaseId}', database_id) .gsub('{tableId}', table_id) @@ -485,10 +481,6 @@ def update_table(database_id:, table_id:, name:, permissions: nil, row_security: raise Appwrite::Exception.new('Missing required parameter: "tableId"') end - if name.nil? - raise Appwrite::Exception.new('Missing required parameter: "name"') - end - api_params = { name: name, permissions: permissions, @@ -1996,6 +1988,7 @@ def get_column(database_id:, table_id:, key:) path: api_path, headers: api_headers, params: api_params, + response_type: Models::ColumnBoolean ) end From 4e9075f5cd60302641e0e6454a079410e314e272 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 2 Feb 2026 12:31:18 +0000 Subject: [PATCH 2/3] update changelog etc --- CHANGELOG.md | 2 + .../databases/create-longtext-attribute.md | 19 + .../databases/create-mediumtext-attribute.md | 19 + .../databases/create-text-attribute.md | 19 + .../databases/create-varchar-attribute.md | 20 + .../databases/update-longtext-attribute.md | 19 + .../databases/update-mediumtext-attribute.md | 19 + .../databases/update-text-attribute.md | 19 + .../databases/update-varchar-attribute.md | 20 + .../tablesdb/create-longtext-column.md | 19 + .../tablesdb/create-mediumtext-column.md | 19 + docs/examples/tablesdb/create-text-column.md | 19 + .../tablesdb/create-varchar-column.md | 20 + .../tablesdb/update-longtext-column.md | 19 + .../tablesdb/update-mediumtext-column.md | 19 + docs/examples/tablesdb/update-text-column.md | 19 + .../tablesdb/update-varchar-column.md | 20 + lib/appwrite.rb | 8 + lib/appwrite/models/attribute_longtext.rb | 86 ++++ lib/appwrite/models/attribute_mediumtext.rb | 86 ++++ lib/appwrite/models/attribute_text.rb | 86 ++++ lib/appwrite/models/attribute_varchar.rb | 91 ++++ lib/appwrite/models/column_longtext.rb | 86 ++++ lib/appwrite/models/column_mediumtext.rb | 86 ++++ lib/appwrite/models/column_text.rb | 86 ++++ lib/appwrite/models/column_varchar.rb | 91 ++++ lib/appwrite/services/databases.rb | 444 +++++++++++++++++ lib/appwrite/services/tables_db.rb | 450 ++++++++++++++++++ 28 files changed, 1910 insertions(+) create mode 100644 docs/examples/databases/create-longtext-attribute.md create mode 100644 docs/examples/databases/create-mediumtext-attribute.md create mode 100644 docs/examples/databases/create-text-attribute.md create mode 100644 docs/examples/databases/create-varchar-attribute.md create mode 100644 docs/examples/databases/update-longtext-attribute.md create mode 100644 docs/examples/databases/update-mediumtext-attribute.md create mode 100644 docs/examples/databases/update-text-attribute.md create mode 100644 docs/examples/databases/update-varchar-attribute.md create mode 100644 docs/examples/tablesdb/create-longtext-column.md create mode 100644 docs/examples/tablesdb/create-mediumtext-column.md create mode 100644 docs/examples/tablesdb/create-text-column.md create mode 100644 docs/examples/tablesdb/create-varchar-column.md create mode 100644 docs/examples/tablesdb/update-longtext-column.md create mode 100644 docs/examples/tablesdb/update-mediumtext-column.md create mode 100644 docs/examples/tablesdb/update-text-column.md create mode 100644 docs/examples/tablesdb/update-varchar-column.md create mode 100644 lib/appwrite/models/attribute_longtext.rb create mode 100644 lib/appwrite/models/attribute_mediumtext.rb create mode 100644 lib/appwrite/models/attribute_text.rb create mode 100644 lib/appwrite/models/attribute_varchar.rb create mode 100644 lib/appwrite/models/column_longtext.rb create mode 100644 lib/appwrite/models/column_mediumtext.rb create mode 100644 lib/appwrite/models/column_text.rb create mode 100644 lib/appwrite/models/column_varchar.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c19c0f..9ce9b3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ## 21.0.0 * Add array-based enum parameters (e.g., `permissions: Array`). +* Breaking change: `Output` enum has been removed; use `ImageFormat` instead. +* Add `getQueueAudits` support to `Health` service. ## 20.1.0 diff --git a/docs/examples/databases/create-longtext-attribute.md b/docs/examples/databases/create-longtext-attribute.md new file mode 100644 index 0000000..eac095d --- /dev/null +++ b/docs/examples/databases/create-longtext-attribute.md @@ -0,0 +1,19 @@ +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 + +databases = Databases.new(client) + +result = databases.create_longtext_attribute( + database_id: '', + collection_id: '', + key: '', + required: false, + default: '', # optional + array: false # optional +) diff --git a/docs/examples/databases/create-mediumtext-attribute.md b/docs/examples/databases/create-mediumtext-attribute.md new file mode 100644 index 0000000..d5e1107 --- /dev/null +++ b/docs/examples/databases/create-mediumtext-attribute.md @@ -0,0 +1,19 @@ +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 + +databases = Databases.new(client) + +result = databases.create_mediumtext_attribute( + database_id: '', + collection_id: '', + key: '', + required: false, + default: '', # optional + array: false # optional +) diff --git a/docs/examples/databases/create-text-attribute.md b/docs/examples/databases/create-text-attribute.md new file mode 100644 index 0000000..01aa127 --- /dev/null +++ b/docs/examples/databases/create-text-attribute.md @@ -0,0 +1,19 @@ +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 + +databases = Databases.new(client) + +result = databases.create_text_attribute( + database_id: '', + collection_id: '', + key: '', + required: false, + default: '', # optional + array: false # optional +) diff --git a/docs/examples/databases/create-varchar-attribute.md b/docs/examples/databases/create-varchar-attribute.md new file mode 100644 index 0000000..a7c5318 --- /dev/null +++ b/docs/examples/databases/create-varchar-attribute.md @@ -0,0 +1,20 @@ +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 + +databases = Databases.new(client) + +result = databases.create_varchar_attribute( + database_id: '', + collection_id: '', + key: '', + size: 1, + required: false, + default: '', # optional + array: false # optional +) diff --git a/docs/examples/databases/update-longtext-attribute.md b/docs/examples/databases/update-longtext-attribute.md new file mode 100644 index 0000000..694a0a3 --- /dev/null +++ b/docs/examples/databases/update-longtext-attribute.md @@ -0,0 +1,19 @@ +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 + +databases = Databases.new(client) + +result = databases.update_longtext_attribute( + database_id: '', + collection_id: '', + key: '', + required: false, + default: '', + new_key: '' # optional +) diff --git a/docs/examples/databases/update-mediumtext-attribute.md b/docs/examples/databases/update-mediumtext-attribute.md new file mode 100644 index 0000000..b60d615 --- /dev/null +++ b/docs/examples/databases/update-mediumtext-attribute.md @@ -0,0 +1,19 @@ +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 + +databases = Databases.new(client) + +result = databases.update_mediumtext_attribute( + database_id: '', + collection_id: '', + key: '', + required: false, + default: '', + new_key: '' # optional +) diff --git a/docs/examples/databases/update-text-attribute.md b/docs/examples/databases/update-text-attribute.md new file mode 100644 index 0000000..e75621b --- /dev/null +++ b/docs/examples/databases/update-text-attribute.md @@ -0,0 +1,19 @@ +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 + +databases = Databases.new(client) + +result = databases.update_text_attribute( + database_id: '', + collection_id: '', + key: '', + required: false, + default: '', + new_key: '' # optional +) diff --git a/docs/examples/databases/update-varchar-attribute.md b/docs/examples/databases/update-varchar-attribute.md new file mode 100644 index 0000000..1ba5df4 --- /dev/null +++ b/docs/examples/databases/update-varchar-attribute.md @@ -0,0 +1,20 @@ +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 + +databases = Databases.new(client) + +result = databases.update_varchar_attribute( + database_id: '', + collection_id: '', + key: '', + required: false, + default: '', + size: 1, # optional + new_key: '' # optional +) diff --git a/docs/examples/tablesdb/create-longtext-column.md b/docs/examples/tablesdb/create-longtext-column.md new file mode 100644 index 0000000..080d393 --- /dev/null +++ b/docs/examples/tablesdb/create-longtext-column.md @@ -0,0 +1,19 @@ +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_longtext_column( + database_id: '', + table_id: '', + key: '', + required: false, + default: '', # optional + array: false # optional +) diff --git a/docs/examples/tablesdb/create-mediumtext-column.md b/docs/examples/tablesdb/create-mediumtext-column.md new file mode 100644 index 0000000..8e67af2 --- /dev/null +++ b/docs/examples/tablesdb/create-mediumtext-column.md @@ -0,0 +1,19 @@ +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_mediumtext_column( + database_id: '', + table_id: '', + key: '', + required: false, + default: '', # optional + array: false # optional +) diff --git a/docs/examples/tablesdb/create-text-column.md b/docs/examples/tablesdb/create-text-column.md new file mode 100644 index 0000000..21100cc --- /dev/null +++ b/docs/examples/tablesdb/create-text-column.md @@ -0,0 +1,19 @@ +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_text_column( + database_id: '', + table_id: '', + key: '', + required: false, + default: '', # optional + array: false # optional +) diff --git a/docs/examples/tablesdb/create-varchar-column.md b/docs/examples/tablesdb/create-varchar-column.md new file mode 100644 index 0000000..8699da7 --- /dev/null +++ b/docs/examples/tablesdb/create-varchar-column.md @@ -0,0 +1,20 @@ +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_varchar_column( + database_id: '', + table_id: '', + key: '', + size: 1, + required: false, + default: '', # optional + array: false # optional +) diff --git a/docs/examples/tablesdb/update-longtext-column.md b/docs/examples/tablesdb/update-longtext-column.md new file mode 100644 index 0000000..0fe87ae --- /dev/null +++ b/docs/examples/tablesdb/update-longtext-column.md @@ -0,0 +1,19 @@ +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.update_longtext_column( + database_id: '', + table_id: '', + key: '', + required: false, + default: '', + new_key: '' # optional +) diff --git a/docs/examples/tablesdb/update-mediumtext-column.md b/docs/examples/tablesdb/update-mediumtext-column.md new file mode 100644 index 0000000..b9ab3e5 --- /dev/null +++ b/docs/examples/tablesdb/update-mediumtext-column.md @@ -0,0 +1,19 @@ +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.update_mediumtext_column( + database_id: '', + table_id: '', + key: '', + required: false, + default: '', + new_key: '' # optional +) diff --git a/docs/examples/tablesdb/update-text-column.md b/docs/examples/tablesdb/update-text-column.md new file mode 100644 index 0000000..ef189a2 --- /dev/null +++ b/docs/examples/tablesdb/update-text-column.md @@ -0,0 +1,19 @@ +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.update_text_column( + database_id: '', + table_id: '', + key: '', + required: false, + default: '', + new_key: '' # optional +) diff --git a/docs/examples/tablesdb/update-varchar-column.md b/docs/examples/tablesdb/update-varchar-column.md new file mode 100644 index 0000000..fcf8337 --- /dev/null +++ b/docs/examples/tablesdb/update-varchar-column.md @@ -0,0 +1,20 @@ +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.update_varchar_column( + database_id: '', + table_id: '', + key: '', + required: false, + default: '', + size: 1, # optional + new_key: '' # optional +) diff --git a/lib/appwrite.rb b/lib/appwrite.rb index 2b5c519..9740768 100644 --- a/lib/appwrite.rb +++ b/lib/appwrite.rb @@ -66,6 +66,10 @@ require_relative 'appwrite/models/attribute_point' require_relative 'appwrite/models/attribute_line' require_relative 'appwrite/models/attribute_polygon' +require_relative 'appwrite/models/attribute_varchar' +require_relative 'appwrite/models/attribute_text' +require_relative 'appwrite/models/attribute_mediumtext' +require_relative 'appwrite/models/attribute_longtext' require_relative 'appwrite/models/table' require_relative 'appwrite/models/column_list' require_relative 'appwrite/models/column_string' @@ -81,6 +85,10 @@ require_relative 'appwrite/models/column_point' require_relative 'appwrite/models/column_line' require_relative 'appwrite/models/column_polygon' +require_relative 'appwrite/models/column_varchar' +require_relative 'appwrite/models/column_text' +require_relative 'appwrite/models/column_mediumtext' +require_relative 'appwrite/models/column_longtext' require_relative 'appwrite/models/index' require_relative 'appwrite/models/column_index' require_relative 'appwrite/models/row' diff --git a/lib/appwrite/models/attribute_longtext.rb b/lib/appwrite/models/attribute_longtext.rb new file mode 100644 index 0000000..65990d8 --- /dev/null +++ b/lib/appwrite/models/attribute_longtext.rb @@ -0,0 +1,86 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class AttributeLongtext + attr_reader :key + attr_reader :type + attr_reader :status + attr_reader :error + attr_reader :required + attr_reader :array + attr_reader :created_at + attr_reader :updated_at + attr_reader :default + + def initialize( + key:, + type:, + status:, + error:, + required:, + array: , + created_at:, + updated_at:, + default: + ) + @key = key + @type = type + @status = validate_status(status) + @error = error + @required = required + @array = array + @created_at = created_at + @updated_at = updated_at + @default = default + end + + def self.from(map:) + AttributeLongtext.new( + key: map["key"], + type: map["type"], + status: map["status"], + error: map["error"], + required: map["required"], + array: map["array"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + default: map["default"] + ) + end + + def to_map + { + "key": @key, + "type": @type, + "status": @status, + "error": @error, + "required": @required, + "array": @array, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "default": @default + } + end + + private + + def validate_status(status) + valid_status = [ + Appwrite::Enums::AttributeStatus::AVAILABLE, + Appwrite::Enums::AttributeStatus::PROCESSING, + Appwrite::Enums::AttributeStatus::DELETING, + Appwrite::Enums::AttributeStatus::STUCK, + Appwrite::Enums::AttributeStatus::FAILED, + ] + + unless valid_status.include?(status) + raise ArgumentError, "Invalid " + status + ". Must be one of: " + valid_status.join(', ') + end + + status + end + + end + end +end diff --git a/lib/appwrite/models/attribute_mediumtext.rb b/lib/appwrite/models/attribute_mediumtext.rb new file mode 100644 index 0000000..22f296f --- /dev/null +++ b/lib/appwrite/models/attribute_mediumtext.rb @@ -0,0 +1,86 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class AttributeMediumtext + attr_reader :key + attr_reader :type + attr_reader :status + attr_reader :error + attr_reader :required + attr_reader :array + attr_reader :created_at + attr_reader :updated_at + attr_reader :default + + def initialize( + key:, + type:, + status:, + error:, + required:, + array: , + created_at:, + updated_at:, + default: + ) + @key = key + @type = type + @status = validate_status(status) + @error = error + @required = required + @array = array + @created_at = created_at + @updated_at = updated_at + @default = default + end + + def self.from(map:) + AttributeMediumtext.new( + key: map["key"], + type: map["type"], + status: map["status"], + error: map["error"], + required: map["required"], + array: map["array"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + default: map["default"] + ) + end + + def to_map + { + "key": @key, + "type": @type, + "status": @status, + "error": @error, + "required": @required, + "array": @array, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "default": @default + } + end + + private + + def validate_status(status) + valid_status = [ + Appwrite::Enums::AttributeStatus::AVAILABLE, + Appwrite::Enums::AttributeStatus::PROCESSING, + Appwrite::Enums::AttributeStatus::DELETING, + Appwrite::Enums::AttributeStatus::STUCK, + Appwrite::Enums::AttributeStatus::FAILED, + ] + + unless valid_status.include?(status) + raise ArgumentError, "Invalid " + status + ". Must be one of: " + valid_status.join(', ') + end + + status + end + + end + end +end diff --git a/lib/appwrite/models/attribute_text.rb b/lib/appwrite/models/attribute_text.rb new file mode 100644 index 0000000..91c0b2f --- /dev/null +++ b/lib/appwrite/models/attribute_text.rb @@ -0,0 +1,86 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class AttributeText + attr_reader :key + attr_reader :type + attr_reader :status + attr_reader :error + attr_reader :required + attr_reader :array + attr_reader :created_at + attr_reader :updated_at + attr_reader :default + + def initialize( + key:, + type:, + status:, + error:, + required:, + array: , + created_at:, + updated_at:, + default: + ) + @key = key + @type = type + @status = validate_status(status) + @error = error + @required = required + @array = array + @created_at = created_at + @updated_at = updated_at + @default = default + end + + def self.from(map:) + AttributeText.new( + key: map["key"], + type: map["type"], + status: map["status"], + error: map["error"], + required: map["required"], + array: map["array"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + default: map["default"] + ) + end + + def to_map + { + "key": @key, + "type": @type, + "status": @status, + "error": @error, + "required": @required, + "array": @array, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "default": @default + } + end + + private + + def validate_status(status) + valid_status = [ + Appwrite::Enums::AttributeStatus::AVAILABLE, + Appwrite::Enums::AttributeStatus::PROCESSING, + Appwrite::Enums::AttributeStatus::DELETING, + Appwrite::Enums::AttributeStatus::STUCK, + Appwrite::Enums::AttributeStatus::FAILED, + ] + + unless valid_status.include?(status) + raise ArgumentError, "Invalid " + status + ". Must be one of: " + valid_status.join(', ') + end + + status + end + + end + end +end diff --git a/lib/appwrite/models/attribute_varchar.rb b/lib/appwrite/models/attribute_varchar.rb new file mode 100644 index 0000000..40f9e67 --- /dev/null +++ b/lib/appwrite/models/attribute_varchar.rb @@ -0,0 +1,91 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class AttributeVarchar + attr_reader :key + attr_reader :type + attr_reader :status + attr_reader :error + attr_reader :required + attr_reader :array + attr_reader :created_at + attr_reader :updated_at + attr_reader :size + attr_reader :default + + def initialize( + key:, + type:, + status:, + error:, + required:, + array: , + created_at:, + updated_at:, + size:, + default: + ) + @key = key + @type = type + @status = validate_status(status) + @error = error + @required = required + @array = array + @created_at = created_at + @updated_at = updated_at + @size = size + @default = default + end + + def self.from(map:) + AttributeVarchar.new( + key: map["key"], + type: map["type"], + status: map["status"], + error: map["error"], + required: map["required"], + array: map["array"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + size: map["size"], + default: map["default"] + ) + end + + def to_map + { + "key": @key, + "type": @type, + "status": @status, + "error": @error, + "required": @required, + "array": @array, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "size": @size, + "default": @default + } + end + + private + + def validate_status(status) + valid_status = [ + Appwrite::Enums::AttributeStatus::AVAILABLE, + Appwrite::Enums::AttributeStatus::PROCESSING, + Appwrite::Enums::AttributeStatus::DELETING, + Appwrite::Enums::AttributeStatus::STUCK, + Appwrite::Enums::AttributeStatus::FAILED, + ] + + unless valid_status.include?(status) + raise ArgumentError, "Invalid " + status + ". Must be one of: " + valid_status.join(', ') + end + + status + end + + end + end +end diff --git a/lib/appwrite/models/column_longtext.rb b/lib/appwrite/models/column_longtext.rb new file mode 100644 index 0000000..5e2357a --- /dev/null +++ b/lib/appwrite/models/column_longtext.rb @@ -0,0 +1,86 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class ColumnLongtext + attr_reader :key + attr_reader :type + attr_reader :status + attr_reader :error + attr_reader :required + attr_reader :array + attr_reader :created_at + attr_reader :updated_at + attr_reader :default + + def initialize( + key:, + type:, + status:, + error:, + required:, + array: , + created_at:, + updated_at:, + default: + ) + @key = key + @type = type + @status = validate_status(status) + @error = error + @required = required + @array = array + @created_at = created_at + @updated_at = updated_at + @default = default + end + + def self.from(map:) + ColumnLongtext.new( + key: map["key"], + type: map["type"], + status: map["status"], + error: map["error"], + required: map["required"], + array: map["array"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + default: map["default"] + ) + end + + def to_map + { + "key": @key, + "type": @type, + "status": @status, + "error": @error, + "required": @required, + "array": @array, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "default": @default + } + end + + private + + def validate_status(status) + valid_status = [ + Appwrite::Enums::ColumnStatus::AVAILABLE, + Appwrite::Enums::ColumnStatus::PROCESSING, + Appwrite::Enums::ColumnStatus::DELETING, + Appwrite::Enums::ColumnStatus::STUCK, + Appwrite::Enums::ColumnStatus::FAILED, + ] + + unless valid_status.include?(status) + raise ArgumentError, "Invalid " + status + ". Must be one of: " + valid_status.join(', ') + end + + status + end + + end + end +end diff --git a/lib/appwrite/models/column_mediumtext.rb b/lib/appwrite/models/column_mediumtext.rb new file mode 100644 index 0000000..a7d7180 --- /dev/null +++ b/lib/appwrite/models/column_mediumtext.rb @@ -0,0 +1,86 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class ColumnMediumtext + attr_reader :key + attr_reader :type + attr_reader :status + attr_reader :error + attr_reader :required + attr_reader :array + attr_reader :created_at + attr_reader :updated_at + attr_reader :default + + def initialize( + key:, + type:, + status:, + error:, + required:, + array: , + created_at:, + updated_at:, + default: + ) + @key = key + @type = type + @status = validate_status(status) + @error = error + @required = required + @array = array + @created_at = created_at + @updated_at = updated_at + @default = default + end + + def self.from(map:) + ColumnMediumtext.new( + key: map["key"], + type: map["type"], + status: map["status"], + error: map["error"], + required: map["required"], + array: map["array"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + default: map["default"] + ) + end + + def to_map + { + "key": @key, + "type": @type, + "status": @status, + "error": @error, + "required": @required, + "array": @array, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "default": @default + } + end + + private + + def validate_status(status) + valid_status = [ + Appwrite::Enums::ColumnStatus::AVAILABLE, + Appwrite::Enums::ColumnStatus::PROCESSING, + Appwrite::Enums::ColumnStatus::DELETING, + Appwrite::Enums::ColumnStatus::STUCK, + Appwrite::Enums::ColumnStatus::FAILED, + ] + + unless valid_status.include?(status) + raise ArgumentError, "Invalid " + status + ". Must be one of: " + valid_status.join(', ') + end + + status + end + + end + end +end diff --git a/lib/appwrite/models/column_text.rb b/lib/appwrite/models/column_text.rb new file mode 100644 index 0000000..e90d60a --- /dev/null +++ b/lib/appwrite/models/column_text.rb @@ -0,0 +1,86 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class ColumnText + attr_reader :key + attr_reader :type + attr_reader :status + attr_reader :error + attr_reader :required + attr_reader :array + attr_reader :created_at + attr_reader :updated_at + attr_reader :default + + def initialize( + key:, + type:, + status:, + error:, + required:, + array: , + created_at:, + updated_at:, + default: + ) + @key = key + @type = type + @status = validate_status(status) + @error = error + @required = required + @array = array + @created_at = created_at + @updated_at = updated_at + @default = default + end + + def self.from(map:) + ColumnText.new( + key: map["key"], + type: map["type"], + status: map["status"], + error: map["error"], + required: map["required"], + array: map["array"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + default: map["default"] + ) + end + + def to_map + { + "key": @key, + "type": @type, + "status": @status, + "error": @error, + "required": @required, + "array": @array, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "default": @default + } + end + + private + + def validate_status(status) + valid_status = [ + Appwrite::Enums::ColumnStatus::AVAILABLE, + Appwrite::Enums::ColumnStatus::PROCESSING, + Appwrite::Enums::ColumnStatus::DELETING, + Appwrite::Enums::ColumnStatus::STUCK, + Appwrite::Enums::ColumnStatus::FAILED, + ] + + unless valid_status.include?(status) + raise ArgumentError, "Invalid " + status + ". Must be one of: " + valid_status.join(', ') + end + + status + end + + end + end +end diff --git a/lib/appwrite/models/column_varchar.rb b/lib/appwrite/models/column_varchar.rb new file mode 100644 index 0000000..c6c2e5a --- /dev/null +++ b/lib/appwrite/models/column_varchar.rb @@ -0,0 +1,91 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class ColumnVarchar + attr_reader :key + attr_reader :type + attr_reader :status + attr_reader :error + attr_reader :required + attr_reader :array + attr_reader :created_at + attr_reader :updated_at + attr_reader :size + attr_reader :default + + def initialize( + key:, + type:, + status:, + error:, + required:, + array: , + created_at:, + updated_at:, + size:, + default: + ) + @key = key + @type = type + @status = validate_status(status) + @error = error + @required = required + @array = array + @created_at = created_at + @updated_at = updated_at + @size = size + @default = default + end + + def self.from(map:) + ColumnVarchar.new( + key: map["key"], + type: map["type"], + status: map["status"], + error: map["error"], + required: map["required"], + array: map["array"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + size: map["size"], + default: map["default"] + ) + end + + def to_map + { + "key": @key, + "type": @type, + "status": @status, + "error": @error, + "required": @required, + "array": @array, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "size": @size, + "default": @default + } + end + + private + + def validate_status(status) + valid_status = [ + Appwrite::Enums::ColumnStatus::AVAILABLE, + Appwrite::Enums::ColumnStatus::PROCESSING, + Appwrite::Enums::ColumnStatus::DELETING, + Appwrite::Enums::ColumnStatus::STUCK, + Appwrite::Enums::ColumnStatus::FAILED, + ] + + unless valid_status.include?(status) + raise ArgumentError, "Invalid " + status + ". Must be one of: " + valid_status.join(', ') + end + + status + end + + end + end +end diff --git a/lib/appwrite/services/databases.rb b/lib/appwrite/services/databases.rb index 5cd5e68..bbaefaf 100644 --- a/lib/appwrite/services/databases.rb +++ b/lib/appwrite/services/databases.rb @@ -1547,6 +1547,224 @@ def update_line_attribute(database_id:, collection_id:, key:, required:, default ) end + # Create a longtext attribute. + # + # + # @param [String] database_id Database ID. + # @param [String] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + # @param [String] key Attribute Key. + # @param [] required Is attribute required? + # @param [String] default Default value for attribute when not provided. Cannot be set when attribute is required. + # @param [] array Is attribute an array? + # + # @return [AttributeLongtext] + def create_longtext_attribute(database_id:, collection_id:, key:, required:, default: nil, array: nil) + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/longtext' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if collection_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "collectionId"') + end + + if key.nil? + raise Appwrite::Exception.new('Missing required parameter: "key"') + end + + if required.nil? + raise Appwrite::Exception.new('Missing required parameter: "required"') + end + + api_params = { + key: key, + required: required, + default: default, + array: array, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::AttributeLongtext + ) + end + + # Update a longtext attribute. Changing the `default` value will not update + # already existing documents. + # + # + # @param [String] database_id Database ID. + # @param [String] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + # @param [String] key Attribute Key. + # @param [] required Is attribute required? + # @param [String] default Default value for attribute when not provided. Cannot be set when attribute is required. + # @param [String] new_key New Attribute Key. + # + # @return [AttributeLongtext] + def update_longtext_attribute(database_id:, collection_id:, key:, required:, default:, new_key: nil) + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/longtext/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if collection_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "collectionId"') + end + + if key.nil? + raise Appwrite::Exception.new('Missing required parameter: "key"') + end + + if required.nil? + raise Appwrite::Exception.new('Missing required parameter: "required"') + end + + if default.nil? + raise Appwrite::Exception.new('Missing required parameter: "default"') + end + + api_params = { + required: required, + default: default, + newKey: new_key, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::AttributeLongtext + ) + end + + # Create a mediumtext attribute. + # + # + # @param [String] database_id Database ID. + # @param [String] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + # @param [String] key Attribute Key. + # @param [] required Is attribute required? + # @param [String] default Default value for attribute when not provided. Cannot be set when attribute is required. + # @param [] array Is attribute an array? + # + # @return [AttributeMediumtext] + def create_mediumtext_attribute(database_id:, collection_id:, key:, required:, default: nil, array: nil) + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if collection_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "collectionId"') + end + + if key.nil? + raise Appwrite::Exception.new('Missing required parameter: "key"') + end + + if required.nil? + raise Appwrite::Exception.new('Missing required parameter: "required"') + end + + api_params = { + key: key, + required: required, + default: default, + array: array, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::AttributeMediumtext + ) + end + + # Update a mediumtext attribute. Changing the `default` value will not update + # already existing documents. + # + # + # @param [String] database_id Database ID. + # @param [String] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + # @param [String] key Attribute Key. + # @param [] required Is attribute required? + # @param [String] default Default value for attribute when not provided. Cannot be set when attribute is required. + # @param [String] new_key New Attribute Key. + # + # @return [AttributeMediumtext] + def update_mediumtext_attribute(database_id:, collection_id:, key:, required:, default:, new_key: nil) + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if collection_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "collectionId"') + end + + if key.nil? + raise Appwrite::Exception.new('Missing required parameter: "key"') + end + + if required.nil? + raise Appwrite::Exception.new('Missing required parameter: "required"') + end + + if default.nil? + raise Appwrite::Exception.new('Missing required parameter: "default"') + end + + api_params = { + required: required, + default: default, + newKey: new_key, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::AttributeMediumtext + ) + end + # # @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createPointColumn` instead. # @@ -1946,6 +2164,115 @@ def update_string_attribute(database_id:, collection_id:, key:, required:, defau ) end + # Create a text attribute. + # + # + # @param [String] database_id Database ID. + # @param [String] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + # @param [String] key Attribute Key. + # @param [] required Is attribute required? + # @param [String] default Default value for attribute when not provided. Cannot be set when attribute is required. + # @param [] array Is attribute an array? + # + # @return [AttributeText] + def create_text_attribute(database_id:, collection_id:, key:, required:, default: nil, array: nil) + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/text' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if collection_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "collectionId"') + end + + if key.nil? + raise Appwrite::Exception.new('Missing required parameter: "key"') + end + + if required.nil? + raise Appwrite::Exception.new('Missing required parameter: "required"') + end + + api_params = { + key: key, + required: required, + default: default, + array: array, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::AttributeText + ) + end + + # Update a text attribute. Changing the `default` value will not update + # already existing documents. + # + # + # @param [String] database_id Database ID. + # @param [String] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + # @param [String] key Attribute Key. + # @param [] required Is attribute required? + # @param [String] default Default value for attribute when not provided. Cannot be set when attribute is required. + # @param [String] new_key New Attribute Key. + # + # @return [AttributeText] + def update_text_attribute(database_id:, collection_id:, key:, required:, default:, new_key: nil) + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/text/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if collection_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "collectionId"') + end + + if key.nil? + raise Appwrite::Exception.new('Missing required parameter: "key"') + end + + if required.nil? + raise Appwrite::Exception.new('Missing required parameter: "required"') + end + + if default.nil? + raise Appwrite::Exception.new('Missing required parameter: "default"') + end + + api_params = { + required: required, + default: default, + newKey: new_key, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::AttributeText + ) + end + # # @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createUrlColumn` instead. # @@ -2061,6 +2388,123 @@ def update_url_attribute(database_id:, collection_id:, key:, required:, default: ) end + # Create a varchar attribute. + # + # + # @param [String] database_id Database ID. + # @param [String] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + # @param [String] key Attribute Key. + # @param [Integer] size Attribute size for varchar attributes, in number of characters. Maximum size is 16381. + # @param [] required Is attribute required? + # @param [String] default Default value for attribute when not provided. Cannot be set when attribute is required. + # @param [] array Is attribute an array? + # + # @return [AttributeVarchar] + def create_varchar_attribute(database_id:, collection_id:, key:, size:, required:, default: nil, array: nil) + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/varchar' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if collection_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "collectionId"') + end + + if key.nil? + raise Appwrite::Exception.new('Missing required parameter: "key"') + end + + if size.nil? + raise Appwrite::Exception.new('Missing required parameter: "size"') + end + + if required.nil? + raise Appwrite::Exception.new('Missing required parameter: "required"') + end + + api_params = { + key: key, + size: size, + required: required, + default: default, + array: array, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::AttributeVarchar + ) + end + + # Update a varchar attribute. Changing the `default` value will not update + # already existing documents. + # + # + # @param [String] database_id Database ID. + # @param [String] collection_id Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). + # @param [String] key Attribute Key. + # @param [] required Is attribute required? + # @param [String] default Default value for attribute when not provided. Cannot be set when attribute is required. + # @param [Integer] size Maximum size of the varchar attribute. + # @param [String] new_key New Attribute Key. + # + # @return [AttributeVarchar] + def update_varchar_attribute(database_id:, collection_id:, key:, required:, default:, size: nil, new_key: nil) + api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/varchar/{key}' + .gsub('{databaseId}', database_id) + .gsub('{collectionId}', collection_id) + .gsub('{key}', key) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if collection_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "collectionId"') + end + + if key.nil? + raise Appwrite::Exception.new('Missing required parameter: "key"') + end + + if required.nil? + raise Appwrite::Exception.new('Missing required parameter: "required"') + end + + if default.nil? + raise Appwrite::Exception.new('Missing required parameter: "default"') + end + + api_params = { + required: required, + default: default, + size: size, + newKey: new_key, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::AttributeVarchar + ) + end + # # @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.getColumn` instead. # diff --git a/lib/appwrite/services/tables_db.rb b/lib/appwrite/services/tables_db.rb index 74151c5..eaf3e9f 100644 --- a/lib/appwrite/services/tables_db.rb +++ b/lib/appwrite/services/tables_db.rb @@ -1465,6 +1465,224 @@ def update_line_column(database_id:, table_id:, key:, required:, default: nil, n ) end + # Create a longtext column. + # + # + # @param [String] database_id Database ID. + # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + # @param [String] key Column Key. + # @param [] required Is column required? + # @param [String] default Default value for column when not provided. Cannot be set when column is required. + # @param [] array Is column an array? + # + # @return [ColumnLongtext] + def create_longtext_column(database_id:, table_id:, key:, required:, default: nil, array: nil) + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if table_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "tableId"') + end + + if key.nil? + raise Appwrite::Exception.new('Missing required parameter: "key"') + end + + if required.nil? + raise Appwrite::Exception.new('Missing required parameter: "required"') + end + + api_params = { + key: key, + required: required, + default: default, + array: array, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::ColumnLongtext + ) + end + + # Update a longtext column. Changing the `default` value will not update + # already existing rows. + # + # + # @param [String] database_id Database ID. + # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + # @param [String] key Column Key. + # @param [] required Is column required? + # @param [String] default Default value for column when not provided. Cannot be set when column is required. + # @param [String] new_key New Column Key. + # + # @return [ColumnLongtext] + def update_longtext_column(database_id:, table_id:, key:, required:, default:, new_key: nil) + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if table_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "tableId"') + end + + if key.nil? + raise Appwrite::Exception.new('Missing required parameter: "key"') + end + + if required.nil? + raise Appwrite::Exception.new('Missing required parameter: "required"') + end + + if default.nil? + raise Appwrite::Exception.new('Missing required parameter: "default"') + end + + api_params = { + required: required, + default: default, + newKey: new_key, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::ColumnLongtext + ) + end + + # Create a mediumtext column. + # + # + # @param [String] database_id Database ID. + # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + # @param [String] key Column Key. + # @param [] required Is column required? + # @param [String] default Default value for column when not provided. Cannot be set when column is required. + # @param [] array Is column an array? + # + # @return [ColumnMediumtext] + def create_mediumtext_column(database_id:, table_id:, key:, required:, default: nil, array: nil) + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if table_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "tableId"') + end + + if key.nil? + raise Appwrite::Exception.new('Missing required parameter: "key"') + end + + if required.nil? + raise Appwrite::Exception.new('Missing required parameter: "required"') + end + + api_params = { + key: key, + required: required, + default: default, + array: array, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::ColumnMediumtext + ) + end + + # Update a mediumtext column. Changing the `default` value will not update + # already existing rows. + # + # + # @param [String] database_id Database ID. + # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + # @param [String] key Column Key. + # @param [] required Is column required? + # @param [String] default Default value for column when not provided. Cannot be set when column is required. + # @param [String] new_key New Column Key. + # + # @return [ColumnMediumtext] + def update_mediumtext_column(database_id:, table_id:, key:, required:, default:, new_key: nil) + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if table_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "tableId"') + end + + if key.nil? + raise Appwrite::Exception.new('Missing required parameter: "key"') + end + + if required.nil? + raise Appwrite::Exception.new('Missing required parameter: "required"') + end + + if default.nil? + raise Appwrite::Exception.new('Missing required parameter: "default"') + end + + api_params = { + required: required, + default: default, + newKey: new_key, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::ColumnMediumtext + ) + end + # Create a geometric point column. # # @param [String] database_id Database ID. @@ -1724,6 +1942,9 @@ def create_relationship_column(database_id:, table_id:, related_table_id:, type: ) end + # + # @deprecated This API has been deprecated since 1.9.0. Please use `TablesDB.createTextColumn` instead. + # # Create a string column. # # @@ -1784,6 +2005,9 @@ def create_string_column(database_id:, table_id:, key:, size:, required:, defaul ) end + # + # @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.updateTextColumn` instead. + # # Update a string column. Changing the `default` value will not update # already existing rows. # @@ -1843,6 +2067,115 @@ def update_string_column(database_id:, table_id:, key:, required:, default:, siz ) end + # Create a text column. + # + # + # @param [String] database_id Database ID. + # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + # @param [String] key Column Key. + # @param [] required Is column required? + # @param [String] default Default value for column when not provided. Cannot be set when column is required. + # @param [] array Is column an array? + # + # @return [ColumnText] + def create_text_column(database_id:, table_id:, key:, required:, default: nil, array: nil) + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/text' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if table_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "tableId"') + end + + if key.nil? + raise Appwrite::Exception.new('Missing required parameter: "key"') + end + + if required.nil? + raise Appwrite::Exception.new('Missing required parameter: "required"') + end + + api_params = { + key: key, + required: required, + default: default, + array: array, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::ColumnText + ) + end + + # Update a text column. Changing the `default` value will not update already + # existing rows. + # + # + # @param [String] database_id Database ID. + # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + # @param [String] key Column Key. + # @param [] required Is column required? + # @param [String] default Default value for column when not provided. Cannot be set when column is required. + # @param [String] new_key New Column Key. + # + # @return [ColumnText] + def update_text_column(database_id:, table_id:, key:, required:, default:, new_key: nil) + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/text/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if table_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "tableId"') + end + + if key.nil? + raise Appwrite::Exception.new('Missing required parameter: "key"') + end + + if required.nil? + raise Appwrite::Exception.new('Missing required parameter: "required"') + end + + if default.nil? + raise Appwrite::Exception.new('Missing required parameter: "default"') + end + + api_params = { + required: required, + default: default, + newKey: new_key, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::ColumnText + ) + end + # Create a URL column. # # @@ -1952,6 +2285,123 @@ def update_url_column(database_id:, table_id:, key:, required:, default:, new_ke ) end + # Create a varchar column. + # + # + # @param [String] database_id Database ID. + # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + # @param [String] key Column Key. + # @param [Integer] size Column size for varchar columns, in number of characters. Maximum size is 16381. + # @param [] required Is column required? + # @param [String] default Default value for column when not provided. Cannot be set when column is required. + # @param [] array Is column an array? + # + # @return [ColumnVarchar] + def create_varchar_column(database_id:, table_id:, key:, size:, required:, default: nil, array: nil) + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if table_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "tableId"') + end + + if key.nil? + raise Appwrite::Exception.new('Missing required parameter: "key"') + end + + if size.nil? + raise Appwrite::Exception.new('Missing required parameter: "size"') + end + + if required.nil? + raise Appwrite::Exception.new('Missing required parameter: "required"') + end + + api_params = { + key: key, + size: size, + required: required, + default: default, + array: array, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::ColumnVarchar + ) + end + + # Update a varchar column. Changing the `default` value will not update + # already existing rows. + # + # + # @param [String] database_id Database ID. + # @param [String] table_id Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). + # @param [String] key Column Key. + # @param [] required Is column required? + # @param [String] default Default value for column when not provided. Cannot be set when column is required. + # @param [Integer] size Maximum size of the varchar column. + # @param [String] new_key New Column Key. + # + # @return [ColumnVarchar] + def update_varchar_column(database_id:, table_id:, key:, required:, default:, size: nil, new_key: nil) + api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar/{key}' + .gsub('{databaseId}', database_id) + .gsub('{tableId}', table_id) + .gsub('{key}', key) + + if database_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "databaseId"') + end + + if table_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "tableId"') + end + + if key.nil? + raise Appwrite::Exception.new('Missing required parameter: "key"') + end + + if required.nil? + raise Appwrite::Exception.new('Missing required parameter: "required"') + end + + if default.nil? + raise Appwrite::Exception.new('Missing required parameter: "default"') + end + + api_params = { + required: required, + default: default, + size: size, + newKey: new_key, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::ColumnVarchar + ) + end + # Get column by ID. # # @param [String] database_id Database ID. From 8692a52113418f7ad69d848fbe7dd848b1a5ac6b Mon Sep 17 00:00:00 2001 From: root Date: Mon, 2 Feb 2026 12:36:18 +0000 Subject: [PATCH 3/3] update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ce9b3a..58a3cba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Add array-based enum parameters (e.g., `permissions: Array`). * Breaking change: `Output` enum has been removed; use `ImageFormat` instead. * Add `getQueueAudits` support to `Health` service. +* Add longtext/mediumtext/text/varchar attribute and column helpers to `Databases` and `TablesDB` services. ## 20.1.0 @@ -59,4 +60,4 @@ ## 14.0.0 -* Fix pong response & chunked upload +* Fix pong response & chunked upload \ No newline at end of file