diff --git a/CHANGELOG.md b/CHANGELOG.md index bfa4691..fc2429f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Change Log +## 23.0.0 + +* [BREAKING] Renamed Webhook model fields: `security` → `tls`, `httpUser` → `authUsername`, `httpPass` → `authPassword`, `signatureKey` → `secret` +* [BREAKING] Renamed Webhook service parameters to match: `security` → `tls`, `httpUser` → `authUsername`, `httpPass` → `authPassword` +* [BREAKING] Renamed `Webhooks#update_signature` to `Webhooks#update_secret` with new optional `secret` parameter +* Added `Client#get_headers` method to retrieve request headers +* Added `secret` parameter to Webhook create and update methods +* Added `x` OAuth provider to `OAuthProvider` enum +* Added `userType` field to `Log` model +* Added `purge` parameter to `update_collection` and `update_table` for cache invalidation +* Added Project service: platform CRUD, key CRUD, protocol/service status management +* Added new models: `Key`, `KeyList`, `Project`, `DevKey`, `MockNumber`, `AuthProvider`, `PlatformAndroid`, `PlatformApple`, `PlatformLinux`, `PlatformList`, `PlatformWeb`, `PlatformWindows`, `BillingLimits`, `Block` +* Added new enums: `PlatformType`, `ProtocolId`, `ServiceId` +* Updated `BuildRuntime`, `Runtime` enums with `dart-3.11` and `flutter-3.41` +* Updated `Scopes` enum with `keys_read`, `keys_write`, `platforms_read`, `platforms_write` +* Updated `X-Appwrite-Response-Format` header to `1.9.1` +* Updated TTL description for list caching in Databases and TablesDB + ## 22.0.0 * [BREAKING] Changed `$sequence` type from `int` to `string` for rows and documents diff --git a/README.md b/README.md index 309889a..096a012 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Appwrite Ruby SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-ruby.svg?style=flat-square) -![Version](https://img.shields.io/badge/api%20version-1.9.0-blue.svg?style=flat-square) +![Version](https://img.shields.io/badge/api%20version-1.9.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) diff --git a/appwrite.gemspec b/appwrite.gemspec index 7550e35..ee3eab3 100644 --- a/appwrite.gemspec +++ b/appwrite.gemspec @@ -1,7 +1,7 @@ Gem::Specification.new do |spec| spec.name = 'appwrite' - spec.version = '22.0.0' + spec.version = '23.0.0' spec.license = 'BSD-3-Clause' spec.summary = 'Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API' spec.author = 'Appwrite Team' diff --git a/docs/examples/databases/create-datetime-attribute.md b/docs/examples/databases/create-datetime-attribute.md index efc8f8e..603230e 100644 --- a/docs/examples/databases/create-datetime-attribute.md +++ b/docs/examples/databases/create-datetime-attribute.md @@ -15,7 +15,7 @@ result = databases.create_datetime_attribute( collection_id: '', key: '', required: false, - default: '', # optional + default: '2020-10-15T06:38:00.000+00:00', # optional array: false # optional ) ``` diff --git a/docs/examples/databases/update-collection.md b/docs/examples/databases/update-collection.md index 2472fd4..a3c1900 100644 --- a/docs/examples/databases/update-collection.md +++ b/docs/examples/databases/update-collection.md @@ -18,6 +18,7 @@ result = databases.update_collection( name: '', # optional permissions: [Permission.read(Role.any())], # optional document_security: false, # optional - enabled: false # optional + enabled: false, # optional + purge: false # optional ) ``` diff --git a/docs/examples/databases/update-datetime-attribute.md b/docs/examples/databases/update-datetime-attribute.md index ff5eb59..342314a 100644 --- a/docs/examples/databases/update-datetime-attribute.md +++ b/docs/examples/databases/update-datetime-attribute.md @@ -15,7 +15,7 @@ result = databases.update_datetime_attribute( collection_id: '', key: '', required: false, - default: '', + default: '2020-10-15T06:38:00.000+00:00', new_key: '' # optional ) ``` diff --git a/docs/examples/messaging/create-email.md b/docs/examples/messaging/create-email.md index c960655..e661a8a 100644 --- a/docs/examples/messaging/create-email.md +++ b/docs/examples/messaging/create-email.md @@ -22,6 +22,6 @@ result = messaging.create_email( attachments: [], # optional draft: false, # optional html: false, # optional - scheduled_at: '' # optional + scheduled_at: '2020-10-15T06:38:00.000+00:00' # optional ) ``` diff --git a/docs/examples/messaging/create-push.md b/docs/examples/messaging/create-push.md index e2e6c97..beff763 100644 --- a/docs/examples/messaging/create-push.md +++ b/docs/examples/messaging/create-push.md @@ -27,7 +27,7 @@ result = messaging.create_push( tag: '', # optional badge: null, # optional draft: false, # optional - scheduled_at: '', # optional + scheduled_at: '2020-10-15T06:38:00.000+00:00', # optional content_available: false, # optional critical: false, # optional priority: MessagePriority::NORMAL # optional diff --git a/docs/examples/messaging/create-sms.md b/docs/examples/messaging/create-sms.md index 00e3ec9..c59279f 100644 --- a/docs/examples/messaging/create-sms.md +++ b/docs/examples/messaging/create-sms.md @@ -17,6 +17,6 @@ result = messaging.create_sms( users: [], # optional targets: [], # optional draft: false, # optional - scheduled_at: '' # optional + scheduled_at: '2020-10-15T06:38:00.000+00:00' # optional ) ``` diff --git a/docs/examples/messaging/update-email.md b/docs/examples/messaging/update-email.md index 24cc136..727fdbc 100644 --- a/docs/examples/messaging/update-email.md +++ b/docs/examples/messaging/update-email.md @@ -21,7 +21,7 @@ result = messaging.update_email( html: false, # optional cc: [], # optional bcc: [], # optional - scheduled_at: '', # optional + scheduled_at: '2020-10-15T06:38:00.000+00:00', # optional attachments: [] # optional ) ``` diff --git a/docs/examples/messaging/update-push.md b/docs/examples/messaging/update-push.md index 9f522ca..e00176b 100644 --- a/docs/examples/messaging/update-push.md +++ b/docs/examples/messaging/update-push.md @@ -27,7 +27,7 @@ result = messaging.update_push( tag: '', # optional badge: null, # optional draft: false, # optional - scheduled_at: '', # optional + scheduled_at: '2020-10-15T06:38:00.000+00:00', # optional content_available: false, # optional critical: false, # optional priority: MessagePriority::NORMAL # optional diff --git a/docs/examples/messaging/update-sms.md b/docs/examples/messaging/update-sms.md index 55cfb5d..233ffb8 100644 --- a/docs/examples/messaging/update-sms.md +++ b/docs/examples/messaging/update-sms.md @@ -17,6 +17,6 @@ result = messaging.update_sms( targets: [], # optional content: '', # optional draft: false, # optional - scheduled_at: '' # optional + scheduled_at: '2020-10-15T06:38:00.000+00:00' # optional ) ``` diff --git a/docs/examples/project/create-android-platform.md b/docs/examples/project/create-android-platform.md new file mode 100644 index 0000000..31c9725 --- /dev/null +++ b/docs/examples/project/create-android-platform.md @@ -0,0 +1,18 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +project = Project.new(client) + +result = project.create_android_platform( + platform_id: '', + name: '', + application_id: '' +) +``` diff --git a/docs/examples/project/create-apple-platform.md b/docs/examples/project/create-apple-platform.md new file mode 100644 index 0000000..d720b22 --- /dev/null +++ b/docs/examples/project/create-apple-platform.md @@ -0,0 +1,18 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +project = Project.new(client) + +result = project.create_apple_platform( + platform_id: '', + name: '', + bundle_identifier: '' +) +``` diff --git a/docs/examples/project/create-key.md b/docs/examples/project/create-key.md new file mode 100644 index 0000000..90c1502 --- /dev/null +++ b/docs/examples/project/create-key.md @@ -0,0 +1,20 @@ +```ruby +require 'appwrite' + +include Appwrite +include Appwrite::Enums + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +project = Project.new(client) + +result = project.create_key( + key_id: '', + name: '', + scopes: [Scopes::SESSIONS_WRITE], + expire: '2020-10-15T06:38:00.000+00:00' # optional +) +``` diff --git a/docs/examples/project/create-linux-platform.md b/docs/examples/project/create-linux-platform.md new file mode 100644 index 0000000..11af487 --- /dev/null +++ b/docs/examples/project/create-linux-platform.md @@ -0,0 +1,18 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +project = Project.new(client) + +result = project.create_linux_platform( + platform_id: '', + name: '', + package_name: '' +) +``` diff --git a/docs/examples/project/create-web-platform.md b/docs/examples/project/create-web-platform.md new file mode 100644 index 0000000..9abfe8e --- /dev/null +++ b/docs/examples/project/create-web-platform.md @@ -0,0 +1,18 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +project = Project.new(client) + +result = project.create_web_platform( + platform_id: '', + name: '', + hostname: 'app.example.com' +) +``` diff --git a/docs/examples/project/create-windows-platform.md b/docs/examples/project/create-windows-platform.md new file mode 100644 index 0000000..8f53f16 --- /dev/null +++ b/docs/examples/project/create-windows-platform.md @@ -0,0 +1,18 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +project = Project.new(client) + +result = project.create_windows_platform( + platform_id: '', + name: '', + package_identifier_name: '' +) +``` diff --git a/docs/examples/project/delete-key.md b/docs/examples/project/delete-key.md new file mode 100644 index 0000000..ed80903 --- /dev/null +++ b/docs/examples/project/delete-key.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +project = Project.new(client) + +result = project.delete_key( + key_id: '' +) +``` diff --git a/docs/examples/project/delete-platform.md b/docs/examples/project/delete-platform.md new file mode 100644 index 0000000..bf8c2e5 --- /dev/null +++ b/docs/examples/project/delete-platform.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +project = Project.new(client) + +result = project.delete_platform( + platform_id: '' +) +``` diff --git a/docs/examples/project/get-key.md b/docs/examples/project/get-key.md new file mode 100644 index 0000000..2d19eae --- /dev/null +++ b/docs/examples/project/get-key.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +project = Project.new(client) + +result = project.get_key( + key_id: '' +) +``` diff --git a/docs/examples/project/get-platform.md b/docs/examples/project/get-platform.md new file mode 100644 index 0000000..276901c --- /dev/null +++ b/docs/examples/project/get-platform.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +project = Project.new(client) + +result = project.get_platform( + platform_id: '' +) +``` diff --git a/docs/examples/project/list-keys.md b/docs/examples/project/list-keys.md new file mode 100644 index 0000000..fe88235 --- /dev/null +++ b/docs/examples/project/list-keys.md @@ -0,0 +1,17 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +project = Project.new(client) + +result = project.list_keys( + queries: [], # optional + total: false # optional +) +``` diff --git a/docs/examples/project/list-platforms.md b/docs/examples/project/list-platforms.md new file mode 100644 index 0000000..3685c81 --- /dev/null +++ b/docs/examples/project/list-platforms.md @@ -0,0 +1,17 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +project = Project.new(client) + +result = project.list_platforms( + queries: [], # optional + total: false # optional +) +``` diff --git a/docs/examples/project/update-android-platform.md b/docs/examples/project/update-android-platform.md new file mode 100644 index 0000000..07e177d --- /dev/null +++ b/docs/examples/project/update-android-platform.md @@ -0,0 +1,18 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +project = Project.new(client) + +result = project.update_android_platform( + platform_id: '', + name: '', + application_id: '' +) +``` diff --git a/docs/examples/project/update-apple-platform.md b/docs/examples/project/update-apple-platform.md new file mode 100644 index 0000000..9faa5c1 --- /dev/null +++ b/docs/examples/project/update-apple-platform.md @@ -0,0 +1,18 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +project = Project.new(client) + +result = project.update_apple_platform( + platform_id: '', + name: '', + bundle_identifier: '' +) +``` diff --git a/docs/examples/project/update-key.md b/docs/examples/project/update-key.md new file mode 100644 index 0000000..2655910 --- /dev/null +++ b/docs/examples/project/update-key.md @@ -0,0 +1,20 @@ +```ruby +require 'appwrite' + +include Appwrite +include Appwrite::Enums + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +project = Project.new(client) + +result = project.update_key( + key_id: '', + name: '', + scopes: [Scopes::SESSIONS_WRITE], + expire: '2020-10-15T06:38:00.000+00:00' # optional +) +``` diff --git a/docs/examples/project/update-labels.md b/docs/examples/project/update-labels.md new file mode 100644 index 0000000..f57cec7 --- /dev/null +++ b/docs/examples/project/update-labels.md @@ -0,0 +1,16 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +project = Project.new(client) + +result = project.update_labels( + labels: [] +) +``` diff --git a/docs/examples/project/update-linux-platform.md b/docs/examples/project/update-linux-platform.md new file mode 100644 index 0000000..9714dce --- /dev/null +++ b/docs/examples/project/update-linux-platform.md @@ -0,0 +1,18 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +project = Project.new(client) + +result = project.update_linux_platform( + platform_id: '', + name: '', + package_name: '' +) +``` diff --git a/docs/examples/project/update-protocol-status.md b/docs/examples/project/update-protocol-status.md new file mode 100644 index 0000000..4b71bf8 --- /dev/null +++ b/docs/examples/project/update-protocol-status.md @@ -0,0 +1,18 @@ +```ruby +require 'appwrite' + +include Appwrite +include Appwrite::Enums + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +project = Project.new(client) + +result = project.update_protocol_status( + protocol_id: ProtocolId::REST, + enabled: false +) +``` diff --git a/docs/examples/project/update-service-status.md b/docs/examples/project/update-service-status.md new file mode 100644 index 0000000..c44606e --- /dev/null +++ b/docs/examples/project/update-service-status.md @@ -0,0 +1,18 @@ +```ruby +require 'appwrite' + +include Appwrite +include Appwrite::Enums + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +project = Project.new(client) + +result = project.update_service_status( + service_id: ServiceId::ACCOUNT, + enabled: false +) +``` diff --git a/docs/examples/project/update-web-platform.md b/docs/examples/project/update-web-platform.md new file mode 100644 index 0000000..46fe9cf --- /dev/null +++ b/docs/examples/project/update-web-platform.md @@ -0,0 +1,18 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +project = Project.new(client) + +result = project.update_web_platform( + platform_id: '', + name: '', + hostname: 'app.example.com' +) +``` diff --git a/docs/examples/project/update-windows-platform.md b/docs/examples/project/update-windows-platform.md new file mode 100644 index 0000000..5e2b106 --- /dev/null +++ b/docs/examples/project/update-windows-platform.md @@ -0,0 +1,18 @@ +```ruby +require 'appwrite' + +include Appwrite + +client = Client.new + .set_endpoint('https://.cloud.appwrite.io/v1') # Your API Endpoint + .set_project('') # Your project ID + .set_key('') # Your secret API key + +project = Project.new(client) + +result = project.update_windows_platform( + platform_id: '', + name: '', + package_identifier_name: '' +) +``` diff --git a/docs/examples/tablesdb/create-datetime-column.md b/docs/examples/tablesdb/create-datetime-column.md index 1a53efc..6599526 100644 --- a/docs/examples/tablesdb/create-datetime-column.md +++ b/docs/examples/tablesdb/create-datetime-column.md @@ -15,7 +15,7 @@ result = tables_db.create_datetime_column( table_id: '', key: '', required: false, - default: '', # optional + default: '2020-10-15T06:38:00.000+00:00', # optional array: false # optional ) ``` diff --git a/docs/examples/tablesdb/update-datetime-column.md b/docs/examples/tablesdb/update-datetime-column.md index 47cb2f8..295139b 100644 --- a/docs/examples/tablesdb/update-datetime-column.md +++ b/docs/examples/tablesdb/update-datetime-column.md @@ -15,7 +15,7 @@ result = tables_db.update_datetime_column( table_id: '', key: '', required: false, - default: '', + default: '2020-10-15T06:38:00.000+00:00', new_key: '' # optional ) ``` diff --git a/docs/examples/tablesdb/update-table.md b/docs/examples/tablesdb/update-table.md index d287db3..a560d71 100644 --- a/docs/examples/tablesdb/update-table.md +++ b/docs/examples/tablesdb/update-table.md @@ -18,6 +18,7 @@ result = tables_db.update_table( name: '', # optional permissions: [Permission.read(Role.any())], # optional row_security: false, # optional - enabled: false # optional + enabled: false, # optional + purge: false # optional ) ``` diff --git a/docs/examples/tokens/create-file-token.md b/docs/examples/tokens/create-file-token.md index a11d622..c734e65 100644 --- a/docs/examples/tokens/create-file-token.md +++ b/docs/examples/tokens/create-file-token.md @@ -13,6 +13,6 @@ tokens = Tokens.new(client) result = tokens.create_file_token( bucket_id: '', file_id: '', - expire: '' # optional + expire: '2020-10-15T06:38:00.000+00:00' # optional ) ``` diff --git a/docs/examples/tokens/update.md b/docs/examples/tokens/update.md index 8875a1e..84a9ddf 100644 --- a/docs/examples/tokens/update.md +++ b/docs/examples/tokens/update.md @@ -12,6 +12,6 @@ tokens = Tokens.new(client) result = tokens.update( token_id: '', - expire: '' # optional + expire: '2020-10-15T06:38:00.000+00:00' # optional ) ``` diff --git a/docs/examples/webhooks/create.md b/docs/examples/webhooks/create.md index 7989c8b..e553910 100644 --- a/docs/examples/webhooks/create.md +++ b/docs/examples/webhooks/create.md @@ -16,8 +16,9 @@ result = webhooks.create( name: '', events: [], enabled: false, # optional - security: false, # optional - http_user: '', # optional - http_pass: '' # optional + tls: false, # optional + auth_username: '', # optional + auth_password: '', # optional + secret: '' # optional ) ``` diff --git a/docs/examples/webhooks/update-signature.md b/docs/examples/webhooks/update-secret.md similarity index 74% rename from docs/examples/webhooks/update-signature.md rename to docs/examples/webhooks/update-secret.md index 11acf67..7aadac1 100644 --- a/docs/examples/webhooks/update-signature.md +++ b/docs/examples/webhooks/update-secret.md @@ -10,7 +10,8 @@ client = Client.new webhooks = Webhooks.new(client) -result = webhooks.update_signature( - webhook_id: '' +result = webhooks.update_secret( + webhook_id: '', + secret: '' # optional ) ``` diff --git a/docs/examples/webhooks/update.md b/docs/examples/webhooks/update.md index 51567d5..1de7c04 100644 --- a/docs/examples/webhooks/update.md +++ b/docs/examples/webhooks/update.md @@ -16,8 +16,8 @@ result = webhooks.update( url: '', events: [], enabled: false, # optional - security: false, # optional - http_user: '', # optional - http_pass: '' # optional + tls: false, # optional + auth_username: '', # optional + auth_password: '' # optional ) ``` diff --git a/lib/appwrite.rb b/lib/appwrite.rb index 1b7eb9c..7d8921b 100644 --- a/lib/appwrite.rb +++ b/lib/appwrite.rb @@ -36,6 +36,7 @@ require_relative 'appwrite/models/deployment_list' require_relative 'appwrite/models/execution_list' require_relative 'appwrite/models/webhook_list' +require_relative 'appwrite/models/key_list' require_relative 'appwrite/models/country_list' require_relative 'appwrite/models/continent_list' require_relative 'appwrite/models/language_list' @@ -122,7 +123,18 @@ require_relative 'appwrite/models/framework_adapter' require_relative 'appwrite/models/deployment' require_relative 'appwrite/models/execution' +require_relative 'appwrite/models/project' require_relative 'appwrite/models/webhook' +require_relative 'appwrite/models/key' +require_relative 'appwrite/models/dev_key' +require_relative 'appwrite/models/mock_number' +require_relative 'appwrite/models/auth_provider' +require_relative 'appwrite/models/platform_web' +require_relative 'appwrite/models/platform_apple' +require_relative 'appwrite/models/platform_android' +require_relative 'appwrite/models/platform_windows' +require_relative 'appwrite/models/platform_linux' +require_relative 'appwrite/models/platform_list' require_relative 'appwrite/models/variable' require_relative 'appwrite/models/country' require_relative 'appwrite/models/continent' @@ -148,6 +160,8 @@ require_relative 'appwrite/models/target' require_relative 'appwrite/models/activity_event' require_relative 'appwrite/models/backup_archive' +require_relative 'appwrite/models/billing_limits' +require_relative 'appwrite/models/block' require_relative 'appwrite/models/backup_policy' require_relative 'appwrite/models/backup_restoration' require_relative 'appwrite/models/activity_event_list' @@ -179,6 +193,8 @@ require_relative 'appwrite/enums/name' require_relative 'appwrite/enums/message_priority' require_relative 'appwrite/enums/smtp_encryption' +require_relative 'appwrite/enums/protocol_id' +require_relative 'appwrite/enums/service_id' require_relative 'appwrite/enums/framework' require_relative 'appwrite/enums/build_runtime' require_relative 'appwrite/enums/adapter' @@ -194,6 +210,7 @@ require_relative 'appwrite/enums/deployment_status' require_relative 'appwrite/enums/execution_trigger' require_relative 'appwrite/enums/execution_status' +require_relative 'appwrite/enums/platform_type' require_relative 'appwrite/enums/health_antivirus_status' require_relative 'appwrite/enums/health_check_status' require_relative 'appwrite/enums/message_status' diff --git a/lib/appwrite/client.rb b/lib/appwrite/client.rb index a10c7a7..b484676 100644 --- a/lib/appwrite/client.rb +++ b/lib/appwrite/client.rb @@ -15,8 +15,8 @@ def initialize 'x-sdk-name'=> 'Ruby', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'ruby', - 'x-sdk-version'=> '22.0.0', - 'X-Appwrite-Response-Format' => '1.9.0' + 'x-sdk-version'=> '23.0.0', + 'X-Appwrite-Response-Format' => '1.9.1' } @endpoint = 'https://cloud.appwrite.io/v1' end @@ -174,6 +174,13 @@ def add_header(key, value) self end + # Get request headers + # + # @return [Hash] + def get_headers + @headers.dup + end + # Send the HTTP request. # # @param [String] method The HTTP method for the request diff --git a/lib/appwrite/enums/build_runtime.rb b/lib/appwrite/enums/build_runtime.rb index 4ac437c..26109d4 100644 --- a/lib/appwrite/enums/build_runtime.rb +++ b/lib/appwrite/enums/build_runtime.rb @@ -49,6 +49,7 @@ module BuildRuntime DART_3_8 = 'dart-3.8' DART_3_9 = 'dart-3.9' DART_3_10 = 'dart-3.10' + DART_3_11 = 'dart-3.11' DOTNET_6_0 = 'dotnet-6.0' DOTNET_7_0 = 'dotnet-7.0' DOTNET_8_0 = 'dotnet-8.0' @@ -87,6 +88,7 @@ module BuildRuntime FLUTTER_3_32 = 'flutter-3.32' FLUTTER_3_35 = 'flutter-3.35' FLUTTER_3_38 = 'flutter-3.38' + FLUTTER_3_41 = 'flutter-3.41' end end end \ No newline at end of file diff --git a/lib/appwrite/enums/o_auth_provider.rb b/lib/appwrite/enums/o_auth_provider.rb index 9a75276..daa11b5 100644 --- a/lib/appwrite/enums/o_auth_provider.rb +++ b/lib/appwrite/enums/o_auth_provider.rb @@ -35,6 +35,7 @@ module OAuthProvider TRADESHIFTBOX = 'tradeshiftBox' TWITCH = 'twitch' WORDPRESS = 'wordpress' + X = 'x' YAHOO = 'yahoo' YAMMER = 'yammer' YANDEX = 'yandex' diff --git a/lib/appwrite/enums/platform_type.rb b/lib/appwrite/enums/platform_type.rb new file mode 100644 index 0000000..49d8b12 --- /dev/null +++ b/lib/appwrite/enums/platform_type.rb @@ -0,0 +1,11 @@ +module Appwrite + module Enums + module PlatformType + WINDOWS = 'windows' + APPLE = 'apple' + ANDROID = 'android' + LINUX = 'linux' + WEB = 'web' + end + end +end \ No newline at end of file diff --git a/lib/appwrite/enums/protocol_id.rb b/lib/appwrite/enums/protocol_id.rb new file mode 100644 index 0000000..a04646c --- /dev/null +++ b/lib/appwrite/enums/protocol_id.rb @@ -0,0 +1,9 @@ +module Appwrite + module Enums + module ProtocolId + REST = 'rest' + GRAPHQL = 'graphql' + WEBSOCKET = 'websocket' + end + end +end \ No newline at end of file diff --git a/lib/appwrite/enums/runtime.rb b/lib/appwrite/enums/runtime.rb index f12d975..9931d93 100644 --- a/lib/appwrite/enums/runtime.rb +++ b/lib/appwrite/enums/runtime.rb @@ -49,6 +49,7 @@ module Runtime DART_3_8 = 'dart-3.8' DART_3_9 = 'dart-3.9' DART_3_10 = 'dart-3.10' + DART_3_11 = 'dart-3.11' DOTNET_6_0 = 'dotnet-6.0' DOTNET_7_0 = 'dotnet-7.0' DOTNET_8_0 = 'dotnet-8.0' @@ -87,6 +88,7 @@ module Runtime FLUTTER_3_32 = 'flutter-3.32' FLUTTER_3_35 = 'flutter-3.35' FLUTTER_3_38 = 'flutter-3.38' + FLUTTER_3_41 = 'flutter-3.41' end end end \ No newline at end of file diff --git a/lib/appwrite/enums/scopes.rb b/lib/appwrite/enums/scopes.rb index 585722f..ed699cd 100644 --- a/lib/appwrite/enums/scopes.rb +++ b/lib/appwrite/enums/scopes.rb @@ -62,6 +62,10 @@ module Scopes WEBHOOKS_WRITE = 'webhooks.write' PROJECT_READ = 'project.read' PROJECT_WRITE = 'project.write' + KEYS_READ = 'keys.read' + KEYS_WRITE = 'keys.write' + PLATFORMS_READ = 'platforms.read' + PLATFORMS_WRITE = 'platforms.write' POLICIES_WRITE = 'policies.write' POLICIES_READ = 'policies.read' ARCHIVES_READ = 'archives.read' diff --git a/lib/appwrite/enums/service_id.rb b/lib/appwrite/enums/service_id.rb new file mode 100644 index 0000000..12ad0cd --- /dev/null +++ b/lib/appwrite/enums/service_id.rb @@ -0,0 +1,23 @@ +module Appwrite + module Enums + module ServiceId + ACCOUNT = 'account' + AVATARS = 'avatars' + DATABASES = 'databases' + TABLESDB = 'tablesdb' + LOCALE = 'locale' + HEALTH = 'health' + PROJECT = 'project' + STORAGE = 'storage' + TEAMS = 'teams' + USERS = 'users' + VCS = 'vcs' + SITES = 'sites' + FUNCTIONS = 'functions' + PROXY = 'proxy' + GRAPHQL = 'graphql' + MIGRATIONS = 'migrations' + MESSAGING = 'messaging' + end + end +end \ No newline at end of file diff --git a/lib/appwrite/models/auth_provider.rb b/lib/appwrite/models/auth_provider.rb new file mode 100644 index 0000000..c1e79e3 --- /dev/null +++ b/lib/appwrite/models/auth_provider.rb @@ -0,0 +1,47 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class AuthProvider + attr_reader :key + attr_reader :name + attr_reader :app_id + attr_reader :secret + attr_reader :enabled + + def initialize( + key:, + name:, + app_id:, + secret:, + enabled: + ) + @key = key + @name = name + @app_id = app_id + @secret = secret + @enabled = enabled + end + + def self.from(map:) + AuthProvider.new( + key: map["key"], + name: map["name"], + app_id: map["appId"], + secret: map["secret"], + enabled: map["enabled"] + ) + end + + def to_map + { + "key": @key, + "name": @name, + "appId": @app_id, + "secret": @secret, + "enabled": @enabled + } + end + end + end +end diff --git a/lib/appwrite/models/billing_limits.rb b/lib/appwrite/models/billing_limits.rb new file mode 100644 index 0000000..012f835 --- /dev/null +++ b/lib/appwrite/models/billing_limits.rb @@ -0,0 +1,62 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class BillingLimits + attr_reader :bandwidth + attr_reader :storage + attr_reader :users + attr_reader :executions + attr_reader :gb_hours + attr_reader :image_transformations + attr_reader :auth_phone + attr_reader :budget_limit + + def initialize( + bandwidth:, + storage:, + users:, + executions:, + gb_hours:, + image_transformations:, + auth_phone:, + budget_limit: + ) + @bandwidth = bandwidth + @storage = storage + @users = users + @executions = executions + @gb_hours = gb_hours + @image_transformations = image_transformations + @auth_phone = auth_phone + @budget_limit = budget_limit + end + + def self.from(map:) + BillingLimits.new( + bandwidth: map["bandwidth"], + storage: map["storage"], + users: map["users"], + executions: map["executions"], + gb_hours: map["GBHours"], + image_transformations: map["imageTransformations"], + auth_phone: map["authPhone"], + budget_limit: map["budgetLimit"] + ) + end + + def to_map + { + "bandwidth": @bandwidth, + "storage": @storage, + "users": @users, + "executions": @executions, + "GBHours": @gb_hours, + "imageTransformations": @image_transformations, + "authPhone": @auth_phone, + "budgetLimit": @budget_limit + } + end + end + end +end diff --git a/lib/appwrite/models/block.rb b/lib/appwrite/models/block.rb new file mode 100644 index 0000000..578ff10 --- /dev/null +++ b/lib/appwrite/models/block.rb @@ -0,0 +1,47 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class Block + attr_reader :created_at + attr_reader :resource_type + attr_reader :resource_id + attr_reader :reason + attr_reader :expired_at + + def initialize( + created_at:, + resource_type:, + resource_id:, + reason: , + expired_at: + ) + @created_at = created_at + @resource_type = resource_type + @resource_id = resource_id + @reason = reason + @expired_at = expired_at + end + + def self.from(map:) + Block.new( + created_at: map["$createdAt"], + resource_type: map["resourceType"], + resource_id: map["resourceId"], + reason: map["reason"], + expired_at: map["expiredAt"] + ) + end + + def to_map + { + "$createdAt": @created_at, + "resourceType": @resource_type, + "resourceId": @resource_id, + "reason": @reason, + "expiredAt": @expired_at + } + end + end + end +end diff --git a/lib/appwrite/models/dev_key.rb b/lib/appwrite/models/dev_key.rb new file mode 100644 index 0000000..cb3f60d --- /dev/null +++ b/lib/appwrite/models/dev_key.rb @@ -0,0 +1,62 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class DevKey + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :name + attr_reader :expire + attr_reader :secret + attr_reader :accessed_at + attr_reader :sdks + + def initialize( + id:, + created_at:, + updated_at:, + name:, + expire:, + secret:, + accessed_at:, + sdks: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @name = name + @expire = expire + @secret = secret + @accessed_at = accessed_at + @sdks = sdks + end + + def self.from(map:) + DevKey.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + name: map["name"], + expire: map["expire"], + secret: map["secret"], + accessed_at: map["accessedAt"], + sdks: map["sdks"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "name": @name, + "expire": @expire, + "secret": @secret, + "accessedAt": @accessed_at, + "sdks": @sdks + } + end + end + end +end diff --git a/lib/appwrite/models/key.rb b/lib/appwrite/models/key.rb new file mode 100644 index 0000000..aaeac7a --- /dev/null +++ b/lib/appwrite/models/key.rb @@ -0,0 +1,67 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class Key + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :name + attr_reader :expire + attr_reader :scopes + attr_reader :secret + attr_reader :accessed_at + attr_reader :sdks + + def initialize( + id:, + created_at:, + updated_at:, + name:, + expire:, + scopes:, + secret:, + accessed_at:, + sdks: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @name = name + @expire = expire + @scopes = scopes + @secret = secret + @accessed_at = accessed_at + @sdks = sdks + end + + def self.from(map:) + Key.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + name: map["name"], + expire: map["expire"], + scopes: map["scopes"], + secret: map["secret"], + accessed_at: map["accessedAt"], + sdks: map["sdks"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "name": @name, + "expire": @expire, + "scopes": @scopes, + "secret": @secret, + "accessedAt": @accessed_at, + "sdks": @sdks + } + end + end + end +end diff --git a/lib/appwrite/models/key_list.rb b/lib/appwrite/models/key_list.rb new file mode 100644 index 0000000..d49db9b --- /dev/null +++ b/lib/appwrite/models/key_list.rb @@ -0,0 +1,32 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class KeyList + attr_reader :total + attr_reader :keys + + def initialize( + total:, + keys: + ) + @total = total + @keys = keys + end + + def self.from(map:) + KeyList.new( + total: map["total"], + keys: map["keys"].map { |it| Key.from(map: it) } + ) + end + + def to_map + { + "total": @total, + "keys": @keys.map { |it| it.to_map } + } + end + end + end +end diff --git a/lib/appwrite/models/log.rb b/lib/appwrite/models/log.rb index a06374d..c4653ac 100644 --- a/lib/appwrite/models/log.rb +++ b/lib/appwrite/models/log.rb @@ -8,6 +8,7 @@ class Log attr_reader :user_email attr_reader :user_name attr_reader :mode + attr_reader :user_type attr_reader :ip attr_reader :time attr_reader :os_code @@ -31,6 +32,7 @@ def initialize( user_email:, user_name:, mode:, + user_type:, ip:, time:, os_code:, @@ -53,6 +55,7 @@ def initialize( @user_email = user_email @user_name = user_name @mode = mode + @user_type = user_type @ip = ip @time = time @os_code = os_code @@ -78,6 +81,7 @@ def self.from(map:) user_email: map["userEmail"], user_name: map["userName"], mode: map["mode"], + user_type: map["userType"], ip: map["ip"], time: map["time"], os_code: map["osCode"], @@ -104,6 +108,7 @@ def to_map "userEmail": @user_email, "userName": @user_name, "mode": @mode, + "userType": @user_type, "ip": @ip, "time": @time, "osCode": @os_code, diff --git a/lib/appwrite/models/mock_number.rb b/lib/appwrite/models/mock_number.rb new file mode 100644 index 0000000..3a353bc --- /dev/null +++ b/lib/appwrite/models/mock_number.rb @@ -0,0 +1,32 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class MockNumber + attr_reader :phone + attr_reader :otp + + def initialize( + phone:, + otp: + ) + @phone = phone + @otp = otp + end + + def self.from(map:) + MockNumber.new( + phone: map["phone"], + otp: map["otp"] + ) + end + + def to_map + { + "phone": @phone, + "otp": @otp + } + end + end + end +end diff --git a/lib/appwrite/models/platform_android.rb b/lib/appwrite/models/platform_android.rb new file mode 100644 index 0000000..042bf0b --- /dev/null +++ b/lib/appwrite/models/platform_android.rb @@ -0,0 +1,71 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class PlatformAndroid + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :name + attr_reader :type + attr_reader :application_id + + def initialize( + id:, + created_at:, + updated_at:, + name:, + type:, + application_id: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @name = name + @type = validate_type(type) + @application_id = application_id + end + + def self.from(map:) + PlatformAndroid.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + name: map["name"], + type: map["type"], + application_id: map["applicationId"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "name": @name, + "type": @type, + "applicationId": @application_id + } + end + + private + + def validate_type(type) + valid_type = [ + Appwrite::Enums::PlatformType::WINDOWS, + Appwrite::Enums::PlatformType::APPLE, + Appwrite::Enums::PlatformType::ANDROID, + Appwrite::Enums::PlatformType::LINUX, + Appwrite::Enums::PlatformType::WEB, + ] + + unless valid_type.include?(type) + raise ArgumentError, "Invalid " + type + ". Must be one of: " + valid_type.join(', ') + end + + type + end + + end + end +end diff --git a/lib/appwrite/models/platform_apple.rb b/lib/appwrite/models/platform_apple.rb new file mode 100644 index 0000000..61174db --- /dev/null +++ b/lib/appwrite/models/platform_apple.rb @@ -0,0 +1,71 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class PlatformApple + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :name + attr_reader :type + attr_reader :bundle_identifier + + def initialize( + id:, + created_at:, + updated_at:, + name:, + type:, + bundle_identifier: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @name = name + @type = validate_type(type) + @bundle_identifier = bundle_identifier + end + + def self.from(map:) + PlatformApple.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + name: map["name"], + type: map["type"], + bundle_identifier: map["bundleIdentifier"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "name": @name, + "type": @type, + "bundleIdentifier": @bundle_identifier + } + end + + private + + def validate_type(type) + valid_type = [ + Appwrite::Enums::PlatformType::WINDOWS, + Appwrite::Enums::PlatformType::APPLE, + Appwrite::Enums::PlatformType::ANDROID, + Appwrite::Enums::PlatformType::LINUX, + Appwrite::Enums::PlatformType::WEB, + ] + + unless valid_type.include?(type) + raise ArgumentError, "Invalid " + type + ". Must be one of: " + valid_type.join(', ') + end + + type + end + + end + end +end diff --git a/lib/appwrite/models/platform_linux.rb b/lib/appwrite/models/platform_linux.rb new file mode 100644 index 0000000..53e2e90 --- /dev/null +++ b/lib/appwrite/models/platform_linux.rb @@ -0,0 +1,71 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class PlatformLinux + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :name + attr_reader :type + attr_reader :package_name + + def initialize( + id:, + created_at:, + updated_at:, + name:, + type:, + package_name: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @name = name + @type = validate_type(type) + @package_name = package_name + end + + def self.from(map:) + PlatformLinux.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + name: map["name"], + type: map["type"], + package_name: map["packageName"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "name": @name, + "type": @type, + "packageName": @package_name + } + end + + private + + def validate_type(type) + valid_type = [ + Appwrite::Enums::PlatformType::WINDOWS, + Appwrite::Enums::PlatformType::APPLE, + Appwrite::Enums::PlatformType::ANDROID, + Appwrite::Enums::PlatformType::LINUX, + Appwrite::Enums::PlatformType::WEB, + ] + + unless valid_type.include?(type) + raise ArgumentError, "Invalid " + type + ". Must be one of: " + valid_type.join(', ') + end + + type + end + + end + end +end diff --git a/lib/appwrite/models/platform_list.rb b/lib/appwrite/models/platform_list.rb new file mode 100644 index 0000000..d374d18 --- /dev/null +++ b/lib/appwrite/models/platform_list.rb @@ -0,0 +1,32 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class PlatformList + attr_reader :total + attr_reader :platforms + + def initialize( + total:, + platforms: + ) + @total = total + @platforms = platforms + end + + def self.from(map:) + PlatformList.new( + total: map["total"], + platforms: map["platforms"] + ) + end + + def to_map + { + "total": @total, + "platforms": @platforms + } + end + end + end +end diff --git a/lib/appwrite/models/platform_web.rb b/lib/appwrite/models/platform_web.rb new file mode 100644 index 0000000..2431d06 --- /dev/null +++ b/lib/appwrite/models/platform_web.rb @@ -0,0 +1,71 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class PlatformWeb + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :name + attr_reader :type + attr_reader :hostname + + def initialize( + id:, + created_at:, + updated_at:, + name:, + type:, + hostname: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @name = name + @type = validate_type(type) + @hostname = hostname + end + + def self.from(map:) + PlatformWeb.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + name: map["name"], + type: map["type"], + hostname: map["hostname"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "name": @name, + "type": @type, + "hostname": @hostname + } + end + + private + + def validate_type(type) + valid_type = [ + Appwrite::Enums::PlatformType::WINDOWS, + Appwrite::Enums::PlatformType::APPLE, + Appwrite::Enums::PlatformType::ANDROID, + Appwrite::Enums::PlatformType::LINUX, + Appwrite::Enums::PlatformType::WEB, + ] + + unless valid_type.include?(type) + raise ArgumentError, "Invalid " + type + ". Must be one of: " + valid_type.join(', ') + end + + type + end + + end + end +end diff --git a/lib/appwrite/models/platform_windows.rb b/lib/appwrite/models/platform_windows.rb new file mode 100644 index 0000000..08dcec1 --- /dev/null +++ b/lib/appwrite/models/platform_windows.rb @@ -0,0 +1,71 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class PlatformWindows + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :name + attr_reader :type + attr_reader :package_identifier_name + + def initialize( + id:, + created_at:, + updated_at:, + name:, + type:, + package_identifier_name: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @name = name + @type = validate_type(type) + @package_identifier_name = package_identifier_name + end + + def self.from(map:) + PlatformWindows.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + name: map["name"], + type: map["type"], + package_identifier_name: map["packageIdentifierName"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "name": @name, + "type": @type, + "packageIdentifierName": @package_identifier_name + } + end + + private + + def validate_type(type) + valid_type = [ + Appwrite::Enums::PlatformType::WINDOWS, + Appwrite::Enums::PlatformType::APPLE, + Appwrite::Enums::PlatformType::ANDROID, + Appwrite::Enums::PlatformType::LINUX, + Appwrite::Enums::PlatformType::WEB, + ] + + unless valid_type.include?(type) + raise ArgumentError, "Invalid " + type + ". Must be one of: " + valid_type.join(', ') + end + + type + end + + end + end +end diff --git a/lib/appwrite/models/project.rb b/lib/appwrite/models/project.rb new file mode 100644 index 0000000..60c16f2 --- /dev/null +++ b/lib/appwrite/models/project.rb @@ -0,0 +1,412 @@ +#frozen_string_literal: true + +module Appwrite + module Models + class Project + attr_reader :id + attr_reader :created_at + attr_reader :updated_at + attr_reader :name + attr_reader :description + attr_reader :team_id + attr_reader :logo + attr_reader :url + attr_reader :legal_name + attr_reader :legal_country + attr_reader :legal_state + attr_reader :legal_city + attr_reader :legal_address + attr_reader :legal_tax_id + attr_reader :auth_duration + attr_reader :auth_limit + attr_reader :auth_sessions_limit + attr_reader :auth_password_history + attr_reader :auth_password_dictionary + attr_reader :auth_personal_data_check + attr_reader :auth_disposable_emails + attr_reader :auth_canonical_emails + attr_reader :auth_free_emails + attr_reader :auth_mock_numbers + attr_reader :auth_session_alerts + attr_reader :auth_memberships_user_name + attr_reader :auth_memberships_user_email + attr_reader :auth_memberships_mfa + attr_reader :auth_invalidate_sessions + attr_reader :o_auth_providers + attr_reader :platforms + attr_reader :webhooks + attr_reader :keys + attr_reader :dev_keys + attr_reader :smtp_enabled + attr_reader :smtp_sender_name + attr_reader :smtp_sender_email + attr_reader :smtp_reply_to + attr_reader :smtp_host + attr_reader :smtp_port + attr_reader :smtp_username + attr_reader :smtp_password + attr_reader :smtp_secure + attr_reader :ping_count + attr_reader :pinged_at + attr_reader :labels + attr_reader :status + attr_reader :auth_email_password + attr_reader :auth_users_auth_magic_url + attr_reader :auth_email_otp + attr_reader :auth_anonymous + attr_reader :auth_invites + attr_reader :auth_jwt + attr_reader :auth_phone + attr_reader :service_status_for_account + attr_reader :service_status_for_avatars + attr_reader :service_status_for_databases + attr_reader :service_status_for_tablesdb + attr_reader :service_status_for_locale + attr_reader :service_status_for_health + attr_reader :service_status_for_project + attr_reader :service_status_for_storage + attr_reader :service_status_for_teams + attr_reader :service_status_for_users + attr_reader :service_status_for_vcs + attr_reader :service_status_for_sites + attr_reader :service_status_for_functions + attr_reader :service_status_for_proxy + attr_reader :service_status_for_graphql + attr_reader :service_status_for_migrations + attr_reader :service_status_for_messaging + attr_reader :protocol_status_for_rest + attr_reader :protocol_status_for_graphql + attr_reader :protocol_status_for_websocket + attr_reader :region + attr_reader :billing_limits + attr_reader :blocks + attr_reader :console_accessed_at + + def initialize( + id:, + created_at:, + updated_at:, + name:, + description:, + team_id:, + logo:, + url:, + legal_name:, + legal_country:, + legal_state:, + legal_city:, + legal_address:, + legal_tax_id:, + auth_duration:, + auth_limit:, + auth_sessions_limit:, + auth_password_history:, + auth_password_dictionary:, + auth_personal_data_check:, + auth_disposable_emails:, + auth_canonical_emails:, + auth_free_emails:, + auth_mock_numbers:, + auth_session_alerts:, + auth_memberships_user_name:, + auth_memberships_user_email:, + auth_memberships_mfa:, + auth_invalidate_sessions:, + o_auth_providers:, + platforms:, + webhooks:, + keys:, + dev_keys:, + smtp_enabled:, + smtp_sender_name:, + smtp_sender_email:, + smtp_reply_to:, + smtp_host:, + smtp_port:, + smtp_username:, + smtp_password:, + smtp_secure:, + ping_count:, + pinged_at:, + labels:, + status:, + auth_email_password:, + auth_users_auth_magic_url:, + auth_email_otp:, + auth_anonymous:, + auth_invites:, + auth_jwt:, + auth_phone:, + service_status_for_account:, + service_status_for_avatars:, + service_status_for_databases:, + service_status_for_tablesdb:, + service_status_for_locale:, + service_status_for_health:, + service_status_for_project:, + service_status_for_storage:, + service_status_for_teams:, + service_status_for_users:, + service_status_for_vcs:, + service_status_for_sites:, + service_status_for_functions:, + service_status_for_proxy:, + service_status_for_graphql:, + service_status_for_migrations:, + service_status_for_messaging:, + protocol_status_for_rest:, + protocol_status_for_graphql:, + protocol_status_for_websocket:, + region:, + billing_limits:, + blocks:, + console_accessed_at: + ) + @id = id + @created_at = created_at + @updated_at = updated_at + @name = name + @description = description + @team_id = team_id + @logo = logo + @url = url + @legal_name = legal_name + @legal_country = legal_country + @legal_state = legal_state + @legal_city = legal_city + @legal_address = legal_address + @legal_tax_id = legal_tax_id + @auth_duration = auth_duration + @auth_limit = auth_limit + @auth_sessions_limit = auth_sessions_limit + @auth_password_history = auth_password_history + @auth_password_dictionary = auth_password_dictionary + @auth_personal_data_check = auth_personal_data_check + @auth_disposable_emails = auth_disposable_emails + @auth_canonical_emails = auth_canonical_emails + @auth_free_emails = auth_free_emails + @auth_mock_numbers = auth_mock_numbers + @auth_session_alerts = auth_session_alerts + @auth_memberships_user_name = auth_memberships_user_name + @auth_memberships_user_email = auth_memberships_user_email + @auth_memberships_mfa = auth_memberships_mfa + @auth_invalidate_sessions = auth_invalidate_sessions + @o_auth_providers = o_auth_providers + @platforms = platforms + @webhooks = webhooks + @keys = keys + @dev_keys = dev_keys + @smtp_enabled = smtp_enabled + @smtp_sender_name = smtp_sender_name + @smtp_sender_email = smtp_sender_email + @smtp_reply_to = smtp_reply_to + @smtp_host = smtp_host + @smtp_port = smtp_port + @smtp_username = smtp_username + @smtp_password = smtp_password + @smtp_secure = smtp_secure + @ping_count = ping_count + @pinged_at = pinged_at + @labels = labels + @status = status + @auth_email_password = auth_email_password + @auth_users_auth_magic_url = auth_users_auth_magic_url + @auth_email_otp = auth_email_otp + @auth_anonymous = auth_anonymous + @auth_invites = auth_invites + @auth_jwt = auth_jwt + @auth_phone = auth_phone + @service_status_for_account = service_status_for_account + @service_status_for_avatars = service_status_for_avatars + @service_status_for_databases = service_status_for_databases + @service_status_for_tablesdb = service_status_for_tablesdb + @service_status_for_locale = service_status_for_locale + @service_status_for_health = service_status_for_health + @service_status_for_project = service_status_for_project + @service_status_for_storage = service_status_for_storage + @service_status_for_teams = service_status_for_teams + @service_status_for_users = service_status_for_users + @service_status_for_vcs = service_status_for_vcs + @service_status_for_sites = service_status_for_sites + @service_status_for_functions = service_status_for_functions + @service_status_for_proxy = service_status_for_proxy + @service_status_for_graphql = service_status_for_graphql + @service_status_for_migrations = service_status_for_migrations + @service_status_for_messaging = service_status_for_messaging + @protocol_status_for_rest = protocol_status_for_rest + @protocol_status_for_graphql = protocol_status_for_graphql + @protocol_status_for_websocket = protocol_status_for_websocket + @region = region + @billing_limits = billing_limits + @blocks = blocks + @console_accessed_at = console_accessed_at + end + + def self.from(map:) + Project.new( + id: map["$id"], + created_at: map["$createdAt"], + updated_at: map["$updatedAt"], + name: map["name"], + description: map["description"], + team_id: map["teamId"], + logo: map["logo"], + url: map["url"], + legal_name: map["legalName"], + legal_country: map["legalCountry"], + legal_state: map["legalState"], + legal_city: map["legalCity"], + legal_address: map["legalAddress"], + legal_tax_id: map["legalTaxId"], + auth_duration: map["authDuration"], + auth_limit: map["authLimit"], + auth_sessions_limit: map["authSessionsLimit"], + auth_password_history: map["authPasswordHistory"], + auth_password_dictionary: map["authPasswordDictionary"], + auth_personal_data_check: map["authPersonalDataCheck"], + auth_disposable_emails: map["authDisposableEmails"], + auth_canonical_emails: map["authCanonicalEmails"], + auth_free_emails: map["authFreeEmails"], + auth_mock_numbers: map["authMockNumbers"].map { |it| MockNumber.from(map: it) }, + auth_session_alerts: map["authSessionAlerts"], + auth_memberships_user_name: map["authMembershipsUserName"], + auth_memberships_user_email: map["authMembershipsUserEmail"], + auth_memberships_mfa: map["authMembershipsMfa"], + auth_invalidate_sessions: map["authInvalidateSessions"], + o_auth_providers: map["oAuthProviders"].map { |it| AuthProvider.from(map: it) }, + platforms: map["platforms"], + webhooks: map["webhooks"].map { |it| Webhook.from(map: it) }, + keys: map["keys"].map { |it| Key.from(map: it) }, + dev_keys: map["devKeys"].map { |it| DevKey.from(map: it) }, + smtp_enabled: map["smtpEnabled"], + smtp_sender_name: map["smtpSenderName"], + smtp_sender_email: map["smtpSenderEmail"], + smtp_reply_to: map["smtpReplyTo"], + smtp_host: map["smtpHost"], + smtp_port: map["smtpPort"], + smtp_username: map["smtpUsername"], + smtp_password: map["smtpPassword"], + smtp_secure: map["smtpSecure"], + ping_count: map["pingCount"], + pinged_at: map["pingedAt"], + labels: map["labels"], + status: map["status"], + auth_email_password: map["authEmailPassword"], + auth_users_auth_magic_url: map["authUsersAuthMagicURL"], + auth_email_otp: map["authEmailOtp"], + auth_anonymous: map["authAnonymous"], + auth_invites: map["authInvites"], + auth_jwt: map["authJWT"], + auth_phone: map["authPhone"], + service_status_for_account: map["serviceStatusForAccount"], + service_status_for_avatars: map["serviceStatusForAvatars"], + service_status_for_databases: map["serviceStatusForDatabases"], + service_status_for_tablesdb: map["serviceStatusForTablesdb"], + service_status_for_locale: map["serviceStatusForLocale"], + service_status_for_health: map["serviceStatusForHealth"], + service_status_for_project: map["serviceStatusForProject"], + service_status_for_storage: map["serviceStatusForStorage"], + service_status_for_teams: map["serviceStatusForTeams"], + service_status_for_users: map["serviceStatusForUsers"], + service_status_for_vcs: map["serviceStatusForVcs"], + service_status_for_sites: map["serviceStatusForSites"], + service_status_for_functions: map["serviceStatusForFunctions"], + service_status_for_proxy: map["serviceStatusForProxy"], + service_status_for_graphql: map["serviceStatusForGraphql"], + service_status_for_migrations: map["serviceStatusForMigrations"], + service_status_for_messaging: map["serviceStatusForMessaging"], + protocol_status_for_rest: map["protocolStatusForRest"], + protocol_status_for_graphql: map["protocolStatusForGraphql"], + protocol_status_for_websocket: map["protocolStatusForWebsocket"], + region: map["region"], + billing_limits: BillingLimits.from(map: map["billingLimits"]), + blocks: map["blocks"].map { |it| Block.from(map: it) }, + console_accessed_at: map["consoleAccessedAt"] + ) + end + + def to_map + { + "$id": @id, + "$createdAt": @created_at, + "$updatedAt": @updated_at, + "name": @name, + "description": @description, + "teamId": @team_id, + "logo": @logo, + "url": @url, + "legalName": @legal_name, + "legalCountry": @legal_country, + "legalState": @legal_state, + "legalCity": @legal_city, + "legalAddress": @legal_address, + "legalTaxId": @legal_tax_id, + "authDuration": @auth_duration, + "authLimit": @auth_limit, + "authSessionsLimit": @auth_sessions_limit, + "authPasswordHistory": @auth_password_history, + "authPasswordDictionary": @auth_password_dictionary, + "authPersonalDataCheck": @auth_personal_data_check, + "authDisposableEmails": @auth_disposable_emails, + "authCanonicalEmails": @auth_canonical_emails, + "authFreeEmails": @auth_free_emails, + "authMockNumbers": @auth_mock_numbers.map { |it| it.to_map }, + "authSessionAlerts": @auth_session_alerts, + "authMembershipsUserName": @auth_memberships_user_name, + "authMembershipsUserEmail": @auth_memberships_user_email, + "authMembershipsMfa": @auth_memberships_mfa, + "authInvalidateSessions": @auth_invalidate_sessions, + "oAuthProviders": @o_auth_providers.map { |it| it.to_map }, + "platforms": @platforms, + "webhooks": @webhooks.map { |it| it.to_map }, + "keys": @keys.map { |it| it.to_map }, + "devKeys": @dev_keys.map { |it| it.to_map }, + "smtpEnabled": @smtp_enabled, + "smtpSenderName": @smtp_sender_name, + "smtpSenderEmail": @smtp_sender_email, + "smtpReplyTo": @smtp_reply_to, + "smtpHost": @smtp_host, + "smtpPort": @smtp_port, + "smtpUsername": @smtp_username, + "smtpPassword": @smtp_password, + "smtpSecure": @smtp_secure, + "pingCount": @ping_count, + "pingedAt": @pinged_at, + "labels": @labels, + "status": @status, + "authEmailPassword": @auth_email_password, + "authUsersAuthMagicURL": @auth_users_auth_magic_url, + "authEmailOtp": @auth_email_otp, + "authAnonymous": @auth_anonymous, + "authInvites": @auth_invites, + "authJWT": @auth_jwt, + "authPhone": @auth_phone, + "serviceStatusForAccount": @service_status_for_account, + "serviceStatusForAvatars": @service_status_for_avatars, + "serviceStatusForDatabases": @service_status_for_databases, + "serviceStatusForTablesdb": @service_status_for_tablesdb, + "serviceStatusForLocale": @service_status_for_locale, + "serviceStatusForHealth": @service_status_for_health, + "serviceStatusForProject": @service_status_for_project, + "serviceStatusForStorage": @service_status_for_storage, + "serviceStatusForTeams": @service_status_for_teams, + "serviceStatusForUsers": @service_status_for_users, + "serviceStatusForVcs": @service_status_for_vcs, + "serviceStatusForSites": @service_status_for_sites, + "serviceStatusForFunctions": @service_status_for_functions, + "serviceStatusForProxy": @service_status_for_proxy, + "serviceStatusForGraphql": @service_status_for_graphql, + "serviceStatusForMigrations": @service_status_for_migrations, + "serviceStatusForMessaging": @service_status_for_messaging, + "protocolStatusForRest": @protocol_status_for_rest, + "protocolStatusForGraphql": @protocol_status_for_graphql, + "protocolStatusForWebsocket": @protocol_status_for_websocket, + "region": @region, + "billingLimits": @billing_limits.to_map, + "blocks": @blocks.map { |it| it.to_map }, + "consoleAccessedAt": @console_accessed_at + } + end + end + end +end diff --git a/lib/appwrite/models/webhook.rb b/lib/appwrite/models/webhook.rb index 6229a2b..77ed5de 100644 --- a/lib/appwrite/models/webhook.rb +++ b/lib/appwrite/models/webhook.rb @@ -9,10 +9,10 @@ class Webhook attr_reader :name attr_reader :url attr_reader :events - attr_reader :security - attr_reader :http_user - attr_reader :http_pass - attr_reader :signature_key + attr_reader :tls + attr_reader :auth_username + attr_reader :auth_password + attr_reader :secret attr_reader :enabled attr_reader :logs attr_reader :attempts @@ -24,10 +24,10 @@ def initialize( name:, url:, events:, - security:, - http_user:, - http_pass:, - signature_key:, + tls:, + auth_username:, + auth_password:, + secret:, enabled:, logs:, attempts: @@ -38,10 +38,10 @@ def initialize( @name = name @url = url @events = events - @security = security - @http_user = http_user - @http_pass = http_pass - @signature_key = signature_key + @tls = tls + @auth_username = auth_username + @auth_password = auth_password + @secret = secret @enabled = enabled @logs = logs @attempts = attempts @@ -55,10 +55,10 @@ def self.from(map:) name: map["name"], url: map["url"], events: map["events"], - security: map["security"], - http_user: map["httpUser"], - http_pass: map["httpPass"], - signature_key: map["signatureKey"], + tls: map["tls"], + auth_username: map["authUsername"], + auth_password: map["authPassword"], + secret: map["secret"], enabled: map["enabled"], logs: map["logs"], attempts: map["attempts"] @@ -73,10 +73,10 @@ def to_map "name": @name, "url": @url, "events": @events, - "security": @security, - "httpUser": @http_user, - "httpPass": @http_pass, - "signatureKey": @signature_key, + "tls": @tls, + "authUsername": @auth_username, + "authPassword": @auth_password, + "secret": @secret, "enabled": @enabled, "logs": @logs, "attempts": @attempts diff --git a/lib/appwrite/service.rb b/lib/appwrite/service.rb index 0231ee7..c0ec9a5 100644 --- a/lib/appwrite/service.rb +++ b/lib/appwrite/service.rb @@ -4,4 +4,4 @@ def initialize(client) @client = client end end -end \ No newline at end of file +end diff --git a/lib/appwrite/services/account.rb b/lib/appwrite/services/account.rb index fd0c6c3..5880c7b 100644 --- a/lib/appwrite/services/account.rb +++ b/lib/appwrite/services/account.rb @@ -27,6 +27,7 @@ def get() params: api_params, response_type: Models::User ) + end # Use this endpoint to allow a new user to register a new account in your @@ -76,6 +77,7 @@ def create(user_id:, email:, password:, name: nil) params: api_params, response_type: Models::User ) + end # Update currently logged in user account email address. After changing user @@ -118,6 +120,7 @@ def update_email(email:, password:) params: api_params, response_type: Models::User ) + end # Get the list of identities for the currently logged in user. @@ -144,6 +147,7 @@ def list_identities(queries: nil, total: nil) params: api_params, response_type: Models::IdentityList ) + end # Delete an identity by its unique ID. @@ -172,6 +176,7 @@ def delete_identity(identity_id:) headers: api_headers, params: api_params, ) + end # Use this endpoint to create a JSON Web Token. You can use the resulting JWT @@ -201,6 +206,7 @@ def create_jwt(duration: nil) params: api_params, response_type: Models::Jwt ) + end # Get the list of latest security activity logs for the currently logged in @@ -228,6 +234,7 @@ def list_logs(queries: nil, total: nil) params: api_params, response_type: Models::LogList ) + end # Enable or disable MFA on an account. @@ -257,6 +264,7 @@ def update_mfa(mfa:) params: api_params, response_type: Models::User ) + end # Add an authenticator app to be used as an MFA factor. Verify the @@ -289,6 +297,7 @@ def create_mfa_authenticator(type:) params: api_params, response_type: Models::MfaType ) + end # Verify an authenticator app after adding it using the [add @@ -326,6 +335,7 @@ def update_mfa_authenticator(type:, otp:) params: api_params, response_type: Models::User ) + end # Delete an authenticator for a user by ID. @@ -354,6 +364,7 @@ def delete_mfa_authenticator(type:) headers: api_headers, params: api_params, ) + end # Begin the process of MFA verification after sign-in. Finish the flow with @@ -385,6 +396,7 @@ def create_mfa_challenge(factor:) params: api_params, response_type: Models::MfaChallenge ) + end # Complete the MFA challenge by providing the one-time password. Finish the @@ -424,6 +436,7 @@ def update_mfa_challenge(challenge_id:, otp:) params: api_params, response_type: Models::Session ) + end # List the factors available on the account to be used as a MFA challange. @@ -446,6 +459,7 @@ def list_mfa_factors() params: api_params, response_type: Models::MfaFactors ) + end # Get recovery codes that can be used as backup for MFA flow. Before getting @@ -471,6 +485,7 @@ def get_mfa_recovery_codes() params: api_params, response_type: Models::MfaRecoveryCodes ) + end # Generate recovery codes as backup for MFA flow. It's recommended to @@ -498,6 +513,7 @@ def create_mfa_recovery_codes() params: api_params, response_type: Models::MfaRecoveryCodes ) + end # Regenerate recovery codes that can be used as backup for MFA flow. Before @@ -524,6 +540,7 @@ def update_mfa_recovery_codes() params: api_params, response_type: Models::MfaRecoveryCodes ) + end # Update currently logged in user account name. @@ -553,6 +570,7 @@ def update_name(name:) params: api_params, response_type: Models::User ) + end # Update currently logged in user password. For validation, user is required @@ -586,6 +604,7 @@ def update_password(password:, old_password: nil) params: api_params, response_type: Models::User ) + end # Update the currently logged in user's phone number. After updating the @@ -625,6 +644,7 @@ def update_phone(phone:, password:) params: api_params, response_type: Models::User ) + end # Get the preferences as a key-value object for the currently logged in user. @@ -647,6 +667,7 @@ def get_prefs() params: api_params, response_type: Models::Preferences ) + end # Update currently logged in user account preferences. The object you pass is @@ -678,6 +699,7 @@ def update_prefs(prefs:) params: api_params, response_type: Models::User ) + end # Sends the user an email with a temporary secret key for password reset. @@ -720,6 +742,7 @@ def create_recovery(email:, url:) params: api_params, response_type: Models::Token ) + end # Use this endpoint to complete the user account password reset. Both the @@ -770,6 +793,7 @@ def update_recovery(user_id:, secret:, password:) params: api_params, response_type: Models::Token ) + end # Get the list of active sessions across different devices for the currently @@ -793,6 +817,7 @@ def list_sessions() params: api_params, response_type: Models::SessionList ) + end # Delete all sessions from the user account and remove any sessions cookies @@ -816,6 +841,7 @@ def delete_sessions() headers: api_headers, params: api_params, ) + end # Use this endpoint to allow a new user to register an anonymous account in @@ -845,6 +871,7 @@ def create_anonymous_session() params: api_params, response_type: Models::Session ) + end # Allow the user to login into their account by providing a valid email and @@ -885,6 +912,7 @@ def create_email_password_session(email:, password:) params: api_params, response_type: Models::Session ) + end # @@ -925,6 +953,7 @@ def update_magic_url_session(user_id:, secret:) params: api_params, response_type: Models::Session ) + end # @@ -965,6 +994,7 @@ def update_phone_session(user_id:, secret:) params: api_params, response_type: Models::Session ) + end # Use this endpoint to create a session from token. Provide the **userId** @@ -1002,6 +1032,7 @@ def create_session(user_id:, secret:) params: api_params, response_type: Models::Session ) + end # Use this endpoint to get a logged in user's session using a Session ID. @@ -1031,6 +1062,7 @@ def get_session(session_id:) params: api_params, response_type: Models::Session ) + end # Use this endpoint to extend a session's length. Extending a session is @@ -1062,6 +1094,7 @@ def update_session(session_id:) params: api_params, response_type: Models::Session ) + end # Logout the user. Use 'current' as the session ID to logout on this device, @@ -1094,6 +1127,7 @@ def delete_session(session_id:) headers: api_headers, params: api_params, ) + end # Block the currently logged in user account. Behind the scene, the user @@ -1119,6 +1153,7 @@ def update_status() params: api_params, response_type: Models::User ) + end # Sends the user an email with a secret key for creating a session. If the @@ -1169,6 +1204,7 @@ def create_email_token(user_id:, email:, phrase: nil) params: api_params, response_type: Models::Token ) + end # Sends the user an email with a secret key for creating a session. If the @@ -1221,6 +1257,7 @@ def create_magic_url_token(user_id:, email:, url: nil, phrase: nil) params: api_params, response_type: Models::Token ) + end # Allow the user to login to their account using the OAuth2 provider of their @@ -1238,7 +1275,7 @@ def create_magic_url_token(user_id:, email:, url: nil, phrase: nil) # about session # limits](https://appwrite.io/docs/authentication-security#limits). # - # @param [OAuthProvider] provider OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom. + # @param [OAuthProvider] provider OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, x, yahoo, yammer, yandex, zoho, zoom. # @param [String] success URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. # @param [String] failure URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. # @param [Array] scopes A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. @@ -1268,6 +1305,7 @@ def create_o_auth2_token(provider:, success: nil, failure: nil, scopes: nil) params: api_params, response_type: "location" ) + end # Sends the user an SMS with a secret key for creating a session. If the @@ -1312,6 +1350,7 @@ def create_phone_token(user_id:, phone:) params: api_params, response_type: Models::Token ) + end # Use this endpoint to send a verification message to your user email address @@ -1355,6 +1394,7 @@ def create_email_verification(url:) params: api_params, response_type: Models::Token ) + end # @@ -1401,6 +1441,7 @@ def create_verification(url:) params: api_params, response_type: Models::Token ) + end # Use this endpoint to complete the user email verification process. Use both @@ -1439,6 +1480,7 @@ def update_email_verification(user_id:, secret:) params: api_params, response_type: Models::Token ) + end # @@ -1480,6 +1522,7 @@ def update_verification(user_id:, secret:) params: api_params, response_type: Models::Token ) + end # Use this endpoint to send a verification SMS to the currently logged in @@ -1510,6 +1553,7 @@ def create_phone_verification() params: api_params, response_type: Models::Token ) + end # Use this endpoint to complete the user phone verification process. Use the @@ -1548,7 +1592,8 @@ def update_phone_verification(user_id:, secret:) params: api_params, response_type: Models::Token ) + end end -end \ No newline at end of file +end diff --git a/lib/appwrite/services/activities.rb b/lib/appwrite/services/activities.rb index cd1b576..e3528c3 100644 --- a/lib/appwrite/services/activities.rb +++ b/lib/appwrite/services/activities.rb @@ -29,6 +29,7 @@ def list_events(queries: nil) params: api_params, response_type: Models::ActivityEventList ) + end # Get event by ID. @@ -58,7 +59,8 @@ def get_event(event_id:) params: api_params, response_type: Models::ActivityEvent ) + end end -end \ No newline at end of file +end diff --git a/lib/appwrite/services/avatars.rb b/lib/appwrite/services/avatars.rb index e100c0c..6356864 100644 --- a/lib/appwrite/services/avatars.rb +++ b/lib/appwrite/services/avatars.rb @@ -47,6 +47,7 @@ def get_browser(code:, width: nil, height: nil, quality: nil) headers: api_headers, params: api_params, ) + end # The credit card endpoint will return you the icon of the credit card @@ -88,6 +89,7 @@ def get_credit_card(code:, width: nil, height: nil, quality: nil) headers: api_headers, params: api_params, ) + end # Use this endpoint to fetch the favorite icon (AKA favicon) of any remote @@ -118,6 +120,7 @@ def get_favicon(url:) headers: api_headers, params: api_params, ) + end # You can use this endpoint to show different country flags icons to your @@ -160,6 +163,7 @@ def get_flag(code:, width: nil, height: nil, quality: nil) headers: api_headers, params: api_params, ) + end # Use this endpoint to fetch a remote image URL and crop it to any image size @@ -201,6 +205,7 @@ def get_image(url:, width: nil, height: nil) headers: api_headers, params: api_params, ) + end # Use this endpoint to show your user initials avatar icon on your website or @@ -245,6 +250,7 @@ def get_initials(name: nil, width: nil, height: nil, background: nil) headers: api_headers, params: api_params, ) + end # Converts a given plain text to a QR code image. You can use the query @@ -280,6 +286,7 @@ def get_qr(text:, size: nil, margin: nil, download: nil) headers: api_headers, params: api_params, ) + end # Use this endpoint to capture a screenshot of any website URL. This endpoint @@ -354,7 +361,8 @@ def get_screenshot(url:, headers: nil, viewport_width: nil, viewport_height: nil headers: api_headers, params: api_params, ) + end end -end \ No newline at end of file +end diff --git a/lib/appwrite/services/backups.rb b/lib/appwrite/services/backups.rb index 1247e28..63e109a 100644 --- a/lib/appwrite/services/backups.rb +++ b/lib/appwrite/services/backups.rb @@ -29,6 +29,7 @@ def list_archives(queries: nil) params: api_params, response_type: Models::BackupArchiveList ) + end # Create a new archive asynchronously for a project. @@ -60,6 +61,7 @@ def create_archive(services:, resource_id: nil) params: api_params, response_type: Models::BackupArchive ) + end # Get a backup archive using it's ID. @@ -88,6 +90,7 @@ def get_archive(archive_id:) params: api_params, response_type: Models::BackupArchive ) + end # Delete an existing archive for a project. @@ -116,6 +119,7 @@ def delete_archive(archive_id:) headers: api_headers, params: api_params, ) + end # List all policies for a project. @@ -140,6 +144,7 @@ def list_policies(queries: nil) params: api_params, response_type: Models::BackupPolicyList ) + end # Create a new backup policy. @@ -193,6 +198,7 @@ def create_policy(policy_id:, services:, retention:, schedule:, name: nil, resou params: api_params, response_type: Models::BackupPolicy ) + end # Get a backup policy using it's ID. @@ -221,6 +227,7 @@ def get_policy(policy_id:) params: api_params, response_type: Models::BackupPolicy ) + end # Update an existing policy using it's ID. @@ -258,6 +265,7 @@ def update_policy(policy_id:, name: nil, retention: nil, schedule: nil, enabled: params: api_params, response_type: Models::BackupPolicy ) + end # Delete a policy using it's ID. @@ -286,6 +294,7 @@ def delete_policy(policy_id:) headers: api_headers, params: api_params, ) + end # Create and trigger a new restoration for a backup on a project. @@ -325,6 +334,7 @@ def create_restoration(archive_id:, services:, new_resource_id: nil, new_resourc params: api_params, response_type: Models::BackupRestoration ) + end # List all backup restorations for a project. @@ -349,6 +359,7 @@ def list_restorations(queries: nil) params: api_params, response_type: Models::BackupRestorationList ) + end # Get the current status of a backup restoration. @@ -377,7 +388,8 @@ def get_restoration(restoration_id:) params: api_params, response_type: Models::BackupRestoration ) + end end -end \ No newline at end of file +end diff --git a/lib/appwrite/services/databases.rb b/lib/appwrite/services/databases.rb index dabe67c..ca0600e 100644 --- a/lib/appwrite/services/databases.rb +++ b/lib/appwrite/services/databases.rb @@ -37,6 +37,7 @@ def list(queries: nil, search: nil, total: nil) params: api_params, response_type: Models::DatabaseList ) + end # @@ -78,6 +79,7 @@ def create(database_id:, name:, enabled: nil) params: api_params, response_type: Models::Database ) + end # List transactions across all databases. @@ -102,6 +104,7 @@ def list_transactions(queries: nil) params: api_params, response_type: Models::TransactionList ) + end # Create a new transaction. @@ -127,6 +130,7 @@ def create_transaction(ttl: nil) params: api_params, response_type: Models::Transaction ) + end # Get a transaction by its unique ID. @@ -155,6 +159,7 @@ def get_transaction(transaction_id:) params: api_params, response_type: Models::Transaction ) + end # Update a transaction, to either commit or roll back its operations. @@ -188,6 +193,7 @@ def update_transaction(transaction_id:, commit: nil, rollback: nil) params: api_params, response_type: Models::Transaction ) + end # Delete a transaction by its unique ID. @@ -216,6 +222,7 @@ def delete_transaction(transaction_id:) headers: api_headers, params: api_params, ) + end # Create multiple operations in a single transaction. @@ -247,6 +254,7 @@ def create_operations(transaction_id:, operations: nil) params: api_params, response_type: Models::Transaction ) + end # @@ -279,6 +287,7 @@ def get(database_id:) params: api_params, response_type: Models::Database ) + end # @@ -315,6 +324,7 @@ def update(database_id:, name: nil, enabled: nil) params: api_params, response_type: Models::Database ) + end # @@ -347,6 +357,7 @@ def delete(database_id:) headers: api_headers, params: api_params, ) + end # @@ -385,6 +396,7 @@ def list_collections(database_id:, queries: nil, search: nil, total: nil) params: api_params, response_type: Models::CollectionList ) + end # @@ -442,6 +454,7 @@ def create_collection(database_id:, collection_id:, name:, permissions: nil, doc params: api_params, response_type: Models::Collection ) + end # @@ -480,6 +493,7 @@ def get_collection(database_id:, collection_id:) params: api_params, response_type: Models::Collection ) + end # @@ -493,9 +507,10 @@ def get_collection(database_id:, collection_id:) # @param [Array] permissions An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). # @param [] document_security Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). # @param [] enabled Is collection enabled? When set to 'disabled', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled. + # @param [] purge When true, purge all cached list responses for this collection as part of the update. Use this to force readers to see fresh data immediately instead of waiting for the cache TTL to expire. # # @return [Collection] - def update_collection(database_id:, collection_id:, name: nil, permissions: nil, document_security: nil, enabled: nil) + def update_collection(database_id:, collection_id:, name: nil, permissions: nil, document_security: nil, enabled: nil, purge: nil) api_path = '/databases/{databaseId}/collections/{collectionId}' .gsub('{databaseId}', database_id) .gsub('{collectionId}', collection_id) @@ -513,6 +528,7 @@ def update_collection(database_id:, collection_id:, name: nil, permissions: nil, permissions: permissions, documentSecurity: document_security, enabled: enabled, + purge: purge, } api_headers = { @@ -526,6 +542,7 @@ def update_collection(database_id:, collection_id:, name: nil, permissions: nil, params: api_params, response_type: Models::Collection ) + end # @@ -564,6 +581,7 @@ def delete_collection(database_id:, collection_id:) headers: api_headers, params: api_params, ) + end # @@ -605,6 +623,7 @@ def list_attributes(database_id:, collection_id:, queries: nil, total: nil) params: api_params, response_type: Models::AttributeList ) + end # @@ -660,6 +679,7 @@ def create_boolean_attribute(database_id:, collection_id:, key:, required:, defa params: api_params, response_type: Models::AttributeBoolean ) + end # @@ -719,6 +739,7 @@ def update_boolean_attribute(database_id:, collection_id:, key:, required:, defa params: api_params, response_type: Models::AttributeBoolean ) + end # @@ -773,6 +794,7 @@ def create_datetime_attribute(database_id:, collection_id:, key:, required:, def params: api_params, response_type: Models::AttributeDatetime ) + end # @@ -832,6 +854,7 @@ def update_datetime_attribute(database_id:, collection_id:, key:, required:, def params: api_params, response_type: Models::AttributeDatetime ) + end # @@ -887,6 +910,7 @@ def create_email_attribute(database_id:, collection_id:, key:, required:, defaul params: api_params, response_type: Models::AttributeEmail ) + end # @@ -947,6 +971,7 @@ def update_email_attribute(database_id:, collection_id:, key:, required:, defaul params: api_params, response_type: Models::AttributeEmail ) + end # @@ -1009,6 +1034,7 @@ def create_enum_attribute(database_id:, collection_id:, key:, elements:, require params: api_params, response_type: Models::AttributeEnum ) + end # @@ -1075,6 +1101,7 @@ def update_enum_attribute(database_id:, collection_id:, key:, elements:, require params: api_params, response_type: Models::AttributeEnum ) + end # @@ -1135,6 +1162,7 @@ def create_float_attribute(database_id:, collection_id:, key:, required:, min: n params: api_params, response_type: Models::AttributeFloat ) + end # @@ -1199,6 +1227,7 @@ def update_float_attribute(database_id:, collection_id:, key:, required:, defaul params: api_params, response_type: Models::AttributeFloat ) + end # @@ -1259,6 +1288,7 @@ def create_integer_attribute(database_id:, collection_id:, key:, required:, min: params: api_params, response_type: Models::AttributeInteger ) + end # @@ -1323,6 +1353,7 @@ def update_integer_attribute(database_id:, collection_id:, key:, required:, defa params: api_params, response_type: Models::AttributeInteger ) + end # @@ -1378,6 +1409,7 @@ def create_ip_attribute(database_id:, collection_id:, key:, required:, default: params: api_params, response_type: Models::AttributeIp ) + end # @@ -1438,6 +1470,7 @@ def update_ip_attribute(database_id:, collection_id:, key:, required:, default:, params: api_params, response_type: Models::AttributeIp ) + end # @@ -1490,6 +1523,7 @@ def create_line_attribute(database_id:, collection_id:, key:, required:, default params: api_params, response_type: Models::AttributeLine ) + end # @@ -1545,6 +1579,7 @@ def update_line_attribute(database_id:, collection_id:, key:, required:, default params: api_params, response_type: Models::AttributeLine ) + end # Create a longtext attribute. @@ -1599,6 +1634,7 @@ def create_longtext_attribute(database_id:, collection_id:, key:, required:, def params: api_params, response_type: Models::AttributeLongtext ) + end # Update a longtext attribute. Changing the `default` value will not update @@ -1656,6 +1692,7 @@ def update_longtext_attribute(database_id:, collection_id:, key:, required:, def params: api_params, response_type: Models::AttributeLongtext ) + end # Create a mediumtext attribute. @@ -1710,6 +1747,7 @@ def create_mediumtext_attribute(database_id:, collection_id:, key:, required:, d params: api_params, response_type: Models::AttributeMediumtext ) + end # Update a mediumtext attribute. Changing the `default` value will not update @@ -1767,6 +1805,7 @@ def update_mediumtext_attribute(database_id:, collection_id:, key:, required:, d params: api_params, response_type: Models::AttributeMediumtext ) + end # @@ -1819,6 +1858,7 @@ def create_point_attribute(database_id:, collection_id:, key:, required:, defaul params: api_params, response_type: Models::AttributePoint ) + end # @@ -1874,6 +1914,7 @@ def update_point_attribute(database_id:, collection_id:, key:, required:, defaul params: api_params, response_type: Models::AttributePoint ) + end # @@ -1926,6 +1967,7 @@ def create_polygon_attribute(database_id:, collection_id:, key:, required:, defa params: api_params, response_type: Models::AttributePolygon ) + end # @@ -1981,6 +2023,7 @@ def update_polygon_attribute(database_id:, collection_id:, key:, required:, defa params: api_params, response_type: Models::AttributePolygon ) + end # @@ -2041,6 +2084,7 @@ def create_relationship_attribute(database_id:, collection_id:, related_collecti params: api_params, response_type: Models::AttributeRelationship ) + end # @@ -2091,6 +2135,7 @@ def update_relationship_attribute(database_id:, collection_id:, key:, on_delete: params: api_params, response_type: Models::AttributeRelationship ) + end # @@ -2154,6 +2199,7 @@ def create_string_attribute(database_id:, collection_id:, key:, size:, required: params: api_params, response_type: Models::AttributeString ) + end # @@ -2216,6 +2262,7 @@ def update_string_attribute(database_id:, collection_id:, key:, required:, defau params: api_params, response_type: Models::AttributeString ) + end # Create a text attribute. @@ -2270,6 +2317,7 @@ def create_text_attribute(database_id:, collection_id:, key:, required:, default params: api_params, response_type: Models::AttributeText ) + end # Update a text attribute. Changing the `default` value will not update @@ -2327,6 +2375,7 @@ def update_text_attribute(database_id:, collection_id:, key:, required:, default params: api_params, response_type: Models::AttributeText ) + end # @@ -2382,6 +2431,7 @@ def create_url_attribute(database_id:, collection_id:, key:, required:, default: params: api_params, response_type: Models::AttributeUrl ) + end # @@ -2442,6 +2492,7 @@ def update_url_attribute(database_id:, collection_id:, key:, required:, default: params: api_params, response_type: Models::AttributeUrl ) + end # Create a varchar attribute. @@ -2502,6 +2553,7 @@ def create_varchar_attribute(database_id:, collection_id:, key:, size:, required params: api_params, response_type: Models::AttributeVarchar ) + end # Update a varchar attribute. Changing the `default` value will not update @@ -2561,6 +2613,7 @@ def update_varchar_attribute(database_id:, collection_id:, key:, required:, defa params: api_params, response_type: Models::AttributeVarchar ) + end # @@ -2572,7 +2625,7 @@ def update_varchar_attribute(database_id:, collection_id:, key:, required:, defa # @param [String] collection_id Collection ID. # @param [String] key Attribute Key. # - # @return [] + # @return [AttributeBoolean, AttributeInteger, AttributeFloat, AttributeEmail, AttributeEnum, AttributeUrl, AttributeIp, AttributeDatetime, AttributeRelationship, AttributeString] def get_attribute(database_id:, collection_id:, key:) api_path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}' .gsub('{databaseId}', database_id) @@ -2597,13 +2650,69 @@ def get_attribute(database_id:, collection_id:, key:) api_headers = { } - @client.call( + response = @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, - response_type: Models::AttributeBoolean ) + + unless response.is_a?(Hash) + raise Exception, "Expected object response when hydrating a response model" + end + + if response['type'] == 'string' && response['format'] == 'email' + + return Models::AttributeEmail.from(map: response) + end + + if response['type'] == 'string' && response['format'] == 'enum' + + return Models::AttributeEnum.from(map: response) + end + + if response['type'] == 'string' && response['format'] == 'url' + + return Models::AttributeUrl.from(map: response) + end + + if response['type'] == 'string' && response['format'] == 'ip' + + return Models::AttributeIp.from(map: response) + end + + if response['type'] == 'boolean' + + return Models::AttributeBoolean.from(map: response) + end + + if response['type'] == 'integer' + + return Models::AttributeInteger.from(map: response) + end + + if response['type'] == 'double' + + return Models::AttributeFloat.from(map: response) + end + + if response['type'] == 'datetime' + + return Models::AttributeDatetime.from(map: response) + end + + if response['type'] == 'relationship' + + return Models::AttributeRelationship.from(map: response) + end + + if response['type'] == 'string' + + return Models::AttributeString.from(map: response) + end + + raise Exception, "Unable to match response to any expected response model" + end # @@ -2647,6 +2756,7 @@ def delete_attribute(database_id:, collection_id:, key:) headers: api_headers, params: api_params, ) + end # @@ -2660,7 +2770,7 @@ def delete_attribute(database_id:, collection_id:, key:) # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. # @param [String] transaction_id Transaction ID to read uncommitted changes within the transaction. # @param [] total When set to false, the total count returned will be 0 and will not be calculated. - # @param [Integer] ttl TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). + # @param [Integer] ttl TTL (seconds) for caching list responses. Responses are stored in an in-memory key-value cache, keyed per project, collection, schema version (attributes and indexes), caller authorization roles, and the exact query — so users with different permissions never share cached entries. Schema changes invalidate cached entries automatically; document writes do not, so choose a TTL you are comfortable serving as stale data. Set to 0 to disable caching. Must be between 0 and 86400 (24 hours). # # @return [DocumentList] def list_documents(database_id:, collection_id:, queries: nil, transaction_id: nil, total: nil, ttl: nil) @@ -2693,6 +2803,7 @@ def list_documents(database_id:, collection_id:, queries: nil, transaction_id: n params: api_params, response_type: Models::DocumentList ) + end # @@ -2750,6 +2861,7 @@ def create_document(database_id:, collection_id:, document_id:, data:, permissio params: api_params, response_type: Models::Document ) + end # @@ -2799,6 +2911,7 @@ def create_documents(database_id:, collection_id:, documents:, transaction_id: n params: api_params, response_type: Models::DocumentList ) + end # @@ -2849,6 +2962,7 @@ def upsert_documents(database_id:, collection_id:, documents:, transaction_id: n params: api_params, response_type: Models::DocumentList ) + end # @@ -2895,6 +3009,7 @@ def update_documents(database_id:, collection_id:, data: nil, queries: nil, tran params: api_params, response_type: Models::DocumentList ) + end # @@ -2938,6 +3053,7 @@ def delete_documents(database_id:, collection_id:, queries: nil, transaction_id: params: api_params, response_type: Models::DocumentList ) + end # @@ -2986,6 +3102,7 @@ def get_document(database_id:, collection_id:, document_id:, queries: nil, trans params: api_params, response_type: Models::Document ) + end # @@ -3039,6 +3156,7 @@ def upsert_document(database_id:, collection_id:, document_id:, data: nil, permi params: api_params, response_type: Models::Document ) + end # @@ -3090,6 +3208,7 @@ def update_document(database_id:, collection_id:, document_id:, data: nil, permi params: api_params, response_type: Models::Document ) + end # @@ -3135,6 +3254,7 @@ def delete_document(database_id:, collection_id:, document_id:, transaction_id: headers: api_headers, params: api_params, ) + end # @@ -3191,6 +3311,7 @@ def decrement_document_attribute(database_id:, collection_id:, document_id:, att params: api_params, response_type: Models::Document ) + end # @@ -3247,6 +3368,7 @@ def increment_document_attribute(database_id:, collection_id:, document_id:, att params: api_params, response_type: Models::Document ) + end # @@ -3288,6 +3410,7 @@ def list_indexes(database_id:, collection_id:, queries: nil, total: nil) params: api_params, response_type: Models::IndexList ) + end # @@ -3350,6 +3473,7 @@ def create_index(database_id:, collection_id:, key:, type:, attributes:, orders: params: api_params, response_type: Models::Index ) + end # @@ -3393,6 +3517,7 @@ def get_index(database_id:, collection_id:, key:) params: api_params, response_type: Models::Index ) + end # @@ -3436,7 +3561,8 @@ def delete_index(database_id:, collection_id:, key:) headers: api_headers, params: api_params, ) + end end -end \ No newline at end of file +end diff --git a/lib/appwrite/services/functions.rb b/lib/appwrite/services/functions.rb index f10a6f6..377e9be 100644 --- a/lib/appwrite/services/functions.rb +++ b/lib/appwrite/services/functions.rb @@ -34,6 +34,7 @@ def list(queries: nil, search: nil, total: nil) params: api_params, response_type: Models::FunctionList ) + end # Create a new function. You can pass a list of @@ -112,6 +113,7 @@ def create(function_id:, name:, runtime:, execute: nil, events: nil, schedule: n params: api_params, response_type: Models::Function ) + end # Get a list of all runtimes that are currently active on your instance. @@ -134,6 +136,7 @@ def list_runtimes() params: api_params, response_type: Models::RuntimeList ) + end # List allowed function specifications for this instance. @@ -156,6 +159,7 @@ def list_specifications() params: api_params, response_type: Models::SpecificationList ) + end # Get a function by its unique ID. @@ -184,6 +188,7 @@ def get(function_id:) params: api_params, response_type: Models::Function ) + end # Update function by its unique ID. @@ -255,6 +260,7 @@ def update(function_id:, name:, runtime: nil, execute: nil, events: nil, schedul params: api_params, response_type: Models::Function ) + end # Delete a function by its unique ID. @@ -283,6 +289,7 @@ def delete(function_id:) headers: api_headers, params: api_params, ) + end # Update the function active deployment. Use this endpoint to switch the code @@ -319,6 +326,7 @@ def update_function_deployment(function_id:, deployment_id:) params: api_params, response_type: Models::Function ) + end # Get a list of all the function's code deployments. You can use the query @@ -354,6 +362,7 @@ def list_deployments(function_id:, queries: nil, search: nil, total: nil) params: api_params, response_type: Models::DeploymentList ) + end # Create a new function code deployment. Use this endpoint to upload a new @@ -413,6 +422,7 @@ def create_deployment(function_id:, code:, activate:, entrypoint: nil, commands: on_progress: on_progress, response_type: Models::Deployment ) + end # Create a new build for an existing function deployment. This endpoint @@ -454,6 +464,7 @@ def create_duplicate_deployment(function_id:, deployment_id:, build_id: nil) params: api_params, response_type: Models::Deployment ) + end # Create a deployment based on a template. @@ -519,6 +530,7 @@ def create_template_deployment(function_id:, repository:, owner:, root_directory params: api_params, response_type: Models::Deployment ) + end # Create a deployment when a function is connected to VCS. @@ -564,6 +576,7 @@ def create_vcs_deployment(function_id:, type:, reference:, activate: nil) params: api_params, response_type: Models::Deployment ) + end # Get a function deployment by its unique ID. @@ -598,6 +611,7 @@ def get_deployment(function_id:, deployment_id:) params: api_params, response_type: Models::Deployment ) + end # Delete a code deployment by its unique ID. @@ -632,6 +646,7 @@ def delete_deployment(function_id:, deployment_id:) headers: api_headers, params: api_params, ) + end # Get a function deployment content by its unique ID. The endpoint response @@ -669,6 +684,7 @@ def get_deployment_download(function_id:, deployment_id:, type: nil) headers: api_headers, params: api_params, ) + end # Cancel an ongoing function deployment build. If the build is already in @@ -708,6 +724,7 @@ def update_deployment_status(function_id:, deployment_id:) params: api_params, response_type: Models::Deployment ) + end # Get a list of all the current user function execution logs. You can use the @@ -741,6 +758,7 @@ def list_executions(function_id:, queries: nil, total: nil) params: api_params, response_type: Models::ExecutionList ) + end # Trigger a function execution. The returned object will return you the @@ -785,6 +803,7 @@ def create_execution(function_id:, body: nil, async: nil, xpath: nil, method: ni params: api_params, response_type: Models::Execution ) + end # Get a function execution log by its unique ID. @@ -819,6 +838,7 @@ def get_execution(function_id:, execution_id:) params: api_params, response_type: Models::Execution ) + end # Delete a function execution by its unique ID. @@ -853,6 +873,7 @@ def delete_execution(function_id:, execution_id:) headers: api_headers, params: api_params, ) + end # Get a list of all variables of a specific function. @@ -881,6 +902,7 @@ def list_variables(function_id:) params: api_params, response_type: Models::VariableList ) + end # Create a new function environment variable. These variables can be accessed @@ -925,6 +947,7 @@ def create_variable(function_id:, key:, value:, secret: nil) params: api_params, response_type: Models::Variable ) + end # Get a variable by its unique ID. @@ -959,6 +982,7 @@ def get_variable(function_id:, variable_id:) params: api_params, response_type: Models::Variable ) + end # Update variable by its unique ID. @@ -1004,6 +1028,7 @@ def update_variable(function_id:, variable_id:, key:, value: nil, secret: nil) params: api_params, response_type: Models::Variable ) + end # Delete a variable by its unique ID. @@ -1038,7 +1063,8 @@ def delete_variable(function_id:, variable_id:) headers: api_headers, params: api_params, ) + end end -end \ No newline at end of file +end diff --git a/lib/appwrite/services/graphql.rb b/lib/appwrite/services/graphql.rb index 0c32737..171e9ae 100644 --- a/lib/appwrite/services/graphql.rb +++ b/lib/appwrite/services/graphql.rb @@ -11,7 +11,7 @@ def initialize(client) # # @param [Hash] query The query or queries to execute. # - # @return [Any] + # @return [] def query(query:) api_path = '/graphql' @@ -34,13 +34,14 @@ def query(query:) headers: api_headers, params: api_params, ) + end # Execute a GraphQL mutation. # # @param [Hash] query The query or queries to execute. # - # @return [Any] + # @return [] def mutation(query:) api_path = '/graphql/mutation' @@ -63,7 +64,8 @@ def mutation(query:) headers: api_headers, params: api_params, ) + end end -end \ No newline at end of file +end diff --git a/lib/appwrite/services/health.rb b/lib/appwrite/services/health.rb index ae8d0b3..5923ff9 100644 --- a/lib/appwrite/services/health.rb +++ b/lib/appwrite/services/health.rb @@ -27,6 +27,7 @@ def get() params: api_params, response_type: Models::HealthStatus ) + end # Check the Appwrite Antivirus server is up and connection is successful. @@ -49,6 +50,7 @@ def get_antivirus() params: api_params, response_type: Models::HealthAntivirus ) + end # Check the Appwrite in-memory cache servers are up and connection is @@ -72,6 +74,7 @@ def get_cache() params: api_params, response_type: Models::HealthStatusList ) + end # Get the SSL certificate for a domain @@ -96,6 +99,7 @@ def get_certificate(domain: nil) params: api_params, response_type: Models::HealthCertificate ) + end # Get console pausing health status. Monitors projects approaching the pause @@ -124,6 +128,7 @@ def get_console_pausing(threshold: nil, inactivity_days: nil) params: api_params, response_type: Models::HealthStatus ) + end # Check the Appwrite database servers are up and connection is successful. @@ -146,6 +151,7 @@ def get_db() params: api_params, response_type: Models::HealthStatusList ) + end # Check the Appwrite pub-sub servers are up and connection is successful. @@ -168,10 +174,12 @@ def get_pub_sub() params: api_params, 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. # @@ -193,6 +201,7 @@ def get_queue_audits(threshold: nil) params: api_params, response_type: Models::HealthQueue ) + end # Get the number of builds that are waiting to be processed in the Appwrite @@ -218,6 +227,7 @@ def get_queue_builds(threshold: nil) params: api_params, response_type: Models::HealthQueue ) + end # Get the number of certificates that are waiting to be issued against @@ -244,6 +254,7 @@ def get_queue_certificates(threshold: nil) params: api_params, response_type: Models::HealthQueue ) + end # Get the number of database changes that are waiting to be processed in the @@ -271,6 +282,7 @@ def get_queue_databases(name: nil, threshold: nil) params: api_params, response_type: Models::HealthQueue ) + end # Get the number of background destructive changes that are waiting to be @@ -296,6 +308,7 @@ def get_queue_deletes(threshold: nil) params: api_params, response_type: Models::HealthQueue ) + end # Returns the amount of failed jobs in a given queue. @@ -327,6 +340,7 @@ def get_failed_jobs(name:, threshold: nil) params: api_params, response_type: Models::HealthQueue ) + end # Get the number of function executions that are waiting to be processed in @@ -352,6 +366,7 @@ def get_queue_functions(threshold: nil) params: api_params, response_type: Models::HealthQueue ) + end # Get the number of logs that are waiting to be processed in the Appwrite @@ -377,6 +392,7 @@ def get_queue_logs(threshold: nil) params: api_params, response_type: Models::HealthQueue ) + end # Get the number of mails that are waiting to be processed in the Appwrite @@ -402,6 +418,7 @@ def get_queue_mails(threshold: nil) params: api_params, response_type: Models::HealthQueue ) + end # Get the number of messages that are waiting to be processed in the Appwrite @@ -427,6 +444,7 @@ def get_queue_messaging(threshold: nil) params: api_params, response_type: Models::HealthQueue ) + end # Get the number of migrations that are waiting to be processed in the @@ -452,6 +470,7 @@ def get_queue_migrations(threshold: nil) params: api_params, response_type: Models::HealthQueue ) + end # Get the number of metrics that are waiting to be processed in the Appwrite @@ -477,6 +496,7 @@ def get_queue_stats_resources(threshold: nil) params: api_params, response_type: Models::HealthQueue ) + end # Get the number of metrics that are waiting to be processed in the Appwrite @@ -502,6 +522,7 @@ def get_queue_usage(threshold: nil) params: api_params, response_type: Models::HealthQueue ) + end # Get the number of webhooks that are waiting to be processed in the Appwrite @@ -527,6 +548,7 @@ def get_queue_webhooks(threshold: nil) params: api_params, response_type: Models::HealthQueue ) + end # Check the Appwrite storage device is up and connection is successful. @@ -549,6 +571,7 @@ def get_storage() params: api_params, response_type: Models::HealthStatus ) + end # Check the Appwrite local storage device is up and connection is successful. @@ -571,6 +594,7 @@ def get_storage_local() params: api_params, response_type: Models::HealthStatus ) + end # Check the Appwrite server time is synced with Google remote NTP server. We @@ -599,7 +623,8 @@ def get_time() params: api_params, response_type: Models::HealthTime ) + end end -end \ No newline at end of file +end diff --git a/lib/appwrite/services/locale.rb b/lib/appwrite/services/locale.rb index 00296f4..b2be273 100644 --- a/lib/appwrite/services/locale.rb +++ b/lib/appwrite/services/locale.rb @@ -32,6 +32,7 @@ def get() params: api_params, response_type: Models::Locale ) + end # List of all locale codes in [ISO @@ -55,6 +56,7 @@ def list_codes() params: api_params, response_type: Models::LocaleCodeList ) + end # List of all continents. You can use the locale header to get the data in a @@ -78,6 +80,7 @@ def list_continents() params: api_params, response_type: Models::ContinentList ) + end # List of all countries. You can use the locale header to get the data in a @@ -101,6 +104,7 @@ def list_countries() params: api_params, response_type: Models::CountryList ) + end # List of all countries that are currently members of the EU. You can use the @@ -124,6 +128,7 @@ def list_countries_eu() params: api_params, response_type: Models::CountryList ) + end # List of all countries phone codes. You can use the locale header to get the @@ -147,6 +152,7 @@ def list_countries_phones() params: api_params, response_type: Models::PhoneList ) + end # List of all currencies, including currency symbol, name, plural, and @@ -171,6 +177,7 @@ def list_currencies() params: api_params, response_type: Models::CurrencyList ) + end # List of all languages classified by ISO 639-1 including 2-letter code, name @@ -194,7 +201,8 @@ def list_languages() params: api_params, response_type: Models::LanguageList ) + end end -end \ No newline at end of file +end diff --git a/lib/appwrite/services/messaging.rb b/lib/appwrite/services/messaging.rb index 28ba2e2..7840c34 100644 --- a/lib/appwrite/services/messaging.rb +++ b/lib/appwrite/services/messaging.rb @@ -33,6 +33,7 @@ def list_messages(queries: nil, search: nil, total: nil) params: api_params, response_type: Models::MessageList ) + end # Create a new email message. @@ -92,6 +93,7 @@ def create_email(message_id:, subject:, content:, topics: nil, users: nil, targe params: api_params, response_type: Models::Message ) + end # Update an email message by its unique ID. This endpoint only works on @@ -146,6 +148,7 @@ def update_email(message_id:, topics: nil, users: nil, targets: nil, subject: ni params: api_params, response_type: Models::Message ) + end # Create a new push notification. @@ -211,6 +214,7 @@ def create_push(message_id:, title: nil, body: nil, topics: nil, users: nil, tar params: api_params, response_type: Models::Message ) + end # Update a push notification by its unique ID. This endpoint only works on @@ -279,6 +283,7 @@ def update_push(message_id:, topics: nil, users: nil, targets: nil, title: nil, params: api_params, response_type: Models::Message ) + end # Create a new SMS message. @@ -324,6 +329,7 @@ def create_sms(message_id:, content:, topics: nil, users: nil, targets: nil, dra params: api_params, response_type: Models::Message ) + end # Update an SMS message by its unique ID. This endpoint only works on @@ -368,6 +374,7 @@ def update_sms(message_id:, topics: nil, users: nil, targets: nil, content: nil, params: api_params, response_type: Models::Message ) + end # Get a message by its unique ID. @@ -397,6 +404,7 @@ def get_message(message_id:) params: api_params, response_type: Models::Message ) + end # Delete a message. If the message is not a draft or scheduled, but has been @@ -426,6 +434,7 @@ def delete(message_id:) headers: api_headers, params: api_params, ) + end # Get the message activity logs listed by its unique ID. @@ -458,6 +467,7 @@ def list_message_logs(message_id:, queries: nil, total: nil) params: api_params, response_type: Models::LogList ) + end # Get a list of the targets associated with a message. @@ -490,6 +500,7 @@ def list_targets(message_id:, queries: nil, total: nil) params: api_params, response_type: Models::TargetList ) + end # Get a list of all providers from the current Appwrite project. @@ -518,6 +529,7 @@ def list_providers(queries: nil, search: nil, total: nil) params: api_params, response_type: Models::ProviderList ) + end # Create a new Apple Push Notification service provider. @@ -565,6 +577,7 @@ def create_apns_provider(provider_id:, name:, auth_key: nil, auth_key_id: nil, t params: api_params, response_type: Models::Provider ) + end # Update a Apple Push Notification service provider by its unique ID. @@ -608,6 +621,7 @@ def update_apns_provider(provider_id:, name: nil, enabled: nil, auth_key: nil, a params: api_params, response_type: Models::Provider ) + end # Create a new Firebase Cloud Messaging provider. @@ -647,6 +661,7 @@ def create_fcm_provider(provider_id:, name:, service_account_json: nil, enabled: params: api_params, response_type: Models::Provider ) + end # Update a Firebase Cloud Messaging provider by its unique ID. @@ -682,6 +697,7 @@ def update_fcm_provider(provider_id:, name: nil, enabled: nil, service_account_j params: api_params, response_type: Models::Provider ) + end # Create a new Mailgun provider. @@ -733,6 +749,7 @@ def create_mailgun_provider(provider_id:, name:, api_key: nil, domain: nil, is_e params: api_params, response_type: Models::Provider ) + end # Update a Mailgun provider by its unique ID. @@ -780,6 +797,7 @@ def update_mailgun_provider(provider_id:, name: nil, api_key: nil, domain: nil, params: api_params, response_type: Models::Provider ) + end # Create a new MSG91 provider. @@ -823,6 +841,7 @@ def create_msg91_provider(provider_id:, name:, template_id: nil, sender_id: nil, params: api_params, response_type: Models::Provider ) + end # Update a MSG91 provider by its unique ID. @@ -862,6 +881,7 @@ def update_msg91_provider(provider_id:, name: nil, enabled: nil, template_id: ni params: api_params, response_type: Models::Provider ) + end # Create a new Resend provider. @@ -909,6 +929,7 @@ def create_resend_provider(provider_id:, name:, api_key: nil, from_name: nil, fr params: api_params, response_type: Models::Provider ) + end # Update a Resend provider by its unique ID. @@ -952,6 +973,7 @@ def update_resend_provider(provider_id:, name: nil, enabled: nil, api_key: nil, params: api_params, response_type: Models::Provider ) + end # Create a new Sendgrid provider. @@ -999,6 +1021,7 @@ def create_sendgrid_provider(provider_id:, name:, api_key: nil, from_name: nil, params: api_params, response_type: Models::Provider ) + end # Update a Sendgrid provider by its unique ID. @@ -1042,6 +1065,7 @@ def update_sendgrid_provider(provider_id:, name: nil, enabled: nil, api_key: nil params: api_params, response_type: Models::Provider ) + end # Create a new SMTP provider. @@ -1105,6 +1129,7 @@ def create_smtp_provider(provider_id:, name:, host:, port: nil, username: nil, p params: api_params, response_type: Models::Provider ) + end # Update a SMTP provider by its unique ID. @@ -1160,6 +1185,7 @@ def update_smtp_provider(provider_id:, name: nil, host: nil, port: nil, username params: api_params, response_type: Models::Provider ) + end # Create a new Telesign provider. @@ -1203,6 +1229,7 @@ def create_telesign_provider(provider_id:, name:, from: nil, customer_id: nil, a params: api_params, response_type: Models::Provider ) + end # Update a Telesign provider by its unique ID. @@ -1242,6 +1269,7 @@ def update_telesign_provider(provider_id:, name: nil, enabled: nil, customer_id: params: api_params, response_type: Models::Provider ) + end # Create a new Textmagic provider. @@ -1285,6 +1313,7 @@ def create_textmagic_provider(provider_id:, name:, from: nil, username: nil, api params: api_params, response_type: Models::Provider ) + end # Update a Textmagic provider by its unique ID. @@ -1324,6 +1353,7 @@ def update_textmagic_provider(provider_id:, name: nil, enabled: nil, username: n params: api_params, response_type: Models::Provider ) + end # Create a new Twilio provider. @@ -1367,6 +1397,7 @@ def create_twilio_provider(provider_id:, name:, from: nil, account_sid: nil, aut params: api_params, response_type: Models::Provider ) + end # Update a Twilio provider by its unique ID. @@ -1406,6 +1437,7 @@ def update_twilio_provider(provider_id:, name: nil, enabled: nil, account_sid: n params: api_params, response_type: Models::Provider ) + end # Create a new Vonage provider. @@ -1449,6 +1481,7 @@ def create_vonage_provider(provider_id:, name:, from: nil, api_key: nil, api_sec params: api_params, response_type: Models::Provider ) + end # Update a Vonage provider by its unique ID. @@ -1488,6 +1521,7 @@ def update_vonage_provider(provider_id:, name: nil, enabled: nil, api_key: nil, params: api_params, response_type: Models::Provider ) + end # Get a provider by its unique ID. @@ -1517,6 +1551,7 @@ def get_provider(provider_id:) params: api_params, response_type: Models::Provider ) + end # Delete a provider by its unique ID. @@ -1545,6 +1580,7 @@ def delete_provider(provider_id:) headers: api_headers, params: api_params, ) + end # Get the provider activity logs listed by its unique ID. @@ -1577,6 +1613,7 @@ def list_provider_logs(provider_id:, queries: nil, total: nil) params: api_params, response_type: Models::LogList ) + end # Get the subscriber activity logs listed by its unique ID. @@ -1609,6 +1646,7 @@ def list_subscriber_logs(subscriber_id:, queries: nil, total: nil) params: api_params, response_type: Models::LogList ) + end # Get a list of all topics from the current Appwrite project. @@ -1637,6 +1675,7 @@ def list_topics(queries: nil, search: nil, total: nil) params: api_params, response_type: Models::TopicList ) + end # Create a new topic. @@ -1674,6 +1713,7 @@ def create_topic(topic_id:, name:, subscribe: nil) params: api_params, response_type: Models::Topic ) + end # Get a topic by its unique ID. @@ -1703,6 +1743,7 @@ def get_topic(topic_id:) params: api_params, response_type: Models::Topic ) + end # Update a topic by its unique ID. @@ -1737,6 +1778,7 @@ def update_topic(topic_id:, name: nil, subscribe: nil) params: api_params, response_type: Models::Topic ) + end # Delete a topic by its unique ID. @@ -1765,6 +1807,7 @@ def delete_topic(topic_id:) headers: api_headers, params: api_params, ) + end # Get the topic activity logs listed by its unique ID. @@ -1797,6 +1840,7 @@ def list_topic_logs(topic_id:, queries: nil, total: nil) params: api_params, response_type: Models::LogList ) + end # Get a list of all subscribers from the current Appwrite project. @@ -1831,6 +1875,7 @@ def list_subscribers(topic_id:, queries: nil, search: nil, total: nil) params: api_params, response_type: Models::SubscriberList ) + end # Create a new subscriber. @@ -1872,6 +1917,7 @@ def create_subscriber(topic_id:, subscriber_id:, target_id:) params: api_params, response_type: Models::Subscriber ) + end # Get a subscriber by its unique ID. @@ -1907,6 +1953,7 @@ def get_subscriber(topic_id:, subscriber_id:) params: api_params, response_type: Models::Subscriber ) + end # Delete a subscriber by its unique ID. @@ -1941,7 +1988,8 @@ def delete_subscriber(topic_id:, subscriber_id:) headers: api_headers, params: api_params, ) + end end -end \ No newline at end of file +end diff --git a/lib/appwrite/services/project.rb b/lib/appwrite/services/project.rb index d9b8b14..a48be0f 100644 --- a/lib/appwrite/services/project.rb +++ b/lib/appwrite/services/project.rb @@ -7,6 +7,840 @@ def initialize(client) @client = client end + # Get a list of all API keys from the current project. + # + # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: expire, accessedAt, name, scopes + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. + # + # @return [KeyList] + def list_keys(queries: nil, total: nil) + api_path = '/project/keys' + + api_params = { + queries: queries, + total: total, + } + + api_headers = { + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::KeyList + ) + + end + + # Create a new API key. It's recommended to have multiple API keys with + # strict scopes for separate functions within your project. + # + # @param [String] key_id Key ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + # @param [String] name Key name. Max length: 128 chars. + # @param [Array] scopes Key scopes list. Maximum of 100 scopes are allowed. + # @param [String] expire Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + # + # @return [Key] + def create_key(key_id:, name:, scopes:, expire: nil) + api_path = '/project/keys' + + if key_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "keyId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if scopes.nil? + raise Appwrite::Exception.new('Missing required parameter: "scopes"') + end + + api_params = { + keyId: key_id, + name: name, + scopes: scopes, + expire: expire, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Key + ) + + end + + # Get a key by its unique ID. + # + # @param [String] key_id Key ID. + # + # @return [Key] + def get_key(key_id:) + api_path = '/project/keys/{keyId}' + .gsub('{keyId}', key_id) + + if key_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "keyId"') + end + + api_params = { + } + + api_headers = { + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Key + ) + + end + + # Update a key by its unique ID. Use this endpoint to update the name, + # scopes, or expiration time of an API key. + # + # @param [String] key_id Key ID. + # @param [String] name Key name. Max length: 128 chars. + # @param [Array] scopes Key scopes list. Maximum of 100 scopes are allowed. + # @param [String] expire Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration. + # + # @return [Key] + def update_key(key_id:, name:, scopes:, expire: nil) + api_path = '/project/keys/{keyId}' + .gsub('{keyId}', key_id) + + if key_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "keyId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if scopes.nil? + raise Appwrite::Exception.new('Missing required parameter: "scopes"') + end + + api_params = { + name: name, + scopes: scopes, + expire: expire, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Key + ) + + end + + # Delete a key by its unique ID. Once deleted, the key can no longer be used + # to authenticate API calls. + # + # @param [String] key_id Key ID. + # + # @return [] + def delete_key(key_id:) + api_path = '/project/keys/{keyId}' + .gsub('{keyId}', key_id) + + if key_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "keyId"') + end + + api_params = { + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, + ) + + end + + # Update the project labels. Labels can be used to easily filter projects in + # an organization. + # + # @param [Array] labels Array of project labels. Replaces the previous labels. Maximum of 1000 labels are allowed, each up to 36 alphanumeric characters long. + # + # @return [Project] + def update_labels(labels:) + api_path = '/project/labels' + + if labels.nil? + raise Appwrite::Exception.new('Missing required parameter: "labels"') + end + + api_params = { + labels: labels, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Project + ) + + end + + # Get a list of all platforms in the project. This endpoint returns an array + # of all platforms and their configurations. + # + # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: type, name, hostname, bundleIdentifier, applicationId, packageIdentifierName, packageName + # @param [] total When set to false, the total count returned will be 0 and will not be calculated. + # + # @return [PlatformList] + def list_platforms(queries: nil, total: nil) + api_path = '/project/platforms' + + api_params = { + queries: queries, + total: total, + } + + api_headers = { + } + + @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::PlatformList + ) + + end + + # Create a new Android platform for your project. Use this endpoint to + # register a new Android platform where your users will run your application + # which will interact with the Appwrite API. + # + # @param [String] platform_id Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + # @param [String] name Platform name. Max length: 128 chars. + # @param [String] application_id Android application ID. Max length: 256 chars. + # + # @return [PlatformAndroid] + def create_android_platform(platform_id:, name:, application_id:) + api_path = '/project/platforms/android' + + if platform_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "platformId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if application_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "applicationId"') + end + + api_params = { + platformId: platform_id, + name: name, + applicationId: application_id, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::PlatformAndroid + ) + + end + + # Update an Android platform by its unique ID. Use this endpoint to update + # the platform's name or application ID. + # + # @param [String] platform_id Platform ID. + # @param [String] name Platform name. Max length: 128 chars. + # @param [String] application_id Android application ID. Max length: 256 chars. + # + # @return [PlatformAndroid] + def update_android_platform(platform_id:, name:, application_id:) + api_path = '/project/platforms/android/{platformId}' + .gsub('{platformId}', platform_id) + + if platform_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "platformId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if application_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "applicationId"') + end + + api_params = { + name: name, + applicationId: application_id, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::PlatformAndroid + ) + + end + + # Create a new Apple platform for your project. Use this endpoint to register + # a new Apple platform where your users will run your application which will + # interact with the Appwrite API. + # + # @param [String] platform_id Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + # @param [String] name Platform name. Max length: 128 chars. + # @param [String] bundle_identifier Apple bundle identifier. Max length: 256 chars. + # + # @return [PlatformApple] + def create_apple_platform(platform_id:, name:, bundle_identifier:) + api_path = '/project/platforms/apple' + + if platform_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "platformId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if bundle_identifier.nil? + raise Appwrite::Exception.new('Missing required parameter: "bundleIdentifier"') + end + + api_params = { + platformId: platform_id, + name: name, + bundleIdentifier: bundle_identifier, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::PlatformApple + ) + + end + + # Update an Apple platform by its unique ID. Use this endpoint to update the + # platform's name or bundle identifier. + # + # @param [String] platform_id Platform ID. + # @param [String] name Platform name. Max length: 128 chars. + # @param [String] bundle_identifier Apple bundle identifier. Max length: 256 chars. + # + # @return [PlatformApple] + def update_apple_platform(platform_id:, name:, bundle_identifier:) + api_path = '/project/platforms/apple/{platformId}' + .gsub('{platformId}', platform_id) + + if platform_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "platformId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if bundle_identifier.nil? + raise Appwrite::Exception.new('Missing required parameter: "bundleIdentifier"') + end + + api_params = { + name: name, + bundleIdentifier: bundle_identifier, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::PlatformApple + ) + + end + + # Create a new Linux platform for your project. Use this endpoint to register + # a new Linux platform where your users will run your application which will + # interact with the Appwrite API. + # + # @param [String] platform_id Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + # @param [String] name Platform name. Max length: 128 chars. + # @param [String] package_name Linux package name. Max length: 256 chars. + # + # @return [PlatformLinux] + def create_linux_platform(platform_id:, name:, package_name:) + api_path = '/project/platforms/linux' + + if platform_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "platformId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if package_name.nil? + raise Appwrite::Exception.new('Missing required parameter: "packageName"') + end + + api_params = { + platformId: platform_id, + name: name, + packageName: package_name, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::PlatformLinux + ) + + end + + # Update a Linux platform by its unique ID. Use this endpoint to update the + # platform's name or package name. + # + # @param [String] platform_id Platform ID. + # @param [String] name Platform name. Max length: 128 chars. + # @param [String] package_name Linux package name. Max length: 256 chars. + # + # @return [PlatformLinux] + def update_linux_platform(platform_id:, name:, package_name:) + api_path = '/project/platforms/linux/{platformId}' + .gsub('{platformId}', platform_id) + + if platform_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "platformId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if package_name.nil? + raise Appwrite::Exception.new('Missing required parameter: "packageName"') + end + + api_params = { + name: name, + packageName: package_name, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::PlatformLinux + ) + + end + + # Create a new web platform for your project. Use this endpoint to register a + # new platform where your users will run your application which will interact + # with the Appwrite API. + # + # @param [String] platform_id Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + # @param [String] name Platform name. Max length: 128 chars. + # @param [String] hostname Platform web hostname. Max length: 256 chars. + # + # @return [PlatformWeb] + def create_web_platform(platform_id:, name:, hostname:) + api_path = '/project/platforms/web' + + if platform_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "platformId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if hostname.nil? + raise Appwrite::Exception.new('Missing required parameter: "hostname"') + end + + api_params = { + platformId: platform_id, + name: name, + hostname: hostname, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::PlatformWeb + ) + + end + + # Update a web platform by its unique ID. Use this endpoint to update the + # platform's name or hostname. + # + # @param [String] platform_id Platform ID. + # @param [String] name Platform name. Max length: 128 chars. + # @param [String] hostname Platform web hostname. Max length: 256 chars. + # + # @return [PlatformWeb] + def update_web_platform(platform_id:, name:, hostname:) + api_path = '/project/platforms/web/{platformId}' + .gsub('{platformId}', platform_id) + + if platform_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "platformId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if hostname.nil? + raise Appwrite::Exception.new('Missing required parameter: "hostname"') + end + + api_params = { + name: name, + hostname: hostname, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::PlatformWeb + ) + + end + + # Create a new Windows platform for your project. Use this endpoint to + # register a new Windows platform where your users will run your application + # which will interact with the Appwrite API. + # + # @param [String] platform_id Platform ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. + # @param [String] name Platform name. Max length: 128 chars. + # @param [String] package_identifier_name Windows package identifier name. Max length: 256 chars. + # + # @return [PlatformWindows] + def create_windows_platform(platform_id:, name:, package_identifier_name:) + api_path = '/project/platforms/windows' + + if platform_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "platformId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if package_identifier_name.nil? + raise Appwrite::Exception.new('Missing required parameter: "packageIdentifierName"') + end + + api_params = { + platformId: platform_id, + name: name, + packageIdentifierName: package_identifier_name, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'POST', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::PlatformWindows + ) + + end + + # Update a Windows platform by its unique ID. Use this endpoint to update the + # platform's name or package identifier name. + # + # @param [String] platform_id Platform ID. + # @param [String] name Platform name. Max length: 128 chars. + # @param [String] package_identifier_name Windows package identifier name. Max length: 256 chars. + # + # @return [PlatformWindows] + def update_windows_platform(platform_id:, name:, package_identifier_name:) + api_path = '/project/platforms/windows/{platformId}' + .gsub('{platformId}', platform_id) + + if platform_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "platformId"') + end + + if name.nil? + raise Appwrite::Exception.new('Missing required parameter: "name"') + end + + if package_identifier_name.nil? + raise Appwrite::Exception.new('Missing required parameter: "packageIdentifierName"') + end + + api_params = { + name: name, + packageIdentifierName: package_identifier_name, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'PUT', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::PlatformWindows + ) + + end + + # Get a platform by its unique ID. This endpoint returns the platform's + # details, including its name, type, and key configurations. + # + # @param [String] platform_id Platform ID. + # + # @return [PlatformWeb, PlatformApple, PlatformAndroid, PlatformWindows, PlatformLinux] + def get_platform(platform_id:) + api_path = '/project/platforms/{platformId}' + .gsub('{platformId}', platform_id) + + if platform_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "platformId"') + end + + api_params = { + } + + api_headers = { + } + + response = @client.call( + method: 'GET', + path: api_path, + headers: api_headers, + params: api_params, + ) + + unless response.is_a?(Hash) + raise Exception, "Expected object response when hydrating a response model" + end + + if response['type'] == 'web' + + return Models::PlatformWeb.from(map: response) + end + + if response['type'] == 'apple' + + return Models::PlatformApple.from(map: response) + end + + if response['type'] == 'android' + + return Models::PlatformAndroid.from(map: response) + end + + if response['type'] == 'windows' + + return Models::PlatformWindows.from(map: response) + end + + if response['type'] == 'linux' + + return Models::PlatformLinux.from(map: response) + end + + raise Exception, "Unable to match response to any expected response model" + + end + + # Delete a platform by its unique ID. This endpoint removes the platform and + # all its configurations from the project. + # + # @param [String] platform_id Platform ID. + # + # @return [] + def delete_platform(platform_id:) + api_path = '/project/platforms/{platformId}' + .gsub('{platformId}', platform_id) + + if platform_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "platformId"') + end + + api_params = { + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'DELETE', + path: api_path, + headers: api_headers, + params: api_params, + ) + + end + + # Update the status of a specific protocol. Use this endpoint to enable or + # disable a protocol in your project. + # + # @param [ProtocolId] protocol_id Protocol name. Can be one of: rest, graphql, websocket + # @param [] enabled Protocol status. + # + # @return [Project] + def update_protocol_status(protocol_id:, enabled:) + api_path = '/project/protocols/{protocolId}/status' + .gsub('{protocolId}', protocol_id) + + if protocol_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "protocolId"') + end + + if enabled.nil? + raise Appwrite::Exception.new('Missing required parameter: "enabled"') + end + + api_params = { + enabled: enabled, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Project + ) + + end + + # Update the status of a specific service. Use this endpoint to enable or + # disable a service in your project. + # + # @param [ServiceId] service_id Service name. Can be one of: account, avatars, databases, tablesdb, locale, health, project, storage, teams, users, vcs, sites, functions, proxy, graphql, migrations, messaging + # @param [] enabled Service status. + # + # @return [Project] + def update_service_status(service_id:, enabled:) + api_path = '/project/services/{serviceId}/status' + .gsub('{serviceId}', service_id) + + if service_id.nil? + raise Appwrite::Exception.new('Missing required parameter: "serviceId"') + end + + if enabled.nil? + raise Appwrite::Exception.new('Missing required parameter: "enabled"') + end + + api_params = { + enabled: enabled, + } + + api_headers = { + "content-type": 'application/json', + } + + @client.call( + method: 'PATCH', + path: api_path, + headers: api_headers, + params: api_params, + response_type: Models::Project + ) + + end + # Get a list of all project environment variables. # # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, resourceType, resourceId, secret @@ -31,6 +865,7 @@ def list_variables(queries: nil, total: nil) params: api_params, response_type: Models::VariableList ) + end # Create a new project environment variable. These variables can be accessed @@ -75,6 +910,7 @@ def create_variable(variable_id:, key:, value:, secret: nil) params: api_params, response_type: Models::Variable ) + end # Get a variable by its unique ID. @@ -103,6 +939,7 @@ def get_variable(variable_id:) params: api_params, response_type: Models::Variable ) + end # Update variable by its unique ID. @@ -138,6 +975,7 @@ def update_variable(variable_id:, key: nil, value: nil, secret: nil) params: api_params, response_type: Models::Variable ) + end # Delete a variable by its unique ID. @@ -166,7 +1004,8 @@ def delete_variable(variable_id:) headers: api_headers, params: api_params, ) + end end -end \ No newline at end of file +end diff --git a/lib/appwrite/services/sites.rb b/lib/appwrite/services/sites.rb index 37893e1..be98543 100644 --- a/lib/appwrite/services/sites.rb +++ b/lib/appwrite/services/sites.rb @@ -34,6 +34,7 @@ def list(queries: nil, search: nil, total: nil) params: api_params, response_type: Models::SiteList ) + end # Create a new site. @@ -115,6 +116,7 @@ def create(site_id:, name:, framework:, build_runtime:, enabled: nil, logging: n params: api_params, response_type: Models::Site ) + end # Get a list of all frameworks that are currently available on the server @@ -138,6 +140,7 @@ def list_frameworks() params: api_params, response_type: Models::FrameworkList ) + end # List allowed site specifications for this instance. @@ -160,6 +163,7 @@ def list_specifications() params: api_params, response_type: Models::SpecificationList ) + end # Get a site by its unique ID. @@ -188,6 +192,7 @@ def get(site_id:) params: api_params, response_type: Models::Site ) + end # Update site by its unique ID. @@ -265,6 +270,7 @@ def update(site_id:, name:, framework:, enabled: nil, logging: nil, timeout: nil params: api_params, response_type: Models::Site ) + end # Delete a site by its unique ID. @@ -293,6 +299,7 @@ def delete(site_id:) headers: api_headers, params: api_params, ) + end # Update the site active deployment. Use this endpoint to switch the code @@ -329,6 +336,7 @@ def update_site_deployment(site_id:, deployment_id:) params: api_params, response_type: Models::Site ) + end # Get a list of all the site's code deployments. You can use the query params @@ -364,6 +372,7 @@ def list_deployments(site_id:, queries: nil, search: nil, total: nil) params: api_params, response_type: Models::DeploymentList ) + end # Create a new site code deployment. Use this endpoint to upload a new @@ -414,6 +423,7 @@ def create_deployment(site_id:, code:, install_command: nil, build_command: nil, on_progress: on_progress, response_type: Models::Deployment ) + end # Create a new build for an existing site deployment. This endpoint allows @@ -453,6 +463,7 @@ def create_duplicate_deployment(site_id:, deployment_id:) params: api_params, response_type: Models::Deployment ) + end # Create a deployment based on a template. @@ -518,6 +529,7 @@ def create_template_deployment(site_id:, repository:, owner:, root_directory:, t params: api_params, response_type: Models::Deployment ) + end # Create a deployment when a site is connected to VCS. @@ -563,6 +575,7 @@ def create_vcs_deployment(site_id:, type:, reference:, activate: nil) params: api_params, response_type: Models::Deployment ) + end # Get a site deployment by its unique ID. @@ -597,6 +610,7 @@ def get_deployment(site_id:, deployment_id:) params: api_params, response_type: Models::Deployment ) + end # Delete a site deployment by its unique ID. @@ -631,6 +645,7 @@ def delete_deployment(site_id:, deployment_id:) headers: api_headers, params: api_params, ) + end # Get a site deployment content by its unique ID. The endpoint response @@ -668,6 +683,7 @@ def get_deployment_download(site_id:, deployment_id:, type: nil) headers: api_headers, params: api_params, ) + end # Cancel an ongoing site deployment build. If the build is already in @@ -707,6 +723,7 @@ def update_deployment_status(site_id:, deployment_id:) params: api_params, response_type: Models::Deployment ) + end # Get a list of all site logs. You can use the query params to filter your @@ -740,6 +757,7 @@ def list_logs(site_id:, queries: nil, total: nil) params: api_params, response_type: Models::ExecutionList ) + end # Get a site request log by its unique ID. @@ -774,6 +792,7 @@ def get_log(site_id:, log_id:) params: api_params, response_type: Models::Execution ) + end # Delete a site log by its unique ID. @@ -808,6 +827,7 @@ def delete_log(site_id:, log_id:) headers: api_headers, params: api_params, ) + end # Get a list of all variables of a specific site. @@ -836,6 +856,7 @@ def list_variables(site_id:) params: api_params, response_type: Models::VariableList ) + end # Create a new site variable. These variables can be accessed during build @@ -880,6 +901,7 @@ def create_variable(site_id:, key:, value:, secret: nil) params: api_params, response_type: Models::Variable ) + end # Get a variable by its unique ID. @@ -914,6 +936,7 @@ def get_variable(site_id:, variable_id:) params: api_params, response_type: Models::Variable ) + end # Update variable by its unique ID. @@ -959,6 +982,7 @@ def update_variable(site_id:, variable_id:, key:, value: nil, secret: nil) params: api_params, response_type: Models::Variable ) + end # Delete a variable by its unique ID. @@ -993,7 +1017,8 @@ def delete_variable(site_id:, variable_id:) headers: api_headers, params: api_params, ) + end end -end \ No newline at end of file +end diff --git a/lib/appwrite/services/storage.rb b/lib/appwrite/services/storage.rb index 68ed8f5..0db59a1 100644 --- a/lib/appwrite/services/storage.rb +++ b/lib/appwrite/services/storage.rb @@ -34,6 +34,7 @@ def list_buckets(queries: nil, search: nil, total: nil) params: api_params, response_type: Models::BucketList ) + end # Create a new storage bucket. @@ -87,6 +88,7 @@ def create_bucket(bucket_id:, name:, permissions: nil, file_security: nil, enabl params: api_params, response_type: Models::Bucket ) + end # Get a storage bucket by its unique ID. This endpoint response returns a @@ -116,6 +118,7 @@ def get_bucket(bucket_id:) params: api_params, response_type: Models::Bucket ) + end # Update a storage bucket by its unique ID. @@ -169,6 +172,7 @@ def update_bucket(bucket_id:, name:, permissions: nil, file_security: nil, enabl params: api_params, response_type: Models::Bucket ) + end # Delete a storage bucket by its unique ID. @@ -197,6 +201,7 @@ def delete_bucket(bucket_id:) headers: api_headers, params: api_params, ) + end # Get a list of all the user files. You can use the query params to filter @@ -232,6 +237,7 @@ def list_files(bucket_id:, queries: nil, search: nil, total: nil) params: api_params, response_type: Models::FileList ) + end # Create a new file. Before using this route, you should create a new bucket @@ -297,6 +303,7 @@ def create_file(bucket_id:, file_id:, file:, permissions: nil, on_progress: nil) on_progress: on_progress, response_type: Models::File ) + end # Get a file by its unique ID. This endpoint response returns a JSON object @@ -332,6 +339,7 @@ def get_file(bucket_id:, file_id:) params: api_params, response_type: Models::File ) + end # Update a file by its unique ID. Only users with write permissions have @@ -372,6 +380,7 @@ def update_file(bucket_id:, file_id:, name: nil, permissions: nil) params: api_params, response_type: Models::File ) + end # Delete a file by its unique ID. Only users with write permissions have @@ -407,6 +416,7 @@ def delete_file(bucket_id:, file_id:) headers: api_headers, params: api_params, ) + end # Get a file content by its unique ID. The endpoint response return with a @@ -444,6 +454,7 @@ def get_file_download(bucket_id:, file_id:, token: nil) headers: api_headers, params: api_params, ) + end # Get a file preview image. Currently, this method supports preview for image @@ -505,6 +516,7 @@ def get_file_preview(bucket_id:, file_id:, width: nil, height: nil, gravity: nil headers: api_headers, params: api_params, ) + end # Get a file content by its unique ID. This endpoint is similar to the @@ -542,7 +554,8 @@ def get_file_view(bucket_id:, file_id:, token: nil) headers: api_headers, params: api_params, ) + end end -end \ No newline at end of file +end diff --git a/lib/appwrite/services/tables_db.rb b/lib/appwrite/services/tables_db.rb index 67f3587..31ef6cc 100644 --- a/lib/appwrite/services/tables_db.rb +++ b/lib/appwrite/services/tables_db.rb @@ -34,6 +34,7 @@ def list(queries: nil, search: nil, total: nil) params: api_params, response_type: Models::DatabaseList ) + end # Create a new Database. @@ -72,6 +73,7 @@ def create(database_id:, name:, enabled: nil) params: api_params, response_type: Models::Database ) + end # List transactions across all databases. @@ -96,6 +98,7 @@ def list_transactions(queries: nil) params: api_params, response_type: Models::TransactionList ) + end # Create a new transaction. @@ -121,6 +124,7 @@ def create_transaction(ttl: nil) params: api_params, response_type: Models::Transaction ) + end # Get a transaction by its unique ID. @@ -149,6 +153,7 @@ def get_transaction(transaction_id:) params: api_params, response_type: Models::Transaction ) + end # Update a transaction, to either commit or roll back its operations. @@ -182,6 +187,7 @@ def update_transaction(transaction_id:, commit: nil, rollback: nil) params: api_params, response_type: Models::Transaction ) + end # Delete a transaction by its unique ID. @@ -210,6 +216,7 @@ def delete_transaction(transaction_id:) headers: api_headers, params: api_params, ) + end # Create multiple operations in a single transaction. @@ -241,6 +248,7 @@ def create_operations(transaction_id:, operations: nil) params: api_params, response_type: Models::Transaction ) + end # Get a database by its unique ID. This endpoint response returns a JSON @@ -270,6 +278,7 @@ def get(database_id:) params: api_params, response_type: Models::Database ) + end # Update a database by its unique ID. @@ -303,6 +312,7 @@ def update(database_id:, name: nil, enabled: nil) params: api_params, response_type: Models::Database ) + end # Delete a database by its unique ID. Only API keys with with databases.write @@ -332,6 +342,7 @@ def delete(database_id:) headers: api_headers, params: api_params, ) + end # Get a list of all tables that belong to the provided databaseId. You can @@ -367,6 +378,7 @@ def list_tables(database_id:, queries: nil, search: nil, total: nil) params: api_params, response_type: Models::TableList ) + end # Create a new Table. Before using this route, you should create a new @@ -421,6 +433,7 @@ def create_table(database_id:, table_id:, name:, permissions: nil, row_security: params: api_params, response_type: Models::Table ) + end # Get a table by its unique ID. This endpoint response returns a JSON object @@ -456,6 +469,7 @@ def get_table(database_id:, table_id:) params: api_params, response_type: Models::Table ) + end # Update a table by its unique ID. @@ -466,9 +480,10 @@ def get_table(database_id:, table_id:) # @param [Array] permissions An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). # @param [] row_security Enables configuring permissions for individual rows. A user needs one of row or table-level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). # @param [] enabled Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. + # @param [] purge When true, purge all cached list responses for this table as part of the update. Use this to force readers to see fresh data immediately instead of waiting for the cache TTL to expire. # # @return [Table] - def update_table(database_id:, table_id:, name: nil, permissions: nil, row_security: nil, enabled: nil) + def update_table(database_id:, table_id:, name: nil, permissions: nil, row_security: nil, enabled: nil, purge: nil) api_path = '/tablesdb/{databaseId}/tables/{tableId}' .gsub('{databaseId}', database_id) .gsub('{tableId}', table_id) @@ -486,6 +501,7 @@ def update_table(database_id:, table_id:, name: nil, permissions: nil, row_secur permissions: permissions, rowSecurity: row_security, enabled: enabled, + purge: purge, } api_headers = { @@ -499,6 +515,7 @@ def update_table(database_id:, table_id:, name: nil, permissions: nil, row_secur params: api_params, response_type: Models::Table ) + end # Delete a table by its unique ID. Only users with write permissions have @@ -534,6 +551,7 @@ def delete_table(database_id:, table_id:) headers: api_headers, params: api_params, ) + end # List columns in the table. @@ -572,6 +590,7 @@ def list_columns(database_id:, table_id:, queries: nil, total: nil) params: api_params, response_type: Models::ColumnList ) + end # Create a boolean column. @@ -624,6 +643,7 @@ def create_boolean_column(database_id:, table_id:, key:, required:, default: nil params: api_params, response_type: Models::ColumnBoolean ) + end # Update a boolean column. Changing the `default` value will not update @@ -680,6 +700,7 @@ def update_boolean_column(database_id:, table_id:, key:, required:, default:, ne params: api_params, response_type: Models::ColumnBoolean ) + end # Create a date time column according to the ISO 8601 standard. @@ -731,6 +752,7 @@ def create_datetime_column(database_id:, table_id:, key:, required:, default: ni params: api_params, response_type: Models::ColumnDatetime ) + end # Update a date time column. Changing the `default` value will not update @@ -787,6 +809,7 @@ def update_datetime_column(database_id:, table_id:, key:, required:, default:, n params: api_params, response_type: Models::ColumnDatetime ) + end # Create an email column. @@ -839,6 +862,7 @@ def create_email_column(database_id:, table_id:, key:, required:, default: nil, params: api_params, response_type: Models::ColumnEmail ) + end # Update an email column. Changing the `default` value will not update @@ -896,6 +920,7 @@ def update_email_column(database_id:, table_id:, key:, required:, default:, new_ params: api_params, response_type: Models::ColumnEmail ) + end # Create an enumeration column. The `elements` param acts as a white-list of @@ -954,6 +979,7 @@ def create_enum_column(database_id:, table_id:, key:, elements:, required:, defa params: api_params, response_type: Models::ColumnEnum ) + end # Update an enum column. Changing the `default` value will not update already @@ -1017,6 +1043,7 @@ def update_enum_column(database_id:, table_id:, key:, elements:, required:, defa params: api_params, response_type: Models::ColumnEnum ) + end # Create a float column. Optionally, minimum and maximum values can be @@ -1074,6 +1101,7 @@ def create_float_column(database_id:, table_id:, key:, required:, min: nil, max: params: api_params, response_type: Models::ColumnFloat ) + end # Update a float column. Changing the `default` value will not update already @@ -1135,6 +1163,7 @@ def update_float_column(database_id:, table_id:, key:, required:, default:, min: params: api_params, response_type: Models::ColumnFloat ) + end # Create an integer column. Optionally, minimum and maximum values can be @@ -1192,6 +1221,7 @@ def create_integer_column(database_id:, table_id:, key:, required:, min: nil, ma params: api_params, response_type: Models::ColumnInteger ) + end # Update an integer column. Changing the `default` value will not update @@ -1253,6 +1283,7 @@ def update_integer_column(database_id:, table_id:, key:, required:, default:, mi params: api_params, response_type: Models::ColumnInteger ) + end # Create IP address column. @@ -1305,6 +1336,7 @@ def create_ip_column(database_id:, table_id:, key:, required:, default: nil, arr params: api_params, response_type: Models::ColumnIp ) + end # Update an ip column. Changing the `default` value will not update already @@ -1362,6 +1394,7 @@ def update_ip_column(database_id:, table_id:, key:, required:, default:, new_key params: api_params, response_type: Models::ColumnIp ) + end # Create a geometric line column. @@ -1411,6 +1444,7 @@ def create_line_column(database_id:, table_id:, key:, required:, default: nil) params: api_params, response_type: Models::ColumnLine ) + end # Update a line column. Changing the `default` value will not update already @@ -1463,6 +1497,7 @@ def update_line_column(database_id:, table_id:, key:, required:, default: nil, n params: api_params, response_type: Models::ColumnLine ) + end # Create a longtext column. @@ -1517,6 +1552,7 @@ def create_longtext_column(database_id:, table_id:, key:, required:, default: ni params: api_params, response_type: Models::ColumnLongtext ) + end # Update a longtext column. Changing the `default` value will not update @@ -1574,6 +1610,7 @@ def update_longtext_column(database_id:, table_id:, key:, required:, default:, n params: api_params, response_type: Models::ColumnLongtext ) + end # Create a mediumtext column. @@ -1628,6 +1665,7 @@ def create_mediumtext_column(database_id:, table_id:, key:, required:, default: params: api_params, response_type: Models::ColumnMediumtext ) + end # Update a mediumtext column. Changing the `default` value will not update @@ -1685,6 +1723,7 @@ def update_mediumtext_column(database_id:, table_id:, key:, required:, default:, params: api_params, response_type: Models::ColumnMediumtext ) + end # Create a geometric point column. @@ -1734,6 +1773,7 @@ def create_point_column(database_id:, table_id:, key:, required:, default: nil) params: api_params, response_type: Models::ColumnPoint ) + end # Update a point column. Changing the `default` value will not update already @@ -1786,6 +1826,7 @@ def update_point_column(database_id:, table_id:, key:, required:, default: nil, params: api_params, response_type: Models::ColumnPoint ) + end # Create a geometric polygon column. @@ -1835,6 +1876,7 @@ def create_polygon_column(database_id:, table_id:, key:, required:, default: nil params: api_params, response_type: Models::ColumnPolygon ) + end # Update a polygon column. Changing the `default` value will not update @@ -1887,6 +1929,7 @@ def update_polygon_column(database_id:, table_id:, key:, required:, default: nil params: api_params, response_type: Models::ColumnPolygon ) + end # Create relationship column. [Learn more about relationship @@ -1944,6 +1987,7 @@ def create_relationship_column(database_id:, table_id:, related_table_id:, type: params: api_params, response_type: Models::ColumnRelationship ) + end # @@ -2007,6 +2051,7 @@ def create_string_column(database_id:, table_id:, key:, size:, required:, defaul params: api_params, response_type: Models::ColumnString ) + end # @@ -2069,6 +2114,7 @@ def update_string_column(database_id:, table_id:, key:, required:, default:, siz params: api_params, response_type: Models::ColumnString ) + end # Create a text column. @@ -2123,6 +2169,7 @@ def create_text_column(database_id:, table_id:, key:, required:, default: nil, a params: api_params, response_type: Models::ColumnText ) + end # Update a text column. Changing the `default` value will not update already @@ -2180,6 +2227,7 @@ def update_text_column(database_id:, table_id:, key:, required:, default:, new_k params: api_params, response_type: Models::ColumnText ) + end # Create a URL column. @@ -2232,6 +2280,7 @@ def create_url_column(database_id:, table_id:, key:, required:, default: nil, ar params: api_params, response_type: Models::ColumnUrl ) + end # Update an url column. Changing the `default` value will not update already @@ -2289,6 +2338,7 @@ def update_url_column(database_id:, table_id:, key:, required:, default:, new_ke params: api_params, response_type: Models::ColumnUrl ) + end # Create a varchar column. @@ -2349,6 +2399,7 @@ def create_varchar_column(database_id:, table_id:, key:, size:, required:, defau params: api_params, response_type: Models::ColumnVarchar ) + end # Update a varchar column. Changing the `default` value will not update @@ -2408,6 +2459,7 @@ def update_varchar_column(database_id:, table_id:, key:, required:, default:, si params: api_params, response_type: Models::ColumnVarchar ) + end # Get column by ID. @@ -2416,7 +2468,7 @@ def update_varchar_column(database_id:, table_id:, key:, required:, default:, si # @param [String] table_id Table ID. # @param [String] key Column Key. # - # @return [] + # @return [ColumnBoolean, ColumnInteger, ColumnFloat, ColumnEmail, ColumnEnum, ColumnUrl, ColumnIp, ColumnDatetime, ColumnRelationship, ColumnString] def get_column(database_id:, table_id:, key:) api_path = '/tablesdb/{databaseId}/tables/{tableId}/columns/{key}' .gsub('{databaseId}', database_id) @@ -2441,13 +2493,69 @@ def get_column(database_id:, table_id:, key:) api_headers = { } - @client.call( + response = @client.call( method: 'GET', path: api_path, headers: api_headers, params: api_params, - response_type: Models::ColumnBoolean ) + + unless response.is_a?(Hash) + raise Exception, "Expected object response when hydrating a response model" + end + + if response['type'] == 'string' && response['format'] == 'email' + + return Models::ColumnEmail.from(map: response) + end + + if response['type'] == 'string' && response['format'] == 'enum' + + return Models::ColumnEnum.from(map: response) + end + + if response['type'] == 'string' && response['format'] == 'url' + + return Models::ColumnUrl.from(map: response) + end + + if response['type'] == 'string' && response['format'] == 'ip' + + return Models::ColumnIp.from(map: response) + end + + if response['type'] == 'boolean' + + return Models::ColumnBoolean.from(map: response) + end + + if response['type'] == 'integer' + + return Models::ColumnInteger.from(map: response) + end + + if response['type'] == 'double' + + return Models::ColumnFloat.from(map: response) + end + + if response['type'] == 'datetime' + + return Models::ColumnDatetime.from(map: response) + end + + if response['type'] == 'relationship' + + return Models::ColumnRelationship.from(map: response) + end + + if response['type'] == 'string' + + return Models::ColumnString.from(map: response) + end + + raise Exception, "Unable to match response to any expected response model" + end # Deletes a column. @@ -2488,6 +2596,7 @@ def delete_column(database_id:, table_id:, key:) headers: api_headers, params: api_params, ) + end # Update relationship column. [Learn more about relationship @@ -2535,6 +2644,7 @@ def update_relationship_column(database_id:, table_id:, key:, on_delete: nil, ne params: api_params, response_type: Models::ColumnRelationship ) + end # List indexes on the table. @@ -2573,6 +2683,7 @@ def list_indexes(database_id:, table_id:, queries: nil, total: nil) params: api_params, response_type: Models::ColumnIndexList ) + end # Creates an index on the columns listed. Your index should include all the @@ -2632,6 +2743,7 @@ def create_index(database_id:, table_id:, key:, type:, columns:, orders: nil, le params: api_params, response_type: Models::ColumnIndex ) + end # Get index by ID. @@ -2672,6 +2784,7 @@ def get_index(database_id:, table_id:, key:) params: api_params, response_type: Models::ColumnIndex ) + end # Delete an index. @@ -2712,6 +2825,7 @@ def delete_index(database_id:, table_id:, key:) headers: api_headers, params: api_params, ) + end # Get a list of all the user's rows in a given table. You can use the query @@ -2722,7 +2836,7 @@ def delete_index(database_id:, table_id:, key:) # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. # @param [String] transaction_id Transaction ID to read uncommitted changes within the transaction. # @param [] total When set to false, the total count returned will be 0 and will not be calculated. - # @param [Integer] ttl TTL (seconds) for cached responses when caching is enabled for select queries. Must be between 0 and 86400 (24 hours). + # @param [Integer] ttl TTL (seconds) for caching list responses. Responses are stored in an in-memory key-value cache, keyed per project, table, schema version (columns and indexes), caller authorization roles, and the exact query — so users with different permissions never share cached entries. Schema changes invalidate cached entries automatically; row writes do not, so choose a TTL you are comfortable serving as stale data. Set to 0 to disable caching. Must be between 0 and 86400 (24 hours). # # @return [RowList] def list_rows(database_id:, table_id:, queries: nil, transaction_id: nil, total: nil, ttl: nil) @@ -2755,6 +2869,7 @@ def list_rows(database_id:, table_id:, queries: nil, transaction_id: nil, total: params: api_params, response_type: Models::RowList ) + end # Create a new Row. Before using this route, you should create a new table @@ -2809,6 +2924,7 @@ def create_row(database_id:, table_id:, row_id:, data:, permissions: nil, transa params: api_params, response_type: Models::Row ) + end # Create new Rows. Before using this route, you should create a new table @@ -2855,6 +2971,7 @@ def create_rows(database_id:, table_id:, rows:, transaction_id: nil) params: api_params, response_type: Models::RowList ) + end # Create or update Rows. Before using this route, you should create a new @@ -2902,6 +3019,7 @@ def upsert_rows(database_id:, table_id:, rows:, transaction_id: nil) params: api_params, response_type: Models::RowList ) + end # Update all rows that match your queries, if no queries are submitted then @@ -2944,6 +3062,7 @@ def update_rows(database_id:, table_id:, data: nil, queries: nil, transaction_id params: api_params, response_type: Models::RowList ) + end # Bulk delete rows using queries, if no queries are passed then all rows are @@ -2984,6 +3103,7 @@ def delete_rows(database_id:, table_id:, queries: nil, transaction_id: nil) params: api_params, response_type: Models::RowList ) + end # Get a row by its unique ID. This endpoint response returns a JSON object @@ -3029,6 +3149,7 @@ def get_row(database_id:, table_id:, row_id:, queries: nil, transaction_id: nil) params: api_params, response_type: Models::Row ) + end # Create or update a Row. Before using this route, you should create a new @@ -3079,6 +3200,7 @@ def upsert_row(database_id:, table_id:, row_id:, data: nil, permissions: nil, tr params: api_params, response_type: Models::Row ) + end # Update a row by its unique ID. Using the patch method you can pass only @@ -3127,6 +3249,7 @@ def update_row(database_id:, table_id:, row_id:, data: nil, permissions: nil, tr params: api_params, response_type: Models::Row ) + end # Delete a row by its unique ID. @@ -3169,6 +3292,7 @@ def delete_row(database_id:, table_id:, row_id:, transaction_id: nil) headers: api_headers, params: api_params, ) + end # Decrement a specific column of a row by a given value. @@ -3222,6 +3346,7 @@ def decrement_row_column(database_id:, table_id:, row_id:, column:, value: nil, params: api_params, response_type: Models::Row ) + end # Increment a specific column of a row by a given value. @@ -3275,7 +3400,8 @@ def increment_row_column(database_id:, table_id:, row_id:, column:, value: nil, params: api_params, response_type: Models::Row ) + end end -end \ No newline at end of file +end diff --git a/lib/appwrite/services/teams.rb b/lib/appwrite/services/teams.rb index 6641530..8cae84c 100644 --- a/lib/appwrite/services/teams.rb +++ b/lib/appwrite/services/teams.rb @@ -34,6 +34,7 @@ def list(queries: nil, search: nil, total: nil) params: api_params, response_type: Models::TeamList ) + end # Create a new team. The user who creates the team will automatically be @@ -73,6 +74,7 @@ def create(team_id:, name:, roles: nil) params: api_params, response_type: Models::Team ) + end # Get a team by its ID. All team members have read access for this resource. @@ -101,6 +103,7 @@ def get(team_id:) params: api_params, response_type: Models::Team ) + end # Update the team's name by its unique ID. @@ -136,6 +139,7 @@ def update_name(team_id:, name:) params: api_params, response_type: Models::Team ) + end # Delete a team using its ID. Only team members with the owner role can @@ -165,6 +169,7 @@ def delete(team_id:) headers: api_headers, params: api_params, ) + end # Use this endpoint to list a team's members using the team's ID. All team @@ -201,6 +206,7 @@ def list_memberships(team_id:, queries: nil, search: nil, total: nil) params: api_params, response_type: Models::MembershipList ) + end # Invite a new member to join your team. Provide an ID for existing users, or @@ -266,6 +272,7 @@ def create_membership(team_id:, roles:, email: nil, user_id: nil, phone: nil, ur params: api_params, response_type: Models::Membership ) + end # Get a team member by the membership unique id. All team members have read @@ -302,6 +309,7 @@ def get_membership(team_id:, membership_id:) params: api_params, response_type: Models::Membership ) + end # Modify the roles of a team member. Only team members with the owner role @@ -346,6 +354,7 @@ def update_membership(team_id:, membership_id:, roles:) params: api_params, response_type: Models::Membership ) + end # This endpoint allows a user to leave a team or for a team owner to delete @@ -382,6 +391,7 @@ def delete_membership(team_id:, membership_id:) headers: api_headers, params: api_params, ) + end # Use this endpoint to allow a user to accept an invitation to join a team @@ -435,6 +445,7 @@ def update_membership_status(team_id:, membership_id:, user_id:, secret:) params: api_params, response_type: Models::Membership ) + end # Get the team's shared preferences by its unique ID. If a preference doesn't @@ -465,6 +476,7 @@ def get_prefs(team_id:) params: api_params, response_type: Models::Preferences ) + end # Update the team's preferences by its unique ID. The object you pass is @@ -502,7 +514,8 @@ def update_prefs(team_id:, prefs:) params: api_params, response_type: Models::Preferences ) + end end -end \ No newline at end of file +end diff --git a/lib/appwrite/services/tokens.rb b/lib/appwrite/services/tokens.rb index 0c04727..19aeb1f 100644 --- a/lib/appwrite/services/tokens.rb +++ b/lib/appwrite/services/tokens.rb @@ -44,6 +44,7 @@ def list(bucket_id:, file_id:, queries: nil, total: nil) params: api_params, response_type: Models::ResourceTokenList ) + end # Create a new token. A token is linked to a file. Token can be passed as a @@ -82,6 +83,7 @@ def create_file_token(bucket_id:, file_id:, expire: nil) params: api_params, response_type: Models::ResourceToken ) + end # Get a token by its unique ID. @@ -110,6 +112,7 @@ def get(token_id:) params: api_params, response_type: Models::ResourceToken ) + end # Update a token by its unique ID. Use this endpoint to update a token's @@ -142,6 +145,7 @@ def update(token_id:, expire: nil) params: api_params, response_type: Models::ResourceToken ) + end # Delete a token by its unique ID. @@ -170,7 +174,8 @@ def delete(token_id:) headers: api_headers, params: api_params, ) + end end -end \ No newline at end of file +end diff --git a/lib/appwrite/services/users.rb b/lib/appwrite/services/users.rb index cd37aa0..25fd3e2 100644 --- a/lib/appwrite/services/users.rb +++ b/lib/appwrite/services/users.rb @@ -34,6 +34,7 @@ def list(queries: nil, search: nil, total: nil) params: api_params, response_type: Models::UserList ) + end # Create a new user. @@ -71,6 +72,7 @@ def create(user_id:, email: nil, phone: nil, password: nil, name: nil) params: api_params, response_type: Models::User ) + end # Create a new user. Password provided must be hashed with the @@ -117,6 +119,7 @@ def create_argon2_user(user_id:, email:, password:, name: nil) params: api_params, response_type: Models::User ) + end # Create a new user. Password provided must be hashed with the @@ -163,6 +166,7 @@ def create_bcrypt_user(user_id:, email:, password:, name: nil) params: api_params, response_type: Models::User ) + end # Get identities for all users. @@ -191,6 +195,7 @@ def list_identities(queries: nil, search: nil, total: nil) params: api_params, response_type: Models::IdentityList ) + end # Delete an identity by its unique ID. @@ -219,6 +224,7 @@ def delete_identity(identity_id:) headers: api_headers, params: api_params, ) + end # Create a new user. Password provided must be hashed with the @@ -265,6 +271,7 @@ def create_md5_user(user_id:, email:, password:, name: nil) params: api_params, response_type: Models::User ) + end # Create a new user. Password provided must be hashed with the @@ -311,6 +318,7 @@ def create_ph_pass_user(user_id:, email:, password:, name: nil) params: api_params, response_type: Models::User ) + end # Create a new user. Password provided must be hashed with the @@ -387,6 +395,7 @@ def create_scrypt_user(user_id:, email:, password:, password_salt:, password_cpu params: api_params, response_type: Models::User ) + end # Create a new user. Password provided must be hashed with the [Scrypt @@ -452,6 +461,7 @@ def create_scrypt_modified_user(user_id:, email:, password:, password_salt:, pas params: api_params, response_type: Models::User ) + end # Create a new user. Password provided must be hashed with the @@ -500,6 +510,7 @@ def create_sha_user(user_id:, email:, password:, password_version: nil, name: ni params: api_params, response_type: Models::User ) + end # Get a user by its unique ID. @@ -528,6 +539,7 @@ def get(user_id:) params: api_params, response_type: Models::User ) + end # Delete a user by its unique ID, thereby releasing it's ID. Since ID is @@ -561,6 +573,7 @@ def delete(user_id:) headers: api_headers, params: api_params, ) + end # Update the user email by its unique ID. @@ -596,6 +609,7 @@ def update_email(user_id:, email:) params: api_params, response_type: Models::User ) + end # Enable or disable whether a user can impersonate other users. When @@ -636,6 +650,7 @@ def update_impersonator(user_id:, impersonator:) params: api_params, response_type: Models::User ) + end # Use this endpoint to create a JSON Web Token for user by its unique ID. You @@ -671,6 +686,7 @@ def create_jwt(user_id:, session_id: nil, duration: nil) params: api_params, response_type: Models::Jwt ) + end # Update the user labels by its unique ID. @@ -711,6 +727,7 @@ def update_labels(user_id:, labels:) params: api_params, response_type: Models::User ) + end # Get the user activity logs list by its unique ID. @@ -743,6 +760,7 @@ def list_logs(user_id:, queries: nil, total: nil) params: api_params, response_type: Models::LogList ) + end # Get the user membership list by its unique ID. @@ -777,6 +795,7 @@ def list_memberships(user_id:, queries: nil, search: nil, total: nil) params: api_params, response_type: Models::MembershipList ) + end # Enable or disable MFA on a user account. @@ -812,6 +831,7 @@ def update_mfa(user_id:, mfa:) params: api_params, response_type: Models::User ) + end # Delete an authenticator app. @@ -846,6 +866,7 @@ def delete_mfa_authenticator(user_id:, type:) headers: api_headers, params: api_params, ) + end # List the factors available on the account to be used as a MFA challange. @@ -874,6 +895,7 @@ def list_mfa_factors(user_id:) params: api_params, response_type: Models::MfaFactors ) + end # Get recovery codes that can be used as backup for MFA flow by User ID. @@ -905,6 +927,7 @@ def get_mfa_recovery_codes(user_id:) params: api_params, response_type: Models::MfaRecoveryCodes ) + end # Regenerate recovery codes that can be used as backup for MFA flow by User @@ -937,6 +960,7 @@ def update_mfa_recovery_codes(user_id:) params: api_params, response_type: Models::MfaRecoveryCodes ) + end # Generate recovery codes used as backup for MFA flow for User ID. Recovery @@ -969,6 +993,7 @@ def create_mfa_recovery_codes(user_id:) params: api_params, response_type: Models::MfaRecoveryCodes ) + end # Update the user name by its unique ID. @@ -1004,6 +1029,7 @@ def update_name(user_id:, name:) params: api_params, response_type: Models::User ) + end # Update the user password by its unique ID. @@ -1039,6 +1065,7 @@ def update_password(user_id:, password:) params: api_params, response_type: Models::User ) + end # Update the user phone by its unique ID. @@ -1074,6 +1101,7 @@ def update_phone(user_id:, number:) params: api_params, response_type: Models::User ) + end # Get the user preferences by its unique ID. @@ -1102,6 +1130,7 @@ def get_prefs(user_id:) params: api_params, response_type: Models::Preferences ) + end # Update the user preferences by its unique ID. The object you pass is stored @@ -1139,6 +1168,7 @@ def update_prefs(user_id:, prefs:) params: api_params, response_type: Models::Preferences ) + end # Get the user sessions list by its unique ID. @@ -1169,6 +1199,7 @@ def list_sessions(user_id:, total: nil) params: api_params, response_type: Models::SessionList ) + end # Creates a session for a user. Returns an immediately usable session object. @@ -1203,6 +1234,7 @@ def create_session(user_id:) params: api_params, response_type: Models::Session ) + end # Delete all user's sessions by using the user's unique ID. @@ -1231,6 +1263,7 @@ def delete_sessions(user_id:) headers: api_headers, params: api_params, ) + end # Delete a user sessions by its unique ID. @@ -1265,6 +1298,7 @@ def delete_session(user_id:, session_id:) headers: api_headers, params: api_params, ) + end # Update the user status by its unique ID. Use this endpoint as an @@ -1301,6 +1335,7 @@ def update_status(user_id:, status:) params: api_params, response_type: Models::User ) + end # List the messaging targets that are associated with a user. @@ -1333,6 +1368,7 @@ def list_targets(user_id:, queries: nil, total: nil) params: api_params, response_type: Models::TargetList ) + end # Create a messaging target. @@ -1384,6 +1420,7 @@ def create_target(user_id:, target_id:, provider_type:, identifier:, provider_id params: api_params, response_type: Models::Target ) + end # Get a user's push notification target by ID. @@ -1418,6 +1455,7 @@ def get_target(user_id:, target_id:) params: api_params, response_type: Models::Target ) + end # Update a messaging target. @@ -1459,6 +1497,7 @@ def update_target(user_id:, target_id:, identifier: nil, provider_id: nil, name: params: api_params, response_type: Models::Target ) + end # Delete a messaging target. @@ -1493,6 +1532,7 @@ def delete_target(user_id:, target_id:) headers: api_headers, params: api_params, ) + end # Returns a token with a secret key for creating a session. Use the user ID @@ -1530,6 +1570,7 @@ def create_token(user_id:, length: nil, expire: nil) params: api_params, response_type: Models::Token ) + end # Update the user email verification status by its unique ID. @@ -1565,6 +1606,7 @@ def update_email_verification(user_id:, email_verification:) params: api_params, response_type: Models::User ) + end # Update the user phone verification status by its unique ID. @@ -1600,7 +1642,8 @@ def update_phone_verification(user_id:, phone_verification:) params: api_params, response_type: Models::User ) + end end -end \ No newline at end of file +end diff --git a/lib/appwrite/services/webhooks.rb b/lib/appwrite/services/webhooks.rb index 19102f5..7077f42 100644 --- a/lib/appwrite/services/webhooks.rb +++ b/lib/appwrite/services/webhooks.rb @@ -10,7 +10,7 @@ def initialize(client) # Get a list of all webhooks belonging to the project. You can use the query # params to filter your results. # - # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, url, httpUser, security, events, enabled, logs, attempts + # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, url, authUsername, tls, events, enabled, logs, attempts # @param [] total When set to false, the total count returned will be 0 and will not be calculated. # # @return [WebhookList] @@ -32,6 +32,7 @@ def list(queries: nil, total: nil) params: api_params, response_type: Models::WebhookList ) + end # Create a new webhook. Use this endpoint to configure a URL that will @@ -42,12 +43,13 @@ def list(queries: nil, total: nil) # @param [String] name Webhook name. Max length: 128 chars. # @param [Array] events Events list. Maximum of 100 events are allowed. # @param [] enabled Enable or disable a webhook. - # @param [] security Certificate verification, false for disabled or true for enabled. - # @param [String] http_user Webhook HTTP user. Max length: 256 chars. - # @param [String] http_pass Webhook HTTP password. Max length: 256 chars. + # @param [] tls Certificate verification, false for disabled or true for enabled. + # @param [String] auth_username Webhook HTTP user. Max length: 256 chars. + # @param [String] auth_password Webhook HTTP password. Max length: 256 chars. + # @param [String] secret Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. # # @return [Webhook] - def create(webhook_id:, url:, name:, events:, enabled: nil, security: nil, http_user: nil, http_pass: nil) + def create(webhook_id:, url:, name:, events:, enabled: nil, tls: nil, auth_username: nil, auth_password: nil, secret: nil) api_path = '/webhooks' if webhook_id.nil? @@ -72,9 +74,10 @@ def create(webhook_id:, url:, name:, events:, enabled: nil, security: nil, http_ name: name, events: events, enabled: enabled, - security: security, - httpUser: http_user, - httpPass: http_pass, + tls: tls, + authUsername: auth_username, + authPassword: auth_password, + secret: secret, } api_headers = { @@ -88,6 +91,7 @@ def create(webhook_id:, url:, name:, events:, enabled: nil, security: nil, http_ params: api_params, response_type: Models::Webhook ) + end # Get a webhook by its unique ID. This endpoint returns details about a @@ -117,6 +121,7 @@ def get(webhook_id:) params: api_params, response_type: Models::Webhook ) + end # Update a webhook by its unique ID. Use this endpoint to update the URL, @@ -127,12 +132,12 @@ def get(webhook_id:) # @param [String] url Webhook URL. # @param [Array] events Events list. Maximum of 100 events are allowed. # @param [] enabled Enable or disable a webhook. - # @param [] security Certificate verification, false for disabled or true for enabled. - # @param [String] http_user Webhook HTTP user. Max length: 256 chars. - # @param [String] http_pass Webhook HTTP password. Max length: 256 chars. + # @param [] tls Certificate verification, false for disabled or true for enabled. + # @param [String] auth_username Webhook HTTP user. Max length: 256 chars. + # @param [String] auth_password Webhook HTTP password. Max length: 256 chars. # # @return [Webhook] - def update(webhook_id:, name:, url:, events:, enabled: nil, security: nil, http_user: nil, http_pass: nil) + def update(webhook_id:, name:, url:, events:, enabled: nil, tls: nil, auth_username: nil, auth_password: nil) api_path = '/webhooks/{webhookId}' .gsub('{webhookId}', webhook_id) @@ -157,9 +162,9 @@ def update(webhook_id:, name:, url:, events:, enabled: nil, security: nil, http_ url: url, events: events, enabled: enabled, - security: security, - httpUser: http_user, - httpPass: http_pass, + tls: tls, + authUsername: auth_username, + authPassword: auth_password, } api_headers = { @@ -173,6 +178,7 @@ def update(webhook_id:, name:, url:, events:, enabled: nil, security: nil, http_ params: api_params, response_type: Models::Webhook ) + end # Delete a webhook by its unique ID. Once deleted, the webhook will no longer @@ -202,17 +208,19 @@ def delete(webhook_id:) headers: api_headers, params: api_params, ) + end - # Update the webhook signature key. This endpoint can be used to regenerate - # the signature key used to sign and validate payload deliveries for a - # specific webhook. + # Update the webhook signing key. This endpoint can be used to regenerate the + # signing key used to sign and validate payload deliveries for a specific + # webhook. # # @param [String] webhook_id Webhook ID. + # @param [String] secret Webhook secret key. If not provided, a new key will be generated automatically. Key must be at least 8 characters long, and at max 256 characters. # # @return [Webhook] - def update_signature(webhook_id:) - api_path = '/webhooks/{webhookId}/signature' + def update_secret(webhook_id:, secret: nil) + api_path = '/webhooks/{webhookId}/secret' .gsub('{webhookId}', webhook_id) if webhook_id.nil? @@ -220,6 +228,7 @@ def update_signature(webhook_id:) end api_params = { + secret: secret, } api_headers = { @@ -233,7 +242,8 @@ def update_signature(webhook_id:) params: api_params, response_type: Models::Webhook ) + end end -end \ No newline at end of file +end